Diff for /embedaddon/sudo/plugins/sudoers/iolog.c between versions 1.1.1.1 and 1.1.1.3

version 1.1.1.1, 2012/02/21 16:23:02 version 1.1.1.3, 2012/10/09 09:29:52
Line 112  mkdir_parents(char *path) Line 112  mkdir_parents(char *path)
 {  {
     struct stat sb;      struct stat sb;
     char *slash = path;      char *slash = path;
       debug_decl(mkdir_parents, SUDO_DEBUG_UTIL)
   
     for (;;) {      for (;;) {
         if ((slash = strchr(slash + 1, '/')) == NULL)          if ((slash = strchr(slash + 1, '/')) == NULL)
Line 119  mkdir_parents(char *path) Line 120  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, _("unable to mkdir %s"), path);                log_fatal(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_fatal(0, _("%s: %s"), path, strerror(ENOTDIR));
         }          }
         *slash = '/';          *slash = '/';
     }      }
       debug_return;
 }  }
   
 /*  /*
Line 133  mkdir_parents(char *path) Line 135  mkdir_parents(char *path)
  * Uses file locking to avoid sequence number collisions.   * Uses file locking to avoid sequence number collisions.
  */   */
 void  void
io_nextid(char *iolog_dir, char sessid[7])io_nextid(char *iolog_dir, char *iolog_dir_fallback, char sessid[7])
 {  {
     struct stat sb;      struct stat sb;
     char buf[32], *ep;      char buf[32], *ep;
Line 143  io_nextid(char *iolog_dir, char sessid[7]) Line 145  io_nextid(char *iolog_dir, char sessid[7])
     ssize_t nread;      ssize_t nread;
     char pathbuf[PATH_MAX];      char pathbuf[PATH_MAX];
     static const char b36char[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";      static const char b36char[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
       debug_decl(io_nextid, SUDO_DEBUG_UTIL)
   
     /*      /*
      * Create I/O log directory if it doesn't already exist.       * Create I/O log directory if it doesn't already exist.
Line 150  io_nextid(char *iolog_dir, char sessid[7]) Line 153  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, _("unable to mkdir %s"), iolog_dir);            log_fatal(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_fatal(0, _("%s exists but is not a directory (0%o)"),
             iolog_dir, (unsigned int) sb.st_mode);              iolog_dir, (unsigned int) sb.st_mode);
     }      }
   
Line 162  io_nextid(char *iolog_dir, char sessid[7]) Line 165  io_nextid(char *iolog_dir, char sessid[7])
     len = snprintf(pathbuf, sizeof(pathbuf), "%s/seq", iolog_dir);      len = snprintf(pathbuf, sizeof(pathbuf), "%s/seq", iolog_dir);
     if (len <= 0 || len >= sizeof(pathbuf)) {      if (len <= 0 || len >= sizeof(pathbuf)) {
         errno = ENAMETOOLONG;          errno = ENAMETOOLONG;
        log_error(USE_ERRNO, "%s/seq", pathbuf);        log_fatal(USE_ERRNO, "%s/seq", pathbuf);
     }      }
     fd = open(pathbuf, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);      fd = open(pathbuf, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
     if (fd == -1)      if (fd == -1)
        log_error(USE_ERRNO, _("unable to open %s"), pathbuf);        log_fatal(USE_ERRNO, _("unable to open %s"), pathbuf);
     lock_file(fd, SUDO_LOCK);      lock_file(fd, SUDO_LOCK);
   
    /* Read seq number (base 36). */    /*
    nread = read(fd, buf, sizeof(buf));     * If there is no seq file in iolog_dir and a fallback dir was
    if (nread != 0) {     * specified, look for seq in the fallback dir.  This is to work
        if (nread == -1)     * around a bug in sudo 1.8.5 and older where iolog_dir was not
            log_error(USE_ERRNO, _("unable to read %s"), pathbuf);     * expanded before the sequence number was updated.
        id = strtoul(buf, &ep, 36);     */
        if (buf == ep || id >= SESSID_MAX)    if (iolog_dir_fallback != NULL && fstat(fd, &sb) == 0 && sb.st_size == 0) {
            log_error(0, _("invalid sequence number %s"), pathbuf);        char fallback[PATH_MAX];
 
         len = snprintf(fallback, sizeof(fallback), "%s/seq",
             iolog_dir_fallback);
         if (len > 0 && len < sizeof(fallback)) {
             int fd2 = open(fallback, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
             if (fd2 != -1) {
                 nread = read(fd2, buf, sizeof(buf));
                 if (nread > 0) {
                     id = strtoul(buf, &ep, 36);
                     if (buf == ep || id >= SESSID_MAX)
                         id = 0;
                 }
                 close(fd2);
             }
         }
     }      }
   
       /* Read current seq number (base 36). */
       if (id == 0) {
           nread = read(fd, buf, sizeof(buf));
           if (nread != 0) {
               if (nread == -1)
                   log_fatal(USE_ERRNO, _("unable to read %s"), pathbuf);
               id = strtoul(buf, &ep, 36);
               if (buf == ep || id >= SESSID_MAX)
                   log_fatal(0, _("invalid sequence number %s"), pathbuf);
           }
       }
     id++;      id++;
   
     /*      /*
Line 190  io_nextid(char *iolog_dir, char sessid[7]) Line 220  io_nextid(char *iolog_dir, char sessid[7])
     }      }
     buf[6] = '\n';      buf[6] = '\n';
   
    /* Stash id logging purposes */    /* Stash id for logging purposes. */
     memcpy(sessid, buf, 6);      memcpy(sessid, buf, 6);
     sessid[6] = '\0';      sessid[6] = '\0';
   
     /* 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, (off_t)0, SEEK_SET) == (off_t)-1 || write(fd, buf, 7) != 7)
        log_error(USE_ERRNO, _("unable to write to %s"), pathbuf);        log_fatal(USE_ERRNO, _("unable to write to %s"), pathbuf);
     close(fd);      close(fd);
   
       debug_return;
 }  }
   
 /*  /*
Line 208  static size_t Line 240  static size_t
 mkdir_iopath(const char *iolog_path, char *pathbuf, size_t pathsize)  mkdir_iopath(const char *iolog_path, char *pathbuf, size_t pathsize)
 {  {
     size_t len;      size_t len;
       debug_decl(mkdir_iopath, SUDO_DEBUG_UTIL)
   
     len = strlcpy(pathbuf, iolog_path, pathsize);      len = strlcpy(pathbuf, iolog_path, pathsize);
     if (len >= pathsize) {      if (len >= pathsize) {
         errno = ENAMETOOLONG;          errno = ENAMETOOLONG;
        log_error(USE_ERRNO, "%s", iolog_path);        log_fatal(USE_ERRNO, "%s", iolog_path);
     }      }
   
     /*      /*
Line 222  mkdir_iopath(const char *iolog_path, char *pathbuf, si Line 255  mkdir_iopath(const char *iolog_path, char *pathbuf, si
     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, _("unable to create %s"), pathbuf);            log_fatal(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, _("unable to create %s"), pathbuf);            log_fatal(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.   * Append suffix to pathbuf after len chars and open the resulting file.
  * Note that the size of pathbuf is assumed to be PATH_MAX.   * 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.   * Returns the open file handle which has the close-on-exec flag set.
  */   */
 static void *  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;      void *vfd = NULL;
     int fd;      int fd;
       debug_decl(open_io_fd, SUDO_DEBUG_UTIL)
   
     pathbuf[len] = '\0';      pathbuf[len] = '\0';
     strlcat(pathbuf, suffix, PATH_MAX);      strlcat(pathbuf, suffix, PATH_MAX);
Line 255  open_io_fd(char *pathbuf, size_t len, const char *suff Line 289  open_io_fd(char *pathbuf, size_t len, const char *suff
 #endif  #endif
             vfd = fdopen(fd, "w");              vfd = fdopen(fd, "w");
     }      }
    return vfd;    debug_return_ptr(vfd);
 }  }
   
 /*  /*
Line 272  iolog_deserialize_info(struct iolog_details *details,  Line 306  iolog_deserialize_info(struct iolog_details *details, 
     unsigned long ulval;      unsigned long ulval;
     uid_t runas_uid = 0;      uid_t runas_uid = 0;
     gid_t runas_gid = 0;      gid_t runas_gid = 0;
       debug_decl(iolog_deserialize_info, SUDO_DEBUG_UTIL)
   
     memset(details, 0, sizeof(*details));      memset(details, 0, sizeof(*details));
   
Line 312  iolog_deserialize_info(struct iolog_details *details,  Line 347  iolog_deserialize_info(struct iolog_details *details, 
                 continue;                  continue;
             }              }
             if (strncmp(*cur, "iolog_stdin=", sizeof("iolog_stdin=") - 1) == 0) {              if (strncmp(*cur, "iolog_stdin=", sizeof("iolog_stdin=") - 1) == 0) {
                if (atobool(*cur + sizeof("iolog_stdin=") - 1) == TRUE)                if (atobool(*cur + sizeof("iolog_stdin=") - 1) == true)
                    details->iolog_stdin = TRUE;                    details->iolog_stdin = true;
                 continue;                  continue;
             }              }
             if (strncmp(*cur, "iolog_stdout=", sizeof("iolog_stdout=") - 1) == 0) {              if (strncmp(*cur, "iolog_stdout=", sizeof("iolog_stdout=") - 1) == 0) {
                if (atobool(*cur + sizeof("iolog_stdout=") - 1) == TRUE)                if (atobool(*cur + sizeof("iolog_stdout=") - 1) == true)
                    details->iolog_stdout = TRUE;                    details->iolog_stdout = true;
                 continue;                  continue;
             }              }
             if (strncmp(*cur, "iolog_stderr=", sizeof("iolog_stderr=") - 1) == 0) {              if (strncmp(*cur, "iolog_stderr=", sizeof("iolog_stderr=") - 1) == 0) {
                if (atobool(*cur + sizeof("iolog_stderr=") - 1) == TRUE)                if (atobool(*cur + sizeof("iolog_stderr=") - 1) == true)
                    details->iolog_stderr = TRUE;                    details->iolog_stderr = true;
                 continue;                  continue;
             }              }
             if (strncmp(*cur, "iolog_ttyin=", sizeof("iolog_ttyin=") - 1) == 0) {              if (strncmp(*cur, "iolog_ttyin=", sizeof("iolog_ttyin=") - 1) == 0) {
                if (atobool(*cur + sizeof("iolog_ttyin=") - 1) == TRUE)                if (atobool(*cur + sizeof("iolog_ttyin=") - 1) == true)
                    details->iolog_ttyin = TRUE;                    details->iolog_ttyin = true;
                 continue;                  continue;
             }              }
             if (strncmp(*cur, "iolog_ttyout=", sizeof("iolog_ttyout=") - 1) == 0) {              if (strncmp(*cur, "iolog_ttyout=", sizeof("iolog_ttyout=") - 1) == 0) {
                if (atobool(*cur + sizeof("iolog_ttyout=") - 1) == TRUE)                if (atobool(*cur + sizeof("iolog_ttyout=") - 1) == true)
                    details->iolog_ttyout = TRUE;                    details->iolog_ttyout = true;
                 continue;                  continue;
             }              }
             if (strncmp(*cur, "iolog_compress=", sizeof("iolog_compress=") - 1) == 0) {              if (strncmp(*cur, "iolog_compress=", sizeof("iolog_compress=") - 1) == 0) {
                if (atobool(*cur + sizeof("iolog_compress=") - 1) == TRUE)                if (atobool(*cur + sizeof("iolog_compress=") - 1) == true)
                    iolog_compress = TRUE; /* must be global */                    iolog_compress = true; /* must be global */
                 continue;                  continue;
             }              }
             break;              break;
