2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

Add warning_gettext() wrapper function that changes to the user locale,

then calls gettext().
Add U_ macro that calls warning_gettext() instead of gettext().
Rename warning2()/error2() back to warning_nodebug()/error_nodebug().
This commit is contained in:
Todd C. Miller 2013-11-18 08:59:57 -07:00
parent 99b7351de0
commit 96eb2c4f8f
50 changed files with 445 additions and 492 deletions

View File

@ -70,7 +70,7 @@ LOCALEDIR_SUFFIX = @LOCALEDIR_SUFFIX@
MSGFMT = msgfmt
MSGMERGE = msgmerge
XGETTEXT = xgettext
XGETTEXT_OPTS = -F -k_ -kN_ --copyright-holder="Todd C. Miller" \
XGETTEXT_OPTS = -F -k_ -kN_ -kU_ --copyright-holder="Todd C. Miller" \
"--msgid-bugs-address=http://www.sudo.ws/bugs" \
--package-name=@PACKAGE_NAME@ --package-version=$(VERSION) \
--flag warning:1:c-format --flag warningx:1:c-format \

View File

@ -90,7 +90,7 @@ aix_setlimits(char *user)
debug_decl(aix_setlimits, SUDO_DEBUG_UTIL)
if (setuserdb(S_READ) != 0)
fatal("unable to open userdb");
fatal(U_("unable to open userdb"));
/*
* For each resource limit, get the soft/hard values for the user
@ -147,10 +147,10 @@ aix_setauthdb(char *user)
if (user != NULL) {
if (setuserdb(S_READ) != 0)
fatal(_("unable to open userdb"));
fatal(U_("unable to open userdb"));
if (getuserattr(user, S_REGISTRY, &registry, SEC_CHAR) == 0) {
if (setauthdb(registry, NULL) != 0)
fatal(_("unable to switch to registry \"%s\" for %s"),
fatal(U_("unable to switch to registry \"%s\" for %s"),
registry, user);
}
enduserdb();
@ -167,7 +167,7 @@ aix_restoreauthdb(void)
debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL)
if (setauthdb(NULL, NULL) != 0)
fatal(_("unable to restore registry"));
fatal(U_("unable to restore registry"));
debug_return;
}

View File

@ -63,7 +63,7 @@ do_cleanup(void)
}
void
fatal2(const char *fmt, ...)
fatal_nodebug(const char *fmt, ...)
{
va_list ap;
@ -78,7 +78,7 @@ fatal2(const char *fmt, ...)
}
void
fatalx2(const char *fmt, ...)
fatalx_nodebug(const char *fmt, ...)
{
va_list ap;
@ -93,7 +93,7 @@ fatalx2(const char *fmt, ...)
}
void
vfatal2(const char *fmt, va_list ap)
vfatal_nodebug(const char *fmt, va_list ap)
{
_warning(1, fmt, ap);
do_cleanup();
@ -104,7 +104,7 @@ vfatal2(const char *fmt, va_list ap)
}
void
vfatalx2(const char *fmt, va_list ap)
vfatalx_nodebug(const char *fmt, va_list ap)
{
_warning(0, fmt, ap);
do_cleanup();
@ -115,7 +115,7 @@ vfatalx2(const char *fmt, va_list ap)
}
void
warning2(const char *fmt, ...)
warning_nodebug(const char *fmt, ...)
{
va_list ap;
@ -125,7 +125,7 @@ warning2(const char *fmt, ...)
}
void
warningx2(const char *fmt, ...)
warningx_nodebug(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@ -134,13 +134,13 @@ warningx2(const char *fmt, ...)
}
void
vwarning2(const char *fmt, va_list ap)
vwarning_nodebug(const char *fmt, va_list ap)
{
_warning(1, fmt, ap);
}
void
vwarningx2(const char *fmt, va_list ap)
vwarningx_nodebug(const char *fmt, va_list ap)
{
_warning(0, fmt, ap);
}

View File

@ -77,7 +77,7 @@ parse_gid_list(const char *gidstr, const gid_t *basegid, GETGROUPS_T **gidsp)
do {
gids[ngids] = (GETGROUPS_T) atoid(cp, ",", &ep, &errstr);
if (errstr != NULL) {
warningx(_("%s: %s"), cp, _(errstr));
warningx(U_("%s: %s"), cp, U_(errstr));
free(gids);
debug_return_int(-1);
}

View File

@ -174,7 +174,7 @@ set_var_group_source(const char *entry, const char *conf_file)
} else if (strcasecmp(entry, "dynamic") == 0) {
sudo_conf_data.group_source = GROUP_SOURCE_DYNAMIC;
} else {
warningx(_("unsupported group source `%s' in %s, line %d"), entry,
warningx(U_("unsupported group source `%s' in %s, line %d"), entry,
conf_file, conf_lineno);
}
}
@ -188,7 +188,7 @@ set_var_max_groups(const char *entry, const char *conf_file)
lval = strtol(entry, &ep, 10);
if (*entry == '\0' || *ep != '\0' || lval <= 0 || lval > INT_MAX ||
(errno == ERANGE && lval == LONG_MAX)) {
warningx(_("invalid max groups `%s' in %s, line %d"), entry,
warningx(U_("invalid max groups `%s' in %s, line %d"), entry,
conf_file, conf_lineno);
} else {
sudo_conf_data.max_groups = (int)lval;
@ -390,20 +390,20 @@ sudo_conf_read(const char *conf_file)
case SUDO_PATH_MISSING:
/* Root should always be able to read sudo.conf. */
if (errno != ENOENT && geteuid() == ROOT_UID)
warning(_("unable to stat %s"), conf_file);
warning(U_("unable to stat %s"), conf_file);
goto done;
case SUDO_PATH_BAD_TYPE:
warningx(_("%s is not a regular file"), conf_file);
warningx(U_("%s is not a regular file"), conf_file);
goto done;
case SUDO_PATH_WRONG_OWNER:
warningx(_("%s is owned by uid %u, should be %u"),
warningx(U_("%s is owned by uid %u, should be %u"),
conf_file, (unsigned int) sb.st_uid, ROOT_UID);
goto done;
case SUDO_PATH_WORLD_WRITABLE:
warningx(_("%s is world writable"), conf_file);
warningx(U_("%s is world writable"), conf_file);
goto done;
case SUDO_PATH_GROUP_WRITABLE:
warningx(_("%s is group writable"), conf_file);
warningx(U_("%s is group writable"), conf_file);
goto done;
default:
/* NOTREACHED */
@ -413,7 +413,7 @@ sudo_conf_read(const char *conf_file)
if ((fp = fopen(conf_file, "r")) == NULL) {
if (errno != ENOENT && geteuid() == ROOT_UID)
warning(_("unable to open %s"), conf_file);
warning(U_("unable to open %s"), conf_file);
goto done;
}

View File

@ -120,82 +120,23 @@
} while (0)
#endif /* SUDO_ERROR_WRAP */
#if defined(__GNUC__) && __GNUC__ == 2
# define fatal_nodebug(fmt...) do { \
warning_set_locale(); \
fatal2(fmt); \
} while (0)
# define fatalx_nodebug(fmt...) do { \
warning_set_locale(); \
fatalx2(fmt); \
} while (0)
# define warning_nodebug(fmt...) do { \
warning_set_locale(); \
warning2(fmt); \
warning_restore_locale(); \
} while (0)
# define warningx_nodebug(fmt...) do { \
warning_set_locale(); \
warningx2(fmt); \
warning_restore_locale(); \
} while (0)
#else
# define fatal_nodebug(...) do { \
warning_set_locale(); \
fatal2(__VA_ARGS__); \
} while (0)
# define fatalx_nodebug(...) do { \
warning_set_locale(); \
fatalx2(__VA_ARGS__); \
} while (0)
# define warning_nodebug(...) do { \
warning_set_locale(); \
warning2(__VA_ARGS__); \
warning_restore_locale(); \
} while (0)
# define warningx_nodebug(...) do { \
warning_set_locale(); \
warningx2(__VA_ARGS__); \
warning_restore_locale(); \
} while (0)
#endif /* __GNUC__ == 2 */
#define vfatal_nodebug(fmt, ap) do { \
warning_set_locale(); \
vfatal2((fmt), (ap)); \
} while (0)
#define vfatalx_nodebug(fmt, ap) do { \
warning_set_locale(); \
vfatalx2((fmt), (ap)); \
} while (0)
#define vwarning_nodebug(fmt, ap) do { \
warning_set_locale(); \
vwarning2((fmt), (ap)); \
warning_restore_locale(); \
} while (0)
#define vwarningx_nodebug(fmt, ap) do { \
warning_set_locale(); \
vwarningx2((fmt), (ap)); \
warning_restore_locale(); \
} while (0)
#define fatal_setjmp() (fatal_enable_setjmp(), sigsetjmp(fatal_jmp, 1))
#define fatal_longjmp(val) siglongjmp(fatal_jmp, val)
extern int (*sudo_printf)(int msg_type, const char *fmt, ...);
extern sigjmp_buf fatal_jmp;
int fatal_callback_register(void (*func)(void));
int fatal_callback_register(void (*func)(void));
char *warning_gettext(const char *msgid) __format_arg(1);
void fatal_disable_setjmp(void);
void fatal_enable_setjmp(void);
void fatal2(const char *, ...) __printf0like(1, 2) __attribute__((__noreturn__));
void fatalx2(const char *, ...) __printflike(1, 2) __attribute__((__noreturn__));
void vfatal2(const char *, va_list ap) __printf0like(1, 0) __attribute__((__noreturn__));
void vfatalx2(const char *, va_list ap) __printflike(1, 0) __attribute__((__noreturn__));
void warning2(const char *, ...) __printf0like(1, 2);
void warningx2(const char *, ...) __printflike(1, 2);
void vwarning2(const char *, va_list ap) __printf0like(1, 0);
void vwarningx2(const char *, va_list ap) __printflike(1, 0);
void warning_set_locale(void);
void warning_restore_locale(void);
void fatal_nodebug(const char *, ...) __printf0like(1, 2) __attribute__((__noreturn__));
void fatalx_nodebug(const char *, ...) __printflike(1, 2) __attribute__((__noreturn__));
void vfatal_nodebug(const char *, va_list ap) __printf0like(1, 0) __attribute__((__noreturn__));
void vfatalx_nodebug(const char *, va_list ap) __printflike(1, 0) __attribute__((__noreturn__));
void warning_nodebug(const char *, ...) __printf0like(1, 2);
void warningx_nodebug(const char *, ...) __printflike(1, 2);
void vwarning_nodebug(const char *, va_list ap) __printf0like(1, 0);
void vwarningx_nodebug(const char *, va_list ap) __printflike(1, 0);
#endif /* _SUDO_FATAL_H_ */

View File

@ -54,6 +54,7 @@
# define _(String) gettext(String)
# define gettext_noop(String) String
# define N_(String) gettext_noop(String)
# define U_(String) warning_gettext(String)
#else /* !HAVE_LIBINTL_H */

View File

@ -63,6 +63,13 @@
# define __printf0like(f, v)
# endif
#endif
#ifndef __format_arg
# if __GNUC_PREREQ__(2, 7)
# define __format_arg(f) __attribute__((__format_arg__ (f)))
# else
# define __format_arg(f)
# endif
#endif
/* Hint to compiler that returned pointer is unique (malloc but not realloc). */
#ifndef __malloc_like

View File

@ -56,22 +56,22 @@ sudo_fwtk_init(struct passwd *pw, sudo_auth *auth)
debug_decl(sudo_fwtk_init, SUDO_DEBUG_AUTH)
if ((confp = cfg_read("sudo")) == (Cfg *)-1) {
warningx(_("unable to read fwtk config"));
warningx(U_("unable to read fwtk config"));
debug_return_int(AUTH_FATAL);
}
if (auth_open(confp)) {
warningx(_("unable to connect to authentication server"));
warningx(U_("unable to connect to authentication server"));
debug_return_int(AUTH_FATAL);
}
/* Get welcome message from auth server */
if (auth_recv(resp, sizeof(resp))) {
warningx(_("lost connection to authentication server"));
warningx(U_("lost connection to authentication server"));
debug_return_int(AUTH_FATAL);
}
if (strncmp(resp, "Authsrv ready", 13) != 0) {
warningx(_("authentication server error:\n%s"), resp);
warningx(U_("authentication server error:\n%s"), resp);
debug_return_int(AUTH_FATAL);
}
@ -91,7 +91,7 @@ sudo_fwtk_verify(struct passwd *pw, char *prompt, sudo_auth *auth)
(void) snprintf(buf, sizeof(buf), "authorize %s 'sudo'", pw->pw_name);
restart:
if (auth_send(buf) || auth_recv(resp, sizeof(resp))) {
warningx(_("lost connection to authentication server"));
warningx(U_("lost connection to authentication server"));
debug_return_int(AUTH_FATAL);
}
@ -124,7 +124,7 @@ restart:
/* Send the user's response to the server */
(void) snprintf(buf, sizeof(buf), "response '%s'", pass);
if (auth_send(buf) || auth_recv(resp, sizeof(resp))) {
warningx(_("lost connection to authentication server"));
warningx(U_("lost connection to authentication server"));
error = AUTH_FATAL;
goto done;
}

View File

@ -100,7 +100,7 @@ sudo_rfc1938_setup(struct passwd *pw, char **promptp, sudo_auth *auth)
*/
if (rfc1938challenge(&rfc1938, pw->pw_name, challenge, sizeof(challenge))) {
if (IS_ONEANDONLY(auth)) {
warningx(_("you do not exist in the %s database"), auth->name);
warningx(U_("you do not exist in the %s database"), auth->name);
debug_return_int(AUTH_FATAL);
} else {
debug_return_int(AUTH_FAILURE);

View File

@ -77,7 +77,7 @@ sudo_securid_init(struct passwd *pw, sudo_auth *auth)
if (AceInitialize() != SD_FALSE)
debug_return_int(AUTH_SUCCESS);
warningx(_("failed to initialise the ACE API library"));
warningx(U_("failed to initialise the ACE API library"));
debug_return_int(AUTH_FATAL);
}
@ -103,7 +103,7 @@ sudo_securid_setup(struct passwd *pw, char **promptp, sudo_auth *auth)
/* Re-initialize SecurID every time. */
if (SD_Init(sd) != ACM_OK) {
warningx(_("unable to contact the SecurID server"));
warningx(U_("unable to contact the SecurID server"));
debug_return_int(AUTH_FATAL);
}
@ -112,23 +112,23 @@ sudo_securid_setup(struct passwd *pw, char **promptp, sudo_auth *auth)
switch (retval) {
case ACM_OK:
warningx(_("User ID locked for SecurID Authentication"));
warningx(U_("User ID locked for SecurID Authentication"));
debug_return_int(AUTH_SUCCESS);
case ACE_UNDEFINED_USERNAME:
warningx(_("invalid username length for SecurID"));
warningx(U_("invalid username length for SecurID"));
debug_return_int(AUTH_FATAL);
case ACE_ERR_INVALID_HANDLE:
warningx(_("invalid Authentication Handle for SecurID"));
warningx(U_("invalid Authentication Handle for SecurID"));
debug_return_int(AUTH_FATAL);
case ACM_ACCESS_DENIED:
warningx(_("SecurID communication failed"));
warningx(U_("SecurID communication failed"));
debug_return_int(AUTH_FATAL);
default:
warningx(_("unknown SecurID error"));
warningx(U_("unknown SecurID error"));
debug_return_int(AUTH_FATAL);
}
}
@ -162,17 +162,17 @@ sudo_securid_verify(struct passwd *pw, char *pass, sudo_auth *auth)
break;
case ACE_UNDEFINED_PASSCODE:
warningx(_("invalid passcode length for SecurID"));
warningx(U_("invalid passcode length for SecurID"));
rval = AUTH_FATAL;
break;
case ACE_UNDEFINED_USERNAME:
warningx(_("invalid username length for SecurID"));
warningx(U_("invalid username length for SecurID"));
rval = AUTH_FATAL;
break;
case ACE_ERR_INVALID_HANDLE:
warningx(_("invalid Authentication Handle for SecurID"));
warningx(U_("invalid Authentication Handle for SecurID"));
rval = AUTH_FATAL;
break;
@ -211,7 +211,7 @@ then enter the new token code.\n", \
break;
default:
warningx(_("unknown SecurID error"));
warningx(U_("unknown SecurID error"));
rval = AUTH_FATAL;
break;
}

