Minor warning/error message cleanup

This commit is contained in:
Todd C. Miller
2011-05-18 13:04:24 -04:00
parent fce0b906eb
commit 7960bde2db
8 changed files with 36 additions and 31 deletions

View File

@@ -222,17 +222,21 @@ update_timestamp(char *timestampdir, char *timestampfile)
*/ */
int fd = open(timestampfile, O_WRONLY|O_CREAT, 0600); int fd = open(timestampfile, O_WRONLY|O_CREAT, 0600);
if (fd == -1) if (fd == -1)
log_error(NO_EXIT|USE_ERRNO, _("Can't open %s"), timestampfile); log_error(NO_EXIT|USE_ERRNO, _("unable to open %s"), timestampfile);
else { else {
lock_file(fd, SUDO_LOCK); lock_file(fd, SUDO_LOCK);
if (write(fd, &tty_info, sizeof(tty_info)) != sizeof(tty_info)) if (write(fd, &tty_info, sizeof(tty_info)) != sizeof(tty_info)) {
log_error(NO_EXIT|USE_ERRNO, _("Can't write %s"), timestampfile); log_error(NO_EXIT|USE_ERRNO, _("unable to write to %s"),
timestampfile);
}
close(fd); close(fd);
} }
} else { } else {
if (touch(-1, timestampdir, NULL) == -1) { if (touch(-1, timestampdir, NULL) == -1) {
if (mkdir(timestampdir, 0700) == -1) if (mkdir(timestampdir, 0700) == -1) {
log_error(NO_EXIT|USE_ERRNO, _("Can't mkdir %s"), timestampdir); log_error(NO_EXIT|USE_ERRNO, _("unable to mkdir %s"),
timestampdir);
}
} }
} }
if (timestamp_uid != 0) if (timestamp_uid != 0)

View File