Line 402  iolog_deserialize_info(struct iolog_details *details,  Line 437  iolog_deserialize_info(struct iolog_details *details, 
             details->runas_gr = sudo_fakegrnam(id);              details->runas_gr = sudo_fakegrnam(id);
         }          }
     }      }
       debug_return;
 }  }
   
 static int  static int
 sudoers_io_open(unsigned int version, sudo_conv_t conversation,  sudoers_io_open(unsigned int version, sudo_conv_t conversation,
     sudo_printf_t plugin_printf, char * const settings[],      sudo_printf_t plugin_printf, char * const settings[],
     char * const user_info[], char * const command_info[],      char * const user_info[], char * const command_info[],
    int argc, char * const argv[], char * const user_env[])    int argc, char * const argv[], char * const user_env[], char * const args[])
 {  {
     struct iolog_details details;      struct iolog_details details;
     char pathbuf[PATH_MAX], sessid[7];      char pathbuf[PATH_MAX], sessid[7];
     char *tofree = NULL;      char *tofree = NULL;
     char * const *cur;      char * const *cur;
       const char *debug_flags = NULL;
     FILE *io_logfile;      FILE *io_logfile;
     size_t len;      size_t len;
     int rval = -1;      int rval = -1;
       debug_decl(sudoers_io_open, SUDO_DEBUG_PLUGIN)
   
     if (!sudo_conv)      if (!sudo_conv)
         sudo_conv = conversation;          sudo_conv = conversation;
Line 425  sudoers_io_open(unsigned int version, sudo_conv_t conv Line 463  sudoers_io_open(unsigned int version, sudo_conv_t conv
   
     /* If we have no command (because -V was specified) just return. */      /* If we have no command (because -V was specified) just return. */
     if (argc == 0)      if (argc == 0)
        return TRUE;        debug_return_bool(true);
   
     if (sigsetjmp(error_jmp, 1)) {      if (sigsetjmp(error_jmp, 1)) {
        /* called via error(), errorx() or log_error() */        /* called via error(), errorx() or log_fatal() */
         rval = -1;          rval = -1;
         goto done;          goto done;
     }      }
Line 439  sudoers_io_open(unsigned int version, sudo_conv_t conv Line 477  sudoers_io_open(unsigned int version, sudo_conv_t conv
     sudo_setgrent();      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.       * Pull iolog settings out of command_info, if any.
      */       */
     iolog_deserialize_info(&details, user_info, command_info);      iolog_deserialize_info(&details, user_info, command_info);
Line 446  sudoers_io_open(unsigned int version, sudo_conv_t conv Line 494  sudoers_io_open(unsigned int version, sudo_conv_t conv
     if (!details.iolog_stdin && !details.iolog_ttyin &&      if (!details.iolog_stdin && !details.iolog_ttyin &&
         !details.iolog_stdout && !details.iolog_stderr &&          !details.iolog_stdout && !details.iolog_stderr &&
         !details.iolog_ttyout) {          !details.iolog_ttyout) {
        rval = FALSE;        rval = false;
         goto done;          goto done;
     }      }
   
Line 455  sudoers_io_open(unsigned int version, sudo_conv_t conv Line 503  sudoers_io_open(unsigned int version, sudo_conv_t conv
         /* Get next session ID and convert it into a path. */          /* Get next session ID and convert it into a path. */
         tofree = emalloc(sizeof(_PATH_SUDO_IO_LOGDIR) + sizeof(sessid) + 2);          tofree = emalloc(sizeof(_PATH_SUDO_IO_LOGDIR) + sizeof(sessid) + 2);
         memcpy(tofree, _PATH_SUDO_IO_LOGDIR, sizeof(_PATH_SUDO_IO_LOGDIR));          memcpy(tofree, _PATH_SUDO_IO_LOGDIR, sizeof(_PATH_SUDO_IO_LOGDIR));
        io_nextid(tofree, sessid);        io_nextid(tofree, NULL, sessid);
         snprintf(tofree + sizeof(_PATH_SUDO_IO_LOGDIR), sizeof(sessid) + 2,          snprintf(tofree + sizeof(_PATH_SUDO_IO_LOGDIR), sizeof(sessid) + 2,
             "%c%c/%c%c/%c%c", sessid[0], sessid[1], sessid[2], sessid[3],              "%c%c/%c%c/%c%c", sessid[0], sessid[1], sessid[2], sessid[3],
             sessid[4], sessid[5]);              sessid[4], sessid[5]);
Line 473  sudoers_io_open(unsigned int version, sudo_conv_t conv Line 521  sudoers_io_open(unsigned int version, sudo_conv_t conv
     /*      /*
      * We create 7 files: a log file, a timing file and 5 for input/output.       * 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)      if (io_logfile == NULL)
        log_error(USE_ERRNO, _("unable to create %s"), pathbuf);        log_fatal(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, _("unable to create %s"), pathbuf);        log_fatal(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, _("unable to create %s"), pathbuf);            log_fatal(USE_ERRNO, _("unable to create %s"), pathbuf);
     } else {      } else {
         sudoers_io.log_ttyin = NULL;          sudoers_io.log_ttyin = NULL;
     }      }
Line 494  sudoers_io_open(unsigned int version, sudo_conv_t conv Line 542  sudoers_io_open(unsigned int version, sudo_conv_t conv
         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, _("unable to create %s"), pathbuf);            log_fatal(USE_ERRNO, _("unable to create %s"), pathbuf);
     } else {      } else {
         sudoers_io.log_stdin = NULL;          sudoers_io.log_stdin = NULL;
     }      }
Line 502  sudoers_io_open(unsigned int version, sudo_conv_t conv Line 550  sudoers_io_open(unsigned int version, sudo_conv_t conv
         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, _("unable to create %s"), pathbuf);            log_fatal(USE_ERRNO, _("unable to create %s"), pathbuf);
     } else {      } else {
         sudoers_io.log_ttyout = NULL;          sudoers_io.log_ttyout = NULL;
     }      }
Line 510  sudoers_io_open(unsigned int version, sudo_conv_t conv Line 558  sudoers_io_open(unsigned int version, sudo_conv_t conv
         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, _("unable to create %s"), pathbuf);            log_fatal(USE_ERRNO, _("unable to create %s"), pathbuf);
     } else {      } else {
         sudoers_io.log_stdout = NULL;          sudoers_io.log_stdout = NULL;
     }      }
Line 518  sudoers_io_open(unsigned int version, sudo_conv_t conv Line 566  sudoers_io_open(unsigned int version, sudo_conv_t conv
         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, _("unable to create %s"), pathbuf);            log_fatal(USE_ERRNO, _("unable to create %s"), pathbuf);
     } else {      } else {
         sudoers_io.log_stderr = NULL;          sudoers_io.log_stderr = NULL;
     }      }
Line 539  sudoers_io_open(unsigned int version, sudo_conv_t conv Line 587  sudoers_io_open(unsigned int version, sudo_conv_t conv
     fputc('\n', io_logfile);      fputc('\n', io_logfile);
     fclose(io_logfile);      fclose(io_logfile);
   
    rval = TRUE;    rval = true;
   
 done:  done:
     efree(tofree);      efree(tofree);
     if (details.runas_pw)      if (details.runas_pw)
        pw_delref(details.runas_pw);        sudo_pw_delref(details.runas_pw);
     sudo_endpwent();      sudo_endpwent();
     if (details.runas_gr)      if (details.runas_gr)
        gr_delref(details.runas_gr);        sudo_gr_delref(details.runas_gr);
     sudo_endgrent();      sudo_endgrent();
   
    return rval;    debug_return_bool(rval);
 }  }
   
 static void  static void
 sudoers_io_close(int exit_status, int error)  sudoers_io_close(int exit_status, int error)
 {  {
     int i;      int i;
       debug_decl(sudoers_io_close, SUDO_DEBUG_PLUGIN)
   
     if (sigsetjmp(error_jmp, 1)) {      if (sigsetjmp(error_jmp, 1)) {
        /* called via error(), errorx() or log_error() */        /* called via error(), errorx() or log_fatal() */
        return;        debug_return;
     }      }
   
     for (i = 0; i < IOFD_MAX; i++) {      for (i = 0; i < IOFD_MAX; i++) {
Line 573  sudoers_io_close(int exit_status, int error) Line 622  sudoers_io_close(int exit_status, int error)
 #endif  #endif
             fclose(io_fds[i].f);              fclose(io_fds[i].f);
     }      }
       debug_return;
 }  }
   
 static int  static int
 sudoers_io_version(int verbose)  sudoers_io_version(int verbose)
 {  {
       debug_decl(sudoers_io_version, SUDO_DEBUG_PLUGIN)
   
     if (sigsetjmp(error_jmp, 1)) {      if (sigsetjmp(error_jmp, 1)) {
        /* called via error(), errorx() or log_error() */        /* called via error(), errorx() or log_fatal() */
        return -1;        debug_return_bool(-1);
     }      }
   
     sudo_printf(SUDO_CONV_INFO_MSG, "Sudoers I/O plugin version %s\n",      sudo_printf(SUDO_CONV_INFO_MSG, "Sudoers I/O plugin version %s\n",
         PACKAGE_VERSION);          PACKAGE_VERSION);
   
    return TRUE;    debug_return_bool(true);
 }  }
   
 /*  /*
Line 596  static int Line 648  static int
 sudoers_io_log(const char *buf, unsigned int len, int idx)  sudoers_io_log(const char *buf, unsigned int len, int idx)
 {  {
     struct timeval now, delay;      struct timeval now, delay;
       debug_decl(sudoers_io_version, SUDO_DEBUG_PLUGIN)
   
     gettimeofday(&now, NULL);      gettimeofday(&now, NULL);
   
     if (sigsetjmp(error_jmp, 1)) {      if (sigsetjmp(error_jmp, 1)) {
        /* called via error(), errorx() or log_error() */        /* called via error(), errorx() or log_fatal() */
        return -1;        debug_return_bool(-1);
     }      }
   
 #ifdef HAVE_ZLIB_H  #ifdef HAVE_ZLIB_H
     if (iolog_compress)      if (iolog_compress)
        gzwrite(io_fds[idx].g, buf, len);        ignore_result(gzwrite(io_fds[idx].g, (const voidp)buf, len));
     else      else
 #endif  #endif
        fwrite(buf, 1, len, io_fds[idx].f);        ignore_result(fwrite(buf, 1, len, io_fds[idx].f));
     delay.tv_sec = now.tv_sec;      delay.tv_sec = now.tv_sec;
     delay.tv_usec = now.tv_usec;      delay.tv_usec = now.tv_usec;
     timevalsub(&delay, &last_time);      timevalsub(&delay, &last_time);
Line 624  sudoers_io_log(const char *buf, unsigned int len, int  Line 677  sudoers_io_log(const char *buf, unsigned int len, int 
     last_time.tv_sec = now.tv_sec;      last_time.tv_sec = now.tv_sec;
     last_time.tv_usec = now.tv_usec;      last_time.tv_usec = now.tv_usec;
   
    return TRUE;    debug_return_bool(true);
 }  }
   
 static int  static int
Line 657  sudoers_io_log_stderr(const char *buf, unsigned int le Line 710  sudoers_io_log_stderr(const char *buf, unsigned int le
     return sudoers_io_log(buf, len, IOFD_STDERR);      return sudoers_io_log(buf, len, IOFD_STDERR);
 }  }
   
struct io_plugin sudoers_io = {__dso_public struct io_plugin sudoers_io = {
     SUDO_IO_PLUGIN,      SUDO_IO_PLUGIN,
     SUDO_API_VERSION,      SUDO_API_VERSION,
     sudoers_io_open,      sudoers_io_open,

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>