View File

@ -88,7 +88,7 @@ bsm_audit_success(char **exec_args)
if (auditon(A_GETCOND, (caddr_t)&au_cond, sizeof(long)) < 0) {
if (errno == AUDIT_NOT_CONFIGURED)
return;
fatal(_("Could not determine audit condition"));
fatal(U_("Could not determine audit condition"));
}
if (au_cond == AUC_NOAUDIT)
debug_return;
@ -131,7 +131,7 @@ bsm_audit_success(char **exec_args)
#else
if (au_close(aufd, 1, AUE_sudo) == -1)
#endif
fatal(_("unable to commit audit record"));
fatal(U_("unable to commit audit record"));
debug_return;
}
@ -155,7 +155,7 @@ bsm_audit_failure(char **exec_args, char const *const fmt, va_list ap)
if (auditon(A_GETCOND, (caddr_t)&au_cond, sizeof(long)) < 0) {
if (errno == AUDIT_NOT_CONFIGURED)
debug_return;
fatal(_("Could not determine audit condition"));
fatal(U_("Could not determine audit condition"));
}
if (au_cond == AUC_NOAUDIT)
debug_return;
@ -196,6 +196,6 @@ bsm_audit_failure(char **exec_args, char const *const fmt, va_list ap)
#else
if (au_close(aufd, 1, AUE_sudo) == -1)
#endif
fatal(_("unable to commit audit record"));
fatal(U_("unable to commit audit record"));
debug_return;
}

View File

