{
struct stat sb;
char *slash = path;
+ debug_decl(mkdir_parents, SUDO_DEBUG_UTIL)
for (;;) {
if ((slash = strchr(slash + 1, '/')) == NULL)
}
*slash = '/';
}
+ debug_return;
}
/*
ssize_t nread;
char pathbuf[PATH_MAX];
static const char b36char[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ debug_decl(io_nextid, SUDO_DEBUG_UTIL)
/*
* Create I/O log directory if it doesn't already exist.
if (lseek(fd, 0, SEEK_SET) == (off_t)-1 || write(fd, buf, 7) != 7)
log_error(USE_ERRNO, _("unable to write to %s"), pathbuf);
close(fd);
+
+ debug_return;
}
/*
mkdir_iopath(const char *iolog_path, char *pathbuf, size_t pathsize)
{
size_t len;
+ debug_decl(mkdir_iopath, SUDO_DEBUG_UTIL)
len = strlcpy(pathbuf, iolog_path, pathsize);
if (len >= pathsize) {
log_error(USE_ERRNO, _("unable to create %s"), pathbuf);
}
- return len;
+ debug_return_size_t(len);
}
/*
* Append suffix to pathbuf after len chars and open the resulting file.
* Note that the size of pathbuf is assumed to be PATH_MAX.
- * Uses zlib if docompress is TRUE.
+ * Uses zlib if docompress is true.
* Returns the open file handle which has the close-on-exec flag set.
*/
static void *
-open_io_fd(char *pathbuf, size_t len, const char *suffix, int docompress)
+open_io_fd(char *pathbuf, size_t len, const char *suffix, bool docompress)
{
void *vfd = NULL;
int fd;
+ debug_decl(open_io_fd, SUDO_DEBUG_UTIL)
pathbuf[len] = '\0';
strlcat(pathbuf, suffix, PATH_MAX);
#endif
vfd = fdopen(fd, "w");
}
- return vfd;
+ debug_return_ptr(vfd);
}
/*
unsigned long ulval;
uid_t runas_uid = 0;
gid_t runas_gid = 0;
+ debug_decl(iolog_deserialize_info, SUDO_DEBUG_UTIL)
memset(details, 0, sizeof(*details));
continue;
}
if (strncmp(*cur, "iolog_stdin=", sizeof("iolog_stdin=") - 1) == 0) {
- if (atobool(*cur + sizeof("iolog_stdin=") - 1) == TRUE)
- details->iolog_stdin = TRUE;
+ if (atobool(*cur + sizeof("iolog_stdin=") - 1) == true)
+ details->iolog_stdin = true;
continue;
}
if (strncmp(*cur, "iolog_stdout=", sizeof("iolog_stdout=") - 1) == 0) {
- if (atobool(*cur + sizeof("iolog_stdout=") - 1) == TRUE)
- details->iolog_stdout = TRUE;
+ if (atobool(*cur + sizeof("iolog_stdout=") - 1) == true)
+ details->iolog_stdout = true;
continue;
}
if (strncmp(*cur, "iolog_stderr=", sizeof("iolog_stderr=") - 1) == 0) {
- if (atobool(*cur + sizeof("iolog_stderr=") - 1) == TRUE)
- details->iolog_stderr = TRUE;
+ if (atobool(*cur + sizeof("iolog_stderr=") - 1) == true)
+ details->iolog_stderr = true;
continue;
}
if (strncmp(*cur, "iolog_ttyin=", sizeof("iolog_ttyin=") - 1) == 0) {
- if (atobool(*cur + sizeof("iolog_ttyin=") - 1) == TRUE)
- details->iolog_ttyin = TRUE;
+ if (atobool(*cur + sizeof("iolog_ttyin=") - 1) == true)
+ details->iolog_ttyin = true;
continue;
}
if (strncmp(*cur, "iolog_ttyout=", sizeof("iolog_ttyout=") - 1) == 0) {
- if (atobool(*cur + sizeof("iolog_ttyout=") - 1) == TRUE)
- details->iolog_ttyout = TRUE;
+ if (atobool(*cur + sizeof("iolog_ttyout=") - 1) == true)
+ details->iolog_ttyout = true;
continue;
}
if (strncmp(*cur, "iolog_compress=", sizeof("iolog_compress=") - 1) == 0) {
- if (atobool(*cur + sizeof("iolog_compress=") - 1) == TRUE)
- iolog_compress = TRUE; /* must be global */
+ if (atobool(*cur + sizeof("iolog_compress=") - 1) == true)
+ iolog_compress = true; /* must be global */
continue;
}
break;
details->runas_gr = sudo_fakegrnam(id);
}
}
+ debug_return;
}
static int
char pathbuf[PATH_MAX], sessid[7];
char *tofree = NULL;
char * const *cur;
+ const char *debug_flags = NULL;
FILE *io_logfile;
size_t len;
int rval = -1;
+ debug_decl(sudoers_io_open, SUDO_DEBUG_PLUGIN)
if (!sudo_conv)
sudo_conv = conversation;
/* If we have no command (because -V was specified) just return. */
if (argc == 0)
- return TRUE;
+ debug_return_bool(true);
if (sigsetjmp(error_jmp, 1)) {
/* called via error(), errorx() or log_error() */
sudo_setpwent();
sudo_setgrent();
+ /*
+ * Check for debug flags in settings list.
+ */
+ for (cur = settings; *cur != NULL; cur++) {
+ if (strncmp(*cur, "debug_flags=", sizeof("debug_flags=") - 1) == 0)
+ debug_flags = *cur + sizeof("debug_flags=") - 1;
+ }
+ if (debug_flags != NULL)
+ sudo_debug_init(NULL, debug_flags);
+
/*
* Pull iolog settings out of command_info, if any.
*/
if (!details.iolog_stdin && !details.iolog_ttyin &&
!details.iolog_stdout && !details.iolog_stderr &&
!details.iolog_ttyout) {
- rval = FALSE;
+ rval = false;
goto done;
}
/*
* We create 7 files: a log file, a timing file and 5 for input/output.
*/
- io_logfile = open_io_fd(pathbuf, len, "/log", FALSE);
+ io_logfile = open_io_fd(pathbuf, len, "/log", false);
if (io_logfile == NULL)
log_error(USE_ERRNO, _("unable to create %s"), pathbuf);
fputc('\n', io_logfile);
fclose(io_logfile);
- rval = TRUE;
+ rval = true;
done:
efree(tofree);
gr_delref(details.runas_gr);
sudo_endgrent();
- return rval;
+ debug_return_bool(rval);
}
static void
sudoers_io_close(int exit_status, int error)
{
int i;
+ debug_decl(sudoers_io_close, SUDO_DEBUG_PLUGIN)
if (sigsetjmp(error_jmp, 1)) {
/* called via error(), errorx() or log_error() */
- return;
+ debug_return;
}
for (i = 0; i < IOFD_MAX; i++) {
#endif
fclose(io_fds[i].f);
}
+ debug_return;
}
static int
sudoers_io_version(int verbose)
{
+ debug_decl(sudoers_io_version, SUDO_DEBUG_PLUGIN)
+
if (sigsetjmp(error_jmp, 1)) {
/* called via error(), errorx() or log_error() */
- return -1;
+ debug_return_bool(-1);
}
sudo_printf(SUDO_CONV_INFO_MSG, "Sudoers I/O plugin version %s\n",
PACKAGE_VERSION);
- return TRUE;
+ debug_return_bool(true);
}
/*
sudoers_io_log(const char *buf, unsigned int len, int idx)
{
struct timeval now, delay;
+ debug_decl(sudoers_io_version, SUDO_DEBUG_PLUGIN)
gettimeofday(&now, NULL);
if (sigsetjmp(error_jmp, 1)) {
/* called via error(), errorx() or log_error() */
- return -1;
+ debug_return_bool(-1);
}
#ifdef HAVE_ZLIB_H
last_time.tv_sec = now.tv_sec;
last_time.tv_usec = now.tv_usec;
- return TRUE;
+ debug_return_bool(true);
}
static int