if (user != NULL) {
if (setuserdb(S_READ) != 0)
- error(1, "unable to open userdb");
+ error(1, _("unable to open userdb"));
if (getuserattr(user, S_REGISTRY, ®istry, SEC_CHAR) == 0) {
if (setauthdb(registry, NULL) != 0)
- error(1, "unable to switch to registry \"%s\" for %s",
+ error(1, _("unable to switch to registry \"%s\" for %s"),
registry, user);
}
enduserdb();
aix_restoreauthdb(void)
{
if (setauthdb(NULL, NULL) != 0)
- error(1, "unable to restore registry");
+ error(1, _("unable to restore registry"));
}
#endif
void *ptr;
if (size == 0)
- errorx(1, "internal error, tried to emalloc(0)");
+ errorx(1, _("internal error, tried to emalloc(0)"));
if ((ptr = malloc(size)) == NULL)
- errorx(1, "unable to allocate memory");
+ errorx(1, _("unable to allocate memory"));
return ptr;
}
void *ptr;
if (nmemb == 0 || size == 0)
- errorx(1, "internal error, tried to emalloc2(0)");
+ errorx(1, _("internal error, tried to emalloc2(0)"));
if (nmemb > SIZE_MAX / size)
- errorx(1, "internal error, emalloc2() overflow");
+ errorx(1, _("internal error, emalloc2() overflow"));
size *= nmemb;
if ((ptr = malloc(size)) == NULL)
- errorx(1, "unable to allocate memory");
+ errorx(1, _("unable to allocate memory"));
return ptr;
}
{
if (size == 0)
- errorx(1, "internal error, tried to erealloc(0)");
+ errorx(1, _("internal error, tried to erealloc(0)"));
ptr = ptr ? realloc(ptr, size) : malloc(size);
if (ptr == NULL)
- errorx(1, "unable to allocate memory");
+ errorx(1, _("unable to allocate memory"));
return ptr;
}
{
if (nmemb == 0 || size == 0)
- errorx(1, "internal error, tried to erealloc3(0)");
+ errorx(1, _("internal error, tried to erealloc3(0)"));
if (nmemb > SIZE_MAX / size)
- errorx(1, "internal error, erealloc3() overflow");
+ errorx(1, _("internal error, erealloc3() overflow"));
size *= nmemb;
ptr = ptr ? realloc(ptr, size) : malloc(size);
if (ptr == NULL)
- errorx(1, "unable to allocate memory");
+ errorx(1, _("unable to allocate memory"));
return ptr;
}
va_end(ap);
if (len == -1)
- errorx(1, "unable to allocate memory");
+ errorx(1, _("unable to allocate memory"));
return len;
}
int len;
if ((len = vasprintf(ret, format, args)) == -1)
- errorx(1, "unable to allocate memory");
+ errorx(1, _("unable to allocate memory"));
return len;
}
{
if (signo > 0 && signo < NSIG)
return (char *)my_sys_siglist[signo];
- return "Unknown signal";
+ return _("Unknown signal");
}
fputs(getprogname(), stderr);
if (fmt != NULL) {
- fputs(": ", stderr);
+ fputs(_(": "), stderr);
vfprintf(stderr, fmt, ap);
}
if (use_errno) {
- fputs(": ", stderr);
+ fputs(_(": "), stderr);
fputs(strerror(serrno), stderr);
}
putc('\n', stderr);
if (!ISSET(details->flags, CD_BACKGROUND)) {
if (ISSET(details->flags, CD_SET_UTMP))
utmp_user = details->utmp_user ? details->utmp_user : user_details.username;
- sudo_debug(8, "allocate pty for I/O logging");
+ sudo_debug(8, _("allocate pty for I/O logging"));
pty_setup(details->euid, user_details.tty, utmp_user);
}
}
* Parent sends signal info to child and child sends back wait status.
*/
if (socketpair(PF_UNIX, SOCK_DGRAM, 0, sv) == -1)
- error(1, "cannot create sockets");
+ error(1, _("cannot create sockets"));
/*
* We use a pipe to atomically handle signal notification within
* the select() loop.
*/
if (pipe_nonblock(signal_pipe) != 0)
- error(1, "cannot create pipe");
+ error(1, _("cannot create pipe"));
zero_bytes(&sa, sizeof(sa));
sigemptyset(&sa.sa_mask);
if (nready == -1) {
if (errno == EINTR)
continue;
- error(1, "select failed");
+ error(1, _("select failed"));
}
if (FD_ISSET(sv[0], fdsw)) {
forward_signals(sv[0]);
if (cstat->type == CMD_WSTATUS) {
if (WIFSTOPPED(cstat->val)) {
/* Suspend parent and tell child how to resume on return. */
- sudo_debug(8, "child stopped, suspending parent");
+ sudo_debug(8, _("child stopped, suspending parent"));
n = suspend_parent(WSTOPSIG(cstat->val));
schedule_signal(n);
continue;
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(_("unable to restore tty label"));
}
#endif
/* If pipe is empty, we are done. */
if (errno == EAGAIN)
break;
- sudo_debug(9, "error reading signal pipe %s", strerror(errno));
+ sudo_debug(9, _("error reading signal pipe %s"), strerror(errno));
cstat->type = CMD_ERRNO;
cstat->val = errno;
return -1;
}
- sudo_debug(9, "received signal %d", signo);
+ sudo_debug(9, _("received signal %d"), signo);
if (signo == SIGCHLD) {
/*
* If logging I/O, child is the intermediate process,
while (!tq_empty(&sigfwd_list)) {
sigfwd = tq_first(&sigfwd_list);
- sudo_debug(9, "sending signal %d to child over backchannel",
+ sudo_debug(9, _("sending signal %d to child over backchannel"),
sigfwd->signo);
cstat.type = CMD_SIGNO;
cstat.val = sigfwd->signo;
if (io_fds[SFD_USERTTY] != -1) {
if (!get_pty(&io_fds[SFD_MASTER], &io_fds[SFD_SLAVE],
slavename, sizeof(slavename), uid))
- error(1, "Can't get pty");
+ error(1, _("can't allocate pty"));
/* Add entry to utmp/utmpx? */
if (utmp_user != NULL)
utmp_login(tty, slavename, io_fds[SFD_SLAVE], utmp_user);
/* Suspend self and continue child when we resume. */
sa.sa_handler = SIG_DFL;
sigaction(signo, &sa, &osa);
- sudo_debug(8, "kill parent %d", signo);
+ sudo_debug(8, _("kill parent %d"), signo);
if (killpg(ppgrp, signo) != 0)
warning("killpg(%d, %d)", ppgrp, signo);
* Only modify term if we are foreground process and either
* the old tty mode was not cooked or child got SIGTT{IN,OU}
*/
- sudo_debug(8, "parent is in %sground, ttymode %d -> %d",
- foreground ? "fore" : "back", oldmode, ttymode);
+ sudo_debug(8,
+ foreground ? _("parent is in foreground, ttymode %d -> %d") :
+ _("parent is in background, ttymode %d -> %d"), oldmode, ttymode);
if (ttymode != TERM_COOKED) {
if (foreground) {
if (io_fds[SFD_STDIN] == -1 || !isatty(STDIN_FILENO)) {
pipeline = TRUE;
if (pipe(io_pipe[STDIN_FILENO]) != 0)
- error(1, "unable to create pipe");
+ error(1, _("unable to create pipe"));
iobufs = io_buf_new(STDIN_FILENO, io_pipe[STDIN_FILENO][1],
log_stdin, iobufs);
io_fds[SFD_STDIN] = io_pipe[STDIN_FILENO][0];
if (io_fds[SFD_STDOUT] == -1 || !isatty(STDOUT_FILENO)) {
pipeline = TRUE;
if (pipe(io_pipe[STDOUT_FILENO]) != 0)
- error(1, "unable to create pipe");
+ error(1, _("unable to create pipe"));
iobufs = 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)) {
if (pipe(io_pipe[STDERR_FILENO]) != 0)
- error(1, "unable to create pipe");
+ error(1, _("unable to create pipe"));
iobufs = 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)
- error(1, "Can't set terminal to raw mode");
+ error(1, _("Can't set terminal to raw mode"));
}
}
int status;
/* Handle signal from parent. */
- sudo_debug(8, "signal %d from parent", signo);
+ sudo_debug(8, _("signal %d from parent"), signo);
switch (signo) {
case SIGALRM:
terminate_child(pid, TRUE);
n = send(fd, cstat, sizeof(*cstat), 0);
} while (n == -1 && errno == EINTR);
if (n != sizeof(*cstat)) {
- sudo_debug(8, "unable to send status to parent: %s", strerror(errno));
+ sudo_debug(8, _("unable to send status to parent: %s"),
+ strerror(errno));
} else {
- sudo_debug(8, "sent status to parent");
+ sudo_debug(8, _("sent status to parent"));
}
cstat->type = CMD_INVALID; /* prevent re-sending */
}
cstat->type = CMD_WSTATUS;
cstat->val = status;
if (WIFSTOPPED(status)) {
- sudo_debug(8, "command stopped, signal %d",
+ sudo_debug(8, _("command stopped, signal %d"),
WSTOPSIG(status));
do {
child_pgrp = tcgetpgrp(io_fds[SFD_SLAVE]);
if (send_status(backchannel, cstat) == -1)
return alive; /* XXX */
} else if (WIFSIGNALED(status)) {
- sudo_debug(8, "command killed, signal %d",
+ sudo_debug(8, _("command killed, signal %d"),
WTERMSIG(status));
} else {
- sudo_debug(8, "command exited: %d",
+ sudo_debug(8, _("command exited: %d"),
WEXITSTATUS(status));
}
}
* the select() loop.
*/
if (pipe_nonblock(signal_pipe) != 0)
- error(1, "cannot create pipe");
+ error(1, _("cannot create pipe"));
/* Reset SIGWINCH and SIGALRM. */
zero_bytes(&sa, sizeof(sa));
if (io_fds[SFD_SLAVE] != -1) {
#ifdef TIOCSCTTY
if (ioctl(io_fds[SFD_SLAVE], TIOCSCTTY, NULL) != 0)
- error(1, "unable to set controlling tty");
+ error(1, _("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)
- error(1, "unable to create pipe");
+ error(1, _("unable to create pipe"));
child = fork();
if (child == -1) {
- warning("Can't fork");
+ warning("fork");
goto bad;
}
if (child == 0) {
goto done;
if (errno == EINTR)
continue;
- error(1, "select failed");
+ error(1, _("select failed"));
}
if (FD_ISSET(signal_pipe[0], fdsr)) {
if (n == -1) {
if (errno == EINTR || errno == EAGAIN)
continue;
- warning("error reading from signal pipe");
+ warning(_("error reading from signal pipe"));
goto done;
}
/*
if (n == -1) {
if (errno == EINTR)
continue;
- warning("error reading from pipe");
+ warning(_("error reading from pipe"));
goto done;
}
/* Got errno or EOF, either way we are done with errpipe. */
if (n == -1) {
if (errno == EINTR)
continue;
- warning("error reading from socketpair");
+ warning(_("error reading from socketpair"));
goto done;
}
if (cstmp.type != CMD_SIGNO) {
- warningx("unexpected reply type on backchannel: %d", cstmp.type);
+ warningx(_("unexpected reply type on backchannel: %d"),
+ cstmp.type);
continue;
}
deliver_signal(child, cstmp.val);
break; /* all I/O flushed */
if (errno == EINTR)
continue;
- error(1, "select failed");
+ error(1, _("select failed"));
}
if (perform_io(fdsr, fdsw, NULL) != 0)
break;
tq_foreach_fwd(plugin_list, info) {
if (info->path[0] == '/') {
if (strlcpy(path, info->path, sizeof(path)) >= sizeof(path)) {
- warningx("%s: %s", info->path, strerror(ENAMETOOLONG));
+ warningx(_("%s: %s"), info->path, strerror(ENAMETOOLONG));
goto done;
}
} else {
if (snprintf(path, sizeof(path), "%s%s", _PATH_SUDO_PLUGIN_DIR,
info->path) >= sizeof(path)) {
- warningx("%s%s: %s", _PATH_SUDO_PLUGIN_DIR, info->path,
+ warningx(_("%s%s: %s"), _PATH_SUDO_PLUGIN_DIR, info->path,
strerror(ENAMETOOLONG));
goto done;
}
goto done;
}
if (sb.st_uid != ROOT_UID) {
- warningx("%s must be owned by uid %d", path, ROOT_UID);
+ warningx(_("%s must be owned by uid %d"), path, ROOT_UID);
goto done;
}
if ((sb.st_mode & (S_IWGRP|S_IWOTH)) != 0) {
- warningx("%s must be only be writable by owner", path);
+ warningx(_("%s must be only be writable by owner"), path);
goto done;
}
/* Open plugin and map in symbol */
handle = dlopen(path, RTLD_LAZY|RTLD_LOCAL);
if (!handle) {
- warningx("unable to dlopen %s: %s", path, dlerror());
+ warningx(_("unable to dlopen %s: %s"), path, dlerror());
goto done;
}
plugin = dlsym(handle, info->symbol_name);
if (!plugin) {
- warningx("unable to find symbol %s in %s", info->symbol_name, path);
+ warningx(_("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("%s: unknown policy type %d", path, plugin->type);
+ warningx(_("%s: unknown policy type %d"), path, plugin->type);
goto done;
}
if (SUDO_API_VERSION_GET_MAJOR(plugin->version) != SUDO_API_VERSION_MAJOR) {
- warningx("%s: incompatible policy major version %d, expected %d",
+ warningx(_("%s: incompatible policy major version %d, expected %d"),
path, SUDO_API_VERSION_GET_MAJOR(plugin->version),
SUDO_API_VERSION_MAJOR);
goto done;
}
if (plugin->type == SUDO_POLICY_PLUGIN) {
if (policy_plugin->handle) {
- warningx("only a single policy plugin may be loaded");
+ warningx(_("only a single policy plugin may be loaded"));
goto done;
}
policy_plugin->handle = handle;
}
}
if (policy_plugin->handle == NULL) {
- warningx("%s: at least one policy plugin must be specified", conf_file);
+ warningx(_("%s: at least one policy plugin must be specified"),
+ conf_file);
goto done;
}
if (policy_plugin->u.policy->check_policy == NULL) {
- warningx("policy plugin %s does not include a check_policy method",
+ warningx(_("policy plugin %s does not include a check_policy method"),
policy_plugin->name);
goto done;
}
"%s%s/", cp == *addrinfo ? "" : " ",
inet_ntoa(sin->sin_addr));
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
- warningx("load_interfaces: overflow detected");
+ warningx(_("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(_("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(_("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(_("load_interfaces: overflow detected"));
goto done;
}
cp += len;
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0)
- error(1, "cannot open socket");
+ error(1, _("cannot 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(_("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(_("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(_("the argument to -C must be a number greater than or equal to 3"));
usage(1);
}
sudo_settings[ARG_CLOSEFROM].value = optarg;
#endif
case 'D':
if ((debug_level = atoi(optarg)) < 1 || debug_level > 9) {
- warningx("the argument to -D must be between 1 and 9 inclusive");
+ warningx(_("the argument to -D must be between 1 and 9 inclusive"));
usage(1);
}
sudo_settings[ARG_DEBUG_LEVEL].value = optarg;
break;
case 'U':
if ((getpwnam(optarg)) == NULL)
- errorx(1, "unknown user: %s", optarg);
+ errorx(1, _("unknown user: %s"), optarg);
list_user = optarg;
break;
case 'u':
if (ISSET(flags, MODE_LOGIN_SHELL)) {
if (ISSET(flags, MODE_SHELL)) {
- warningx("you may not specify both the `-i' and `-s' options");
+ warningx(_("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(_("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(_("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(_("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(_("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(_("the `-A' and `-S' options may not be used together"));
usage(1);
}
if ((argc == 0 && mode == MODE_EDIT) ||
settings[j] = fmt_string(sudo_settings[i].name,
sudo_settings[i].value);
if (settings[j] == NULL)
- errorx(1, "unable to allocate memory");
+ errorx(1, _("unable to allocate memory"));
j++;
}
}
argv--;
argv[0] = "sudoedit";
#else
- errorx(1, "sudoedit is not supported on this platform");
+ errorx(1, _("sudoedit is not supported on this platform"));
#endif
}
static void
usage_excl(int fatal)
{
- warningx("Only one of the -e, -h, -i, -K, -l, -s, -v or -V options may be specified");
+ warningx(_("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
)
- error(1, "unable to open audit system");
+ error(1, _("unable to open audit system"));
return -1;
}
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(_("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(_("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(_("%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(_("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(_("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(_("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(_("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(_("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("cannot open %s", ttyn);
+ warning(_("cannot 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(_("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(_("you must specify a role for type %s"), type);
errno = EINVAL;
return NULL;
}
if (!type) {
if (get_default_type(role, &typebuf)) {
- warningx("unable to get default type for role %s", role);
+ warningx(_("unable to get default type for role %s"), role);
errno = EINVAL;
return NULL;
}
* type we will be running the command as.
*/
if (context_role_set(context, role)) {
- warning("failed to set new role %s", role);
+ warning(_("failed to set new role %s"), role);
goto bad;
}
if (context_type_set(context, type)) {
- warning("failed to set new type %s", type);
+ warning(_("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(_("%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(_("failed to get old_context"));
goto done;
}
se_state.enforcing = security_getenforce();
if (se_state.enforcing < 0) {
- warning("unable to determine enforcing mode.");
+ warning(_("unable to determine enforcing mode."));
goto done;
}
goto done;
if (relabel_tty(ttyn, ptyfd) < 0) {
- warning("unable to setup tty context for %s", se_state.new_context);
+ warning(_("unable to setup tty context for %s"), se_state.new_context);
goto done;
}
int argc, serrno;
if (setexeccon(se_state.new_context)) {
- warning("unable to set exec context to %s", se_state.new_context);
+ warning(_("unable to set exec context to %s"), se_state.new_context);
if (se_state.enforcing)
return;
}
#ifdef HAVE_SETKEYCREATECON
if (setkeycreatecon(se_state.new_context)) {
- warning("unable to set key creation context to %s", se_state.new_context);
+ warning(_("unable to set key creation context to %s"), se_state.new_context);
if (se_state.enforcing)
return;
}
char *cp, *cmnd;
if (argc < 2)
- errx(EXIT_FAILURE, "requires at least one argument");
+ errx(EXIT_FAILURE, _("requires at least one argument"));
/* Shift argv and make a copy of the command to execute. */
argv++;
*cp = '-';
}
execv(cmnd, argv);
- warn("unable to execute %s", argv[0]);
+ warn(_("unable to execute %s"), argv[0]);
_exit(EXIT_FAILURE);
}
#endif /* HAVE_GETPRPWNAM && HAVE_SET_AUTH_PARAMETERS */
if (geteuid() != 0)
- errorx(1, "must be setuid root");
+ errorx(1, _("must be setuid root"));
/* Reset signal mask, disable core dumps and make sure fds 0-2 are open. */
(void) sigemptyset(&mask);
/* Print sudo version early, in case of plugin init failure. */
if (ISSET(sudo_mode, MODE_VERSION)) {
- printf("Sudo version %s\n", PACKAGE_VERSION);
+ printf(_("Sudo version %s\n"), PACKAGE_VERSION);
if (user_details.uid == ROOT_UID)
- (void) printf("Configure args: %s\n", CONFIGURE_ARGS);
+ (void) printf(_("Configure args: %s\n"), CONFIGURE_ARGS);
}
/* Read sudo.conf and load plugins. */
if (!sudo_load_plugins(_PATH_SUDO_CONF, &policy_plugin, &io_plugins))
- errorx(1, "fatal error, unable to load plugins");
+ errorx(1, _("fatal error, unable to load plugins"));
/* Open policy plugin. */
ok = policy_open(&policy_plugin, settings, user_info, envp);
if (ok == -2)
usage(1);
else
- errorx(1, "unable to initialize policy plugin");
+ errorx(1, _("unable to initialize policy plugin"));
}
switch (sudo_mode & MODE_MASK) {
usage(1);
break;
default:
- errorx(1, "error initializing I/O plugin %s", plugin->name);
+ errorx(1, _("error initializing I/O plugin %s"),
+ plugin->name);
}
}
command_info_to_details(command_info, &command_details);
/* The close method was called by sudo_edit/run_command. */
break;
default:
- errorx(1, "unexpected sudo mode 0x%x", sudo_mode);
+ errorx(1, _("unexpected sudo mode 0x%x"), sudo_mode);
}
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)
- error(1, "unable to open %s", _PATH_DEVNULL);
+ error(1, _("unable to open %s"), _PATH_DEVNULL);
if (miss[STDIN_FILENO] && dup2(devnull, STDIN_FILENO) == -1)
error(1, "dup2");
if (miss[STDOUT_FILENO] && dup2(devnull, STDOUT_FILENO) == -1)
ud->groups = emalloc2(ud->ngroups, sizeof(GETGROUPS_T));
if (getgroups(ud->ngroups, ud->groups) < 0)
- error(1, "can't get group vector");
+ error(1, _("can't get group vector"));
glsize = sizeof("groups=") - 1 + (ud->ngroups * (MAX_UID_T_LEN + 1));
gid_list = emalloc(glsize);
memcpy(gid_list, "groups=", sizeof("groups=") - 1);
pw = getpwuid(ud->uid);
if (pw == NULL)
- errorx(1, "unknown uid %u: who are you?", (unsigned int)ud->uid);
+ errorx(1, _("unknown uid %u: who are you?"), (unsigned int)ud->uid);
user_info[i] = fmt_string("user", pw->pw_name);
if (user_info[i] == NULL)
- errorx(1, "unable to allocate memory");
+ errorx(1, _("unable to allocate memory"));
ud->username = user_info[i] + sizeof("user=") - 1;
/* Stash user's shell for use with the -s flag; don't pass to plugin. */
if (getcwd(cwd, sizeof(cwd)) != NULL) {
user_info[++i] = fmt_string("cwd", cwd);
if (user_info[i] == NULL)
- errorx(1, "unable to allocate memory");
+ errorx(1, _("unable to allocate memory"));
ud->cwd = user_info[i] + sizeof("cwd=") - 1;
}
(cp = ttyname(STDERR_FILENO))) {
user_info[++i] = fmt_string("tty", cp);
if (user_info[i] == NULL)
- errorx(1, "unable to allocate memory");
+ errorx(1, _("unable to allocate memory"));
ud->tty = user_info[i] + sizeof("tty=") - 1;
}
strlcpy(host, "localhost", sizeof(host));
user_info[++i] = fmt_string("host", host);
if (user_info[i] == NULL)
- errorx(1, "unable to allocate memory");
+ errorx(1, _("unable to allocate memory"));
ud->host = user_info[i] + sizeof("host=") - 1;
get_ttysize(&ud->ts_lines, &ud->ts_cols);
case SETPROJ_ERR_TASK:
switch (errno) {
case EAGAIN:
- warningx("resource control limit has been reached");
+ warningx(_("resource control limit has been reached"));
break;
case ESRCH:
- warningx("user \"%s\" is not a member of project \"%s\"",
+ warningx(_("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(_("the invoking task is final"));
break;
default:
- warningx("could not join project \"%s\"", proj.pj_name);
+ warningx(_("could not join project \"%s\""), proj.pj_name);
}
case SETPROJ_ERR_POOL:
switch (errno) {
case EACCES:
- warningx("no resource pool accepting default bindings "
- "exists for project \"%s\"", proj.pj_name);
+ warningx(_("no resource pool accepting default bindings "
+ "exists for project \"%s\""), proj.pj_name);
break;
case ESRCH:
- warningx("specified resource pool does not exist for "
- "project \"%s\"", proj.pj_name);
+ warningx(_("specified resource pool does not exist for "
+ "project \"%s\""), proj.pj_name);
break;
default:
- warningx("could not bind to default resource pool for "
- "project \"%s\"", proj.pj_name);
+ warningx(_("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(_("setproject failed for project \"%s\""), proj.pj_name);
} else {
- warningx("warning, resource control assignment failed for "
- "project \"%s\"", proj.pj_name);
+ warningx(_("warning, resource control assignment failed for "
+ "project \"%s\""), proj.pj_name);
}
}
} else {
/* Solaris privileges, remove PRIV_PROC_EXEC post-execve. */
if (priv_set(PRIV_OFF, PRIV_LIMIT, "PRIV_PROC_EXEC", NULL) == 0)
return;
- warning("unable to remove PRIV_PROC_EXEC from PRIV_LIMIT");
+ warning(_("unable to remove PRIV_PROC_EXEC from PRIV_LIMIT"));
#endif /* HAVE_PRIV_SET */
nenvp = emalloc2(env_size, sizeof(char *));
*/
lc = login_getclass((char *)details->login_class);
if (!lc) {
- warningx("unknown login class %s", details->login_class);
+ warningx(_("unknown login class %s"), details->login_class);
errno = ENOENT;
goto done;
}
flags = LOGIN_SETRESOURCES|LOGIN_SETPRIORITY;
if (setusercontext(lc, pw, pw->pw_uid, flags)) {
if (pw->pw_uid != ROOT_UID) {
- warning("unable to set user context");
+ warning(_("unable to set user context"));
goto done;
} else
- warning("unable to set user context");
+ warning(_("unable to set user context"));
}
}
#endif /* HAVE_LOGIN_CAP_H */
*/
#ifdef HAVE_SETEUID
if (ISSET(details->flags, CD_SET_EGID) && setegid(details->egid)) {
- warning("unable to set egid to runas gid %u", details->egid);
+ warning(_("unable to set egid to runas gid %u"), details->egid);
goto done;
}
#endif
if (ISSET(details->flags, CD_SET_GID) && setgid(details->gid)) {
- warning("unable to set gid to runas gid %u", details->gid);
+ warning(_("unable to set gid to runas gid %u"), details->gid);
goto done;
}
#ifdef HAVE_GETGROUPS
if (details->ngroups >= 0) {
if (setgroups(details->ngroups, details->groups) < 0) {
- warning("unable to set supplementary group IDs");
+ warning(_("unable to set supplementary group IDs"));
goto done;
}
}
#else
if (pw && initgroups(pw->pw_name, pw->pw_gid) < 0) {
- warning("unable to set supplementary group IDs");
+ warning(_("unable to set supplementary group IDs"));
goto done;
}
#endif
if (ISSET(details->flags, CD_SET_PRIORITY)) {
if (setpriority(PRIO_PROCESS, 0, details->priority) != 0) {
- warning("unable to set process priority");
+ warning(_("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(_("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(_("unable to change to runas uid (%u, %u)"), details->uid,
details->euid);
goto done;
}
#elif HAVE_SETREUID
if (setreuid(details->uid, details->euid) != 0) {
- warning("unable to change to runas uid (%u, %u)", details->uid,
+ warning(_("unable to change to runas uid (%u, %u)"), details->uid,
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(_("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(_("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(_("unexpected child termination condition: %d"), cstat.type);
break;
}
return exitcode;
int verbose, const char *list_user)
{
if (plugin->u.policy->list == NULL) {
- warningx("policy plugin %s does not support listing privileges",
+ warningx(_("policy plugin %s does not support listing privileges"),
plugin->name);
return FALSE;
}
policy_validate(struct plugin_container *plugin)
{
if (plugin->u.policy->validate == NULL) {
- warningx("policy plugin %s does not support the -v flag",
+ warningx(_("policy plugin %s does not support the -v flag"),
plugin->name);
return FALSE;
}
policy_invalidate(struct plugin_container *plugin, int remove)
{
if (plugin->u.policy->invalidate == NULL) {
- errorx(1, "policy plugin %s does not support the -k/-K flags",
+ errorx(1, _("policy plugin %s does not support the -k/-K flags"),
plugin->name);
}
plugin->u.policy->invalidate(remove);
return;
/* Backet fmt with program name and a newline to make it a single write */
- easprintf(&fmt2, "%s: %s\n", getprogname(), fmt);
+ easprintf(&fmt2, _("%s: %s\n"), getprogname(), fmt);
va_start(ap, fmt);
vfprintf(stderr, fmt2, ap);
va_end(ap);
* We will change the euid as needed below.
*/
if (setuid(ROOT_UID) != 0) {
- warning("unable to change to uid to root (%u)", ROOT_UID);
+ warning(_("unable to change to uid to root (%u)"), ROOT_UID);
return 1;
}
editor_argc++;
}
if (nfiles == 0) {
- warningx("plugin error: missing file list for sudoedit");
+ warningx(_("plugin error: missing file list for sudoedit"));
return 1;
}
if (rc)
warning("%s", files[i]);
else
- warningx("%s: not a regular file", files[i]);
+ warningx(_("%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(_("%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(_("%s: not a regular file"), tf[i].tfile);
+ warningx(_("%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(_("%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(_("unable to write to %s"), tf[i].ofile);
+ warningx(_("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(_("%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(_("unable to read temporary file"));
+ warningx(_("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(_("unable to write to %s"), tf[i].ofile);
+ warningx(_("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("DISPLAY") == NULL) {
- warningx("no tty present and no askpass program specified");
+ warningx(_("no tty present and no askpass program specified"));
return 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')
- errorx(1, "no askpass program specified, try setting SUDO_ASKPASS");
+ errorx(1, _("no askpass program specified, try setting SUDO_ASKPASS"));
return sudo_askpass(askpass, prompt);
}
pid_t pid;
if (pipe(pfd) == -1)
- error(1, "unable to create pipe");
+ error(1, _("unable to create pipe"));
if ((pid = fork()) == -1)
- error(1, "unable to fork");
+ error(1, _("unable to fork"));
if (pid == 0) {
/* child, point stdout to output side of the pipe and exec askpass */
}
(void) setuid(ROOT_UID);
if (setgid(user_details.gid)) {
- warning("unable to set gid to %u", (unsigned int)user_details.gid);
+ warning(_("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(_("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(_("unable to run %s"), askpass);
_exit(255);
}
* doesn't take an argument.
*/
if ((sfd = dup(STDIN_FILENO)) == -1)
- error(1, "Can't save stdin");
+ error(1, _("can't save stdin"));
if (dup2(ttyfd, STDIN_FILENO) == -1)
- error(1, "Can't dup2 stdin");
+ error(1, _("can't dup2 stdin"));
slot = ttyslot();
if (dup2(sfd, STDIN_FILENO) == -1)
- error(1, "Can't restore stdin");
+ error(1, _("can't restore stdin"));
close(sfd);
return slot;