@@ -119,7 +119,7 @@ mkdir_parents(char *path)
*slash = '\0'; *slash = '\0';
if (stat(path, &sb) != 0) { if (stat(path, &sb) != 0) {
if (mkdir(path, S_IRWXU) != 0) if (mkdir(path, S_IRWXU) != 0)
log_error(USE_ERRNO, _("Can't mkdir %s"), path); log_error(USE_ERRNO, _("unable to mkdir %s"), path);
} else if (!S_ISDIR(sb.st_mode)) { } else if (!S_ISDIR(sb.st_mode)) {
log_error(0, _("%s: %s"), path, strerror(ENOTDIR)); log_error(0, _("%s: %s"), path, strerror(ENOTDIR));
} }
@@ -150,7 +150,7 @@ io_nextid(char *iolog_dir, char sessid[7])
mkdir_parents(iolog_dir); mkdir_parents(iolog_dir);
if (stat(iolog_dir, &sb) != 0) { if (stat(iolog_dir, &sb) != 0) {
if (mkdir(iolog_dir, S_IRWXU) != 0) if (mkdir(iolog_dir, S_IRWXU) != 0)
log_error(USE_ERRNO, _("Can't mkdir %s"), iolog_dir); log_error(USE_ERRNO, _("unable to mkdir %s"), iolog_dir);
} else if (!S_ISDIR(sb.st_mode)) { } else if (!S_ISDIR(sb.st_mode)) {
log_error(0, _("%s exists but is not a directory (0%o)"), log_error(0, _("%s exists but is not a directory (0%o)"),
iolog_dir, (unsigned int) sb.st_mode); iolog_dir, (unsigned int) sb.st_mode);
@@ -196,7 +196,7 @@ io_nextid(char *iolog_dir, char sessid[7])
/* Rewind and overwrite old seq file. */ /* Rewind and overwrite old seq file. */
if (lseek(fd, 0, SEEK_SET) == (off_t)-1 || write(fd, buf, 7) != 7) if (lseek(fd, 0, SEEK_SET) == (off_t)-1 || write(fd, buf, 7) != 7)
log_error(USE_ERRNO, _("Can't write to %s"), pathbuf); log_error(USE_ERRNO, _("unable to write to %s"), pathbuf);
close(fd); close(fd);
} }
@@ -222,10 +222,10 @@ mkdir_iopath(const char *iolog_path, char *pathbuf, size_t pathsize)
mkdir_parents(pathbuf); mkdir_parents(pathbuf);
if (len >= 6 && strcmp(&pathbuf[len - 6], "XXXXXX") == 0) { if (len >= 6 && strcmp(&pathbuf[len - 6], "XXXXXX") == 0) {
if (mkdtemp(pathbuf) == NULL) if (mkdtemp(pathbuf) == NULL)
log_error(USE_ERRNO, _("Can't create %s"), pathbuf); log_error(USE_ERRNO, _("unable to create %s"), pathbuf);
} else { } else {
if (mkdir(pathbuf, S_IRWXU) != 0) if (mkdir(pathbuf, S_IRWXU) != 0)
log_error(USE_ERRNO, _("Can't create %s"), pathbuf); log_error(USE_ERRNO, _("unable to create %s"), pathbuf);
} }
return len; return len;
@@ -477,18 +477,18 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
*/ */
io_logfile = open_io_fd(pathbuf, len, "/log", FALSE); io_logfile = open_io_fd(pathbuf, len, "/log", FALSE);
if (io_logfile == NULL) if (io_logfile == NULL)
log_error(USE_ERRNO, _("Can't create %s"), pathbuf); log_error(USE_ERRNO, _("unable to create %s"), pathbuf);
io_fds[IOFD_TIMING].v = open_io_fd(pathbuf, len, "/timing", io_fds[IOFD_TIMING].v = open_io_fd(pathbuf, len, "/timing",
iolog_compress); iolog_compress);
if (io_fds[IOFD_TIMING].v == NULL) if (io_fds[IOFD_TIMING].v == NULL)
log_error(USE_ERRNO, _("Can't create %s"), pathbuf); log_error(USE_ERRNO, _("unable to create %s"), pathbuf);
if (details.iolog_ttyin) { if (details.iolog_ttyin) {
io_fds[IOFD_TTYIN].v = open_io_fd(pathbuf, len, "/ttyin", io_fds[IOFD_TTYIN].v = open_io_fd(pathbuf, len, "/ttyin",
iolog_compress); iolog_compress);
if (io_fds[IOFD_TTYIN].v == NULL) if (io_fds[IOFD_TTYIN].v == NULL)
log_error(USE_ERRNO, _("Can't create %s"), pathbuf); log_error(USE_ERRNO, _("unable to create %s"), pathbuf);
} else { } else {
sudoers_io.log_ttyin = NULL; sudoers_io.log_ttyin = NULL;
} }
@@ -496,7 +496,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
io_fds[IOFD_STDIN].v = open_io_fd(pathbuf, len, "/stdin", io_fds[IOFD_STDIN].v = open_io_fd(pathbuf, len, "/stdin",
iolog_compress); iolog_compress);
if (io_fds[IOFD_STDIN].v == NULL) if (io_fds[IOFD_STDIN].v == NULL)
log_error(USE_ERRNO, _("Can't create %s"), pathbuf); log_error(USE_ERRNO, _("unable to create %s"), pathbuf);
} else { } else {
sudoers_io.log_stdin = NULL; sudoers_io.log_stdin = NULL;
} }
@@ -504,7 +504,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
io_fds[IOFD_TTYOUT].v = open_io_fd(pathbuf, len, "/ttyout", io_fds[IOFD_TTYOUT].v = open_io_fd(pathbuf, len, "/ttyout",
iolog_compress); iolog_compress);
if (io_fds[IOFD_TTYOUT].v == NULL) if (io_fds[IOFD_TTYOUT].v == NULL)
log_error(USE_ERRNO, _("Can't create %s"), pathbuf); log_error(USE_ERRNO, _("unable to create %s"), pathbuf);
} else { } else {
sudoers_io.log_ttyout = NULL; sudoers_io.log_ttyout = NULL;
} }
@@ -512,7 +512,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
io_fds[IOFD_STDOUT].v = open_io_fd(pathbuf, len, "/stdout", io_fds[IOFD_STDOUT].v = open_io_fd(pathbuf, len, "/stdout",
iolog_compress); iolog_compress);
if (io_fds[IOFD_STDOUT].v == NULL) if (io_fds[IOFD_STDOUT].v == NULL)
log_error(USE_ERRNO, _("Can't create %s"), pathbuf); log_error(USE_ERRNO, _("unable to create %s"), pathbuf);
} else { } else {
sudoers_io.log_stdout = NULL; sudoers_io.log_stdout = NULL;
} }
@@ -520,7 +520,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
io_fds[IOFD_STDERR].v = open_io_fd(pathbuf, len, "/stderr", io_fds[IOFD_STDERR].v = open_io_fd(pathbuf, len, "/stderr",
iolog_compress); iolog_compress);
if (io_fds[IOFD_STDERR].v == NULL) if (io_fds[IOFD_STDERR].v == NULL)
log_error(USE_ERRNO, _("Can't create %s"), pathbuf); log_error(USE_ERRNO, _("unable to create %s"), pathbuf);
} else { } else {
sudoers_io.log_stderr = NULL; sudoers_io.log_stderr = NULL;
} }

View File

