From 3ee9cef0da9122d3485ba2a421aea05b23d6344d Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 7 Nov 2011 16:33:49 -0500 Subject: [PATCH] Fold SUDO_DEBUG_PROGERR and SUDO_DEBUG_SYSERR into SUDO_DEBUG_ERROR --- common/sudo_debug.c | 3 +-- include/error.h | 16 ++++++++-------- include/sudo_debug.h | 15 +++++++-------- plugins/sudoers/logging.c | 10 +++++----- src/exec.c | 4 ++-- src/exec_pty.c | 6 +++--- 6 files changed, 26 insertions(+), 28 deletions(-) diff --git a/common/sudo_debug.c b/common/sudo_debug.c index a03546191..5d7537b19 100644 --- a/common/sudo_debug.c +++ b/common/sudo_debug.c @@ -57,8 +57,7 @@ /* Note: this must match the order in sudo_debug.h */ const char *const sudo_debug_priorities[] = { "crit", - "syserr", - "progerr", + "err", "warn", "notice", "diag", diff --git a/include/error.h b/include/error.h index b6768e6bf..fdc1e08bf 100644 --- a/include/error.h +++ b/include/error.h @@ -38,36 +38,36 @@ #else /* SUDO_ERROR_WRAP */ # if defined(__GNUC__) && __GNUC__ == 2 # define error(rval, fmt...) do { \ - sudo_debug_printf2(SUDO_DEBUG_SYSERR|sudo_debug_subsys, (fmt)); \ + sudo_debug_printf2(SUDO_DEBUG_ERROR|sudo_debug_subsys, (fmt)); \ error2((rval), (fmt)); \ } while (0) # define errorx(rval, fmt...) do { \ - sudo_debug_printf2(SUDO_DEBUG_PROGERR|sudo_debug_subsys, (fmt)); \ + sudo_debug_printf2(SUDO_DEBUG_ERROR|sudo_debug_subsys, (fmt)); \ errorx2((rval), (fmt)); \ } while (0) # define warning(fmt...) do { \ - sudo_debug_printf2(SUDO_DEBUG_SYSERR|sudo_debug_subsys, (fmt)); \ + sudo_debug_printf2(SUDO_DEBUG_ERROR|sudo_debug_subsys, (fmt)); \ warning2((fmt)); \ } while (0) # define warningx(fmt...) do { \ - sudo_debug_printf2(SUDO_DEBUG_PROGERR|sudo_debug_subsys, (fmt)); \ + sudo_debug_printf2(SUDO_DEBUG_ERROR|sudo_debug_subsys, (fmt)); \ warningx2((fmt)); \ } while (0) # else # define error(rval, ...) do { \ - sudo_debug_printf2(SUDO_DEBUG_SYSERR|sudo_debug_subsys, __VA_ARGS__); \ + sudo_debug_printf2(SUDO_DEBUG_ERROR|sudo_debug_subsys, __VA_ARGS__); \ error2((rval), __VA_ARGS__); \ } while (0) # define errorx(rval, ...) do { \ - sudo_debug_printf2(SUDO_DEBUG_PROGERR|sudo_debug_subsys, __VA_ARGS__); \ + sudo_debug_printf2(SUDO_DEBUG_ERROR|sudo_debug_subsys, __VA_ARGS__); \ errorx2((rval), __VA_ARGS__); \ } while (0) # define warning(...) do { \ - sudo_debug_printf2(SUDO_DEBUG_SYSERR|sudo_debug_subsys, __VA_ARGS__); \ + sudo_debug_printf2(SUDO_DEBUG_ERROR|sudo_debug_subsys, __VA_ARGS__); \ warning2(__VA_ARGS__); \ } while (0) # define warningx(...) do { \ - sudo_debug_printf2(SUDO_DEBUG_PROGERR|sudo_debug_subsys, __VA_ARGS__); \ + sudo_debug_printf2(SUDO_DEBUG_ERROR|sudo_debug_subsys, __VA_ARGS__); \ warningx2(__VA_ARGS__); \ } while (0) # endif /* __GNUC__ == 2 */ diff --git a/include/sudo_debug.h b/include/sudo_debug.h index 96733c272..f63138f6a 100644 --- a/include/sudo_debug.h +++ b/include/sudo_debug.h @@ -31,14 +31,13 @@ * Note: order must match sudo_debug_priorities[] */ #define SUDO_DEBUG_CRIT 1 /* critical errors */ -#define SUDO_DEBUG_SYSERR 2 /* system errors */ -#define SUDO_DEBUG_PROGERR 3 /* program errors */ -#define SUDO_DEBUG_WARN 4 /* non-fatal warnings */ -#define SUDO_DEBUG_NOTICE 5 /* non-error condition notices */ -#define SUDO_DEBUG_DIAG 6 /* diagnostic messages */ -#define SUDO_DEBUG_INFO 7 /* informational message */ -#define SUDO_DEBUG_TRACE 8 /* log function enter/exit */ -#define SUDO_DEBUG_DEBUG 9 /* very verbose debugging */ +#define SUDO_DEBUG_ERROR 2 /* non-critical errors */ +#define SUDO_DEBUG_WARN 3 /* non-fatal warnings */ +#define SUDO_DEBUG_NOTICE 4 /* non-error condition notices */ +#define SUDO_DEBUG_DIAG 5 /* diagnostic messages */ +#define SUDO_DEBUG_INFO 6 /* informational message */ +#define SUDO_DEBUG_TRACE 7 /* log function enter/exit */ +#define SUDO_DEBUG_DEBUG 8 /* very verbose debugging */ /* * Sudo debug subsystems. diff --git a/plugins/sudoers/logging.c b/plugins/sudoers/logging.c index 1e866fc96..395f83b41 100644 --- a/plugins/sudoers/logging.c +++ b/plugins/sudoers/logging.c @@ -425,7 +425,7 @@ send_mail(const char *fmt, ...) case -1: /* Error. */ mysyslog(LOG_ERR, _("unable to fork: %m")); - sudo_debug_printf(SUDO_DEBUG_SYSERR, "unable to fork: %s", + sudo_debug_printf(SUDO_DEBUG_ERROR, "unable to fork: %s", strerror(errno)); _exit(1); case 0: @@ -477,7 +477,7 @@ send_mail(const char *fmt, ...) if (pipe(pfd) == -1) { mysyslog(LOG_ERR, _("unable to open pipe: %m")); - sudo_debug_printf(SUDO_DEBUG_SYSERR, "unable to open pipe: %s", + sudo_debug_printf(SUDO_DEBUG_ERROR, "unable to open pipe: %s", strerror(errno)); sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys); _exit(1); @@ -487,7 +487,7 @@ send_mail(const char *fmt, ...) case -1: /* Error. */ mysyslog(LOG_ERR, _("unable to fork: %m")); - sudo_debug_printf(SUDO_DEBUG_SYSERR, "unable to fork: %s", + sudo_debug_printf(SUDO_DEBUG_ERROR, "unable to fork: %s", strerror(errno)); sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys); _exit(1); @@ -502,7 +502,7 @@ send_mail(const char *fmt, ...) if (pfd[0] != STDIN_FILENO) { if (dup2(pfd[0], STDIN_FILENO) == -1) { mysyslog(LOG_ERR, _("unable to dup stdin: %m")); - sudo_debug_printf(SUDO_DEBUG_SYSERR, + sudo_debug_printf(SUDO_DEBUG_ERROR, "unable to dup stdin: %s", strerror(errno)); _exit(127); } @@ -538,7 +538,7 @@ send_mail(const char *fmt, ...) execv(mpath, argv); #endif /* NO_ROOT_MAILER */ mysyslog(LOG_ERR, _("unable to execute %s: %m"), mpath); - sudo_debug_printf(SUDO_DEBUG_SYSERR, "unable to execute %s: %s", + sudo_debug_printf(SUDO_DEBUG_ERROR, "unable to execute %s: %s", mpath, strerror(errno)); _exit(127); } diff --git a/src/exec.c b/src/exec.c index 2d6d8605f..1742887e3 100644 --- a/src/exec.c +++ b/src/exec.c @@ -144,7 +144,7 @@ static int fork_cmnd(struct command_details *details, int sv[2]) else #endif my_execve(details->command, details->argv, details->envp); - sudo_debug_printf(SUDO_DEBUG_SYSERR, "unable to exec %s: %s", + sudo_debug_printf(SUDO_DEBUG_ERROR, "unable to exec %s: %s", details->command, strerror(errno)); } cstat.type = CMD_ERRNO; @@ -442,7 +442,7 @@ handle_signals(int fd, pid_t child, int log_io, struct command_status *cstat) /* If pipe is empty, we are done. */ if (errno == EAGAIN) break; - sudo_debug_printf(SUDO_DEBUG_SYSERR, "error reading signal pipe %s", + sudo_debug_printf(SUDO_DEBUG_ERROR, "error reading signal pipe %s", strerror(errno)); cstat->type = CMD_ERRNO; cstat->val = errno; diff --git a/src/exec_pty.c b/src/exec_pty.c index 02fc30ca6..9af4a05fe 100644 --- a/src/exec_pty.c +++ b/src/exec_pty.c @@ -439,7 +439,7 @@ perform_io(fd_set *fdsr, fd_set *fdsw, struct command_status *cstat) if (errno == EAGAIN) break; if (errno != ENXIO && errno != EBADF) { - sudo_debug_printf(SUDO_DEBUG_SYSERR, + sudo_debug_printf(SUDO_DEBUG_ERROR, "error reading fd %d: %s", iob->rfd, strerror(errno)); errors++; @@ -476,7 +476,7 @@ perform_io(fd_set *fdsr, fd_set *fdsw, struct command_status *cstat) } if (errno != EAGAIN) { errors++; - sudo_debug_printf(SUDO_DEBUG_SYSERR, + sudo_debug_printf(SUDO_DEBUG_ERROR, "error writing fd %d: %s", iob->wfd, strerror(errno)); } } else { @@ -788,7 +788,7 @@ send_status(int fd, struct command_status *cstat) n = send(fd, cstat, sizeof(*cstat), 0); } while (n == -1 && errno == EINTR); if (n != sizeof(*cstat)) { - sudo_debug_printf(SUDO_DEBUG_SYSERR, + sudo_debug_printf(SUDO_DEBUG_ERROR, "unable to send status to parent: %s", strerror(errno)); } cstat->type = CMD_INVALID; /* prevent re-sending */