policy.lo prompt.lo set_perms.lo sudo_nss.lo sudoers.lo \
timestamp.lo @SUDOERS_OBJS@
-VISUDO_OBJS = visudo.o goodpath.o find_path.o error.o
+VISUDO_OBJS = find_path.o goodpath.o locale.o plugin_error.o visudo.o
-REPLAY_OBJS = getdate.o sudoreplay.o error.o
+REPLAY_OBJS = getdate.o locale.o plugin_error.o sudoreplay.o
-TEST_OBJS = interfaces.o testsudoers.o tsgetgrpw.o error.o group_plugin.o \
- net_ifs.o
+TEST_OBJS = group_plugin.o interfaces.o locale.o net_ifs.o plugin_error.o \
+ testsudoers.o tsgetgrpw.o
-CHECK_ADDR_OBJS = check_addr.o match_addr.o interfaces.o error.o
+CHECK_ADDR_OBJS = check_addr.o interfaces.o locale.o match_addr.o plugin_error.o
-CHECK_FILL_OBJS = check_fill.o toke_util.o error.o
+CHECK_FILL_OBJS = check_fill.o locale.o plugin_error.o toke_util.o
-CHECK_IOLOG_PATH_OBJS = check_iolog_path.o error.o iolog_path.o pwutil.o \
- pwutil_impl.o redblack.o
+CHECK_IOLOG_PATH_OBJS = check_iolog_path.o iolog_path.o locale.o \
+ plugin_error.o pwutil.o pwutil_impl.o redblack.o
-CHECK_SYMBOLS_OBJS = check_symbols.o error.o
+CHECK_SYMBOLS_OBJS = check_symbols.o locale.o plugin_error.o
-CHECK_WRAP_OBJS = check_wrap.o logwrap.o error.o
+CHECK_WRAP_OBJS = check_wrap.o locale.o logwrap.o plugin_error.o
LIBOBJDIR = $(top_builddir)/@ac_config_libobj_dir@/
$(devdir)/def_data.h $(srcdir)/logging.h $(srcdir)/sudo_nss.h \
$(incdir)/sudo_plugin.h $(incdir)/sudo_debug.h $(incdir)/gettext.h
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/env.c
-error.o: $(top_srcdir)/src/error.c $(top_builddir)/config.h \
- $(incdir)/missing.h $(incdir)/alloc.h $(incdir)/error.h \
- $(incdir)/gettext.h
- $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(top_srcdir)/src/error.c
find_path.lo: $(srcdir)/find_path.c $(top_builddir)/config.h \
$(srcdir)/sudoers.h $(top_srcdir)/compat/stdbool.h \
$(top_builddir)/pathnames.h $(incdir)/missing.h \
$(incdir)/alloc.h $(incdir)/error.h $(srcdir)/logging.h \
$(incdir)/sudo_plugin.h $(incdir)/gettext.h
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/plugin_error.c
+plugin_error.o: plugin_error.lo
policy.lo: $(srcdir)/policy.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
$(top_srcdir)/compat/stdbool.h $(top_builddir)/pathnames.h \
$(incdir)/missing.h $(incdir)/error.h $(incdir)/alloc.h \
#include "sudoers.h"
static int current_locale = SUDOERS_LOCALE_USER;
+static char *user_locale;
+static char *sudoers_locale;
int
sudoers_getlocale(void)
return current_locale;
}
+void
+sudoers_initlocale(const char *ulocale, const char *slocale)
+{
+ if (ulocale != NULL) {
+ efree(user_locale);
+ user_locale = estrdup(ulocale);
+ }
+ if (slocale != NULL) {
+ efree(sudoers_locale);
+ sudoers_locale = estrdup(slocale);
+ }
+}
+
/*
* Set locale to user or sudoers value.
* Returns true on success and false on failure,
if (current_locale != SUDOERS_LOCALE_USER) {
current_locale = SUDOERS_LOCALE_USER;
res = setlocale(LC_ALL, user_locale ? user_locale : "");
+ if (res != NULL && user_locale == NULL)
+ user_locale = estrdup(setlocale(LC_ALL, NULL));
}
break;
case SUDOERS_LOCALE_SUDOERS:
*prevlocale = current_locale;
if (current_locale != SUDOERS_LOCALE_SUDOERS) {
current_locale = SUDOERS_LOCALE_SUDOERS;
- res = setlocale(LC_ALL, def_sudoers_locale);
- if (res == NULL) {
- if (strcmp(def_sudoers_locale, "C") != 0) {
- efree(def_sudoers_locale);
- def_sudoers_locale = estrdup("C");
+ res = setlocale(LC_ALL, sudoers_locale ? sudoers_locale : "C");
+ if (res == NULL && sudoers_locale != NULL) {
+ if (strcmp(sudoers_locale, "C") != 0) {
+ efree(sudoers_locale);
+ sudoers_locale = estrdup("C");
res = setlocale(LC_ALL, "C");
}
}
void log_failure(int status, int flags);
void log_error(int flags, const char *fmt, ...) __printflike(2, 3);
void log_fatal(int flags, const char *fmt, ...) __printflike(2, 3) __attribute__((__noreturn__));
+void sudoers_initlocale(const char *ulocale, const char *slocale);
void writeln_wrap(FILE *fp, char *line, size_t len, size_t maxlen);
#endif /* _LOGGING_H */
*/
static char *find_editor(int nfiles, char **files, char ***argv_out);
static int cb_runas_default(const char *);
+static int cb_sudoers_locale(const char *);
static int set_cmnd(void);
static void create_admin_success_flag(void);
static void init_vars(char * const *);
(void) tzset(); /* set the timezone if applicable */
#endif /* HAVE_TZSET */
- user_locale = estrdup(setlocale(LC_ALL, NULL));
+ sudoers_initlocale(setlocale(LC_ALL, NULL), def_sudoers_locale);
for (ep = envp; *ep; ep++) {
/* XXX - don't fill in if empty string */
/* Set runas callback. */
sudo_defs_table[I_RUNAS_DEFAULT].callback = cb_runas_default;
+ /* Set locale callback. */
+ sudo_defs_table[I_SUDOERS_LOCALE].callback = cb_sudoers_locale;
+
/* It is now safe to use log_fatal() and set_perms() */
debug_return;
}
return true;
}
+/*
+/*
+ * Callback for sudoers_locale sudoers setting.
+ */
+static int
+cb_sudoers_locale(const char *locale)
+{
+ sudoers_initlocale(NULL, locale);
+ return true;
+}
+
/*
* Cleanup hook for error()/errorx()
*/
#endif
const char *cwd;
char *iolog_file;
- char *locale;
GETGROUPS_T *gids;
int ngids;
int closefrom;
#define user_tty (sudo_user.tty)
#define user_ttypath (sudo_user.ttypath)
#define user_cwd (sudo_user.cwd)
-#define user_locale (sudo_user.locale)
#define user_cmnd (sudo_user.cmnd)
#define user_args (sudo_user.cmnd_args)
#define user_base (sudo_user.cmnd_base)
#include "alloc.h"
#include "error.h"
#include "gettext.h"
+#include "logging.h"
#include "sudo_plugin.h"
#include "sudo_conf.h"
#include "sudo_debug.h"
extern int term_raw(int, int);
extern int term_restore(int, int);
extern void get_ttysize(int *rowp, int *colp);
-void cleanup(int);
+void sudoers_cleanup(int);
static int list_sessions(int, char **, const char *, const char *, const char *);
static int parse_expr(struct search_node **, char **);
setprogname(argc > 0 ? argv[0] : "sudoreplay");
#endif
- setlocale(LC_ALL, "");
+ sudoers_setlocale(SUDOERS_LOCALE_USER, NULL);
decimal = localeconv()->decimal_point;
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have sudoreplay domain */
textdomain("sudoers");
memset(&sa, 0, sizeof(sa));
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESETHAND;
- sa.sa_handler = cleanup;
+ sa.sa_handler = sudoers_cleanup;
(void) sigaction(SIGINT, &sa, NULL);
(void) sigaction(SIGKILL, &sa, NULL);
(void) sigaction(SIGTERM, &sa, NULL);
* Cleanup hook for error()/errorx()
*/
void
-cleanup(int signo)
+sudoers_cleanup(int signo)
{
term_restore(STDIN_FILENO, 0);
if (signo)
void print_privilege(struct privilege *);
void print_userspecs(void);
void usage(void) __attribute__((__noreturn__));
-void cleanup(int);
+void sudoers_cleanup(int);
static void set_runaspw(const char *);
static void set_runasgr(const char *);
static int cb_runas_default(const char *);
setprogname(argc > 0 ? argv[0] : "testsudoers");
#endif
- setlocale(LC_ALL, "");
+ sudoers_setlocale(SUDOERS_LOCALE_USER, NULL);
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have own domain */
textdomain("sudoers");
}
void
-cleanup(int gotsignal)
+sudoers_cleanup(int gotsignal)
{
if (!gotsignal) {
sudo_endpwent();
static void help(void) __attribute__((__noreturn__));
static void usage(int);
-void cleanup(int);
+void sudoers_cleanup(int);
extern void sudoerserror(const char *);
extern void sudoersrestart(FILE *);
setprogname(argc > 0 ? argv[0] : "visudo");
#endif
- setlocale(LC_ALL, "");
+ sudoers_setlocale(SUDOERS_LOCALE_USER, NULL);
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have visudo domain */
textdomain("sudoers");
case 'Q' : parse_error = false; /* ignore parse error */
break;
case 'x' : /* XXX - should return instead of exiting */
- cleanup(0);
+ sudoers_cleanup(0);
sudo_debug_exit_int(__func__, __FILE__,
__LINE__, sudo_debug_subsys, 0);
exit(0);
* Unlink any sudoers temp files that remain.
*/
void
-cleanup(int gotsignal)
+sudoers_cleanup(int gotsignal)
{
struct sudoersfile *sp;
{
const char *signame, *myname;
- cleanup(signo);
+ sudoers_cleanup(signo);
#define emsg " exiting due to signal: "
myname = getprogname();
signame = strsignal(signo);