then calls gettext().
Add U_ macro that calls warning_gettext() instead of gettext().
Rename warning2()/error2() back to warning_nodebug()/error_nodebug().
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 \
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
if (user != NULL) {
if (setuserdb(S_READ) != 0)
- fatal(_("unable to open userdb"));
+ fatal(U_("unable to open userdb"));
if (getuserattr(user, S_REGISTRY, ®istry, 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();
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;
}
}
void
-fatal2(const char *fmt, ...)
+fatal_nodebug(const char *fmt, ...)
{
va_list ap;
}
void
-fatalx2(const char *fmt, ...)
+fatalx_nodebug(const char *fmt, ...)
{
va_list ap;
}
void
-vfatal2(const char *fmt, va_list ap)
+vfatal_nodebug(const char *fmt, va_list ap)
{
_warning(1, fmt, ap);
do_cleanup();
}
void
-vfatalx2(const char *fmt, va_list ap)
+vfatalx_nodebug(const char *fmt, va_list ap)
{
_warning(0, fmt, ap);
do_cleanup();
}
void
-warning2(const char *fmt, ...)
+warning_nodebug(const char *fmt, ...)
{
va_list ap;
}
void
-warningx2(const char *fmt, ...)
+warningx_nodebug(const char *fmt, ...)
{
va_list ap;
va_start(ap, 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);
}
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);
}
} 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);
}
}
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;
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 */
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;
}
} 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_ */
# 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 */
# 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
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);
}
(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);
}
/* 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;
}
*/
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);
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);
}
/* 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);
}
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);
}
}
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;
break;
default:
- warningx(_("unknown SecurID error"));
+ warningx(U_("unknown SecurID error"));
rval = AUTH_FATAL;
break;
}
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;
#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;
}
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;
#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;
}
break;
}
if (!cur->name) {
- warningx(_("unknown defaults entry `%s'"), var);
+ warningx(U_("unknown defaults entry `%s'"), var);
debug_return_bool(false);
}
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;
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;
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;
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;
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;
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;
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;
}
if (cur->name == NULL) {
if (!quiet)
- warningx(_("unknown defaults entry `%s'"), def->var);
+ warningx(U_("unknown defaults entry `%s'"), def->var);
rc = false;
}
}
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 *));
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);
}
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)
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;
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;
}
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;
}
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') {
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
nldaps++;
host = uri + 8;
} else {
- warningx(_("unsupported LDAP uri type: %s"), uri);
+ warningx(U_("unsupported LDAP uri type: %s"), uri);
goto done;
}
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);
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 *
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;
}
}
}
}
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;
}
/* 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;
}
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;
}
/* 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) {
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));
}
}
}
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 */
}
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);
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);
}
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;
/* 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);
return res ? true : false;
}
-static int warning_locale;
-
-void
-warning_set_locale(void)
+char *
+warning_gettext(const char *msgid)
{
- sudoers_setlocale(SUDOERS_LOCALE_USER, &warning_locale);
-}
+ int warning_locale;
+ char *msg;
-void
-warning_restore_locale(void)
-{
+ sudoers_setlocale(SUDOERS_LOCALE_USER, &warning_locale);
+ msg = gettext(msgid);
sudoers_setlocale(warning_locale, NULL);
+
+ return msg;
}
* 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;
* 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);
}
switch (pid = sudo_debug_fork()) {
case -1:
/* Error. */
- fatal(_("unable to fork"));
+ fatal(U_("unable to fork"));
break;
case 0:
/* Child. */
debug_return_str(line);
toobig:
- fatalx(_("internal error: insufficient space for log line"));
+ fatalx(U_("internal error: insufficient space for log line"));
}
}
}
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) {
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);
}
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);
}
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=")) {
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;
}
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;
}
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;
}
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=")) {
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;
}
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;
}
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;
}
}
(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;
}
}
/* 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(). */
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);
}
}
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()");
}
/* 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();
/* 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
/* 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++;
/* 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);
/* 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++;
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;
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);
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);
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);
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);
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);
/* 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);
}
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);
}
}
}
if (sources == 0) {
- warningx(_("no valid sudoers sources found, quitting"));
+ warningx(U_("no valid sudoers sources found, quitting"));
debug_return_bool(-1);
}
/* 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;
}
/* 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;
/* 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;
}
/* 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;
}
/* 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);
* 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);
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++ = ' ';
}
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)
}
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);
}
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':
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);
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;
/* 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. */
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. */
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;
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;
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)
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)
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 */
}
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;
}
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);
}
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)
fp = fopen(logfile, "r");
if (fp == NULL) {
- warning(_("unable to open %s"), logfile);
+ warning(U_("unable to open %s"), logfile);
goto bad;
}
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));
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;
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. */
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)
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++ = ' ';
}
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;
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;
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);
}
}
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);
}
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);
}
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);
}
/* 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. */
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);
(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);
* 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;
}
if (modified)
sp->modified = modified;
else
- warningx(_("%s unchanged"), sp->tpath);
+ warningx(U_("%s unchanged"), sp->tpath);
rval = true;
done:
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 */
/* 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;
}
}
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;
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;
}
} 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 */
/* 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);
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;
}
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 */
}
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;
}
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);
} 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;
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, ":");
/* 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);
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);
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);
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;
}
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;
}
* 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 */
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,
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,
* 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).
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");
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
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;
}
/* 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
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);
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;
}
/* 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"));
}
}
}
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];
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];
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];
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"));
}
}
* 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
child = sudo_debug_fork();
switch (child) {
case -1:
- fatal(_("unable to fork"));
+ fatal(U_("unable to fork"));
break;
case 0:
/* child */
"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 &&
"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"));
}
}
}
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"));
}
}
}
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 {
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 {
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? */
}
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;
* 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));
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)
/* 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) {
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.
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);
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;
}
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;
/* 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;
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;
/* 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;
}
}
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;
/*
- * 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
#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);
}
"%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;
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;
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;
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;
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.
"%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;
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;
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;
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);
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) &&
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) ||
argv--;
argv[0] = "sudoedit";
#else
- fatalx(_("sudoedit is not supported on this platform"));
+ fatalx(U_("sudoedit is not supported on this platform"));
#endif
}
{
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);
}
/* 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",
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);
}
/* 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) {
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;
}
}
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;
}
/* 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;
}
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,
/* 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;
}
* 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;
}
*/
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;
}
/* 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;
}
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;
}
}
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;
}
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);
*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);
}
* 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);
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);
}
}
/* 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);
if (ok == -2)
usage(1);
else
- fatalx(_("unable to initialize policy plugin"));
+ fatalx(U_("unable to initialize policy plugin"));
}
init_signals();
usage(1);
break;
default:
- fatalx(_("error initializing I/O plugin %s"),
+ fatalx(U_("error initializing I/O plugin %s"),
plugin->name);
}
}
/* 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);
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)
* 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"));
}
/*
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)
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;
}
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;
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;
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;
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;
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;
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;
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;
/* 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);
}
}
*/
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;
}
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;
}
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;
}
}
(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;
}
}
#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;
}
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;
}
}
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);
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;
}
{
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,
{
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);
}
{
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);
}
{
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);
* 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;
}
editor_argc++;
}
if (nfiles == 0) {
- warningx(_("plugin error: missing file list for sudoedit"));
+ warningx(U_("plugin error: missing file list for sudoedit"));
goto cleanup;
}
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;
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;
}
}
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;
*/
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;
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;
}
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;
}
}
/* 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);
}
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);
/* 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));
}
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 */
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);
}
* 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);