mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-04 08:15:15 +00:00
Call gettext() in sudoerserror() in the user's locale and pass the untranslated string to it.
This commit is contained in:
@@ -180,10 +180,11 @@ update-pot:
|
||||
case "$$domain" in \
|
||||
sudo) tmpfiles=; cfiles="src/*c common/*c compat/*c";; \
|
||||
sudoers) \
|
||||
echo "syntax error" > confstr.sh; \
|
||||
sed -n -e 's/^badpass_message="/gettext "/p' \
|
||||
-e 's/^passprompt="/gettext "/p' \
|
||||
-e 's/^mailsub="/gettext "/p' configure.in \
|
||||
> confstr.sh; \
|
||||
>> confstr.sh; \
|
||||
tmpfiles=confstr.sh; \
|
||||
cfiles="plugins/sudoers/*.c plugins/sudoers/auth/*.c";; \
|
||||
*) echo unknown domain $$domain; continue;; \
|
||||
|
@@ -122,7 +122,7 @@ alias_add(char *name, int type, struct member *members)
|
||||
/* a->seqno = 0; */
|
||||
list2tq(&a->members, members);
|
||||
if (rbinsert(aliases, a)) {
|
||||
snprintf(errbuf, sizeof(errbuf), _("Alias `%s' already defined"), name);
|
||||
snprintf(errbuf, sizeof(errbuf), N_("Alias `%s' already defined"), name);
|
||||
alias_free(a);
|
||||
debug_return_str(errbuf);
|
||||
}
|
||||
|
@@ -147,9 +147,30 @@ sudoerserror(const char *s)
|
||||
if (sudoers_warnings && s != NULL) {
|
||||
LEXTRACE("<*> ");
|
||||
#ifndef TRACELEXER
|
||||
/* XXX 's' will be in sudoers locale, not user's */
|
||||
if (trace_print == NULL || trace_print == sudoers_trace_print)
|
||||
warningx(N_(">>> %s: %s near line %d <<<"), sudoers, s, sudolineno);
|
||||
if (trace_print == NULL || trace_print == sudoers_trace_print) {
|
||||
int oldlocale;
|
||||
const char fmt[] = ">>> %s: %s near line %d <<<\n";
|
||||
|
||||
/* Warnings are displayed in the user's locale. */
|
||||
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
|
||||
if (sudo_conv != NULL) {
|
||||
struct sudo_conv_message msg;
|
||||
struct sudo_conv_reply repl;
|
||||
char *str;
|
||||
|
||||
easprintf(&str, _(fmt), sudoers, _(s), sudolineno);
|
||||
|
||||
memset(&msg, 0, sizeof(repl));
|
||||
memset(&repl, 0, sizeof(repl));
|
||||
msg.msg_type = SUDO_CONV_ERROR_MSG;
|
||||
msg.msg = str;
|
||||
sudo_conv(1, &msg, &repl);
|
||||
efree(str);
|
||||
} else {
|
||||
fprintf(stderr, _(fmt), sudoers, _(s), sudolineno);
|
||||
}
|
||||
sudoers_setlocale(oldlocale, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
parse_error = true;
|
||||
|
@@ -109,9 +109,30 @@ sudoerserror(const char *s)
|
||||
if (sudoers_warnings && s != NULL) {
|
||||
LEXTRACE("<*> ");
|
||||
#ifndef TRACELEXER
|
||||
/* XXX 's' will be in sudoers locale, not user's */
|
||||
if (trace_print == NULL || trace_print == sudoers_trace_print)
|
||||
warningx(N_(">>> %s: %s near line %d <<<"), sudoers, s, sudolineno);
|
||||
if (trace_print == NULL || trace_print == sudoers_trace_print) {
|
||||
int oldlocale;
|
||||
const char fmt[] = ">>> %s: %s near line %d <<<\n";
|
||||
|
||||
/* Warnings are displayed in the user's locale. */
|
||||
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
|
||||
if (sudo_conv != NULL) {
|
||||
struct sudo_conv_message msg;
|
||||
struct sudo_conv_reply repl;
|
||||
char *str;
|
||||
|
||||
easprintf(&str, _(fmt), sudoers, _(s), sudolineno);
|
||||
|
||||
memset(&msg, 0, sizeof(repl));
|
||||
memset(&repl, 0, sizeof(repl));
|
||||
msg.msg_type = SUDO_CONV_ERROR_MSG;
|
||||
msg.msg = str;
|
||||
sudo_conv(1, &msg, &repl);
|
||||
efree(str);
|
||||
} else {
|
||||
fprintf(stderr, _(fmt), sudoers, _(s), sudolineno);
|
||||
}
|
||||
sudoers_setlocale(oldlocale, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
parse_error = true;
|
||||
|
@@ -3411,13 +3411,8 @@ switch_dir(struct include_stack *stack, char *dirpath)
|
||||
|
||||
if (!(dir = opendir(dirpath))) {
|
||||
if (errno != ENOENT) {
|
||||
char *errbuf;
|
||||
if (asprintf(&errbuf, _("%s: %s"), dirpath, strerror(errno)) != -1) {
|
||||
sudoerserror(errbuf);
|
||||
free(errbuf);
|
||||
} else {
|
||||
sudoerserror(strerror(errno));
|
||||
}
|
||||
warning("%s", dirpath);
|
||||
sudoerserror(NULL);
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
@@ -3539,14 +3534,15 @@ _push_include(char *path, bool isdir)
|
||||
/* push current state onto stack */
|
||||
if (idepth >= istacksize) {
|
||||
if (idepth > MAX_SUDOERS_DEPTH) {
|
||||
sudoerserror(_("too many levels of includes"));
|
||||
sudoerserror(N_("too many levels of includes"));
|
||||
debug_return_bool(false);
|
||||
}
|
||||
istacksize += SUDOERS_STACK_INCREMENT;
|
||||
istack = (struct include_stack *) realloc(istack,
|
||||
sizeof(*istack) * istacksize);
|
||||
if (istack == NULL) {
|
||||
sudoerserror(strerror(errno));
|
||||
warning(NULL);
|
||||
sudoerserror(NULL);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
}
|
||||
@@ -3697,7 +3693,8 @@ parse_include(char *base)
|
||||
len += (int)(ep - cp);
|
||||
path = pp = malloc(len + dirlen + 1);
|
||||
if (path == NULL) {
|
||||
sudoerserror(strerror(errno));
|
||||
warning(NULL);
|
||||
sudoerserror(NULL);
|
||||
debug_return_str(NULL);
|
||||
}
|
||||
if (dirlen) {
|
||||
|
@@ -689,13 +689,8 @@ switch_dir(struct include_stack *stack, char *dirpath)
|
||||
|
||||
if (!(dir = opendir(dirpath))) {
|
||||
if (errno != ENOENT) {
|
||||
char *errbuf;
|
||||
if (asprintf(&errbuf, _("%s: %s"), dirpath, strerror(errno)) != -1) {
|
||||
sudoerserror(errbuf);
|
||||
free(errbuf);
|
||||
} else {
|
||||
sudoerserror(strerror(errno));
|
||||
}
|
||||
warning("%s", dirpath);
|
||||
sudoerserror(NULL);
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
@@ -817,14 +812,15 @@ _push_include(char *path, bool isdir)
|
||||
/* push current state onto stack */
|
||||
if (idepth >= istacksize) {
|
||||
if (idepth > MAX_SUDOERS_DEPTH) {
|
||||
sudoerserror(_("too many levels of includes"));
|
||||
sudoerserror(N_("too many levels of includes"));
|
||||
debug_return_bool(false);
|
||||
}
|
||||
istacksize += SUDOERS_STACK_INCREMENT;
|
||||
istack = (struct include_stack *) realloc(istack,
|
||||
sizeof(*istack) * istacksize);
|
||||
if (istack == NULL) {
|
||||
sudoerserror(strerror(errno));
|
||||
warning(NULL);
|
||||
sudoerserror(NULL);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
}
|
||||
@@ -975,7 +971,8 @@ parse_include(char *base)
|
||||
len += (int)(ep - cp);
|
||||
path = pp = malloc(len + dirlen + 1);
|
||||
if (path == NULL) {
|
||||
sudoerserror(strerror(errno));
|
||||
warning(NULL);
|
||||
sudoerserror(NULL);
|
||||
debug_return_str(NULL);
|
||||
}
|
||||
if (dirlen) {
|
||||
|
@@ -111,7 +111,8 @@ fill_txt(const char *src, int len, int olen)
|
||||
|
||||
dst = olen ? realloc(sudoerslval.string, olen + len + 1) : malloc(len + 1);
|
||||
if (dst == NULL) {
|
||||
sudoerserror(strerror(errno));
|
||||
warning(NULL);
|
||||
sudoerserror(NULL);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
sudoerslval.string = dst;
|
||||
@@ -165,7 +166,8 @@ fill_cmnd(const char *src, int len)
|
||||
|
||||
dst = sudoerslval.command.cmnd = (char *) malloc(len + 1);
|
||||
if (sudoerslval.command.cmnd == NULL) {
|
||||
sudoerserror(strerror(errno));
|
||||
warning(NULL);
|
||||
sudoerserror(NULL);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
|
||||
@@ -205,7 +207,8 @@ fill_args(const char *s, int len, int addspace)
|
||||
(char *) malloc(arg_size);
|
||||
if (p == NULL) {
|
||||
efree(sudoerslval.command.args);
|
||||
sudoerserror(strerror(errno));
|
||||
warning(NULL);
|
||||
sudoerserror(NULL);
|
||||
debug_return_bool(false);
|
||||
} else
|
||||
sudoerslval.command.args = p;
|
||||
@@ -216,7 +219,8 @@ fill_args(const char *s, int len, int addspace)
|
||||
if (addspace)
|
||||
*p++ = ' ';
|
||||
if (strlcpy(p, s, arg_size - (p - sudoerslval.command.args)) != len) {
|
||||
sudoerserror(_("fill_args: buffer overflow")); /* paranoia */
|
||||
warningx(N_("fill_args: buffer overflow")); /* paranoia */
|
||||
sudoerserror(NULL);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
arg_len = new_len;
|
||||
|
Reference in New Issue
Block a user