Fold SUDO_DEBUG_PROGERR and SUDO_DEBUG_SYSERR into SUDO_DEBUG_ERROR

This commit is contained in:
Todd C. Miller
2011-11-07 16:33:49 -05:00
parent d0eb3ae6a0
commit 3ee9cef0da
6 changed files with 26 additions and 28 deletions

View File

@@ -57,8 +57,7 @@
/* Note: this must match the order in sudo_debug.h */ /* Note: this must match the order in sudo_debug.h */
const char *const sudo_debug_priorities[] = { const char *const sudo_debug_priorities[] = {
"crit", "crit",
"syserr", "err",
"progerr",
"warn", "warn",
"notice", "notice",
"diag", "diag",

View File

@@ -38,36 +38,36 @@
#else /* SUDO_ERROR_WRAP */ #else /* SUDO_ERROR_WRAP */
# if defined(__GNUC__) && __GNUC__ == 2 # if defined(__GNUC__) && __GNUC__ == 2
# define error(rval, fmt...) do { \ # 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)); \ error2((rval), (fmt)); \
} while (0) } while (0)
# define errorx(rval, fmt...) do { \ # 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)); \ errorx2((rval), (fmt)); \
} while (0) } while (0)
# define warning(fmt...) do { \ # 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)); \ warning2((fmt)); \
} while (0) } while (0)
# define warningx(fmt...) do { \ # 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)); \ warningx2((fmt)); \
} while (0) } while (0)
# else # else
# define error(rval, ...) do { \ # 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__); \ error2((rval), __VA_ARGS__); \
} while (0) } while (0)
# define errorx(rval, ...) do { \ # 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__); \ errorx2((rval), __VA_ARGS__); \
} while (0) } while (0)
# define warning(...) do { \ # 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__); \ warning2(__VA_ARGS__); \
} while (0) } while (0)
# define warningx(...) do { \ # 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__); \ warningx2(__VA_ARGS__); \
} while (0) } while (0)
# endif /* __GNUC__ == 2 */ # endif /* __GNUC__ == 2 */

View File

@@ -31,14 +31,13 @@
* Note: order must match sudo_debug_priorities[] * Note: order must match sudo_debug_priorities[]
*/ */
#define SUDO_DEBUG_CRIT 1 /* critical errors */ #define SUDO_DEBUG_CRIT 1 /* critical errors */
#define SUDO_DEBUG_SYSERR 2 /* system errors */ #define SUDO_DEBUG_ERROR 2 /* non-critical errors */
#define SUDO_DEBUG_PROGERR 3 /* program errors */ #define SUDO_DEBUG_WARN 3 /* non-fatal warnings */
#define SUDO_DEBUG_WARN 4 /* non-fatal warnings */ #define SUDO_DEBUG_NOTICE 4 /* non-error condition notices */
#define SUDO_DEBUG_NOTICE 5 /* non-error condition notices */ #define SUDO_DEBUG_DIAG 5 /* diagnostic messages */
#define SUDO_DEBUG_DIAG 6 /* diagnostic messages */ #define SUDO_DEBUG_INFO 6 /* informational message */
#define SUDO_DEBUG_INFO 7 /* informational message */ #define SUDO_DEBUG_TRACE 7 /* log function enter/exit */
#define SUDO_DEBUG_TRACE 8 /* log function enter/exit */ #define SUDO_DEBUG_DEBUG 8 /* very verbose debugging */
#define SUDO_DEBUG_DEBUG 9 /* very verbose debugging */
/* /*
* Sudo debug subsystems. * Sudo debug subsystems.

View File

@@ -425,7 +425,7 @@ send_mail(const char *fmt, ...)
case -1: case -1:
/* Error. */ /* Error. */
mysyslog(LOG_ERR, _("unable to fork: %m")); 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)); strerror(errno));
_exit(1); _exit(1);
case 0: case 0:
@@ -477,7 +477,7 @@ send_mail(const char *fmt, ...)
if (pipe(pfd) == -1) { if (pipe(pfd) == -1) {
mysyslog(LOG_ERR, _("unable to open pipe: %m")); 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)); strerror(errno));
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys); sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);
_exit(1); _exit(1);
@@ -487,7 +487,7 @@ send_mail(const char *fmt, ...)
case -1: case -1:
/* Error. */ /* Error. */
mysyslog(LOG_ERR, _("unable to fork: %m")); 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)); strerror(errno));
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys); sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);
_exit(1); _exit(1);
@@ -502,7 +502,7 @@ send_mail(const char *fmt, ...)
if (pfd[0] != STDIN_FILENO) { if (pfd[0] != STDIN_FILENO) {
if (dup2(pfd[0], STDIN_FILENO) == -1) { if (dup2(pfd[0], STDIN_FILENO) == -1) {
mysyslog(LOG_ERR, _("unable to dup stdin: %m")); 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)); "unable to dup stdin: %s", strerror(errno));
_exit(127); _exit(127);
} }
@@ -538,7 +538,7 @@ send_mail(const char *fmt, ...)
execv(mpath, argv); execv(mpath, argv);
#endif /* NO_ROOT_MAILER */ #endif /* NO_ROOT_MAILER */
mysyslog(LOG_ERR, _("unable to execute %s: %m"), mpath); 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)); mpath, strerror(errno));
_exit(127); _exit(127);
} }

View File

@@ -144,7 +144,7 @@ static int fork_cmnd(struct command_details *details, int sv[2])
else else
#endif #endif
my_execve(details->command, details->argv, details->envp); 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)); details->command, strerror(errno));
} }
cstat.type = CMD_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 pipe is empty, we are done. */
if (errno == EAGAIN) if (errno == EAGAIN)
break; 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)); strerror(errno));
cstat->type = CMD_ERRNO; cstat->type = CMD_ERRNO;
cstat->val = errno; cstat->val = errno;

View File

@@ -439,7 +439,7 @@ perform_io(fd_set *fdsr, fd_set *fdsw, struct command_status *cstat)
if (errno == EAGAIN) if (errno == EAGAIN)
break; break;
if (errno != ENXIO && errno != EBADF) { if (errno != ENXIO && errno != EBADF) {
sudo_debug_printf(SUDO_DEBUG_SYSERR, sudo_debug_printf(SUDO_DEBUG_ERROR,
"error reading fd %d: %s", iob->rfd, "error reading fd %d: %s", iob->rfd,
strerror(errno)); strerror(errno));
errors++; errors++;
@@ -476,7 +476,7 @@ perform_io(fd_set *fdsr, fd_set *fdsw, struct command_status *cstat)
} }
if (errno != EAGAIN) { if (errno != EAGAIN) {
errors++; errors++;
sudo_debug_printf(SUDO_DEBUG_SYSERR, sudo_debug_printf(SUDO_DEBUG_ERROR,
"error writing fd %d: %s", iob->wfd, strerror(errno)); "error writing fd %d: %s", iob->wfd, strerror(errno));
} }
} else { } else {
@@ -788,7 +788,7 @@ send_status(int fd, struct command_status *cstat)
n = send(fd, cstat, sizeof(*cstat), 0); n = send(fd, cstat, sizeof(*cstat), 0);
} while (n == -1 && errno == EINTR); } while (n == -1 && errno == EINTR);
if (n != sizeof(*cstat)) { 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)); "unable to send status to parent: %s", strerror(errno));
} }
cstat->type = CMD_INVALID; /* prevent re-sending */ cstat->type = CMD_INVALID; /* prevent re-sending */