Skip to content

Commit

Permalink
pam_start.c: call bindtextdomain() to expose Linux-PAM locales
Browse files Browse the repository at this point in the history
Without the change locales are not visible to applications using PAM if
PAM library is installed into a --prefix= different from the default
one.
  • Loading branch information
trofi committed Aug 25, 2023
1 parent 81d5593 commit 77bd338
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions libpam/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions libpam/pam_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 77bd338

Please sign in to comment.