@ -204,7 +204,7 @@ set_default(char *var, char *val, int op)
break;
}
if (!cur->name) {
warningx(_("unknown defaults entry `%s'"), var);
warningx(U_("unknown defaults entry `%s'"), var);
debug_return_bool(false);
}
@ -212,20 +212,20 @@ set_default(char *var, char *val, int op)
case T_LOGFAC:
if (!store_syslogfac(val, cur, op)) {
if (val)
warningx(_("value `%s' is invalid for option `%s'"),
warningx(U_("value `%s' is invalid for option `%s'"),
val, var);
else
warningx(_("no value specified for `%s'"), var);
warningx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
break;
case T_LOGPRI:
if (!store_syslogpri(val, cur, op)) {
if (val)
warningx(_("value `%s' is invalid for option `%s'"),
warningx(U_("value `%s' is invalid for option `%s'"),
val, var);
else
warningx(_("no value specified for `%s'"), var);
warningx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
break;
@ -233,16 +233,16 @@ set_default(char *var, char *val, int op)
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
if (!ISSET(cur->type, T_BOOL) || op != false) {
warningx(_("no value specified for `%s'"), var);
warningx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
}
if (ISSET(cur->type, T_PATH) && val && *val != '/') {
warningx(_("values for `%s' must start with a '/'"), var);
warningx(U_("values for `%s' must start with a '/'"), var);
debug_return_bool(false);
}
if (!store_str(val, cur, op)) {
warningx(_("value `%s' is invalid for option `%s'"), val, var);
warningx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
@ -250,12 +250,12 @@ set_default(char *var, char *val, int op)
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
if (!ISSET(cur->type, T_BOOL) || op != false) {
warningx(_("no value specified for `%s'"), var);
warningx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
}
if (!store_int(val, cur, op)) {
warningx(_("value `%s' is invalid for option `%s'"), val, var);
warningx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
@ -263,12 +263,12 @@ set_default(char *var, char *val, int op)
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
if (!ISSET(cur->type, T_BOOL) || op != false) {
warningx(_("no value specified for `%s'"), var);
warningx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
}
if (!store_uint(val, cur, op)) {
warningx(_("value `%s' is invalid for option `%s'"), val, var);
warningx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
@ -276,12 +276,12 @@ set_default(char *var, char *val, int op)
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
if (!ISSET(cur->type, T_BOOL) || op != false) {
warningx(_("no value specified for `%s'"), var);
warningx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
}
if (!store_float(val, cur, op)) {
warningx(_("value `%s' is invalid for option `%s'"), val, var);
warningx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
@ -289,18 +289,18 @@ set_default(char *var, char *val, int op)
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
if (!ISSET(cur->type, T_BOOL) || op != false) {
warningx(_("no value specified for `%s'"), var);
warningx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
}
if (!store_mode(val, cur, op)) {
warningx(_("value `%s' is invalid for option `%s'"), val, var);
warningx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
case T_FLAG:
if (val) {
warningx(_("option `%s' does not take a value"), var);
warningx(U_("option `%s' does not take a value"), var);
debug_return_bool(false);
}
cur->sd_un.flag = op;
@ -309,22 +309,22 @@ set_default(char *var, char *val, int op)
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
if (!ISSET(cur->type, T_BOOL) || op != false) {
warningx(_("no value specified for `%s'"), var);
warningx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
}
if (!store_list(val, cur, op)) {
warningx(_("value `%s' is invalid for option `%s'"), val, var);
warningx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
case T_TUPLE:
if (!val && !ISSET(cur->type, T_BOOL)) {
warningx(_("no value specified for `%s'"), var);
warningx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
if (!store_tuple(val, cur, op)) {
warningx(_("value `%s' is invalid for option `%s'"), val, var);
warningx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
@ -590,7 +590,7 @@ check_defaults(int what, bool quiet)
}
if (cur->name == NULL) {
if (!quiet)
warningx(_("unknown defaults entry `%s'"), def->var);
warningx(U_("unknown defaults entry `%s'"), def->var);
rc = false;
}
}

View File

@ -285,12 +285,12 @@ sudo_putenv_nodebug(char *str, bool dupcheck, bool overwrite)
size_t nsize;
if (env.env_size > SIZE_MAX - 128) {
fatalx_nodebug(_("internal error, %s overflow"),
fatalx_nodebug(U_("internal error, %s overflow"),
"sudo_putenv_nodebug()");
}
nsize = env.env_size + 128;
if (nsize > SIZE_MAX / sizeof(char *)) {
fatalx_nodebug(_("internal error, %s overflow"),
fatalx_nodebug(U_("internal error, %s overflow"),
"sudo_putenv_nodebug()");
}
nenvp = realloc(env.envp, nsize * sizeof(char *));
@ -364,7 +364,7 @@ sudo_putenv(char *str, bool dupcheck, bool overwrite)
if (rval == -1) {
#ifdef ENV_DEBUG
if (env.envp[env.env_len] != NULL)
fatalx(_("sudo_putenv: corrupted envp, length mismatch"));
fatalx(U_("sudo_putenv: corrupted envp, length mismatch"));
#endif
fatal(NULL);
}
@ -392,7 +392,7 @@ sudo_setenv2(const char *var, const char *val, bool dupcheck, bool overwrite)
strlcat(estring, "=", esize) >= esize ||
strlcat(estring, val, esize) >= esize) {
fatalx(_("internal error, %s overflow"), "sudo_setenv2()");
fatalx(U_("internal error, %s overflow"), "sudo_setenv2()");
}
rval = sudo_putenv(estring, dupcheck, overwrite);
if (rval == -1)

View File

@ -99,28 +99,28 @@ group_plugin_load(char *plugin_info)
goto done;
}
if (sb.st_uid != ROOT_UID) {
warningx(_("%s must be owned by uid %d"), path, ROOT_UID);
warningx(U_("%s must be owned by uid %d"), path, ROOT_UID);
goto done;
}
if ((sb.st_mode & (S_IWGRP|S_IWOTH)) != 0) {
warningx(_("%s must only be writable by owner"), path);
warningx(U_("%s must only be writable by owner"), path);
goto done;
}
/* Open plugin and map in symbol. */
group_handle = dlopen(path, RTLD_LAZY|RTLD_GLOBAL);
if (!group_handle) {
warningx(_("unable to dlopen %s: %s"), path, dlerror());
warningx(U_("unable to dlopen %s: %s"), path, dlerror());
goto done;
}
group_plugin = dlsym(group_handle, "group_plugin");
if (group_plugin == NULL) {
warningx(_("unable to find symbol \"group_plugin\" in %s"), path);
warningx(U_("unable to find symbol \"group_plugin\" in %s"), path);
goto done;
}
if (GROUP_API_VERSION_GET_MAJOR(group_plugin->version) != GROUP_API_VERSION_MAJOR) {
warningx(_("%s: incompatible group plugin major version %d, expected %d"),
warningx(U_("%s: incompatible group plugin major version %d, expected %d"),
path, GROUP_API_VERSION_GET_MAJOR(group_plugin->version),
GROUP_API_VERSION_MAJOR);
goto done;

View File

@ -438,7 +438,7 @@ iolog_deserialize_info(struct iolog_details *details, char * const user_info[],
if (runas_uid_str != NULL) {
id = atoid(runas_uid_str, NULL, NULL, &errstr);
if (errstr != NULL)
warningx("runas uid %s: %s", runas_uid_str, _(errstr));
warningx("runas uid %s: %s", runas_uid_str, U_(errstr));
else
runas_uid = (uid_t)id;
}
@ -447,7 +447,7 @@ iolog_deserialize_info(struct iolog_details *details, char * const user_info[],
if (runas_gid_str != NULL) {
id = atoid(runas_gid_str, NULL, NULL, &errstr);
if (errstr != NULL)
warningx("runas gid %s: %s", runas_gid_str, _(errstr));
warningx("runas gid %s: %s", runas_gid_str, U_(errstr));
else
runas_gid = (gid_t)id;
}

View File

@ -404,7 +404,7 @@ sudo_ldap_conf_add_ports(void)
hostbuf[0] = '\0';
len = snprintf(defport, sizeof(defport), ":%d", ldap_conf.port);
if (len <= 0 || (size_t)len >= sizeof(defport))
fatalx(_("sudo_ldap_conf_add_ports: port too large"));
fatalx(U_("sudo_ldap_conf_add_ports: port too large"));
for ((host = strtok(ldap_conf.host, " \t")); host; (host = strtok(NULL, " \t"))) {
if (hostbuf[0] != '\0') {
@ -427,7 +427,7 @@ sudo_ldap_conf_add_ports(void)
debug_return;
toobig:
fatalx(_("sudo_ldap_conf_add_ports: out of space expanding hostbuf"));
fatalx(U_("sudo_ldap_conf_add_ports: out of space expanding hostbuf"));
}
#endif
@ -459,7 +459,7 @@ sudo_ldap_parse_uri(const struct ldap_config_str_list *uri_list)
nldaps++;
host = uri + 8;
} else {
warningx(_("unsupported LDAP uri type: %s"), uri);
warningx(U_("unsupported LDAP uri type: %s"), uri);
goto done;
}
@ -490,11 +490,11 @@ sudo_ldap_parse_uri(const struct ldap_config_str_list *uri_list)
if (nldaps != 0) {
if (nldap != 0) {
warningx(_("unable to mix ldap and ldaps URIs"));
warningx(U_("unable to mix ldap and ldaps URIs"));
goto done;
}
if (ldap_conf.ssl_mode == SUDO_LDAP_STARTTLS)
warningx(_("starttls not supported when using ldaps"));
warningx(U_("starttls not supported when using ldaps"));
ldap_conf.ssl_mode = SUDO_LDAP_SSL;
}
efree(buf);
@ -512,7 +512,7 @@ done:
debug_return_int(rc);
toobig:
fatalx(_("sudo_ldap_parse_uri: out of space building hostbuf"));
fatalx(U_("sudo_ldap_parse_uri: out of space building hostbuf"));
}
#else
static char *
@ -526,7 +526,7 @@ sudo_ldap_join_uri(struct ldap_config_str_list *uri_list)
STAILQ_FOREACH(uri, uri_list, entries) {
if (ldap_conf.ssl_mode == SUDO_LDAP_STARTTLS) {
if (strncasecmp(uri->val, "ldaps://", 8) == 0) {
warningx(_("starttls not supported when using ldaps"));
warningx(U_("starttls not supported when using ldaps"));
ldap_conf.ssl_mode = SUDO_LDAP_SSL;
}
}
@ -593,10 +593,10 @@ sudo_ldap_init(LDAP **ldp, const char *host, int port)
}
}
if (rc != LDAP_SUCCESS) {
warningx(_("unable to initialize SSL cert and key db: %s"),
warningx(U_("unable to initialize SSL cert and key db: %s"),
ldapssl_err2string(rc));
if (ldap_conf.tls_certfile == NULL)
warningx(_("you must set TLS_CERT in %s to use SSL"),
warningx(U_("you must set TLS_CERT in %s to use SSL"),
path_ldap_conf);
goto done;
}
@ -1087,13 +1087,13 @@ sudo_ldap_timefilter(char *buffer, size_t buffersize)
/* Make sure we have a formatted timestamp for __now__. */
time(&now);
if ((tp = gmtime(&now)) == NULL) {
warning(_("unable to get GMT time"));
warning(U_("unable to get GMT time"));
goto done;
}
/* Format the timestamp according to the RFC. */
if (strftime(timebuffer, sizeof(timebuffer), "%Y%m%d%H%M%S.0Z", tp) == 0) {
warningx(_("unable to format timestamp"));
warningx(U_("unable to format timestamp"));
goto done;
}
@ -1101,7 +1101,7 @@ sudo_ldap_timefilter(char *buffer, size_t buffersize)
bytes = snprintf(buffer, buffersize, "(&(|(!(sudoNotAfter=*))(sudoNotAfter>=%s))(|(!(sudoNotBefore=*))(sudoNotBefore<=%s)))",
timebuffer, timebuffer);
if (bytes <= 0 || (size_t)bytes >= buffersize) {
warning(_("unable to build time filter"));
warning(U_("unable to build time filter"));
bytes = 0;
}
@ -1320,7 +1320,7 @@ sudo_ldap_build_pass1(struct passwd *pw)
/* Add ALL to list and end the global OR */
if (strlcat(buf, "(sudoUser=ALL)", sz) >= sz)
fatalx(_("sudo_ldap_build_pass1 allocation mismatch"));
fatalx(U_("sudo_ldap_build_pass1 allocation mismatch"));
/* Add the time restriction, or simply end the global OR. */
if (ldap_conf.timed) {
@ -2494,7 +2494,7 @@ sudo_ldap_open(struct sudo_nss *nss)
rc = ldap_initialize(&ld, buf);
efree(buf);
if (rc != LDAP_SUCCESS) {
warningx(_("unable to initialize LDAP: %s"),
warningx(U_("unable to initialize LDAP: %s"),
ldap_err2string(rc));
}
}
@ -2536,7 +2536,7 @@ sudo_ldap_open(struct sudo_nss *nss)
}
DPRINTF1("ldap_start_tls_s_np() ok");
#else
warningx(_("start_tls specified but LDAP libs do not support ldap_start_tls_s() or ldap_start_tls_s_np()"));
warningx(U_("start_tls specified but LDAP libs do not support ldap_start_tls_s() or ldap_start_tls_s_np()"));
#endif /* !HAVE_LDAP_START_TLS_S && !HAVE_LDAP_START_TLS_S_NP */
}
@ -2769,7 +2769,7 @@ sudo_ldap_result_add_entry(struct ldap_result *lres, LDAPMessage *entry)
DPRINTF2("order attribute raw: %s", (*bv)->bv_val);
order = strtod((*bv)->bv_val, &ep);
if (ep == (*bv)->bv_val || *ep != '\0') {
warningx(_("invalid sudoOrder attribute: %s"), (*bv)->bv_val);
warningx(U_("invalid sudoOrder attribute: %s"), (*bv)->bv_val);
order = 0.0;
}
DPRINTF2("order attribute: %f", order);

View File

@ -54,7 +54,7 @@ static linux_audit_open(void)
if (au_fd == -1) {
/* Kernel may not have audit support. */
if (errno != EINVAL && errno != EPROTONOSUPPORT && errno != EAFNOSUPPORT)
fatal(_("unable to open audit system"));
fatal(U_("unable to open audit system"));
} else {
(void)fcntl(au_fd, F_SETFD, FD_CLOEXEC);
}
@ -79,7 +79,7 @@ linux_audit_command(char *argv[], int result)
for (av = argv; *av != NULL; av++) {
n = strlcpy(cp, *av, size - (cp - command));
if (n >= size - (cp - command)) {
fatalx(_("internal error, %s overflow"),
fatalx(U_("internal error, %s overflow"),
"linux_audit_command()");
}
cp += n;
@ -90,7 +90,7 @@ linux_audit_command(char *argv[], int result)
/* Log command, ignoring ECONNREFUSED on error. */
rc = audit_log_user_command(au_fd, AUDIT_USER_CMD, command, NULL, result);
if (rc <= 0 && errno != ECONNREFUSED)
warning(_("unable to send audit message"));
warning(U_("unable to send audit message"));
efree(command);

View File

@ -108,16 +108,15 @@ sudoers_setlocale(int newlocale, int *prevlocale)
return res ? true : false;
}
static int warning_locale;
void
warning_set_locale(void)
char *
warning_gettext(const char *msgid)
{
int warning_locale;
char *msg;
sudoers_setlocale(SUDOERS_LOCALE_USER, &warning_locale);
}
void
warning_restore_locale(void)
{
msg = gettext(msgid);
sudoers_setlocale(warning_locale, NULL);
return msg;
}

View File

@ -332,9 +332,9 @@ log_failure(int status, int flags)
* their path to just contain a single dir.
*/
if (flags == NOT_FOUND)
warningx(_("%s: command not found"), user_cmnd);
warningx(U_("%s: command not found"), user_cmnd);
else if (flags == NOT_FOUND_DOT)
warningx(_("ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run."), user_cmnd, user_cmnd, user_cmnd);
warningx(U_("ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run."), user_cmnd, user_cmnd, user_cmnd);
}
debug_return;
@ -491,18 +491,18 @@ vlog_warning(int flags, const char *fmt, va_list ap)
* Tell the user (in their locale).
*/
if (!ISSET(flags, NO_STDERR)) {
warning_set_locale();
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
if (fmt == INCORRECT_PASSWORD_ATTEMPT) {
int tries = va_arg(ap2, int);
warningx2(ngettext("%d incorrect password attempt",
warningx_nodebug(ngettext("%d incorrect password attempt",
"%d incorrect password attempts", tries), tries);
} else {
if (ISSET(flags, USE_ERRNO))
vwarning2(_(fmt), ap2);
vwarning_nodebug(_(fmt), ap2);
else
vwarningx2(_(fmt), ap2);
vwarningx_nodebug(_(fmt), ap2);
}
warning_restore_locale();
sudoers_setlocale(oldlocale, NULL);
va_end(ap2);
}
@ -579,7 +579,7 @@ send_mail(const char *fmt, ...)
switch (pid = sudo_debug_fork()) {
case -1:
/* Error. */
fatal(_("unable to fork"));
fatal(U_("unable to fork"));
break;
case 0:
/* Child. */
@ -911,5 +911,5 @@ new_logline(const char *message, int serrno)
debug_return_str(line);
toobig:
fatalx(_("internal error: insufficient space for log line"));
fatalx(U_("internal error: insufficient space for log line"));
}

View File

@ -605,7 +605,7 @@ digest_matches(char *file, struct sudo_digest *sd)
}
}
if (func == NULL) {
warningx(_("unsupported digest type %d for %s"), sd->digest_type, file);
warningx(U_("unsupported digest type %d for %s"), sd->digest_type, file);
debug_return_bool(false);
}
if (strlen(sd->digest_str) == func->digest_len * 2) {
@ -635,7 +635,7 @@ digest_matches(char *file, struct sudo_digest *sd)
func->update(&ctx, buf, nread);
}
if (ferror(fp)) {
warningx(_("%s: read error"), file);
warningx(U_("%s: read error"), file);
fclose(fp);
debug_return_bool(false);
}
@ -644,7 +644,7 @@ digest_matches(char *file, struct sudo_digest *sd)
debug_return_bool(memcmp(file_digest, sudoers_digest, func->digest_len) == 0);
bad_format:
warningx(_("digest for %s (%s) is not in %s form"), file,
warningx(U_("digest for %s (%s) is not in %s form"), file,
sd->digest_str, func->digest_name);
debug_return_bool(false);
}

View File

@ -108,14 +108,14 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
p = *cur + sizeof("sudoers_uid=") - 1;
sudoers_uid = (uid_t) atoid(p, NULL, NULL, &errstr);
if (errstr != NULL)
fatalx(_("%s: %s"), *cur, _(errstr));
fatalx(U_("%s: %s"), *cur, U_(errstr));
continue;
}
if (MATCHES(*cur, "sudoers_gid=")) {
p = *cur + sizeof("sudoers_gid=") - 1;
sudoers_gid = (gid_t) atoid(p, NULL, NULL, &errstr);
if (errstr != NULL)
fatalx(_("%s: %s"), *cur, _(errstr));
fatalx(U_("%s: %s"), *cur, U_(errstr));
continue;
}
if (MATCHES(*cur, "sudoers_mode=")) {
@ -123,10 +123,10 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
p = *cur + sizeof("sudoers_mode=") - 1;
lval = strtol(p, &ep, 8);
if (*p == '\0' || *ep != '\0')
fatalx(_("%s: %s"), *cur, _("invalid value"));
fatalx(U_("%s: %s"), *cur, U_("invalid value"));
if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
|| (lval > 0777 || lval < 0))
fatalx(_("%s: %s"), *cur, _("value out of range"));
fatalx(U_("%s: %s"), *cur, U_("value out of range"));
sudoers_mode = (mode_t) lval;
continue;
}
@ -149,10 +149,10 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
p = *cur + sizeof("closefrom=") - 1;
lval = strtol(p, &ep, 10);
if (*p == '\0' || *ep != '\0')
fatalx(_("%s: %s"), *cur, _("invalid value"));
fatalx(U_("%s: %s"), *cur, U_("invalid value"));
if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
|| (lval > INT_MAX || lval < 3))
fatalx(_("%s: %s"), *cur, _("value out of range"));
fatalx(U_("%s: %s"), *cur, U_("value out of range"));
user_closefrom = (int) lval;
continue;
}
@ -269,10 +269,10 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
p = *cur + sizeof("max_groups=") - 1;
lval = strtol(p, &ep, 10);
if (*p == '\0' || *ep != '\0')
fatalx(_("%s: %s"), *cur, _("invalid value"));
fatalx(U_("%s: %s"), *cur, U_("invalid value"));
if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
|| (lval > INT_MAX || lval <= 0))
fatalx(_("%s: %s"), *cur, _("value out of range"));
fatalx(U_("%s: %s"), *cur, U_("value out of range"));
sudo_user.max_groups = (int) lval;
continue;
}
@ -291,14 +291,14 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
p = *cur + sizeof("uid=") - 1;
user_uid = (uid_t) atoid(p, NULL, NULL, &errstr);
if (errstr != NULL)
fatalx(_("%s: %s"), *cur, _(errstr));
fatalx(U_("%s: %s"), *cur, U_(errstr));
continue;
}
if (MATCHES(*cur, "gid=")) {
p = *cur + sizeof("gid=") - 1;
user_gid = (gid_t) atoid(p, NULL, NULL, &errstr);
if (errstr != NULL)
fatalx(_("%s: %s"), *cur, _(errstr));
fatalx(U_("%s: %s"), *cur, U_(errstr));
continue;
}
if (MATCHES(*cur, "groups=")) {
@ -326,10 +326,10 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
p = *cur + sizeof("lines=") - 1;
lval = strtol(p, &ep, 10);
if (*p == '\0' || *ep != '\0')
fatalx(_("%s: %s"), *cur, _("invalid value"));
fatalx(U_("%s: %s"), *cur, U_("invalid value"));
if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
|| (lval > INT_MAX || lval <= 0))
fatalx(_("%s: %s"), *cur, _("value out of range"));
fatalx(U_("%s: %s"), *cur, U_("value out of range"));
sudo_user.lines = (int) lval;
continue;
}
@ -338,10 +338,10 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
p = *cur + sizeof("cols=") - 1;
lval = strtol(p, &ep, 10);
if (*p == '\0' || *ep != '\0')
fatalx(_("%s: %s"), *cur, _("invalid value"));
fatalx(U_("%s: %s"), *cur, U_("invalid value"));
if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
|| (lval > INT_MAX || lval <= 0))
fatalx(_("%s: %s"), *cur, _("value out of range"));
fatalx(U_("%s: %s"), *cur, U_("value out of range"));
sudo_user.cols = (int) lval;
continue;
}
@ -349,7 +349,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
p = *cur + sizeof("sid=") - 1;
sudo_user.sid = (pid_t) atoid(p, NULL, NULL, &errstr);
if (errstr != NULL)
fatalx(_("%s: %s"), *cur, _(errstr));
fatalx(U_("%s: %s"), *cur, U_(errstr));
continue;
}
}
@ -464,14 +464,14 @@ sudoers_policy_exec_setup(char *argv[], char *envp[], mode_t cmnd_umask,
(unsigned int)runas_pw->pw_gid;
len = snprintf(cp, glsize - (cp - gid_list), "%u", egid);
if (len < 0 || (size_t)len >= glsize - (cp - gid_list))
fatalx(_("internal error, %s overflow"), "runas_groups");
fatalx(U_("internal error, %s overflow"), "runas_groups");
cp += len;
for (i = 0; i < grlist->ngids; i++) {
if (grlist->gids[i] != egid) {
len = snprintf(cp, glsize - (cp - gid_list), ",%u",
(unsigned int) grlist->gids[i]);
if (len < 0 || (size_t)len >= glsize - (cp - gid_list))
fatalx(_("internal error, %s overflow"), "runas_groups");
fatalx(U_("internal error, %s overflow"), "runas_groups");
cp += len;
}
}
@ -561,7 +561,7 @@ sudoers_policy_close(int exit_status, int error_code)
/* We do not currently log the exit status. */
if (error_code) {
errno = error_code;
warning(_("unable to execute %s"), safe_cmnd);
warning(U_("unable to execute %s"), safe_cmnd);
}
/* Close the session we opened in sudoers_policy_init_session(). */
@ -679,7 +679,7 @@ sudoers_policy_list(int argc, char * const argv[], int verbose,
if (list_user) {
list_pw = sudo_getpwnam(list_user);
if (list_pw == NULL) {
warningx(_("unknown user: %s"), list_user);
warningx(U_("unknown user: %s"), list_user);
debug_return_bool(-1);
}
}

View File

@ -168,5 +168,5 @@ expand_prompt(const char *old_prompt, const char *user, const char *host)
oflow:
/* We pre-allocate enough space, so this should never happen. */
fatalx(_("internal error, %s overflow"), "expand_prompt()");
fatalx(U_("internal error, %s overflow"), "expand_prompt()");
}

View File

@ -145,7 +145,7 @@ sudo_getpwuid(uid_t uid)
/* item->d.pw = NULL; */
}
if (rbinsert(pwcache_byuid, item) != NULL)
fatalx(_("unable to cache uid %u, already exists"),
fatalx(U_("unable to cache uid %u, already exists"),
(unsigned int) uid);
#ifdef HAVE_SETAUTHDB
aix_restoreauthdb();
@ -187,7 +187,7 @@ sudo_getpwnam(const char *name)
/* item->d.pw = NULL; */
}
if (rbinsert(pwcache_byname, item) != NULL)
fatalx(_("unable to cache user %s, already exists"), name);
fatalx(U_("unable to cache user %s, already exists"), name);
#ifdef HAVE_SETAUTHDB
aix_restoreauthdb();
#endif
@ -383,7 +383,7 @@ sudo_getgrgid(gid_t gid)
/* item->d.gr = NULL; */
}
if (rbinsert(grcache_bygid, item) != NULL)
fatalx(_("unable to cache gid %u, already exists"),
fatalx(U_("unable to cache gid %u, already exists"),
(unsigned int) gid);
done:
item->refcnt++;
@ -419,7 +419,7 @@ sudo_getgrnam(const char *name)
/* item->d.gr = NULL; */
}
if (rbinsert(grcache_byname, item) != NULL)
fatalx(_("unable to cache group %s, already exists"), name);
fatalx(U_("unable to cache group %s, already exists"), name);
done:
item->refcnt++;
debug_return_ptr(item->d.gr);
@ -575,7 +575,7 @@ sudo_get_grlist(struct passwd *pw)
/* item->d.grlist = NULL; */
}
if (rbinsert(grlist_cache, item) != NULL)
fatalx(_("unable to cache group list for %s, already exists"),
fatalx(U_("unable to cache group list for %s, already exists"),
pw->pw_name);
done:
item->refcnt++;
@ -595,9 +595,9 @@ sudo_set_grlist(struct passwd *pw, char * const *groups, char * const *gids)
key.k.name = pw->pw_name;
if ((node = rbfind(grlist_cache, &key)) == NULL) {
if ((item = sudo_make_grlist_item(pw, groups, gids)) == NULL)
fatalx(_("unable to parse groups for %s"), pw->pw_name);
fatalx(U_("unable to parse groups for %s"), pw->pw_name);
if (rbinsert(grlist_cache, item) != NULL)
fatalx(_("unable to cache group list for %s, already exists"),
fatalx(U_("unable to cache group list for %s, already exists"),
pw->pw_name);
}
debug_return;

View File

@ -359,8 +359,10 @@ set_perms(int perm)
perm_stack_depth++;
debug_return_bool(1);
bad:
warningx("%s: %s", _(errstr),
errno == EAGAIN ? _("too many processes") : strerror(errno));
if (errno == EAGAIN)
warningx(U_("%s: %s"), U_(errstr), U_("too many processes"));
else
warning("%s", U_(errstr));
if (noexit)
debug_return_bool(0);
exit(1);
@ -696,8 +698,10 @@ set_perms(int perm)
perm_stack_depth++;
debug_return_bool(1);
bad:
warningx("%s: %s", _(errstr),
errno == EAGAIN ? _("too many processes") : strerror(errno));
if (errno == EAGAIN)
warningx(U_("%s: %s"), U_(errstr), U_("too many processes"));
else
warning("%s", U_(errstr));
if (noexit)
debug_return_bool(0);
exit(1);
@ -1053,8 +1057,10 @@ set_perms(int perm)
perm_stack_depth++;
debug_return_bool(1);
bad:
warningx("%s: %s", _(errstr),
errno == EAGAIN ? _("too many processes") : strerror(errno));
if (errno == EAGAIN)
warningx(U_("%s: %s"), U_(errstr), U_("too many processes"));
else
warning("%s", U_(errstr));
if (noexit)
debug_return_bool(0);
exit(1);
@ -1347,8 +1353,10 @@ set_perms(int perm)
perm_stack_depth++;
debug_return_bool(1);
bad:
warningx("%s: %s", _(errstr),
errno == EAGAIN ? _("too many processes") : strerror(errno));
if (errno == EAGAIN)
warningx(U_("%s: %s"), U_(errstr), U_("too many processes"));
else
warning("%s", U_(errstr));
if (noexit)
debug_return_bool(0);
exit(1);
@ -1513,8 +1521,10 @@ set_perms(int perm)
perm_stack_depth++;
debug_return_bool(1);
bad:
warningx("%s: %s", _(errstr),
errno == EAGAIN ? _("too many processes") : strerror(errno));
if (errno == EAGAIN)
warningx(U_("%s: %s"), U_(errstr), U_("too many processes"));
else
warning("%s", U_(errstr));
if (noexit)
debug_return_bool(0);
exit(1);

View File

@ -252,14 +252,14 @@ static int sudo_sss_open(struct sudo_nss *nss)
/* Load symbols */
handle->ssslib = dlopen(path, RTLD_LAZY);
if (handle->ssslib == NULL) {
warningx(_("unable to dlopen %s: %s"), path, dlerror());
warningx(_("unable to initialize SSS source. Is SSSD installed on your machine?"));
warningx(U_("unable to dlopen %s: %s"), path, dlerror());
warningx(U_("unable to initialize SSS source. Is SSSD installed on your machine?"));
debug_return_int(EFAULT);
}
handle->fn_send_recv = dlsym(handle->ssslib, "sss_sudo_send_recv");
if (handle->fn_send_recv == NULL) {
warningx(_("unable to find symbol \"%s\" in %s"), path,
warningx(U_("unable to find symbol \"%s\" in %s"), path,
"sss_sudo_send_recv");
debug_return_int(EFAULT);
}
@ -267,28 +267,28 @@ static int sudo_sss_open(struct sudo_nss *nss)
handle->fn_send_recv_defaults =
dlsym(handle->ssslib, "sss_sudo_send_recv_defaults");
if (handle->fn_send_recv_defaults == NULL) {
warningx(_("unable to find symbol \"%s\" in %s"), path,
warningx(U_("unable to find symbol \"%s\" in %s"), path,
"sss_sudo_send_recv_defaults");
debug_return_int(EFAULT);
}
handle->fn_free_result = dlsym(handle->ssslib, "sss_sudo_free_result");
if (handle->fn_free_result == NULL) {
warningx(_("unable to find symbol \"%s\" in %s"), path,
warningx(U_("unable to find symbol \"%s\" in %s"), path,
"sss_sudo_free_result");
debug_return_int(EFAULT);
}
handle->fn_get_values = dlsym(handle->ssslib, "sss_sudo_get_values");
if (handle->fn_get_values == NULL) {
warningx(_("unable to find symbol \"%s\" in %s"), path,
warningx(U_("unable to find symbol \"%s\" in %s"), path,
"sss_sudo_get_values");
debug_return_int(EFAULT);
}
handle->fn_free_values = dlsym(handle->ssslib, "sss_sudo_free_values");
if (handle->fn_free_values == NULL) {
warningx(_("unable to find symbol \"%s\" in %s"), path,
warningx(U_("unable to find symbol \"%s\" in %s"), path,
"sss_sudo_free_values");
debug_return_int(EFAULT);
}

View File

@ -160,7 +160,7 @@ sudoers_policy_init(void *info, char * const envp[])
}
}
if (sources == 0) {
warningx(_("no valid sudoers sources found, quitting"));
warningx(U_("no valid sudoers sources found, quitting"));
debug_return_bool(-1);
}
@ -222,7 +222,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
/* Is root even allowed to run sudo? */
if (user_uid == 0 && !def_root_sudo) {
warningx(_("sudoers specifies that root is not allowed to sudo"));
warningx(U_("sudoers specifies that root is not allowed to sudo"));
goto bad;
}
@ -261,7 +261,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
/* Check for -C overriding def_closefrom. */
if (user_closefrom >= 0 && user_closefrom != def_closefrom) {
if (!def_closefrom_override) {
warningx(_("you are not permitted to use the -C option"));
warningx(U_("you are not permitted to use the -C option"));
goto bad;
}
def_closefrom = user_closefrom;
@ -325,7 +325,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
/* Bail if a tty is required and we don't have one. */
if (def_requiretty && !tty_present()) {
audit_failure(NewArgv, N_("no tty"));
warningx(_("sorry, you must have a tty to run sudo"));
warningx(U_("sorry, you must have a tty to run sudo"));
goto bad;
}
@ -374,15 +374,15 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
/* Finally tell the user if the command did not exist. */
if (cmnd_status == NOT_FOUND_DOT) {
audit_failure(NewArgv, N_("command in current directory"));
warningx(_("ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run."), user_cmnd, user_cmnd, user_cmnd);
warningx(U_("ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run."), user_cmnd, user_cmnd, user_cmnd);
goto bad;
} else if (cmnd_status == NOT_FOUND) {
if (ISSET(sudo_mode, MODE_CHECK)) {
audit_failure(NewArgv, N_("%s: command not found"), NewArgv[0]);
warningx(_("%s: command not found"), NewArgv[0]);
warningx(U_("%s: command not found"), NewArgv[0]);
} else {
audit_failure(NewArgv, N_("%s: command not found"), user_cmnd);
warningx(_("%s: command not found"), user_cmnd);
warningx(U_("%s: command not found"), user_cmnd);
}
goto bad;
}
@ -390,7 +390,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
/* If user specified env vars make sure sudoers allows it. */
if (ISSET(sudo_mode, MODE_RUN) && !def_setenv) {
if (ISSET(sudo_mode, MODE_PRESERVE_ENV)) {
warningx(_("sorry, you are not allowed to preserve the environment"));
warningx(U_("sorry, you are not allowed to preserve the environment"));
goto bad;
} else
validate_env_vars(sudo_user.env_vars);
@ -558,7 +558,7 @@ init_vars(char * const envp[])
* YP/NIS/NIS+/LDAP/etc daemon has died.
*/
if (sudo_mode == MODE_KILL || sudo_mode == MODE_INVALIDATE)
fatalx(_("unknown uid: %u"), (unsigned int) user_uid);
fatalx(U_("unknown uid: %u"), (unsigned int) user_uid);
/* Need to make a fake struct passwd for the call to log_fatal(). */
sudo_user.pw = sudo_mkpwent(user_name, user_uid, user_gid, NULL, NULL);
@ -652,7 +652,7 @@ set_cmnd(void)
for (to = user_args, av = NewArgv + 1; *av; av++) {
n = strlcpy(to, *av, size - (to - user_args));
if (n >= size - (to - user_args))
fatalx(_("internal error, %s overflow"), "set_cmnd()");
fatalx(U_("internal error, %s overflow"), "set_cmnd()");
to += n;
*to++ = ' ';
}
@ -761,7 +761,7 @@ set_loginclass(struct passwd *pw)
if (login_class && strcmp(login_class, "-") != 0) {
if (user_uid != 0 &&
strcmp(runas_user ? runas_user : def_runas_default, "root") != 0)
fatalx(_("only root can use `-c %s'"), login_class);
fatalx(U_("only root can use `-c %s'"), login_class);
} else {
login_class = pw->pw_class;
if (!login_class || !*login_class)
@ -1001,7 +1001,7 @@ find_editor(int nfiles, char **files, char ***argv_out)
}
if (!editor_path) {
audit_failure(NewArgv, N_("%s: command not found"), editor);
warningx(_("%s: command not found"), editor);
warningx(U_("%s: command not found"), editor);
}
debug_return_str(editor_path);
}

View File

@ -274,7 +274,7 @@ main(int argc, char *argv[])
else if (strcmp(cp, "ttyout") == 0)
io_log_files[IOFD_TTYOUT].enabled = true;
else
fatalx(_("invalid filter option: %s"), optarg);
fatalx(U_("invalid filter option: %s"), optarg);
}
break;
case 'h':
@ -287,13 +287,13 @@ main(int argc, char *argv[])
errno = 0;
max_wait = strtod(optarg, &ep);
if (*ep != '\0' || errno != 0)
fatalx(_("invalid max wait: %s"), optarg);
fatalx(U_("invalid max wait: %s"), optarg);
break;
case 's':
errno = 0;
speed_factor = strtod(optarg, &ep);
if (*ep != '\0' || errno != 0)
fatalx(_("invalid speed factor: %s"), optarg);
fatalx(U_("invalid speed factor: %s"), optarg);
break;
case 'V':
(void) printf(_("%s version %s\n"), getprogname(), PACKAGE_VERSION);
@ -328,13 +328,13 @@ main(int argc, char *argv[])
plen = snprintf(path, sizeof(path), "%s/%.2s/%.2s/%.2s/timing",
session_dir, id, &id[2], &id[4]);
if (plen <= 0 || (size_t)plen >= sizeof(path))
fatalx(_("%s/%.2s/%.2s/%.2s/timing: %s"), session_dir,
fatalx(U_("%s/%.2s/%.2s/%.2s/timing: %s"), session_dir,
id, &id[2], &id[4], strerror(ENAMETOOLONG));
} else {
plen = snprintf(path, sizeof(path), "%s/%s/timing",
session_dir, id);
if (plen <= 0 || (size_t)plen >= sizeof(path))
fatalx(_("%s/%s/timing: %s"), session_dir,
fatalx(U_("%s/%s/timing: %s"), session_dir,
id, strerror(ENAMETOOLONG));
}
plen -= 7;
@ -342,7 +342,7 @@ main(int argc, char *argv[])
/* Open files for replay, applying replay filter for the -f flag. */
for (idx = 0; idx < IOFD_MAX; idx++) {
if (open_io_fd(path, plen, &io_log_files[idx]) == -1)
fatal(_("unable to open %s"), path);
fatal(U_("unable to open %s"), path);
}
/* Parse log file. */
@ -412,7 +412,7 @@ replay_session(const double max_wait, const char *decimal)
if (idx != -1)
(void) fcntl(STDIN_FILENO, F_SETFL, idx | O_NONBLOCK);
if (!term_raw(STDIN_FILENO, 1))
fatal(_("unable to set tty to raw mode"));
fatal(U_("unable to set tty to raw mode"));
}
/* Setup event base and input/output events. */
@ -442,7 +442,7 @@ replay_session(const double max_wait, const char *decimal)
char last_char = '\0';
if (!parse_timing(buf, decimal, &idx, &seconds, &nbytes))
fatalx(_("invalid timing file line: %s"), buf);
fatalx(U_("invalid timing file line: %s"), buf);
/* Adjust delay using speed factor and clamp to max_wait */
to_wait = seconds / speed_factor;
@ -581,7 +581,7 @@ write_output(int fd, int what, void *v)
switch (nwritten) {
case -1:
if (errno != EINTR && errno != EAGAIN)
fatal(_("unable to write to %s"), "stdout");
fatal(U_("unable to write to %s"), "stdout");
break;
case 0:
break;
@ -648,7 +648,7 @@ parse_expr(struct search_node_list *head, char *argv[], bool sub_expr)
continue;
case 'c': /* command */
if (av[0][1] == '\0')
fatalx(_("ambiguous expression \"%s\""), *av);
fatalx(U_("ambiguous expression \"%s\""), *av);
if (strncmp(*av, "cwd", strlen(*av)) == 0)
type = ST_CWD;
else if (strncmp(*av, "command", strlen(*av)) == 0)
@ -673,7 +673,7 @@ parse_expr(struct search_node_list *head, char *argv[], bool sub_expr)
break;
case 't': /* tty or to date */
if (av[0][1] == '\0')
fatalx(_("ambiguous expression \"%s\""), *av);
fatalx(U_("ambiguous expression \"%s\""), *av);
if (strncmp(*av, "todate", strlen(*av)) == 0)
type = ST_TODATE;
else if (strncmp(*av, "tty", strlen(*av)) == 0)
@ -695,11 +695,11 @@ parse_expr(struct search_node_list *head, char *argv[], bool sub_expr)
if (av[0][1] != '\0')
goto bad;
if (!sub_expr)
fatalx(_("unmatched ')' in expression"));
fatalx(U_("unmatched ')' in expression"));
debug_return_int(av - argv + 1);
bad:
default:
fatalx(_("unknown search term \"%s\""), *av);
fatalx(U_("unknown search term \"%s\""), *av);
/* NOTREACHED */
}
@ -713,17 +713,17 @@ parse_expr(struct search_node_list *head, char *argv[], bool sub_expr)
av += parse_expr(&sn->u.expr, av + 1, true);
} else {
if (*(++av) == NULL)
fatalx(_("%s requires an argument"), av[-1]);
fatalx(U_("%s requires an argument"), av[-1]);
#ifdef HAVE_REGCOMP
if (type == ST_PATTERN) {
if (regcomp(&sn->u.cmdre, *av, REG_EXTENDED|REG_NOSUB) != 0)
fatalx(_("invalid regular expression: %s"), *av);
fatalx(U_("invalid regular expression: %s"), *av);
} else
#endif
if (type == ST_TODATE || type == ST_FROMDATE) {
sn->u.tstamp = get_date(*av);
if (sn->u.tstamp == -1)
fatalx(_("could not parse date \"%s\""), *av);
fatalx(U_("could not parse date \"%s\""), *av);
} else {
sn->u.ptr = *av;
}
@ -732,11 +732,11 @@ parse_expr(struct search_node_list *head, char *argv[], bool sub_expr)
STAILQ_INSERT_TAIL(head, sn, entries);
}
if (sub_expr)
fatalx(_("unmatched '(' in expression"));
fatalx(U_("unmatched '(' in expression"));
if (or)
fatalx(_("illegal trailing \"or\""));
fatalx(U_("illegal trailing \"or\""));
if (not)
fatalx(_("illegal trailing \"!\""));
fatalx(U_("illegal trailing \"!\""));
debug_return_int(av - argv);
}
@ -789,7 +789,7 @@ match_expr(struct search_node_list *head, struct log_info *log, bool last_match)
res = log->tstamp <= sn->u.tstamp;
break;
default:
fatalx(_("unknown search type %d"), sn->type);
fatalx(U_("unknown search type %d"), sn->type);
/* NOTREACHED */
}
if (sn->negated)
@ -811,7 +811,7 @@ parse_logfile(char *logfile)
fp = fopen(logfile, "r");
if (fp == NULL) {
warning(_("unable to open %s"), logfile);
warning(U_("unable to open %s"), logfile);
goto bad;
}
@ -975,7 +975,7 @@ find_sessions(const char *dir, REGEX_T *re, const char *user, const char *tty)
d = opendir(dir);
if (d == NULL)
fatal(_("unable to open %s"), dir);
fatal(U_("unable to open %s"), dir);
/* XXX - would be faster to chdir and use relative names */
sdlen = strlcpy(pathbuf, dir, sizeof(pathbuf));
@ -1055,7 +1055,7 @@ list_sessions(int argc, char **argv, const char *pattern, const char *user,
if (pattern) {
re = &rebuf;
if (regcomp(re, pattern, REG_EXTENDED|REG_NOSUB) != 0)
fatalx(_("invalid regular expression: %s"), pattern);
fatalx(U_("invalid regular expression: %s"), pattern);
}
#else
re = (char *) pattern;
@ -1082,7 +1082,7 @@ check_input(int fd, int what, void *v)
switch (read(fd, &ch, 1)) {
case -1:
if (errno != EINTR && errno != EAGAIN)
fatal(_("unable to read %s"), "stdin");
fatal(U_("unable to read %s"), "stdin");
break;
case 0:
/* Ignore EOF. */

View File

@ -212,7 +212,7 @@ main(int argc, char *argv[])
argc -= 2;
}
if ((sudo_user.pw = sudo_getpwnam(user_name)) == NULL)
fatalx(_("unknown user: %s"), user_name);
fatalx(U_("unknown user: %s"), user_name);
if (user_host == NULL) {
if (gethostname(hbuf, sizeof(hbuf)) != 0)
@ -242,7 +242,7 @@ main(int argc, char *argv[])
for (to = user_args, from = argv; *from; from++) {
n = strlcpy(to, *from, size - (to - user_args));
if (n >= size - (to - user_args))
fatalx(_("internal error, %s overflow"), "init_vars()");
fatalx(U_("internal error, %s overflow"), "init_vars()");
to += n;
*to++ = ' ';
}
@ -360,7 +360,7 @@ set_runaspw(const char *user)
runas_pw = sudo_fakepwnam(user, runas_gr ? runas_gr->gr_gid : 0);
} else {
if ((runas_pw = sudo_getpwnam(user)) == NULL)
fatalx(_("unknown user: %s"), user);
fatalx(U_("unknown user: %s"), user);
}
debug_return;
@ -378,7 +378,7 @@ set_runasgr(const char *group)
runas_gr = sudo_fakegrnam(group);
} else {
if ((runas_gr = sudo_getgrnam(group)) == NULL)
fatalx(_("unknown group: %s"), group);
fatalx(U_("unknown group: %s"), group);
}
debug_return;

View File

@ -410,7 +410,7 @@ remove_timestamp(bool remove)
if (!remove) {
timevalclear(&tv);
if (touch(-1, path, &tv) == -1 && errno != ENOENT)
fatal(_("unable to reset %s to the Unix epoch"), path);
fatal(U_("unable to reset %s to the Unix epoch"), path);
}
}

View File

@ -4179,19 +4179,19 @@ _push_include(char *path, bool isdir)
debug_return_bool(false);
case SUDO_PATH_WRONG_OWNER:
if (sudoers_warnings) {
warningx(_("%s is owned by uid %u, should be %u"),
warningx(U_("%s is owned by uid %u, should be %u"),
path, (unsigned int) sb.st_uid,
(unsigned int) sudoers_uid);
}
debug_return_bool(false);
case SUDO_PATH_WORLD_WRITABLE:
if (sudoers_warnings) {
warningx(_("%s is world writable"), path);
warningx(U_("%s is world writable"), path);
}
debug_return_bool(false);
case SUDO_PATH_GROUP_WRITABLE:
if (sudoers_warnings) {
warningx(_("%s is owned by gid %u, should be %u"),
warningx(U_("%s is owned by gid %u, should be %u"),
path, (unsigned int) sb.st_gid,
(unsigned int) sudoers_gid);
}

View File

@ -920,19 +920,19 @@ _push_include(char *path, bool isdir)
debug_return_bool(false);
case SUDO_PATH_WRONG_OWNER:
if (sudoers_warnings) {
warningx(_("%s is owned by uid %u, should be %u"),
warningx(U_("%s is owned by uid %u, should be %u"),
path, (unsigned int) sb.st_uid,
(unsigned int) sudoers_uid);
}
debug_return_bool(false);
case SUDO_PATH_WORLD_WRITABLE:
if (sudoers_warnings) {
warningx(_("%s is world writable"), path);
warningx(U_("%s is world writable"), path);
}
debug_return_bool(false);
case SUDO_PATH_GROUP_WRITABLE:
if (sudoers_warnings) {
warningx(_("%s is owned by gid %u, should be %u"),
warningx(U_("%s is owned by gid %u, should be %u"),
path, (unsigned int) sb.st_gid,
(unsigned int) sudoers_gid);
}

View File

@ -173,7 +173,7 @@ fill_args(const char *s, int len, int addspace)
if (addspace)
*p++ = ' ';
if (strlcpy(p, s, arg_size - (p - sudoerslval.command.args)) != (size_t)len) {
warningx(_("fill_args: buffer overflow")); /* paranoia */
warningx(U_("fill_args: buffer overflow")); /* paranoia */
sudoerserror(NULL);
debug_return_bool(false);
}

View File

@ -229,7 +229,7 @@ main(int argc, char *argv[])
/* Mock up a fake sudo_user struct. */
user_cmnd = user_base = "";
if ((sudo_user.pw = sudo_getpwuid(getuid())) == NULL)
fatalx(_("you do not exist in the %s database"), "passwd");
fatalx(U_("you do not exist in the %s database"), "passwd");
get_hostname();
/* Setup defaults data structures. */
@ -333,7 +333,7 @@ edit_sudoers(struct sudoersfile *sp, char *editor, char *args, int lineno)
debug_decl(edit_sudoers, SUDO_DEBUG_UTIL)
if (fstat(sp->fd, &sb) == -1)
fatal(_("unable to stat %s"), sp->path);
fatal(U_("unable to stat %s"), sp->path);
orig_size = sb.st_size;
mtim_get(&sb, &orig_mtim);
@ -349,13 +349,13 @@ edit_sudoers(struct sudoersfile *sp, char *editor, char *args, int lineno)
(void) lseek(sp->fd, (off_t)0, SEEK_SET);
while ((nread = read(sp->fd, buf, sizeof(buf))) > 0)
if (write(tfd, buf, nread) != nread)
fatal(_("write error"));
fatal(U_("write error"));
/* Add missing newline at EOF if needed. */
if (nread > 0 && buf[nread - 1] != '\n') {
buf[0] = '\n';
if (write(tfd, buf, 1) != 1)
fatal(_("write error"));
fatal(U_("write error"));
}
}
(void) close(tfd);
@ -437,18 +437,18 @@ edit_sudoers(struct sudoersfile *sp, char *editor, char *args, int lineno)
* Sanity checks.
*/
if (stat(sp->tpath, &sb) < 0) {
warningx(_("unable to stat temporary file (%s), %s unchanged"),
warningx(U_("unable to stat temporary file (%s), %s unchanged"),
sp->tpath, sp->path);
goto done;
}
if (sb.st_size == 0 && orig_size != 0) {
warningx(_("zero length temporary file (%s), %s unchanged"),
warningx(U_("zero length temporary file (%s), %s unchanged"),
sp->tpath, sp->path);
sp->modified = true;
goto done;
}
} else {
warningx(_("editor (%s) failed, %s unchanged"), editor, sp->path);
warningx(U_("editor (%s) failed, %s unchanged"), editor, sp->path);
goto done;
}
@ -471,7 +471,7 @@ edit_sudoers(struct sudoersfile *sp, char *editor, char *args, int lineno)
if (modified)
sp->modified = modified;
else
warningx(_("%s unchanged"), sp->tpath);
warningx(U_("%s unchanged"), sp->tpath);
rval = true;
done:
@ -496,7 +496,7 @@ reparse_sudoers(char *editor, char *args, bool strict, bool quiet)
last = TAILQ_LAST(&sudoerslist, sudoersfile_list);
fp = fopen(sp->tpath, "r+");
if (fp == NULL)
fatalx(_("unable to re-open temporary file (%s), %s unchanged."),
fatalx(U_("unable to re-open temporary file (%s), %s unchanged."),
sp->tpath, sp->path);
/* Clean slate for each parse */
@ -506,7 +506,7 @@ reparse_sudoers(char *editor, char *args, bool strict, bool quiet)
/* Parse the sudoers temp file(s) */
sudoersrestart(fp);
if (sudoersparse() && !parse_error) {
warningx(_("unabled to parse temporary file (%s), unknown error"),
warningx(U_("unabled to parse temporary file (%s), unknown error"),
sp->tpath);
parse_error = true;
errorfile = sp->path;
@ -542,7 +542,7 @@ reparse_sudoers(char *editor, char *args, bool strict, bool quiet)
}
}
if (errorfile != NULL && sp == NULL) {
fatalx(_("internal error, unable to find %s in list!"),
fatalx(U_("internal error, unable to find %s in list!"),
sudoers);
}
break;
@ -598,23 +598,23 @@ install_sudoers(struct sudoersfile *sp, bool oldperms)
if (oldperms) {
/* Use perms of the existing file. */
if (fstat(sp->fd, &sb) == -1)
fatal(_("unable to stat %s"), sp->path);
fatal(U_("unable to stat %s"), sp->path);
if (chown(sp->tpath, sb.st_uid, sb.st_gid) != 0) {
warning(_("unable to set (uid, gid) of %s to (%u, %u)"),
warning(U_("unable to set (uid, gid) of %s to (%u, %u)"),
sp->tpath, (unsigned int)sb.st_uid, (unsigned int)sb.st_gid);
}
if (chmod(sp->tpath, sb.st_mode & 0777) != 0) {
warning(_("unable to change mode of %s to 0%o"), sp->tpath,
warning(U_("unable to change mode of %s to 0%o"), sp->tpath,
(unsigned int)(sb.st_mode & 0777));
}
} else {
if (chown(sp->tpath, SUDOERS_UID, SUDOERS_GID) != 0) {
warning(_("unable to set (uid, gid) of %s to (%u, %u)"),
warning(U_("unable to set (uid, gid) of %s to (%u, %u)"),
sp->tpath, SUDOERS_UID, SUDOERS_GID);
goto done;
}
if (chmod(sp->tpath, SUDOERS_MODE) != 0) {
warning(_("unable to change mode of %s to 0%o"), sp->tpath,
warning(U_("unable to change mode of %s to 0%o"), sp->tpath,
SUDOERS_MODE);
goto done;
}
@ -631,7 +631,7 @@ install_sudoers(struct sudoersfile *sp, bool oldperms)
} else {
if (errno == EXDEV) {
char *av[4];
warningx(_("%s and %s not on the same file system, using mv to rename"),
warningx(U_("%s and %s not on the same file system, using mv to rename"),
sp->tpath, sp->path);
/* Build up argument vector for the command */
@ -645,7 +645,7 @@ install_sudoers(struct sudoersfile *sp, bool oldperms)
/* And run it... */
if (run_command(_PATH_MV, av)) {
warningx(_("command failed: '%s %s %s', %s unchanged"),
warningx(U_("command failed: '%s %s %s', %s unchanged"),
_PATH_MV, sp->tpath, sp->path, sp->path);
(void) unlink(sp->tpath);
efree(sp->tpath);
@ -655,7 +655,7 @@ install_sudoers(struct sudoersfile *sp, bool oldperms)
efree(sp->tpath);
sp->tpath = NULL;
} else {
warning(_("error renaming %s, %s unchanged"), sp->tpath, sp->path);
warning(U_("error renaming %s, %s unchanged"), sp->tpath, sp->path);
(void) unlink(sp->tpath);
goto done;
}
@ -772,14 +772,14 @@ run_command(char *path, char **argv)
switch (pid = sudo_debug_fork()) {
case -1:
fatal(_("unable to execute %s"), path);
fatal(U_("unable to execute %s"), path);
break; /* NOTREACHED */
case 0:
sudo_endpwent();
sudo_endgrent();
closefrom(STDERR_FILENO + 1);
execv(path, argv);
warning(_("unable to run %s"), path);
warning(U_("unable to run %s"), path);
_exit(127);
break; /* NOTREACHED */
}
@ -831,13 +831,13 @@ check_syntax(char *sudoers_path, bool quiet, bool strict, bool oldperms)
sudoers_path = "stdin";
} else if ((sudoersin = fopen(sudoers_path, "r")) == NULL) {
if (!quiet)
warning(_("unable to open %s"), sudoers_path);
warning(U_("unable to open %s"), sudoers_path);
goto done;
}
init_parser(sudoers_path, quiet);
if (sudoersparse() && !parse_error) {
if (!quiet)
warningx(_("failed to parse %s file, unknown error"), sudoers_path);
warningx(U_("failed to parse %s file, unknown error"), sudoers_path);
parse_error = true;
errorfile = sudoers_path;
}
@ -917,7 +917,7 @@ open_sudoers(const char *path, bool doedit, bool *keepopen)
debug_return_ptr(NULL);
}
if (!checkonly && !lock_file(entry->fd, SUDO_TLOCK))
fatalx(_("%s busy, try again later"), entry->path);
fatalx(U_("%s busy, try again later"), entry->path);
if ((fp = fdopen(entry->fd, "r")) == NULL)
fatal("%s", entry->path);
TAILQ_INSERT_TAIL(&sudoerslist, entry, entries);
@ -961,7 +961,7 @@ get_editor(char **args)
} else {
if (def_env_editor) {
/* If we are honoring $EDITOR this is a fatal error. */
fatalx(_("specified editor (%s) doesn't exist"), UserEditor);
fatalx(U_("specified editor (%s) doesn't exist"), UserEditor);
} else {
/* Otherwise, just ignore $EDITOR. */
UserEditor = NULL;
@ -984,7 +984,7 @@ get_editor(char **args)
if (stat(UserEditor, &user_editor_sb) != 0) {
/* Should never happen since we already checked above. */
fatal(_("unable to stat editor (%s)"), UserEditor);
fatal(U_("unable to stat editor (%s)"), UserEditor);
}
EditorPath = estrdup(def_editor);
Editor = strtok(EditorPath, ":");
@ -1032,7 +1032,7 @@ get_editor(char **args)
/* Bleah, none of the editors existed! */
if (Editor == NULL || *Editor == '\0')
fatalx(_("no editor found (editor path = %s)"), def_editor);
fatalx(U_("no editor found (editor path = %s)"), def_editor);
}
*args = EditorArgs;
debug_return_str(Editor);
@ -1125,15 +1125,15 @@ check_alias(char *name, int type, int strict, int quiet)
if (!quiet) {
if (errno == ELOOP) {
warningx(strict ?
_("Error: cycle in %s_Alias `%s'") :
_("Warning: cycle in %s_Alias `%s'"),
U_("Error: cycle in %s_Alias `%s'") :
U_("Warning: cycle in %s_Alias `%s'"),
type == HOSTALIAS ? "Host" : type == CMNDALIAS ? "Cmnd" :
type == USERALIAS ? "User" : type == RUNASALIAS ? "Runas" :
"Unknown", name);
} else {
warningx(strict ?
_("Error: %s_Alias `%s' referenced but not defined") :
_("Warning: %s_Alias `%s' referenced but not defined"),
U_("Error: %s_Alias `%s' referenced but not defined") :
U_("Warning: %s_Alias `%s' referenced but not defined"),
type == HOSTALIAS ? "Host" : type == CMNDALIAS ? "Cmnd" :
type == USERALIAS ? "User" : type == RUNASALIAS ? "Runas" :
"Unknown", name);
@ -1275,7 +1275,7 @@ print_unused(void *v1, void *v2)
struct alias *a = (struct alias *)v1;
char *prefix = (char *)v2;
warningx_nodebug(_("%s: unused %s_Alias %s"), prefix,
warningx_nodebug(U_("%s: unused %s_Alias %s"), prefix,
a->type == HOSTALIAS ? "Host" : a->type == CMNDALIAS ? "Cmnd" :
a->type == USERALIAS ? "User" : a->type == RUNASALIAS ? "Runas" :
"Unknown", a->name);

View File

@ -569,7 +569,7 @@ print_defaults_json(int indent, bool need_comma)
break;
}
if (!cur->name) {
warningx(_("unknown defaults entry `%s'"), def->var);
warningx(U_("unknown defaults entry `%s'"), def->var);
/* XXX - just pass it through as a string anyway? */
continue;
}
@ -943,13 +943,13 @@ export_sudoers(char *sudoers_path, bool quiet, bool strict)
sudoers_path = "stdin";
} else if ((sudoersin = fopen(sudoers_path, "r")) == NULL) {
if (!quiet)
warning(_("unable to open %s"), sudoers_path);
warning(U_("unable to open %s"), sudoers_path);
goto done;
}
init_parser(sudoers_path, quiet);
if (sudoersparse() && !parse_error) {
if (!quiet)
warningx(_("failed to parse %s file, unknown error"), sudoers_path);
warningx(U_("failed to parse %s file, unknown error"), sudoers_path);
parse_error = true;
errorfile = sudoers_path;
}

View File

@ -130,12 +130,12 @@ static int fork_cmnd(struct command_details *details, int sv[2])
* or certain pam modules won't be able to track their state.
*/
if (policy_init_session(details) != true)
fatalx(_("policy plugin failed session initialization"));
fatalx(U_("policy plugin failed session initialization"));
cmnd_pid = sudo_debug_fork();
switch (cmnd_pid) {
case -1:
fatal(_("unable to fork"));
fatal(U_("unable to fork"));
break;
case 0:
/* child */
@ -306,7 +306,7 @@ exec_event_setup(int backchannel, struct exec_closure *ec)
if (signal_event == NULL)
fatal(NULL);
if (sudo_ev_add(evbase, signal_event, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
/* Event for command status via backchannel. */
backchannel_event = sudo_ev_alloc(backchannel,
@ -314,7 +314,7 @@ exec_event_setup(int backchannel, struct exec_closure *ec)
if (backchannel_event == NULL)
fatal(NULL);
if (sudo_ev_add(evbase, backchannel_event, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
/* The signal forwarding event gets added on demand. */
sigfwd_event = sudo_ev_alloc(backchannel,
@ -391,7 +391,7 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
* Parent sends signal info to child and child sends back wait status.
*/
if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1)
fatal(_("unable to create sockets"));
fatal(U_("unable to create sockets"));
/*
* Signals to forward to the child process (excluding SIGALRM and SIGCHLD).
@ -474,7 +474,7 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
if (log_io)
add_io_events(evbase);
if (sudo_ev_loop(evbase, 0) == -1)
warning(_("error in event loop"));
warning(U_("error in event loop"));
if (sudo_ev_got_break(evbase)) {
/* error from callback */
sudo_debug_printf(SUDO_DEBUG_ERROR, "event loop exited prematurely");
@ -489,7 +489,7 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
if (ISSET(details->flags, CD_RBAC_ENABLED)) {
/* This is probably not needed in log_io mode. */
if (selinux_restore_tty() != 0)
warningx(_("unable to restore tty label"));
warningx(U_("unable to restore tty label"));
}
#endif
@ -838,7 +838,7 @@ schedule_signal(struct sudo_event_base *evbase, int signo)
TAILQ_INSERT_TAIL(&sigfwd_list, sigfwd, entries);
if (sudo_ev_add(evbase, sigfwd_event, NULL, true) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
debug_return;
}

View File

@ -67,7 +67,7 @@ disable_execute(char *const envp[])
/* Solaris privileges, remove PRIV_PROC_EXEC post-execve. */
if (priv_set(PRIV_OFF, PRIV_LIMIT, "PRIV_PROC_EXEC", NULL) == 0)
debug_return_ptr(envp);
warning(_("unable to remove PRIV_PROC_EXEC from PRIV_LIMIT"));
warning(U_("unable to remove PRIV_PROC_EXEC from PRIV_LIMIT"));
#endif /* HAVE_PRIV_SET */
#ifdef _PATH_SUDO_NOEXEC

View File

@ -181,7 +181,7 @@ pty_setup(uid_t uid, const char *tty, const char *utmp_user)
if (io_fds[SFD_USERTTY] != -1) {
if (!get_pty(&io_fds[SFD_MASTER], &io_fds[SFD_SLAVE],
slavename, sizeof(slavename), uid))
fatal(_("unable to allocate pty"));
fatal(U_("unable to allocate pty"));
/* Add entry to utmp/utmpx? */
if (utmp_user != NULL)
utmp_login(tty, slavename, io_fds[SFD_SLAVE], utmp_user);
@ -504,12 +504,12 @@ io_callback(int fd, int what, void *v)
if (iob->wevent != NULL &&
(foreground || !USERTTY_EVENT(iob->wevent))) {
if (sudo_ev_add(evbase, iob->wevent, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
}
/* Re-enable reader if buffer is not full. */
if (iob->len != sizeof(iob->buf)) {
if (sudo_ev_add(evbase, iob->revent, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
}
break;
}
@ -567,14 +567,14 @@ io_callback(int fd, int what, void *v)
/* Re-enable writer if buffer is not empty. */
if (iob->len > iob->off) {
if (sudo_ev_add(evbase, iob->wevent, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
}
/* Enable reader if buffer is not full. */
if (iob->revent != NULL &&
(ttymode == TERM_RAW || !USERTTY_EVENT(iob->revent))) {
if (iob->len != sizeof(iob->buf)) {
if (sudo_ev_add(evbase, iob->revent, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
}
}
}
@ -679,7 +679,7 @@ fork_pty(struct command_details *details, int sv[], sigset_t *omask)
sudo_debug_printf(SUDO_DEBUG_INFO, "stdin not a tty, creating a pipe");
pipeline = true;
if (pipe(io_pipe[STDIN_FILENO]) != 0)
fatal(_("unable to create pipe"));
fatal(U_("unable to create pipe"));
io_buf_new(STDIN_FILENO, io_pipe[STDIN_FILENO][1],
log_stdin, &iobufs);
io_fds[SFD_STDIN] = io_pipe[STDIN_FILENO][0];
@ -688,7 +688,7 @@ fork_pty(struct command_details *details, int sv[], sigset_t *omask)
sudo_debug_printf(SUDO_DEBUG_INFO, "stdout not a tty, creating a pipe");
pipeline = true;
if (pipe(io_pipe[STDOUT_FILENO]) != 0)
fatal(_("unable to create pipe"));
fatal(U_("unable to create pipe"));
io_buf_new(io_pipe[STDOUT_FILENO][0], STDOUT_FILENO,
log_stdout, &iobufs);
io_fds[SFD_STDOUT] = io_pipe[STDOUT_FILENO][1];
@ -696,7 +696,7 @@ fork_pty(struct command_details *details, int sv[], sigset_t *omask)
if (io_fds[SFD_STDERR] == -1 || !isatty(STDERR_FILENO)) {
sudo_debug_printf(SUDO_DEBUG_INFO, "stderr not a tty, creating a pipe");
if (pipe(io_pipe[STDERR_FILENO]) != 0)
fatal(_("unable to create pipe"));
fatal(U_("unable to create pipe"));
io_buf_new(io_pipe[STDERR_FILENO][0], STDERR_FILENO,
log_stderr, &iobufs);
io_fds[SFD_STDERR] = io_pipe[STDERR_FILENO][1];
@ -732,7 +732,7 @@ fork_pty(struct command_details *details, int sv[], sigset_t *omask)
n = term_raw(io_fds[SFD_USERTTY], 0);
} while (!n && errno == EINTR);
if (!n)
fatal(_("unable to set terminal to raw mode"));
fatal(U_("unable to set terminal to raw mode"));
}
}
@ -741,7 +741,7 @@ fork_pty(struct command_details *details, int sv[], sigset_t *omask)
* or certain pam modules won't be able to track their state.
*/
if (policy_init_session(details) != true)
fatalx(_("policy plugin failed session initialization"));
fatalx(U_("policy plugin failed session initialization"));
/*
* Block some signals until cmnd_pid is set in the parent to avoid a
@ -757,7 +757,7 @@ fork_pty(struct command_details *details, int sv[], sigset_t *omask)
child = sudo_debug_fork();
switch (child) {
case -1:
fatal(_("unable to fork"));
fatal(U_("unable to fork"));
break;
case 0:
/* child */
@ -867,7 +867,7 @@ add_io_events(struct sudo_event_base *evbase)
"added I/O revent %p, fd %d, events %d",
iob->revent, iob->revent->fd, iob->revent->events);
if (sudo_ev_add(evbase, iob->revent, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
}
}
if (iob->wevent != NULL &&
@ -877,7 +877,7 @@ add_io_events(struct sudo_event_base *evbase)
"added I/O wevent %p, fd %d, events %d",
iob->wevent, iob->wevent->fd, iob->wevent->events);
if (sudo_ev_add(evbase, iob->wevent, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
}
}
}
@ -922,14 +922,14 @@ del_io_events(void)
if (iob->revent != NULL && !USERTTY_EVENT(iob->revent)) {
if (iob->len != sizeof(iob->buf)) {
if (sudo_ev_add(evbase, iob->revent, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
}
}
/* Flush any write buffers with data in them. */
if (iob->wevent != NULL) {
if (iob->len > iob->off) {
if (sudo_ev_add(evbase, iob->wevent, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
}
}
}
@ -1088,7 +1088,7 @@ mon_signal_pipe_cb(int fd, int what, void *v)
n = read(fd, &signo, sizeof(signo));
if (n == -1) {
if (errno != EINTR && errno != EAGAIN) {
warning(_("error reading from signal pipe"));
warning(U_("error reading from signal pipe"));
sudo_ev_loopbreak(mc->evbase);
}
} else {
@ -1121,7 +1121,7 @@ mon_errpipe_cb(int fd, int what, void *v)
n = read(fd, mc->cstat, sizeof(struct command_status));
if (n == -1) {
if (errno != EINTR && errno != EAGAIN) {
warning(_("error reading from pipe"));
warning(U_("error reading from pipe"));
sudo_ev_loopbreak(mc->evbase);
}
} else {
@ -1146,7 +1146,7 @@ mon_backchannel_cb(int fd, int what, void *v)
if (n == -1) {
if (errno == EINTR || errno == EAGAIN)
debug_return;
warning(_("error reading from socketpair"));
warning(U_("error reading from socketpair"));
} else {
/* short read or EOF, parent process died? */
}
@ -1155,7 +1155,7 @@ mon_backchannel_cb(int fd, int what, void *v)
if (cstmp.type == CMD_SIGNO) {
deliver_signal(cmnd_pid, cstmp.val, true);
} else {
warningx(_("unexpected reply type on backchannel: %d"), cstmp.type);
warningx(U_("unexpected reply type on backchannel: %d"), cstmp.type);
}
}
debug_return;
@ -1189,7 +1189,7 @@ exec_monitor(struct command_details *details, int backchannel)
* the event loop.
*/
if (pipe_nonblock(signal_pipe) != 0)
fatal(_("unable to create pipe"));
fatal(U_("unable to create pipe"));
/* Reset SIGWINCH and SIGALRM. */
memset(&sa, 0, sizeof(sa));
@ -1245,7 +1245,7 @@ exec_monitor(struct command_details *details, int backchannel)
if (io_fds[SFD_SLAVE] != -1) {
#ifdef TIOCSCTTY
if (ioctl(io_fds[SFD_SLAVE], TIOCSCTTY, NULL) != 0)
fatal(_("unable to set controlling tty"));
fatal(U_("unable to set controlling tty"));
#else
/* Set controlling tty by reopening slave. */
if ((n = open(slavename, O_RDWR)) >= 0)
@ -1266,10 +1266,10 @@ exec_monitor(struct command_details *details, int backchannel)
/* Start command and wait for it to stop or exit */
if (pipe(errpipe) == -1)
fatal(_("unable to create pipe"));
fatal(U_("unable to create pipe"));
cmnd_pid = sudo_debug_fork();
if (cmnd_pid == -1) {
warning(_("unable to fork"));
warning(U_("unable to fork"));
goto bad;
}
if (cmnd_pid == 0) {
@ -1331,21 +1331,21 @@ exec_monitor(struct command_details *details, int backchannel)
if (mc.signal_pipe_event == NULL)
fatal(NULL);
if (sudo_ev_add(evbase, mc.signal_pipe_event, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
mc.errpipe_event = sudo_ev_alloc(errpipe[0],
SUDO_EV_READ|SUDO_EV_PERSIST, mon_errpipe_cb, &mc);
if (mc.errpipe_event == NULL)
fatal(NULL);
if (sudo_ev_add(evbase, mc.errpipe_event, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
mc.backchannel_event = sudo_ev_alloc(backchannel,
SUDO_EV_READ|SUDO_EV_PERSIST, mon_backchannel_cb, &mc);
if (mc.backchannel_event == NULL)
fatal(NULL);
if (sudo_ev_add(evbase, mc.backchannel_event, NULL, false) == -1)
fatal(_("unable to add event to queue"));
fatal(U_("unable to add event to queue"));
/*
* Wait for errno on pipe, signal on backchannel or for SIGCHLD.

View File

@ -67,9 +67,9 @@ sudo_stat_plugin(struct plugin_info *info, char *fullpath,
if (info->path[0] == '/') {
if (strlcpy(fullpath, info->path, pathsize) >= pathsize) {
warningx(_("error in %s, line %d while loading plugin `%s'"),
warningx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
warningx(_("%s: %s"), info->path, strerror(ENAMETOOLONG));
warningx(U_("%s: %s"), info->path, strerror(ENAMETOOLONG));
goto done;
}
status = stat(fullpath, sb);
@ -77,9 +77,9 @@ sudo_stat_plugin(struct plugin_info *info, char *fullpath,
int len = snprintf(fullpath, pathsize, "%s%s", _PATH_SUDO_PLUGIN_DIR,
info->path);
if (len <= 0 || (size_t)len >= pathsize) {
warningx(_("error in %s, line %d while loading plugin `%s'"),
warningx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
warningx(_("%s%s: %s"), _PATH_SUDO_PLUGIN_DIR, info->path,
warningx(U_("%s%s: %s"), _PATH_SUDO_PLUGIN_DIR, info->path,
strerror(ENAMETOOLONG));
goto done;
}
@ -130,21 +130,21 @@ sudo_check_plugin(struct plugin_info *info, char *fullpath, size_t pathsize)
debug_decl(sudo_check_plugin, SUDO_DEBUG_PLUGIN)
if (sudo_stat_plugin(info, fullpath, pathsize, &sb) != 0) {
warningx(_("error in %s, line %d while loading plugin `%s'"),
warningx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
warning("%s%s", _PATH_SUDO_PLUGIN_DIR, info->path);
goto done;
}
if (sb.st_uid != ROOT_UID) {
warningx(_("error in %s, line %d while loading plugin `%s'"),
warningx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
warningx(_("%s must be owned by uid %d"), fullpath, ROOT_UID);
warningx(U_("%s must be owned by uid %d"), fullpath, ROOT_UID);
goto done;
}
if ((sb.st_mode & (S_IWGRP|S_IWOTH)) != 0) {
warningx(_("error in %s, line %d while loading plugin `%s'"),
warningx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
warningx(_("%s must be only be writable by owner"), fullpath);
warningx(U_("%s must be only be writable by owner"), fullpath);
goto done;
}
rval = true;
@ -183,29 +183,29 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
/* Open plugin and map in symbol */
handle = dlopen(path, RTLD_LAZY|RTLD_GLOBAL);
if (!handle) {
warningx(_("error in %s, line %d while loading plugin `%s'"),
warningx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
warningx(_("unable to dlopen %s: %s"), path, dlerror());
warningx(U_("unable to dlopen %s: %s"), path, dlerror());
goto done;
}
plugin = dlsym(handle, info->symbol_name);
if (!plugin) {
warningx(_("error in %s, line %d while loading plugin `%s'"),
warningx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
warningx(_("unable to find symbol `%s' in %s"), info->symbol_name, path);
warningx(U_("unable to find symbol `%s' in %s"), info->symbol_name, path);
goto done;
}
if (plugin->type != SUDO_POLICY_PLUGIN && plugin->type != SUDO_IO_PLUGIN) {
warningx(_("error in %s, line %d while loading plugin `%s'"),
warningx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
warningx(_("unknown policy type %d found in %s"), plugin->type, path);
warningx(U_("unknown policy type %d found in %s"), plugin->type, path);
goto done;
}
if (SUDO_API_VERSION_GET_MAJOR(plugin->version) != SUDO_API_VERSION_MAJOR) {
warningx(_("error in %s, line %d while loading plugin `%s'"),
warningx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
warningx(_("incompatible plugin major version %d (expected %d) found in %s"),
warningx(U_("incompatible plugin major version %d (expected %d) found in %s"),
SUDO_API_VERSION_GET_MAJOR(plugin->version),
SUDO_API_VERSION_MAJOR, path);
goto done;
@ -214,12 +214,12 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
if (policy_plugin->handle) {
/* Ignore duplicate entries. */
if (strcmp(policy_plugin->name, info->symbol_name) != 0) {
warningx(_("ignoring policy plugin `%s' in %s, line %d"),
warningx(U_("ignoring policy plugin `%s' in %s, line %d"),
info->symbol_name, _PATH_SUDO_CONF, info->lineno);
warningx(_("only a single policy plugin may be specified"));
warningx(U_("only a single policy plugin may be specified"));
goto done;
}
warningx(_("ignoring duplicate policy plugin `%s' in %s, line %d"),
warningx(U_("ignoring duplicate policy plugin `%s' in %s, line %d"),
info->symbol_name, _PATH_SUDO_CONF, info->lineno);
dlclose(handle);
handle = NULL;
@ -234,7 +234,7 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
/* Check for duplicate entries. */
TAILQ_FOREACH(container, io_plugins, entries) {
if (strcmp(container->name, info->symbol_name) == 0) {
warningx(_("ignoring duplicate I/O plugin `%s' in %s, line %d"),
warningx(U_("ignoring duplicate I/O plugin `%s' in %s, line %d"),
info->symbol_name, _PATH_SUDO_CONF, info->lineno);
dlclose(handle);
handle = NULL;
@ -305,7 +305,7 @@ sudo_load_plugins(struct plugin_container *policy_plugin,
}
}
if (policy_plugin->u.policy->check_policy == NULL) {
warningx(_("policy plugin %s does not include a check_policy method"),
warningx(U_("policy plugin %s does not include a check_policy method"),
policy_plugin->name);
rval = false;
goto done;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2013 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -23,16 +23,11 @@
#include "missing.h"
#include "fatal.h"
#include "gettext.h"
/* No need to swap locales in the front end. */
void
warning_set_locale(void)
char *
warning_gettext(const char *msgid)
{
return;
}
void
warning_restore_locale(void)
{
return;
return gettext(msgid);
}

View File

@ -153,7 +153,7 @@ get_net_ifs(char **addrinfo)
"%s%s/", cp == *addrinfo ? "" : " ",
inet_ntoa(sin->sin_addr));
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
warningx(_("load_interfaces: overflow detected"));
warningx(U_("load_interfaces: overflow detected"));
goto done;
}
cp += len;
@ -162,7 +162,7 @@ get_net_ifs(char **addrinfo)
len = snprintf(cp, ailen - (*addrinfo - cp),
"%s", inet_ntoa(sin->sin_addr));
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
warningx(_("load_interfaces: overflow detected"));
warningx(U_("load_interfaces: overflow detected"));
goto done;
}
cp += len;
@ -174,7 +174,7 @@ get_net_ifs(char **addrinfo)
len = snprintf(cp, ailen - (*addrinfo - cp),
"%s%s/", cp == *addrinfo ? "" : " ", addrbuf);
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
warningx(_("load_interfaces: overflow detected"));
warningx(U_("load_interfaces: overflow detected"));
goto done;
}
cp += len;
@ -183,7 +183,7 @@ get_net_ifs(char **addrinfo)
inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf, sizeof(addrbuf));
len = snprintf(cp, ailen - (*addrinfo - cp), "%s", addrbuf);
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
warningx(_("load_interfaces: overflow detected"));
warningx(U_("load_interfaces: overflow detected"));
goto done;
}
cp += len;
@ -223,7 +223,7 @@ get_net_ifs(char **addrinfo)
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0)
fatal(_("unable to open socket"));
fatal(U_("unable to open socket"));
/*
* Get interface configuration or return.
@ -294,7 +294,7 @@ get_net_ifs(char **addrinfo)
"%s%s/", cp == *addrinfo ? "" : " ",
inet_ntoa(sin->sin_addr));
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
warningx(_("load_interfaces: overflow detected"));
warningx(U_("load_interfaces: overflow detected"));
goto done;
}
cp += len;
@ -318,7 +318,7 @@ get_net_ifs(char **addrinfo)
len = snprintf(cp, ailen - (*addrinfo - cp),
"%s", inet_ntoa(sin->sin_addr));
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
warningx(_("load_interfaces: overflow detected"));
warningx(U_("load_interfaces: overflow detected"));
goto done;
}
cp += len;

View File

@ -243,7 +243,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp,
break;
case 'C':
if (atoi(optarg) < 3) {
warningx(_("the argument to -C must be a number greater than or equal to 3"));
warningx(U_("the argument to -C must be a number greater than or equal to 3"));
usage(1);
}
sudo_settings[ARG_CLOSEFROM].value = optarg;
@ -405,11 +405,11 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp,
if (ISSET(flags, MODE_LOGIN_SHELL)) {
if (ISSET(flags, MODE_SHELL)) {
warningx(_("you may not specify both the `-i' and `-s' options"));
warningx(U_("you may not specify both the `-i' and `-s' options"));
usage(1);
}
if (ISSET(flags, MODE_PRESERVE_ENV)) {
warningx(_("you may not specify both the `-i' and `-E' options"));
warningx(U_("you may not specify both the `-i' and `-E' options"));
usage(1);
}
SET(flags, MODE_SHELL);
@ -419,9 +419,9 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp,
if (mode == MODE_EDIT &&
(ISSET(flags, MODE_PRESERVE_ENV) || env_add[0] != NULL)) {
if (ISSET(mode, MODE_PRESERVE_ENV))
warningx(_("the `-E' option is not valid in edit mode"));
warningx(U_("the `-E' option is not valid in edit mode"));
if (env_add[0] != NULL)
warningx(_("you may not specify environment variables in edit mode"));
warningx(U_("you may not specify environment variables in edit mode"));
usage(1);
}
if ((runas_user != NULL || runas_group != NULL) &&
@ -429,11 +429,11 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp,
usage(1);
}
if (list_user != NULL && mode != MODE_LIST && mode != MODE_CHECK) {
warningx(_("the `-U' option may only be used with the `-l' option"));
warningx(U_("the `-U' option may only be used with the `-l' option"));
usage(1);
}
if (ISSET(tgetpass_flags, TGP_STDIN) && ISSET(tgetpass_flags, TGP_ASKPASS)) {
warningx(_("the `-A' and `-S' options may not be used together"));
warningx(U_("the `-A' and `-S' options may not be used together"));
usage(1);
}
if ((argc == 0 && mode == MODE_EDIT) ||
@ -516,7 +516,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp,
argv--;
argv[0] = "sudoedit";
#else
fatalx(_("sudoedit is not supported on this platform"));
fatalx(U_("sudoedit is not supported on this platform"));
#endif
}
@ -589,7 +589,7 @@ usage_excl(int fatal)
{
debug_decl(usage_excl, SUDO_DEBUG_ARGS)
warningx(_("Only one of the -e, -h, -i, -K, -l, -s, -v or -V options may be specified"));
warningx(U_("Only one of the -e, -h, -i, -K, -l, -s, -v or -V options may be specified"));
usage(fatal);
}

View File

@ -74,7 +74,7 @@ audit_role_change(const security_context_t old_context,
/* Kernel may not have audit support. */
if (errno != EINVAL && errno != EPROTONOSUPPORT && errno != EAFNOSUPPORT
)
fatal(_("unable to open audit system"));
fatal(U_("unable to open audit system"));
} else {
/* audit role change using the same format as newrole(1) */
easprintf(&message, "newrole: old-context=%s new-context=%s",
@ -82,7 +82,7 @@ audit_role_change(const security_context_t old_context,
rc = audit_log_user_message(au_fd, AUDIT_USER_ROLE_CHANGE,
message, NULL, NULL, ttyn, 1);
if (rc <= 0)
warning(_("unable to send audit message"));
warning(U_("unable to send audit message"));
efree(message);
close(au_fd);
}
@ -110,17 +110,17 @@ selinux_restore_tty(void)
/* Verify that the tty still has the context set by sudo. */
if ((retval = fgetfilecon(se_state.ttyfd, &chk_tty_context)) < 0) {
warning(_("unable to fgetfilecon %s"), se_state.ttyn);
warning(U_("unable to fgetfilecon %s"), se_state.ttyn);
goto skip_relabel;
}
if ((retval = strcmp(chk_tty_context, se_state.new_tty_context))) {
warningx(_("%s changed labels"), se_state.ttyn);
warningx(U_("%s changed labels"), se_state.ttyn);
goto skip_relabel;
}
if ((retval = fsetfilecon(se_state.ttyfd, se_state.tty_context)) < 0)
warning(_("unable to restore context for %s"), se_state.ttyn);
warning(U_("unable to restore context for %s"), se_state.ttyn);
skip_relabel:
if (se_state.ttyfd != -1) {
@ -160,7 +160,7 @@ relabel_tty(const char *ttyn, int ptyfd)
if (ptyfd == -1) {
se_state.ttyfd = open(ttyn, O_RDWR|O_NONBLOCK);
if (se_state.ttyfd == -1) {
warning(_("unable to open %s, not relabeling tty"), ttyn);
warning(U_("unable to open %s, not relabeling tty"), ttyn);
if (se_state.enforcing)
goto bad;
}
@ -169,21 +169,21 @@ relabel_tty(const char *ttyn, int ptyfd)
}
if (fgetfilecon(se_state.ttyfd, &tty_con) < 0) {
warning(_("unable to get current tty context, not relabeling tty"));
warning(U_("unable to get current tty context, not relabeling tty"));
if (se_state.enforcing)
goto bad;
}
if (tty_con && (security_compute_relabel(se_state.new_context, tty_con,
SECCLASS_CHR_FILE, &new_tty_con) < 0)) {
warning(_("unable to get new tty context, not relabeling tty"));
warning(U_("unable to get new tty context, not relabeling tty"));
if (se_state.enforcing)
goto bad;
}
if (new_tty_con != NULL) {
if (fsetfilecon(se_state.ttyfd, new_tty_con) < 0) {
warning(_("unable to set new tty context"));
warning(U_("unable to set new tty context"));
if (se_state.enforcing)
goto bad;
}
@ -193,7 +193,7 @@ relabel_tty(const char *ttyn, int ptyfd)
/* Reopen pty that was relabeled, std{in,out,err} are reset later. */
se_state.ttyfd = open(ttyn, O_RDWR|O_NOCTTY, 0);
if (se_state.ttyfd == -1) {
warning(_("unable to open %s"), ttyn);
warning(U_("unable to open %s"), ttyn);
if (se_state.enforcing)
goto bad;
}
@ -206,7 +206,7 @@ relabel_tty(const char *ttyn, int ptyfd)
close(se_state.ttyfd);
se_state.ttyfd = open(ttyn, O_RDWR|O_NONBLOCK);
if (se_state.ttyfd == -1) {
warning(_("unable to open %s"), ttyn);
warning(U_("unable to open %s"), ttyn);
goto bad;
}
(void)fcntl(se_state.ttyfd, F_SETFL,
@ -249,13 +249,13 @@ get_exec_context(security_context_t old_context, const char *role, const char *t
/* We must have a role, the type is optional (we can use the default). */
if (!role) {
warningx(_("you must specify a role for type %s"), type);
warningx(U_("you must specify a role for type %s"), type);
errno = EINVAL;
goto bad;
}
if (!type) {
if (get_default_type(role, &typebuf)) {
warningx(_("unable to get default type for role %s"), role);
warningx(U_("unable to get default type for role %s"), role);
errno = EINVAL;
goto bad;
}
@ -273,11 +273,11 @@ get_exec_context(security_context_t old_context, const char *role, const char *t
* type we will be running the command as.
*/
if (context_role_set(context, role)) {
warning(_("failed to set new role %s"), role);
warning(U_("failed to set new role %s"), role);
goto bad;
}
if (context_type_set(context, type)) {
warning(_("failed to set new type %s"), type);
warning(U_("failed to set new type %s"), type);
goto bad;
}
@ -286,7 +286,7 @@ get_exec_context(security_context_t old_context, const char *role, const char *t
*/
new_context = estrdup(context_str(context));
if (security_check_context(new_context) < 0) {
warningx(_("%s is not a valid context"), new_context);
warningx(U_("%s is not a valid context"), new_context);
errno = EINVAL;
goto bad;
}
@ -321,13 +321,13 @@ selinux_setup(const char *role, const char *type, const char *ttyn,
/* Store the caller's SID in old_context. */
if (getprevcon(&se_state.old_context)) {
warning(_("failed to get old_context"));
warning(U_("failed to get old_context"));
goto done;
}
se_state.enforcing = security_getenforce();
if (se_state.enforcing < 0) {
warning(_("unable to determine enforcing mode."));
warning(U_("unable to determine enforcing mode."));
goto done;
}
@ -339,7 +339,7 @@ selinux_setup(const char *role, const char *type, const char *ttyn,
goto done;
if (relabel_tty(ttyn, ptyfd) < 0) {
warning(_("unable to set tty context to %s"), se_state.new_context);
warning(U_("unable to set tty context to %s"), se_state.new_context);
goto done;
}
@ -378,14 +378,14 @@ selinux_execve(const char *path, char *const argv[], char *const envp[],
}
if (setexeccon(se_state.new_context)) {
warning(_("unable to set exec context to %s"), se_state.new_context);
warning(U_("unable to set exec context to %s"), se_state.new_context);
if (se_state.enforcing)
debug_return;
}
#ifdef HAVE_SETKEYCREATECON
if (setkeycreatecon(se_state.new_context)) {
warning(_("unable to set key creation context to %s"), se_state.new_context);
warning(U_("unable to set key creation context to %s"), se_state.new_context);
if (se_state.enforcing)
debug_return;
}

View File

@ -54,7 +54,7 @@ main(int argc, char *argv[], char *envp[])
textdomain(PACKAGE_NAME);
if (argc < 2)
fatalx(_("requires at least one argument"));
fatalx(U_("requires at least one argument"));
/* Read sudo.conf. */
sudo_conf_read(NULL);
@ -75,7 +75,7 @@ main(int argc, char *argv[], char *envp[])
*cp = '-';
}
sudo_execve(cmnd, argv, envp, noexec);
warning(_("unable to execute %s"), argv[0]);
warning(U_("unable to execute %s"), argv[0]);
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, EXIT_FAILURE);
_exit(EXIT_FAILURE);
}

View File

@ -123,7 +123,7 @@ init_signals(void)
* the select() loop without races (we may not have pselect()).
*/
if (pipe_nonblock(signal_pipe) != 0)
fatal(_("unable to create pipe"));
fatal(U_("unable to create pipe"));
memset(&sa, 0, sizeof(sa));
sigfillset(&sa.sa_mask);

View File

@ -85,38 +85,38 @@ set_project(struct passwd *pw)
case SETPROJ_ERR_TASK:
switch (errno) {
case EAGAIN:
warningx(_("resource control limit has been reached"));
warningx(U_("resource control limit has been reached"));
break;
case ESRCH:
warningx(_("user \"%s\" is not a member of project \"%s\""),
warningx(U_("user \"%s\" is not a member of project \"%s\""),
pw->pw_name, proj.pj_name);
break;
case EACCES:
warningx(_("the invoking task is final"));
warningx(U_("the invoking task is final"));
break;
default:
warningx(_("could not join project \"%s\""), proj.pj_name);
warningx(U_("could not join project \"%s\""), proj.pj_name);
}
case SETPROJ_ERR_POOL:
switch (errno) {
case EACCES:
warningx(_("no resource pool accepting default bindings "
warningx(U_("no resource pool accepting default bindings "
"exists for project \"%s\""), proj.pj_name);
break;
case ESRCH:
warningx(_("specified resource pool does not exist for "
warningx(U_("specified resource pool does not exist for "
"project \"%s\""), proj.pj_name);
break;
default:
warningx(_("could not bind to default resource pool for "
warningx(U_("could not bind to default resource pool for "
"project \"%s\""), proj.pj_name);
}
break;
default:
if (errval <= 0) {
warningx(_("setproject failed for project \"%s\""), proj.pj_name);
warningx(U_("setproject failed for project \"%s\""), proj.pj_name);
} else {
warningx(_("warning, resource control assignment failed for "
warningx(U_("warning, resource control assignment failed for "
"project \"%s\""), proj.pj_name);
}
}

View File

@ -200,7 +200,7 @@ main(int argc, char *argv[], char *envp[])
/* Load plugins. */
if (!sudo_load_plugins(&policy_plugin, &io_plugins))
fatalx(_("fatal error, unable to load plugins"));
fatalx(U_("fatal error, unable to load plugins"));
/* Open policy plugin. */
ok = policy_open(&policy_plugin, settings, user_info, envp);
@ -208,7 +208,7 @@ main(int argc, char *argv[], char *envp[])
if (ok == -2)
usage(1);
else
fatalx(_("unable to initialize policy plugin"));
fatalx(U_("unable to initialize policy plugin"));
}
init_signals();
@ -264,7 +264,7 @@ main(int argc, char *argv[], char *envp[])
usage(1);
break;
default:
fatalx(_("error initializing I/O plugin %s"),
fatalx(U_("error initializing I/O plugin %s"),
plugin->name);
}
}
@ -290,7 +290,7 @@ main(int argc, char *argv[], char *envp[])
/* The close method was called by sudo_edit/run_command. */
break;
default:
fatalx(_("unexpected sudo mode 0x%x"), sudo_mode);
fatalx(U_("unexpected sudo mode 0x%x"), sudo_mode);
}
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, exitcode);
exit(exitcode);
@ -325,7 +325,7 @@ fix_fds(void)
miss[STDERR_FILENO] = fcntl(STDERR_FILENO, F_GETFL, 0) == -1;
if (miss[STDIN_FILENO] || miss[STDOUT_FILENO] || miss[STDERR_FILENO]) {
if ((devnull = open(_PATH_DEVNULL, O_RDWR, 0644)) == -1)
fatal(_("unable to open %s"), _PATH_DEVNULL);
fatal(U_("unable to open %s"), _PATH_DEVNULL);
if (miss[STDIN_FILENO] && dup2(devnull, STDIN_FILENO) == -1)
fatal("dup2");
if (miss[STDOUT_FILENO] && dup2(devnull, STDOUT_FILENO) == -1)
@ -410,7 +410,7 @@ get_user_groups(struct user_details *ud)
* Typically, this is because NFS can only support up to 16 groups.
*/
if (fill_group_list(ud, maxgroups) == -1)
fatal(_("unable to get group vector"));
fatal(U_("unable to get group vector"));
}
/*
@ -462,7 +462,7 @@ get_user_info(struct user_details *ud)
pw = getpwuid(ud->uid);
if (pw == NULL)
fatalx(_("unknown uid %u: who are you?"), (unsigned int)ud->uid);
fatalx(U_("unknown uid %u: who are you?"), (unsigned int)ud->uid);
user_info[i] = fmt_string("user", pw->pw_name);
if (user_info[i] == NULL)
@ -557,11 +557,11 @@ command_info_to_details(char * const info[], struct command_details *details)
cp = info[i] + sizeof("closefrom=") - 1;
lval = strtol(cp, &ep, 10);
if (*cp == '\0' || *ep != '\0')
fatalx(_("%s: %s"), info[i], _("invalid value"));
fatalx(U_("%s: %s"), info[i], U_("invalid value"));
if ((errno == ERANGE &&
(lval == LONG_MAX || lval == LONG_MIN)) ||
(lval > INT_MAX || lval < 0))
fatalx(_("%s: %s"), info[i], _("value out of range"));
fatalx(U_("%s: %s"), info[i], U_("value out of range"));
details->closefrom = (int)lval;
break;
}
@ -582,11 +582,11 @@ command_info_to_details(char * const info[], struct command_details *details)
cp = info[i] + sizeof("nice=") - 1;
lval = strtol(cp, &ep, 10);
if (*cp == '\0' || *ep != '\0')
fatalx(_("%s: %s"), info[i], _("invalid value"));
fatalx(U_("%s: %s"), info[i], U_("invalid value"));
if ((errno == ERANGE &&
(lval == LONG_MAX || lval == LONG_MIN)) ||
(lval > INT_MAX || lval < INT_MIN))
fatalx(_("%s: %s"), info[i], _("value out of range"));
fatalx(U_("%s: %s"), info[i], U_("value out of range"));
details->priority = (int)lval;
SET(details->flags, CD_SET_PRIORITY);
break;
@ -609,7 +609,7 @@ command_info_to_details(char * const info[], struct command_details *details)
cp = info[i] + sizeof("runas_egid=") - 1;
id = atoid(cp, NULL, NULL, &errstr);
if (errstr != NULL)
fatalx(_("%s: %s"), info[i], _(errstr));
fatalx(U_("%s: %s"), info[i], U_(errstr));
details->egid = (gid_t)id;
SET(details->flags, CD_SET_EGID);
break;
@ -618,7 +618,7 @@ command_info_to_details(char * const info[], struct command_details *details)
cp = info[i] + sizeof("runas_euid=") - 1;
id = atoid(cp, NULL, NULL, &errstr);
if (errstr != NULL)
fatalx(_("%s: %s"), info[i], _(errstr));
fatalx(U_("%s: %s"), info[i], U_(errstr));
details->euid = (uid_t)id;
SET(details->flags, CD_SET_EUID);
break;
@ -627,7 +627,7 @@ command_info_to_details(char * const info[], struct command_details *details)
cp = info[i] + sizeof("runas_gid=") - 1;
id = atoid(cp, NULL, NULL, &errstr);
if (errstr != NULL)
fatalx(_("%s: %s"), info[i], _(errstr));
fatalx(U_("%s: %s"), info[i], U_(errstr));
details->gid = (gid_t)id;
SET(details->flags, CD_SET_GID);
break;
@ -642,7 +642,7 @@ command_info_to_details(char * const info[], struct command_details *details)
cp = info[i] + sizeof("runas_uid=") - 1;
id = atoid(cp, NULL, NULL, &errstr);
if (errstr != NULL)
fatalx(_("%s: %s"), info[i], _(errstr));
fatalx(U_("%s: %s"), info[i], U_(errstr));
details->uid = (uid_t)id;
SET(details->flags, CD_SET_UID);
break;
@ -690,11 +690,11 @@ command_info_to_details(char * const info[], struct command_details *details)
cp = info[i] + sizeof("timeout=") - 1;
lval = strtol(cp, &ep, 10);
if (*cp == '\0' || *ep != '\0')
fatalx(_("%s: %s"), info[i], _("invalid value"));
fatalx(U_("%s: %s"), info[i], U_("invalid value"));
if ((errno == ERANGE &&
(lval == LONG_MAX || lval == LONG_MIN)) ||
(lval > INT_MAX || lval < 0))
fatalx(_("%s: %s"), info[i], _("value out of range"));
fatalx(U_("%s: %s"), info[i], U_("value out of range"));
details->timeout = (int)lval;
SET(details->flags, CD_SET_TIMEOUT);
break;
@ -706,11 +706,11 @@ command_info_to_details(char * const info[], struct command_details *details)
cp = info[i] + sizeof("umask=") - 1;
lval = strtol(cp, &ep, 8);
if (*cp == '\0' || *ep != '\0')
fatalx(_("%s: %s"), info[i], _("invalid value"));
fatalx(U_("%s: %s"), info[i], U_("invalid value"));
if ((errno == ERANGE &&
(lval == LONG_MAX || lval == LONG_MIN)) ||
(lval > 0777 || lval < 0))
fatalx(_("%s: %s"), info[i], _("value out of range"));
fatalx(U_("%s: %s"), info[i], U_("value out of range"));
details->umask = (mode_t)lval;
SET(details->flags, CD_SET_UMASK);
break;
@ -784,16 +784,16 @@ sudo_check_suid(const char *sudo)
/* Try to determine why sudo was not running as root. */
if (sb.st_uid != ROOT_UID || !ISSET(sb.st_mode, S_ISUID)) {
fatalx(
_("%s must be owned by uid %d and have the setuid bit set"),
U_("%s must be owned by uid %d and have the setuid bit set"),
sudo, ROOT_UID);
} else {
fatalx(_("effective uid is not %d, is %s on a file system "
fatalx(U_("effective uid is not %d, is %s on a file system "
"with the 'nosuid' option set or an NFS file system without"
" root privileges?"), ROOT_UID, sudo);
}
} else {
fatalx(
_("effective uid is not %d, is sudo installed setuid root?"),
U_("effective uid is not %d, is sudo installed setuid root?"),
ROOT_UID);
}
}
@ -919,7 +919,7 @@ exec_setup(struct command_details *details, const char *ptyname, int ptyfd)
*/
lc = login_getclass((char *)details->login_class);
if (!lc) {
warningx(_("unknown login class %s"), details->login_class);
warningx(U_("unknown login class %s"), details->login_class);
errno = ENOENT;
goto done;
}
@ -932,7 +932,7 @@ exec_setup(struct command_details *details, const char *ptyname, int ptyfd)
flags = LOGIN_SETRESOURCES|LOGIN_SETPRIORITY;
}
if (setusercontext(lc, details->pw, details->pw->pw_uid, flags)) {
warning(_("unable to set user context"));
warning(U_("unable to set user context"));
if (details->pw->pw_uid != ROOT_UID)
goto done;
}
@ -946,27 +946,27 @@ exec_setup(struct command_details *details, const char *ptyname, int ptyfd)
if (!ISSET(details->flags, CD_PRESERVE_GROUPS)) {
if (details->ngroups >= 0) {
if (sudo_setgroups(details->ngroups, details->groups) < 0) {
warning(_("unable to set supplementary group IDs"));
warning(U_("unable to set supplementary group IDs"));
goto done;
}
}
}
#ifdef HAVE_SETEUID
if (ISSET(details->flags, CD_SET_EGID) && setegid(details->egid)) {
warning(_("unable to set effective gid to runas gid %u"),
warning(U_("unable to set effective gid to runas gid %u"),
(unsigned int)details->egid);
goto done;
}
#endif
if (ISSET(details->flags, CD_SET_GID) && setgid(details->gid)) {
warning(_("unable to set gid to runas gid %u"),
warning(U_("unable to set gid to runas gid %u"),
(unsigned int)details->gid);
goto done;
}
if (ISSET(details->flags, CD_SET_PRIORITY)) {
if (setpriority(PRIO_PROCESS, 0, details->priority) != 0) {
warning(_("unable to set process priority"));
warning(U_("unable to set process priority"));
goto done;
}
}
@ -974,7 +974,7 @@ exec_setup(struct command_details *details, const char *ptyname, int ptyfd)
(void) umask(details->umask);
if (details->chroot) {
if (chroot(details->chroot) != 0 || chdir("/") != 0) {
warning(_("unable to change root to %s"), details->chroot);
warning(U_("unable to change root to %s"), details->chroot);
goto done;
}
}
@ -987,19 +987,19 @@ exec_setup(struct command_details *details, const char *ptyname, int ptyfd)
#ifdef HAVE_SETRESUID
if (setresuid(details->uid, details->euid, details->euid) != 0) {
warning(_("unable to change to runas uid (%u, %u)"), details->uid,
warning(U_("unable to change to runas uid (%u, %u)"), details->uid,
details->euid);
goto done;
}
#elif defined(HAVE_SETREUID)
if (setreuid(details->uid, details->euid) != 0) {
warning(_("unable to change to runas uid (%u, %u)"),
warning(U_("unable to change to runas uid (%u, %u)"),
(unsigned int)details->uid, (unsigned int)details->euid);
goto done;
}
#else
if (seteuid(details->euid) != 0 || setuid(details->euid) != 0) {
warning(_("unable to change to runas uid (%u, %u)"), details->uid,
warning(U_("unable to change to runas uid (%u, %u)"), details->uid,
details->euid);
goto done;
}
@ -1016,7 +1016,7 @@ exec_setup(struct command_details *details, const char *ptyname, int ptyfd)
if (details->chroot || strcmp(details->cwd, user_details.cwd) != 0) {
/* Note: cwd is relative to the new root, if any. */
if (chdir(details->cwd) != 0) {
warning(_("unable to change directory to %s"), details->cwd);
warning(U_("unable to change directory to %s"), details->cwd);
goto done;
}
}
@ -1073,7 +1073,7 @@ run_command(struct command_details *details)
exitcode = WTERMSIG(cstat.val) | 128;
break;
default:
warningx(_("unexpected child termination condition: %d"), cstat.type);
warningx(U_("unexpected child termination condition: %d"), cstat.type);
break;
}
debug_return_int(exitcode);
@ -1110,7 +1110,7 @@ policy_close(struct plugin_container *plugin, int exit_status, int error)
if (plugin->u.policy->close != NULL)
plugin->u.policy->close(exit_status, error);
else
warning(_("unable to execute %s"), command_details.command);
warning(U_("unable to execute %s"), command_details.command);
debug_return;
}
@ -1130,7 +1130,7 @@ policy_check(struct plugin_container *plugin, int argc, char * const argv[],
{
debug_decl(policy_check, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->check_policy == NULL) {
fatalx(_("policy plugin %s is missing the `check_policy' method"),
fatalx(U_("policy plugin %s is missing the `check_policy' method"),
plugin->name);
}
debug_return_bool(plugin->u.policy->check_policy(argc, argv, env_add,
@ -1143,7 +1143,7 @@ policy_list(struct plugin_container *plugin, int argc, char * const argv[],
{
debug_decl(policy_list, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->list == NULL) {
warningx(_("policy plugin %s does not support listing privileges"),
warningx(U_("policy plugin %s does not support listing privileges"),
plugin->name);
debug_return_bool(false);
}
@ -1155,7 +1155,7 @@ policy_validate(struct plugin_container *plugin)
{
debug_decl(policy_validate, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->validate == NULL) {
warningx(_("policy plugin %s does not support the -v option"),
warningx(U_("policy plugin %s does not support the -v option"),
plugin->name);
debug_return_bool(false);
}
@ -1167,7 +1167,7 @@ policy_invalidate(struct plugin_container *plugin, int remove)
{
debug_decl(policy_invalidate, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->invalidate == NULL) {
fatalx(_("policy plugin %s does not support the -k/-K options"),
fatalx(U_("policy plugin %s does not support the -k/-K options"),
plugin->name);
}
plugin->u.policy->invalidate(remove);

View File

@ -107,7 +107,7 @@ sudo_edit(struct command_details *command_details)
* We will change the euid as needed below.
*/
if (setuid(ROOT_UID) != 0) {
warning(_("unable to change uid to root (%u)"), ROOT_UID);
warning(U_("unable to change uid to root (%u)"), ROOT_UID);
goto cleanup;
}
@ -139,7 +139,7 @@ sudo_edit(struct command_details *command_details)
editor_argc++;
}
if (nfiles == 0) {
warningx(_("plugin error: missing file list for sudoedit"));
warningx(U_("plugin error: missing file list for sudoedit"));
goto cleanup;
}
@ -167,7 +167,7 @@ sudo_edit(struct command_details *command_details)
if (rc)
warning("%s", files[i]);
else
warningx(_("%s: not a regular file"), files[i]);
warningx(U_("%s: not a regular file"), files[i]);
if (ofd != -1)
close(ofd);
continue;
@ -201,7 +201,7 @@ sudo_edit(struct command_details *command_details)
if (nwritten == -1)
warning("%s", tf[j].tfile);
else
warningx(_("%s: short write"), tf[j].tfile);
warningx(U_("%s: short write"), tf[j].tfile);
goto cleanup;
}
}
@ -267,8 +267,8 @@ sudo_edit(struct command_details *command_details)
if (rc)
warning("%s", tf[i].tfile);
else
warningx(_("%s: not a regular file"), tf[i].tfile);
warningx(_("%s left unmodified"), tf[i].ofile);
warningx(U_("%s: not a regular file"), tf[i].tfile);
warningx(U_("%s left unmodified"), tf[i].ofile);
if (tfd != -1)
close(tfd);
continue;
@ -281,7 +281,7 @@ sudo_edit(struct command_details *command_details)
*/
timevalsub(&tv1, &tv2);
if (timevalisset(&tv2)) {
warningx(_("%s unchanged"), tf[i].ofile);
warningx(U_("%s unchanged"), tf[i].ofile);
unlink(tf[i].tfile);
close(tfd);
continue;
@ -293,8 +293,8 @@ sudo_edit(struct command_details *command_details)
switch_user(ROOT_UID, user_details.egid,
user_details.ngroups, user_details.groups);
if (ofd == -1) {
warning(_("unable to write to %s"), tf[i].ofile);
warningx(_("contents of edit session left in %s"), tf[i].tfile);
warning(U_("unable to write to %s"), tf[i].ofile);
warningx(U_("contents of edit session left in %s"), tf[i].tfile);
close(tfd);
continue;
}
@ -303,7 +303,7 @@ sudo_edit(struct command_details *command_details)
if (nwritten == -1)
warning("%s", tf[i].ofile);
else
warningx(_("%s: short write"), tf[i].ofile);
warningx(U_("%s: short write"), tf[i].ofile);
break;
}
}
@ -311,11 +311,11 @@ sudo_edit(struct command_details *command_details)
/* success, got EOF */
unlink(tf[i].tfile);
} else if (nread < 0) {
warning(_("unable to read temporary file"));
warningx(_("contents of edit session left in %s"), tf[i].tfile);
warning(U_("unable to read temporary file"));
warningx(U_("contents of edit session left in %s"), tf[i].tfile);
} else {
warning(_("unable to write to %s"), tf[i].ofile);
warningx(_("contents of edit session left in %s"), tf[i].tfile);
warning(U_("unable to write to %s"), tf[i].ofile);
warningx(U_("contents of edit session left in %s"), tf[i].tfile);
}
close(ofd);
}

View File

@ -87,7 +87,7 @@ tgetpass(const char *prompt, int timeout, int flags)
if (!ISSET(flags, TGP_STDIN|TGP_ECHO|TGP_ASKPASS|TGP_NOECHO_TRY) &&
!tty_present()) {
if (askpass == NULL || getenv_unhooked("DISPLAY") == NULL) {
warningx(_("no tty present and no askpass program specified"));
warningx(U_("no tty present and no askpass program specified"));
debug_return_str(NULL);
}
SET(flags, TGP_ASKPASS);
@ -96,7 +96,7 @@ tgetpass(const char *prompt, int timeout, int flags)
/* If using a helper program to get the password, run it instead. */
if (ISSET(flags, TGP_ASKPASS)) {
if (askpass == NULL || *askpass == '\0')
fatalx(_("no askpass program specified, try setting SUDO_ASKPASS"));
fatalx(U_("no askpass program specified, try setting SUDO_ASKPASS"));
debug_return_str_masked(sudo_askpass(askpass, prompt));
}
@ -215,10 +215,10 @@ sudo_askpass(const char *askpass, const char *prompt)
debug_decl(sudo_askpass, SUDO_DEBUG_CONV)
if (pipe(pfd) == -1)
fatal(_("unable to create pipe"));
fatal(U_("unable to create pipe"));
if ((pid = fork()) == -1)
fatal(_("unable to fork"));
fatal(U_("unable to fork"));
if (pid == 0) {
/* child, point stdout to output side of the pipe and exec askpass */
@ -229,16 +229,16 @@ sudo_askpass(const char *askpass, const char *prompt)
if (setuid(ROOT_UID) == -1)
warning("setuid(%d)", ROOT_UID);
if (setgid(user_details.gid)) {
warning(_("unable to set gid to %u"), (unsigned int)user_details.gid);
warning(U_("unable to set gid to %u"), (unsigned int)user_details.gid);
_exit(255);
}
if (setuid(user_details.uid)) {
warning(_("unable to set uid to %u"), (unsigned int)user_details.uid);
warning(U_("unable to set uid to %u"), (unsigned int)user_details.uid);
_exit(255);
}
closefrom(STDERR_FILENO + 1);
execl(askpass, askpass, prompt, (char *)NULL);
warning(_("unable to run %s"), askpass);
warning(U_("unable to run %s"), askpass);
_exit(255);
}

View File

@ -275,12 +275,12 @@ utmp_slot(const char *line, int ttyfd)
* doesn't take an argument.
*/
if ((sfd = dup(STDIN_FILENO)) == -1)
fatal(_("unable to save stdin"));
fatal(U_("unable to save stdin"));
if (dup2(ttyfd, STDIN_FILENO) == -1)
fatal(_("unable to dup2 stdin"));
fatal(U_("unable to dup2 stdin"));
slot = ttyslot();
if (dup2(sfd, STDIN_FILENO) == -1)
fatal(_("unable to restore stdin"));
fatal(U_("unable to restore stdin"));
close(sfd);
debug_return_int(slot);