1 |
jpp |
1.1 |
diff -up ./plugins/sudoers/sudoers.c.sudoerslocale ./plugins/sudoers/sudoers.c |
2 |
|
|
--- ./plugins/sudoers/sudoers.c.sudoerslocale 2016-10-06 18:02:34.926199094 +0200 |
3 |
|
|
+++ ./plugins/sudoers/sudoers.c 2016-10-06 18:05:09.660837351 +0200 |
4 |
|
|
@@ -146,6 +146,7 @@ sudoers_policy_open(unsigned int version |
5 |
|
|
sigaction_t sa; |
6 |
|
|
struct sudo_nss *nss; |
7 |
|
|
struct sudo_nss *nss_next; |
8 |
|
|
+ char *oldlocale; |
9 |
|
|
debug_decl(sudoers_policy_open, SUDO_DEBUG_PLUGIN) |
10 |
|
|
|
11 |
|
|
sudo_version = version; |
12 |
|
|
@@ -201,7 +202,17 @@ sudoers_policy_open(unsigned int version |
13 |
|
|
set_perms(PERM_INITIAL); |
14 |
|
|
set_perms(PERM_ROOT); |
15 |
|
|
|
16 |
|
|
- /* Open and parse sudoers, set global defaults */ |
17 |
|
|
+ /* |
18 |
|
|
+ * Open and parse sudoers, set global defaults. |
19 |
|
|
+ * Uses the C locale unless another is specified in sudoers. |
20 |
|
|
+ */ |
21 |
|
|
+#ifdef HAVE_SETLOCALE |
22 |
|
|
+ if (!(oldlocale = setlocale(LC_ALL, def_sudoers_locale))) { |
23 |
|
|
+ warningx(_("unable to set locale to \"%s\", using \"C\""), def_sudoers_locale); |
24 |
|
|
+ setlocale(LC_ALL, "C"); |
25 |
|
|
+ } |
26 |
|
|
+#endif |
27 |
|
|
+ |
28 |
|
|
for (nss = snl->first; nss != NULL; nss = nss_next) { |
29 |
|
|
nss_next = nss->next; |
30 |
|
|
if (nss->open(nss) == 0 && nss->parse(nss) == 0) { |
31 |
|
|
@@ -250,6 +261,15 @@ sudoers_policy_open(unsigned int version |
32 |
|
|
|
33 |
|
|
restore_perms(); |
34 |
|
|
|
35 |
|
|
+ /* Restore user's locale. */ |
36 |
|
|
+#ifdef HAVE_SETLOCALE |
37 |
|
|
+ if (oldlocale) |
38 |
|
|
+ setlocale(LC_ALL, oldlocale); |
39 |
|
|
+ else |
40 |
|
|
+ warningx(_("unable to restore user's locale, the C locale remains")); |
41 |
|
|
+#endif |
42 |
|
|
+ |
43 |
|
|
+ |
44 |
|
|
debug_return_bool(true); |
45 |
|
|
} |
46 |
|
|
|