]> granicus.if.org Git - sudo/commitdiff
Add initial scaffolding to support localization via gettext()
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 4 May 2011 19:26:31 +0000 (15:26 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 4 May 2011 19:26:31 +0000 (15:26 -0400)
config.h.in
configure
configure.in
plugins/sudoers/auth/pam.c

index 0f7384dd3b11330cc5dc1d777dbb9e8b7f8110d0..e00d722f958d0332769e37ed024c756fb54b79ec 100644 (file)
@@ -91,9 +91,6 @@
    don't. */
 #undef HAVE_DECL___SYS_SIGLIST
 
-/* Define to 1 if you have the `dgettext' function. */
-#undef HAVE_DGETTEXT
-
 /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
    */
 #undef HAVE_DIRENT_H
 /* Define to 1 if you have the `ldap_unbind_ext_s' function. */
 #undef HAVE_LDAP_UNBIND_EXT_S
 
+/* Define to 1 if you have the <libintl.h> header file. */
+#undef HAVE_LIBINTL_H
+
 /* Define to 1 to enable Linux audit support. */
 #undef HAVE_LINUX_AUDIT
 
 #undef ISSET
 #define ISSET(t, f)     ((t) & (f))
 
+/*
+ * Internationalization support.
+ */
+#ifdef HAVE_LIBINTL_H
+# define _(String) gettext(String)
+# define gettext_noop(String) String
+# define N_(String) gettext_noop(String)
+#else
+# define _(String) String 
+# define N_(String) String
+# define textdomain(Domain)
+# define bindtextdomain(Package, Directory)
+#endif /* HAVE_LIBINTL_H */
+
 /* New ANSI-style OS defs for HP-UX and ConvexOS. */
 #if defined(hpux) && !defined(__hpux)
 # define __hpux                1
index f278418543f897cfe54da2a73c314812929646be..63ae1b490a7fea28fbb17f7c23bca1e01ec5525b 100755 (executable)
--- a/configure
+++ b/configure
 done
 
 
+# gettext() and friends may be located in libc (Linux and Solaris)
+# or in libintl.  However, it is possible to have libintl installed
+# even when gettext() is present in libc.  In the case of GNU libintl,
+# gettext() will be defined to gettext_libintl in libintl.h.
+# Since gcc prefers /usr/local/include to /usr/include, we need to
+# make sure we use the gettext() that matches the include file.
+# First check that it links w/o additional libs, then try with -lintl.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <libintl.h>
+int
+main ()
+{
+(void)gettext((char *)0, (char *)0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  $as_echo "#define HAVE_LIBINTL_H 1" >>confdefs.h
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gettext in -lintl" >&5
+$as_echo_n "checking for gettext in -lintl... " >&6; }
+if test "${ac_cv_lib_intl_gettext+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lintl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gettext ();
+int
+main ()
+{
+return gettext ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_intl_gettext=yes
+else
+  ac_cv_lib_intl_gettext=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+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"
+    $as_echo "#define HAVE_LIBINTL_H 1" >>confdefs.h
+
+fi
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
 case ${enable_zlib-"yes"} in
     yes)
        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzdopen in -lz" >&5
@@ -16966,74 +17034,6 @@ else
 $as_echo "yes" >&6; }
 fi
 
-
-       case $host in
-           *-*-linux*|*-*-solaris*)
-                   # dgettext() may be defined to dgettext_libintl in the
-                   # header file, so first check that it links w/ additional
-                   # libs, then try with -lintl
-                   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <libintl.h>
-int
-main ()
-{
-(void)dgettext((char *)0, (char *)0);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  $as_echo "#define HAVE_DGETTEXT 1" >>confdefs.h
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dgettext in -lintl" >&5
-$as_echo_n "checking for dgettext in -lintl... " >&6; }
-if test "${ac_cv_lib_intl_dgettext+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lintl  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dgettext ();
-int
-main ()
-{
-return dgettext ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_intl_dgettext=yes
-else
-  ac_cv_lib_intl_dgettext=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_dgettext" >&5
-$as_echo "$ac_cv_lib_intl_dgettext" >&6; }
-if test "x$ac_cv_lib_intl_dgettext" = x""yes; then :
-  LIBS="${LIBS} -lintl"
-                       $as_echo "#define HAVE_DGETTEXT 1" >>confdefs.h
-
-fi
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-                   ;;
-       esac
     fi
 fi
 
index ec4a90fd78a3972d24e2e0789b4927fb70a12f29..4144518698679255794a8cf95e96a50d7aa62a63 100644 (file)
@@ -2130,6 +2130,19 @@ AC_CHECK_FUNCS(getprogname, , [
     AC_MSG_RESULT($sudo_cv___progname)
 ])
 
+# gettext() and friends may be located in libc (Linux and Solaris)
+# or in libintl.  However, it is possible to have libintl installed
+# even when gettext() is present in libc.  In the case of GNU libintl,
+# gettext() will be defined to gettext_libintl in libintl.h.
+# Since gcc prefers /usr/local/include to /usr/include, we need to
+# make sure we use the gettext() that matches the include file.
+# First check that it links w/o additional libs, then try with -lintl.
+AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[#include <libintl.h>]], [(void)gettext((char *)0, (char *)0);])],
+[AC_DEFINE(HAVE_LIBINTL_H)],
+[AC_CHECK_LIB(intl, gettext, [LIBS="${LIBS} -lintl"]
+    [AC_DEFINE(HAVE_LIBINTL_H)])])
+
 dnl
 dnl Deferred zlib option processing.
 dnl By default we use the system zlib if it is present.
