diff --git a/configure b/configure index 5d7a552ac..e9b88a727 100755 --- a/configure +++ b/configure @@ -680,6 +680,7 @@ password_timeout timeout timedir iolog_dir +LIBINTL LT_STATIC LIBDL CONFIGURE_ARGS @@ -2841,6 +2842,7 @@ $as_echo "$as_me: Configuring Sudo version $PACKAGE_VERSION" >&6;} + # @@ -2898,6 +2900,7 @@ LDAP="#" BAMAN=0 LCMAN=0 SEMAN=0 +LIBINTL= ZLIB= ZLIB_SRC= AUTH_OBJS= @@ -16781,7 +16784,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_gettext" >&5 $as_echo "$ac_cv_lib_intl_gettext" >&6; } if test "x$ac_cv_lib_intl_gettext" = x""yes; then : - LIBS="${LIBS} -lintl" + LIBINTL="-lintl" $as_echo "#define HAVE_LIBINTL_H 1" >>confdefs.h else @@ -16823,7 +16826,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_gettext_liconv" >&5 $as_echo "$ac_cv_lib_intl_gettext_liconv" >&6; } if test "x$ac_cv_lib_intl_gettext_liconv" = x""yes; then : - LIBS="${LIBS} -lintl -liconv" + LIBINTL="-lintl -liconv" $as_echo "#define HAVE_LIBINTL_H 1" >>confdefs.h fi diff --git a/configure.in b/configure.in index e0c56e785..e189b2edc 100644 --- a/configure.in +++ b/configure.in @@ -64,6 +64,7 @@ AC_SUBST([ac_config_libobj_dir]) AC_SUBST([CONFIGURE_ARGS]) AC_SUBST([LIBDL]) AC_SUBST([LT_STATIC]) +AC_SUBST([LIBINTL]) dnl dnl Variables that get substituted in docs (not overridden by environment) dnl @@ -161,6 +162,7 @@ LDAP="#" BAMAN=0 LCMAN=0 SEMAN=0 +LIBINTL= ZLIB= ZLIB_SRC= AUTH_OBJS= @@ -2163,10 +2165,10 @@ if test "$enable_nls" = "yes"; then AC_DEFINE(HAVE_LIBINTL_H) else AC_CHECK_LIB(intl, gettext, - [LIBS="${LIBS} -lintl"] + [LIBINTL="-lintl"] [AC_DEFINE(HAVE_LIBINTL_H)], [ - AC_CHECK_LIB(intl, gettext, [LIBS="${LIBS} -lintl -liconv"] + AC_CHECK_LIB(intl, gettext, [LIBINTL="-lintl -liconv"] AC_DEFINE(HAVE_LIBINTL_H), [], [-liconv]) ]) fi diff --git a/plugins/sudoers/Makefile.in b/plugins/sudoers/Makefile.in index d8c298bd2..abbd7da40 100644 --- a/plugins/sudoers/Makefile.in +++ b/plugins/sudoers/Makefile.in @@ -43,7 +43,7 @@ YACC = @YACC@ INSTALL = $(SHELL) $(top_srcdir)/install-sh -c # Libraries -LIBS = $(top_builddir)/common/libcommon.la $(top_builddir)/@ac_config_libobj_dir@/libreplace.la +LIBS = $(top_builddir)/common/libcommon.la $(top_builddir)/@ac_config_libobj_dir@/libreplace.la @LIBINTL@ NET_LIBS = @NET_LIBS@ SUDOERS_LIBS = @SUDOERS_LIBS@ @AFS_LIBS@ @GETGROUPS_LIB@ $(LIBS) $(NET_LIBS) @ZLIB@ REPLAY_LIBS = @REPLAY_LIBS@ @ZLIB@ @@ -67,6 +67,7 @@ sbindir = @sbindir@ sysconfdir = @sysconfdir@ libexecdir = @libexecdir@ datarootdir = @datarootdir@ +localedir = @localedir@ localstatedir = @localstatedir@ # File extension for shared objects @@ -94,7 +95,9 @@ sudoers_gid = @SUDOERS_GID@ sudoers_mode = @SUDOERS_MODE@ # Pass in paths and uid/gid + OS dependent defines -DEFS = @OSDEFS@ -D_PATH_SUDOERS=\"$(sudoersdir)/sudoers\" -DSUDOERS_UID=$(sudoers_uid) -DSUDOERS_GID=$(sudoers_gid) -DSUDOERS_MODE=$(sudoers_mode) +DEFS = @OSDEFS@ -D_PATH_SUDOERS=\"$(sudoersdir)/sudoers\" \ + -DSUDOERS_UID=$(sudoers_uid) -DSUDOERS_GID=$(sudoers_gid) \ + -DSUDOERS_MODE=$(sudoers_mode) -DLOCALEDIR=\"$(localedir)\" #### End of system configuration section. #### diff --git a/plugins/sudoers/iolog.c b/plugins/sudoers/iolog.c index d891e9860..de23e474b 100644 --- a/plugins/sudoers/iolog.c +++ b/plugins/sudoers/iolog.c @@ -433,6 +433,10 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation, goto done; } +#ifdef HAVE_LIBINTL_H + bindtextdomain("sudoers", LOCALEDIR); +#endif + sudo_setpwent(); sudo_setgrent(); diff --git a/plugins/sudoers/plugin_error.c b/plugins/sudoers/plugin_error.c index 0c608cdc4..468f1d451 100644 --- a/plugins/sudoers/plugin_error.c +++ b/plugins/sudoers/plugin_error.c @@ -25,6 +25,8 @@ #include #ifdef HAVE_LIBINTL_H # include +# undef _ +# define _(String) dgettext("sudoers", String) #endif #include "missing.h" diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index 88e077ea0..b01dec56e 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -163,6 +163,10 @@ sudoers_policy_open(unsigned int version, sudo_conv_t conversation, return -1; } +#ifdef HAVE_LIBINTL_H + bindtextdomain("sudoers", LOCALEDIR); +#endif + /* * Signal setup: * Ignore keyboard-generated signals so the user cannot interrupt diff --git a/plugins/sudoers/sudoers.h b/plugins/sudoers/sudoers.h index bb8a8484c..f866a496c 100644 --- a/plugins/sudoers/sudoers.h +++ b/plugins/sudoers/sudoers.h @@ -41,6 +41,8 @@ #ifdef HAVE_LIBINTL_H # include +# undef _ +# define _(String) dgettext("sudoers", String) #endif /* diff --git a/plugins/sudoers/sudoreplay.c b/plugins/sudoers/sudoreplay.c index 6849e77d6..e567966c4 100644 --- a/plugins/sudoers/sudoreplay.c +++ b/plugins/sudoers/sudoreplay.c @@ -245,6 +245,10 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); decimal = localeconv()->decimal_point; #endif +#ifdef HAVE_LIBINTL_H + bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have sudoreplay domain */ + textdomain("sudoers"); +#endif while ((ch = getopt(argc, argv, "d:f:hlm:s:V")) != -1) { switch(ch) { diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index af504a8c2..144d9e4dd 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -58,6 +58,7 @@ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ +#include #include #include #include @@ -70,10 +71,11 @@ #if TIME_WITH_SYS_TIME # include #endif -#ifdef __STDC__ -# include -#else -# include +#ifdef HAVE_SETLOCALE +# include +#endif +#ifdef HAVE_LIBINTL_H +# include #endif #include "sudoers.h" @@ -152,6 +154,14 @@ main(int argc, char *argv[]) malloc_options = "AFGJPR"; #endif +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif +#ifdef HAVE_LIBINTL_H + bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have visudo domain */ + textdomain("sudoers"); +#endif + #if !defined(HAVE_GETPROGNAME) && !defined(HAVE___PROGNAME) setprogname(argc > 0 ? argv[0] : "visudo"); #endif diff --git a/src/Makefile.in b/src/Makefile.in index c1b15bc43..34a90254f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -34,7 +34,7 @@ INSTALL = $(SHELL) $(top_srcdir)/install-sh -c # Libraries LT_LIBS = $(top_builddir)/common/libcommon.la $(LIBOBJDIR)libreplace.la -LIBS = @LIBS@ @SUDO_LIBS@ @GETGROUPS_LIB@ @NET_LIBS@ $(LT_LIBS) +LIBS = @LIBS@ @SUDO_LIBS@ @GETGROUPS_LIB@ @NET_LIBS@ @LIBINTL@ $(LT_LIBS) # C preprocessor flags CPPFLAGS = -I$(incdir) -I$(top_builddir) -I$(srcdir) -I. @CPPFLAGS@ @@ -53,6 +53,7 @@ sbindir = @sbindir@ sysconfdir = @sysconfdir@ libexecdir = @libexecdir@ datarootdir = @datarootdir@ +localedir = @localedir@ localstatedir = @localstatedir@ noexecfile = @NOEXECFILE@ noexecdir = @NOEXECDIR@ @@ -62,7 +63,8 @@ install_uid = 0 install_gid = 0 # OS dependent defines -DEFS = @OSDEFS@ -D_PATH_SUDO_CONF=\"$(sysconfdir)/sudo.conf\" +DEFS = @OSDEFS@ -D_PATH_SUDO_CONF=\"$(sysconfdir)/sudo.conf\" \ + -DLOCALEDIR=\"$(localedir)\" #### End of system configuration section. #### diff --git a/src/sesh.c b/src/sesh.c index 15d93f74f..00f13a145 100644 --- a/src/sesh.c +++ b/src/sesh.c @@ -26,6 +26,9 @@ #include #include #include +#ifdef HAVE_SETLOCALE +# include +#endif #ifdef HAVE_LIBINTL_H # include #endif @@ -37,6 +40,14 @@ main (int argc, char *argv[]) { char *cp, *cmnd; +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif +#ifdef HAVE_LIBINTL_H + bindtextdomain("sudo", LOCALEDIR); + textdomain("sudo"); +#endif + if (argc < 2) errx(EXIT_FAILURE, _("requires at least one argument")); diff --git a/src/sudo.c b/src/sudo.c index 00ae2fc75..e3100670b 100644 --- a/src/sudo.c +++ b/src/sudo.c @@ -178,6 +178,11 @@ main(int argc, char *argv[], char *envp[]) setprogname(argv[0]); #endif +#ifdef HAVE_LIBINTL_H + bindtextdomain("sudo", LOCALEDIR); + textdomain("sudo"); +#endif + /* Must be done before we do any password lookups */ #if defined(HAVE_GETPRPWNAM) && defined(HAVE_SET_AUTH_PARAMETERS) (void) set_auth_parameters(argc, argv);