aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Trofimovich <slyich@gmail.com>2023-08-16 08:56:18 +0100
committerSergei Trofimovich <slyich@gmail.com>2023-08-25 08:13:19 +0100
commit77bd338125cde583ecdfb9fd69619bcd2baf15c2 (patch)
tree15b24291742422334fbbc8f81c381d6fe4617428
parent81d5593e32ef06e749ab8c591111d37b95c42e01 (diff)
downloadpam-77bd338125cde583ecdfb9fd69619bcd2baf15c2.tar.gz
pam-77bd338125cde583ecdfb9fd69619bcd2baf15c2.tar.bz2
pam-77bd338125cde583ecdfb9fd69619bcd2baf15c2.zip
pam_start.c: call bindtextdomain() to expose Linux-PAM locales
Without the change locales are not visible to applications using PAM if PAM library is installed into a --prefix= different from the default one.
-rw-r--r--configure.ac1
-rw-r--r--libpam/Makefile.am1
-rw-r--r--libpam/pam_start.c15
3 files changed, 17 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 7565a830..39124d87 100644
--- a/configure.ac
+++ b/configure.ac
@@ -676,6 +676,7 @@ AM_CONDITIONAL(ENABLE_GENERATE_PDF, test -n "$FO2PDF")
AM_GNU_GETTEXT_VERSION([0.18.3])
AM_GNU_GETTEXT([external])
+AC_CHECK_FUNCS(bindtextdomain)
AC_CHECK_FUNCS(dngettext)
AH_BOTTOM([#ifdef ENABLE_NLS
diff --git a/libpam/Makefile.am b/libpam/Makefile.am
index 389d5d02..0d2fb6f3 100644
--- a/libpam/Makefile.am
+++ b/libpam/Makefile.am
@@ -3,6 +3,7 @@
#
AM_CFLAGS = -DDEFAULT_MODULE_PATH=\"$(SECUREDIR)/\" -DLIBPAM_COMPILE \
+ -DLOCALEDIR=\"$(localedir)\" \
-I$(srcdir)/include $(LIBPRELUDE_CFLAGS) $(ECONF_CFLAGS) \
-DPAM_VERSION=\"$(VERSION)\" -DSYSCONFDIR=\"$(sysconfdir)\" \
$(WARN_CFLAGS)
diff --git a/libpam/pam_start.c b/libpam/pam_start.c
index 5e9b0948..c32ce61c 100644
--- a/libpam/pam_start.c
+++ b/libpam/pam_start.c
@@ -25,6 +25,21 @@ static int _pam_start_internal (
D(("called pam_start: [%s] [%s] [%p] [%p]"
,service_name, user, pam_conversation, pamh));
+#ifdef HAVE_BINDTEXTDOMAIN
+ /* Bind text domain to pull in PAM translations for a case where
+ linux-pam is installed to non-default prefix.
+
+ It is safe to call bindtextdomain() from multiple threads, but it
+ has a chance to have some overhead. Let's try to do it once (or a
+ small number of times as `bound_text_domain` is not protected by
+ a lock. */
+ static int bound_text_domain = 0;
+ if (!bound_text_domain) {
+ bound_text_domain = 1;
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ }
+#endif
+
if (pamh == NULL) {
pam_syslog(NULL, LOG_CRIT,
"pam_start: invalid argument: pamh == NULL");