Add calls to bindtextdomain() and textdomain()

Currently there are two domains, one for the sudo front-end and
one for the sudoers plugin and its associated utilities.
This commit is contained in:
Todd C. Miller
2011-05-17 16:38:40 -04:00
parent 19a81af6b0
commit c3a259f5ee
12 changed files with 64 additions and 12 deletions

7
configure vendored
View File

@@ -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

View File

@@ -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

View File

@@ -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. ####

View File

@@ -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();

View File

@@ -25,6 +25,8 @@
#include <setjmp.h>
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
# undef _
# define _(String) dgettext("sudoers", String)
#endif
#include "missing.h"

View File

@@ -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

View File

@@ -41,6 +41,8 @@
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
# undef _
# define _(String) dgettext("sudoers", String)
#endif
/*

View File

@@ -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) {

View File

@@ -58,6 +58,7 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include <stdarg.h>
#include <ctype.h>
#include <pwd.h>
#include <grp.h>
@@ -70,10 +71,11 @@
#if TIME_WITH_SYS_TIME
# include <time.h>
#endif
#ifdef __STDC__
# include <stdarg.h>
#else
# include <varargs.h>
#ifdef HAVE_SETLOCALE
# include <locale.h>
#endif
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
#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

View File

@@ -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. ####

View File

@@ -26,6 +26,9 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef HAVE_SETLOCALE
# include <locale.h>
#endif
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
#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"));

View File

@@ -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);