@@ -2256,19 +2269,6 @@ if test ${with_pam-"no"} != "no"; then
                            AC_MSG_WARN([Ignoring unknown argument to --enable-pam-session: $enableval])
                            ;;
            esac], AC_MSG_RESULT(yes))
-
-       case $host in
-           *-*-linux*|*-*-solaris*)
-                   # dgettext() may be defined to dgettext_libintl in the
-                   # header file, so first check that it links w/ additional
-                   # libs, then try with -lintl
-                   AC_LINK_IFELSE([AC_LANG_PROGRAM(
-                   [[#include <libintl.h>]], [(void)dgettext((char *)0, (char *)0);])],
-                   [AC_DEFINE(HAVE_DGETTEXT)],
-                   [AC_CHECK_LIB(intl, dgettext, [LIBS="${LIBS} -lintl"]
-                       [AC_DEFINE(HAVE_DGETTEXT)])])
-                   ;;
-       esac
     fi
 fi
 
@@ -2981,7 +2981,6 @@ AH_TEMPLATE(HAVE_BSM_AUDIT, [Define to 1 to enable BSM audit support.])
 AH_TEMPLATE(HAVE_DCE, [Define to 1 if you use OSF DCE.])
 AH_TEMPLATE(HAVE_DD_FD, [Define to 1 if your `DIR' contains dd_fd.])
 AH_TEMPLATE(HAVE_DIRFD, [Define to 1 if you have the `dirfd' function or macro.])
-AH_TEMPLATE(HAVE_DGETTEXT, [Define to 1 if you have the `dgettext' function.])
 AH_TEMPLATE(HAVE_DISPCRYPT, [Define to 1 if you have the `dispcrypt' function.])
 AH_TEMPLATE(HAVE_DLOPEN, [Define to 1 if you have the `dlopen' function.])
 AH_TEMPLATE(HAVE_EXTENDED_GLOB, [Define to 1 if your glob.h defines the GLOB_BRACE and GLOB_TILDE flags.])
@@ -3006,6 +3005,7 @@ AH_TEMPLATE(HAVE_KRB5_INIT_SECURE_CONTEXT, [Define to 1 if you have the `krb5_in
 AH_TEMPLATE(HAVE_KRB5_VERIFY_USER, [Define to 1 if you have the `krb5_verify_user' function.])
 AH_TEMPLATE(HAVE_LBER_H, [Define to 1 if your LDAP needs <lber.h>. (OpenLDAP does not)])
 AH_TEMPLATE(HAVE_LDAP, [Define to 1 if you use LDAP for sudoers.])
+AH_TEMPLATE(HAVE_LIBINTL_H, [Define to 1 if you have the <libintl.h> header file.])
 AH_TEMPLATE(HAVE_LINUX_AUDIT, [Define to 1 to enable Linux audit support.])
 AH_TEMPLATE(HAVE_OPIE, [Define to 1 if you use NRL OPIE.])
 AH_TEMPLATE(HAVE_PAM, [Define to 1 if you use PAM authentication.])
@@ -3099,6 +3099,20 @@ AH_BOTTOM([/*
 #undef ISSET
 #define ISSET(t, f)     ((t) & (f))
 
+/*
+ * Internationalization support.
+ */
+#ifdef HAVE_LIBINTL_H
+# define _(String) gettext(String)
+# define gettext_noop(String) String
+# define N_(String) gettext_noop(String)
+#else
+# define _(String) String 
+# define N_(String) String
+# define textdomain(Domain)
+# define bindtextdomain(Package, Directory)
+#endif /* HAVE_LIBINTL_H */
+
 /* New ANSI-style OS defs for HP-UX and ConvexOS. */
 #if defined(hpux) && !defined(__hpux)
 # define __hpux                1
index 4ff4eed2592a59229e166c5f7e85bf5712a20e6a..e601b8885e6eae8f545f3b5376832488dac52c21 100644 (file)
@@ -49,7 +49,7 @@
 # include <security/pam_appl.h>
 #endif
 
-#ifdef HAVE_DGETTEXT
+#ifdef HAVE_LIBINTL_H
 # include <libintl.h>
 # if defined(__LINUX_PAM__)
 #  define PAM_TEXT_DOMAIN      "Linux-PAM"
@@ -293,7 +293,7 @@ converse(int num_msg, PAM_CONST struct pam_message **msg,
                    (def_prompt[9] == ' ' && def_prompt[10] == '\0'));
 
                /* Only override PAM prompt if it matches /^Password: ?/ */
-#if defined(PAM_TEXT_DOMAIN) && defined(HAVE_DGETTEXT)
+#if defined(PAM_TEXT_DOMAIN) && defined(HAVE_LIBINTL_H)
                if (!def_passprompt_override && (std_prompt ||
                    (strcmp(pm->msg, dgettext(PAM_TEXT_DOMAIN, "Password: ")) &&
                    strcmp(pm->msg, dgettext(PAM_TEXT_DOMAIN, "Password:")))))