*/
struct plugin_container policy_plugin;
struct plugin_container_list io_plugins;
+int debug_level;
/*
* Local functions
user_info, envp);
}
- /* XXX - should not need to check for MODE_INVALIDATE ORed in */
- warningx("sudo_mode %d", sudo_mode); /* XXX */
+ sudo_debug(9, "sudo_mode %d", sudo_mode);
switch (sudo_mode & MODE_MASK) {
case MODE_VERSION:
policy_plugin.u.policy->show_version(!user_details.uid);
case MODE_RUN:
ok = policy_plugin.u.policy->check_policy(nargc, nargv, env_add,
&command_info, &argv_out, &user_env_out);
- warningx("policy plugin returns %d", ok); /* XXX */
+ sudo_debug(8, "policy plugin returns %d", ok);
if (ok != TRUE)
exit(ok); /* plugin printed error message */
command_info_to_details(command_info, &command_details);
/* If there are I/O plugins, allocate a pty and exec */
if (!tq_empty(&io_plugins)) {
- warningx("script mode"); /* XXX */
+ sudo_debug(8, "script mode");
script_setup(details->euid);
script_execve(details, argv, envp, &cstat);
} else {
_exit(1);
}
close(sv[1]);
- warningx("waiting for child"); /* XXX */
+ sudo_debug(9, "waiting for child");
/* wait for child to complete or for data on sv[0] */
fdsr = (fd_set *)emalloc2(howmany(sv[0] + 1, NFDBITS), sizeof(fd_mask));
exit(exitcode);
}
-#if 0 /* XXX - convert warning/error to something log this */
/*
* Simple debugging/logging.
- * XXX - use askpass if configured?
*/
void
-sudo_log(int level, const char *fmt, ...)
+sudo_debug(int level, const char *fmt, ...)
{
va_list ap;
- switch (level) {
- case SUDO_LOG_INFO:
- va_start(ap, fmt);
- vfprintf(stdout, fmt, ap);
- va_end(ap);
- break;
- case SUDO_LOG_DEBUG1:
- case SUDO_LOG_DEBUG2:
- case SUDO_LOG_DEBUG3:
- case SUDO_LOG_DEBUG4:
- case SUDO_LOG_DEBUG5:
- case SUDO_LOG_DEBUG6:
- case SUDO_LOG_DEBUG7:
- case SUDO_LOG_DEBUG8:
- case SUDO_LOG_DEBUG9:
- if (level > debug_level)
- return;
- /* FALLTHROUGH */
- case SUDO_LOG_WARN:
- case SUDO_LOG_ERROR:
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- }
+ if (level > debug_level)
+ return;
+
+ fputs(getprogname(), stderr);
+ fputs(": ", stderr);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ putc('\n', stderr);
}
-#endif
extern int errno;
#endif
-#ifdef ntoyet
/*
* Sudo logging/debugging, printf-style.
- * XXX - not hooked up yet
* The debug level may be set on the command line via the -D flag.
* A higher debug level yields more verbose debugging.
*/
-#define SUDO_LOG_DEBUG1 1
-#define SUDO_LOG_DEBUG2 2
-#define SUDO_LOG_DEBUG3 3
-#define SUDO_LOG_DEBUG4 4
-#define SUDO_LOG_DEBUG5 5
-#define SUDO_LOG_DEBUG6 6
-#define SUDO_LOG_DEBUG7 7
-#define SUDO_LOG_DEBUG8 8
-#define SUDO_LOG_DEBUG9 9
-#define SUDO_LOG_INFO 10
-#define SUDO_LOG_WARN 11
-#define SUDO_LOG_ERROR 12
-void sudo_log(int level, const char *format, ...) __printflike(2, 3);
-#endif
+void sudo_debug(int level, const char *format, ...) __printflike(2, 3);
#endif /* _SUDO_SUDO_H */