From: Todd C. Miller Date: Mon, 12 Nov 2012 10:42:48 +0000 (-0500) Subject: Parse sudo.conf in the "C" locale. X-Git-Tag: SUDO_1_8_7~1^2~338 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4bd4a91714b8cf0dcf7662aa0b79426a5d035fb7;p=sudo Parse sudo.conf in the "C" locale. --- diff --git a/common/sudo_conf.c b/common/sudo_conf.c index a3100ac8b..608a78b3c 100644 --- a/common/sudo_conf.c +++ b/common/sudo_conf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011 Todd C. Miller + * Copyright (c) 2009-2012 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -295,6 +295,13 @@ sudo_conf_read(void) struct stat sb; FILE *fp; char *cp; +#ifdef HAVE_SETLOCALE + char *prev_locale = estrdup(setlocale(LC_ALL, NULL)); + + /* Parse sudo.conf in the "C" locale. */ + if (prev_locale[0] != 'C' || prev_locale[1] != '\0') + setlocale(LC_ALL, "C"); +#endif switch (sudo_secure_file(_PATH_SUDO_CONF, ROOT_UID, -1, &sb)) { case SUDO_PATH_SECURE: @@ -346,5 +353,11 @@ sudo_conf_read(void) } fclose(fp); done: +#ifdef HAVE_SETLOCALE + /* Restore locale if needed. */ + if (prev_locale[0] != 'C' || prev_locale[1] != '\0') + setlocale(LC_ALL, prev_locale); + efree(prev_locale); +#endif return; }