@@ -190,10 +190,10 @@ do_logfile(char *msg)
fp = fopen(def_logfile, "a"); fp = fopen(def_logfile, "a");
(void) umask(oldmask); (void) umask(oldmask);
if (fp == NULL) { if (fp == NULL) {
send_mail(_("Can't open log file: %s: %s"), send_mail(_("unable to open log file: %s: %s"),
def_logfile, strerror(errno)); def_logfile, strerror(errno));
} else if (!lock_file(fileno(fp), SUDO_LOCK)) { } else if (!lock_file(fileno(fp), SUDO_LOCK)) {
send_mail(_("Can't lock log file: %s: %s"), send_mail(_("unable to lock log file: %s: %s"),
def_logfile, strerror(errno)); def_logfile, strerror(errno));
} else { } else {
time_t now; time_t now;

View File

@@ -122,7 +122,7 @@ static int fork_cmnd(struct command_details *details, int sv[2])
child = fork(); child = fork();
switch (child) { switch (child) {
case -1: case -1:
error(1, "fork"); error(1, _("unable to fork"));
break; break;
case 0: case 0:
/* child */ /* child */

View File

@@ -559,14 +559,14 @@ fork_pty(struct command_details *details, int sv[], int *maxfd)
n = term_raw(io_fds[SFD_USERTTY], 0); n = term_raw(io_fds[SFD_USERTTY], 0);
} while (!n && errno == EINTR); } while (!n && errno == EINTR);
if (!n) if (!n)
error(1, _("Can't set terminal to raw mode")); error(1, _("unable to set terminal to raw mode"));
} }
} }
child = fork(); child = fork();
switch (child) { switch (child) {
case -1: case -1:
error(1, "fork"); error(1, _("unable to fork"));
break; break;
case 0: case 0:
/* child */ /* child */
@@ -873,7 +873,7 @@ exec_monitor(struct command_details *details, int backchannel)
error(1, _("unable to create pipe")); error(1, _("unable to create pipe"));
child = fork(); child = fork();
if (child == -1) { if (child == -1) {
warning("fork"); warning(_("unable to fork"));
goto bad; goto bad;
} }
if (child == 0) { if (child == 0) {

View File

@@ -183,8 +183,8 @@ sudo_load_plugins(const char *conf_file,
} }
plugin = dlsym(handle, info->symbol_name); plugin = dlsym(handle, info->symbol_name);
if (!plugin) { if (!plugin) {
warningx(_("unable to find symbol %s in %s"), info->symbol_name, warningx(_("%s: unable to find symbol %s"), path,
path); info->symbol_name);
goto done; goto done;
} }
@@ -200,7 +200,8 @@ sudo_load_plugins(const char *conf_file,
} }
if (plugin->type == SUDO_POLICY_PLUGIN) { if (plugin->type == SUDO_POLICY_PLUGIN) {
if (policy_plugin->handle) { if (policy_plugin->handle) {
warningx(_("only a single policy plugin may be loaded")); warningx(_("%s: only a single policy plugin may be loaded"),
conf_file);
goto done; goto done;
} }
policy_plugin->handle = handle; policy_plugin->handle = handle;

View File

@@ -212,7 +212,7 @@ main(int argc, char *argv[], char *envp[])
if (ISSET(sudo_mode, MODE_VERSION)) { 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) if (user_details.uid == ROOT_UID)
(void) printf(_("Configure args: %s\n"), CONFIGURE_ARGS); (void) printf(_("Configure options: %s\n"), CONFIGURE_ARGS);
} }
/* Read sudo.conf and load plugins. */ /* Read sudo.conf and load plugins. */
@@ -916,7 +916,7 @@ exec_setup(struct command_details *details, const char *ptyname, int ptyfd)
*/ */
#ifdef HAVE_SETEUID #ifdef HAVE_SETEUID
if (ISSET(details->flags, CD_SET_EGID) && setegid(details->egid)) { 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 effective gid to runas gid %u"), details->egid);
goto done; goto done;
} }
#endif #endif
@@ -1129,7 +1129,7 @@ static int
policy_validate(struct plugin_container *plugin) policy_validate(struct plugin_container *plugin)
{ {
if (plugin->u.policy->validate == NULL) { 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 option"),
plugin->name); plugin->name);
return FALSE; return FALSE;
} }
@@ -1140,7 +1140,7 @@ static void
policy_invalidate(struct plugin_container *plugin, int remove) policy_invalidate(struct plugin_container *plugin, int remove)
{ {
if (plugin->u.policy->invalidate == NULL) { 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 options"),
plugin->name); plugin->name);
} }
plugin->u.policy->invalidate(remove); plugin->u.policy->invalidate(remove);

View File

@@ -105,7 +105,7 @@ sudo_edit(struct command_details *command_details)
* We will change the euid as needed below. * We will change the euid as needed below.
*/ */
if (setuid(ROOT_UID) != 0) { if (setuid(ROOT_UID) != 0) {
warning(_("unable to change to uid to root (%u)"), ROOT_UID); warning(_("unable to change uid to root (%u)"), ROOT_UID);
return 1; return 1;
} }