Move sudoers locale callback function to locale.c and user it in

visudo and testsudoers.
This commit is contained in:
Todd C. Miller
2016-07-20 14:16:00 -06:00
parent 30f7ecca10
commit b5c2ca2fe5
5 changed files with 24 additions and 17 deletions

View File

@@ -37,6 +37,7 @@
#include "sudo_compat.h"
#include "sudo_fatal.h"
#include "sudoers_debug.h"
#include "defaults.h"
#include "logging.h"
static int current_locale = SUDOERS_LOCALE_USER;
@@ -133,3 +134,18 @@ sudoers_warn_setlocale(bool restore, int *cookie)
debug_return_bool(sudoers_setlocale(*cookie, NULL));
debug_return_bool(sudoers_setlocale(SUDOERS_LOCALE_USER, cookie));
}
/*
* Callback for sudoers_locale sudoers setting.
*/
bool
sudoers_locale_callback(const union sudo_defs_val *sd_un)
{
debug_decl(sudoers_locale_callback, SUDOERS_DEBUG_UTIL)
if (sudoers_initlocale(NULL, sd_un->str)) {
if (setlocale(LC_ALL, sd_un->str) != NULL)
debug_return_bool(true);
}
debug_return_bool(false);
}