From: Todd C. Miller Date: Sun, 14 Sep 2008 00:45:24 +0000 (+0000) Subject: Add sudoers_locale Defaults option to override the default sudoers X-Git-Tag: SUDO_1_7_0~87 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b02daa8272d6fc1c7dc46746d8d1d968c58f8e33;p=sudo Add sudoers_locale Defaults option to override the default sudoers locale of "C". --- diff --git a/def_data.c b/def_data.c index 0dd21be8c..da859e894 100644 --- a/def_data.c +++ b/def_data.c @@ -294,6 +294,10 @@ struct sudo_defs_types sudo_defs_table[] = { "env_file", T_STR|T_PATH|T_BOOL, "Path to the sudo-specific environment file: %s", NULL, + }, { + "sudoers_locale", T_STR, + "Locale to use while parsing sudoers: %s", + NULL, }, { NULL, 0, NULL } diff --git a/def_data.h b/def_data.h index 103b55e85..72d793eab 100644 --- a/def_data.h +++ b/def_data.h @@ -134,6 +134,8 @@ #define I_ASKPASS 66 #define def_env_file (sudo_defs_table[67].sd_un.str) #define I_ENV_FILE 67 +#define def_sudoers_locale (sudo_defs_table[68].sd_un.str) +#define I_SUDOERS_LOCALE 68 enum def_tupple { never, diff --git a/def_data.in b/def_data.in index fa58e8d1a..f92c63116 100644 --- a/def_data.in +++ b/def_data.in @@ -217,3 +217,6 @@ askpass env_file T_STR|T_PATH|T_BOOL "Path to the sudo-specific environment file: %s" +sudoers_locale + T_STR + "Locale to use while parsing sudoers: %s" diff --git a/defaults.c b/defaults.c index fc2008210..7ea686eeb 100644 --- a/defaults.c +++ b/defaults.c @@ -426,6 +426,7 @@ init_defaults() #ifdef _PATH_SUDO_ASKPASS def_askpass = estrdup(_PATH_SUDO_ASKPASS); #endif + def_sudoers_locale = estrdup("C"); def_env_reset = TRUE; def_set_logname = TRUE; def_closefrom = STDERR_FILENO + 1; diff --git a/sudo.c b/sudo.c index 685d04dea..5be5cbc48 100644 --- a/sudo.c +++ b/sudo.c @@ -326,7 +326,11 @@ main(argc, argv, envp) cmnd_status = set_cmnd(sudo_mode); #ifdef HAVE_SETLOCALE - setlocale(LC_ALL, "C"); + if (!setlocale(LC_ALL, def_sudoers_locale)) { + warningx("unable to set locale to \"%s\", using \"C\"", + def_sudoers_locale); + setlocale(LC_ALL, "C"); + } #endif validated = FLAG_NO_USER | FLAG_NO_HOST;