From: Todd C. Miller Date: Thu, 30 Jun 2016 18:40:19 +0000 (-0600) Subject: Set the sudoers locale before opening the sudoers file. X-Git-Tag: SUDO_1_8_18^2~130 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7bfe2e7969494cc3ab3e6d00d7fe5568e62a9bb2;p=sudo Set the sudoers locale before opening the sudoers file. Previously the sudoers locale was used when evaluating sudoers but not during the inital parse. Bug #748 --- diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index 9d7991e40..f44b00dfe 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -149,7 +149,7 @@ int sudoers_policy_init(void *info, char * const envp[]) { struct sudo_nss *nss, *nss_next; - int sources = 0; + int oldlocale, sources = 0; int rval = -1; debug_decl(sudoers_policy_init, SUDOERS_DEBUG_PLUGIN) @@ -183,7 +183,11 @@ sudoers_policy_init(void *info, char * const envp[]) if (!set_perms(PERM_ROOT)) debug_return_int(-1); - /* Open and parse sudoers, set global defaults */ + /* + * Open and parse sudoers, set global defaults. + * Uses the C locale unless another is specified in sudoers. + */ + sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale); TAILQ_FOREACH_SAFE(nss, snl, entries, nss_next) { if (nss->open(nss) == 0 && nss->parse(nss) == 0) { sources++; @@ -245,6 +249,9 @@ cleanup: if (!restore_perms()) rval = -1; + /* Restore user's locale. */ + sudoers_setlocale(oldlocale, NULL); + debug_return_int(rval); }