From 3cdd8da3ca8466f19e440f0e46e52b53dae6dd45 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 14 Dec 2007 17:02:50 -0800 Subject: Fix for bug #5082 from Mathias Gug , Steve Langasek . Recent versions of Linux-PAM support localization of user prompts, so Samba must use the C locale when invoking PAM (directly or via /usr/bin/passwd) to ensure that password chat values match the prompts in a locale-invariant fashion. Jeremy. (This used to be commit bc13e939546a5bcb78925a6b117e89fde20f6451) --- source3/smbd/chgpasswd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source3/smbd') diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c index 5a1d71d2af..58b67a58cd 100644 --- a/source3/smbd/chgpasswd.c +++ b/source3/smbd/chgpasswd.c @@ -125,6 +125,7 @@ static int dochild(int master, const char *slavedev, const struct passwd *pass, struct termios stermios; gid_t gid; uid_t uid; + char * const eptrs[1] = { NULL }; if (pass == NULL) { @@ -221,7 +222,7 @@ static int dochild(int master, const char *slavedev, const struct passwd *pass, passwordprogram)); /* execl() password-change application */ - if (execl("/bin/sh", "sh", "-c", passwordprogram, NULL) < 0) + if (execle("/bin/sh", "sh", "-c", passwordprogram, NULL, eptrs) < 0) { DEBUG(3, ("Bad status returned from %s\n", passwordprogram)); return (False); @@ -518,6 +519,9 @@ bool chgpasswd(const char *name, const struct passwd *pass, #ifdef WITH_PAM if (lp_pam_password_change()) { bool ret; +#ifdef HAVE_SETLOCALE + const char *prevlocale = setlocale(LC_MESSAGES, "C"); +#endif if (as_root) become_root(); @@ -531,6 +535,10 @@ bool chgpasswd(const char *name, const struct passwd *pass, if (as_root) unbecome_root(); +#ifdef HAVE_SETLOCALE + setlocale(LC_MESSAGES, prevlocale); +#endif + return ret; } #endif -- cgit