/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to plugin-runner.c

  • Committer: Teddy Hogeborn
  • Date: 2009-01-13 04:45:33 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090113044533-de691yv0fa5w6quw
* plugins.d/mandos-client.c: Only comment changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
                                   sigprocmask(), SIG_BLOCK, SIGCHLD,
65
65
                                   SIG_UNBLOCK, kill() */
66
66
#include <errno.h>              /* errno, EBADF */
67
 
#include <inttypes.h>           /* intmax_t, SCNdMAX, PRIdMAX,  */
68
67
 
69
68
#define BUFFER_SIZE 256
70
69
 
309
308
  struct dirent *dirst;
310
309
  struct stat st;
311
310
  fd_set rfds_all;
312
 
  int ret, numchars, maxfd = 0;
 
311
  int ret, maxfd = 0;
313
312
  ssize_t sret;
314
 
  intmax_t tmpmax;
315
313
  uid_t uid = 65534;
316
314
  gid_t gid = 65534;
317
315
  bool debug = false;
465
463
      /* This is already done by parse_opt_config_file() */
466
464
      break;
467
465
    case 130:                   /* --userid */
468
 
      ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars);
469
 
      if(ret < 1 or tmpmax != (uid_t)tmpmax
470
 
         or arg[numchars] != '\0'){
471
 
        fprintf(stderr, "Bad user ID number: \"%s\", using %"
472
 
                PRIdMAX "\n", arg, (intmax_t)uid);
473
 
      } else {
474
 
        uid = (uid_t)tmpmax;
 
466
      /* In the GNU C library, uid_t is always unsigned int */
 
467
      ret = sscanf(arg, "%u", &uid);
 
468
      if(ret != 1){
 
469
        fprintf(stderr, "Bad user ID number: \"%s\", using %u\n", arg,
 
470
                uid);
475
471
      }
476
472
      break;
477
473
    case 131:                   /* --groupid */
478
 
      ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars);
479
 
      if(ret < 1 or tmpmax != (gid_t)tmpmax
480
 
         or arg[numchars] != '\0'){
481
 
        fprintf(stderr, "Bad group ID number: \"%s\", using %"
482
 
                PRIdMAX "\n", arg, (intmax_t)gid);
483
 
      } else {
484
 
        gid = (gid_t)tmpmax;
 
474
      /* In the GNU C library, gid_t is always unsigned int */
 
475
      ret = sscanf(arg, "%u", &gid);
 
476
      if(ret != 1){
 
477
        fprintf(stderr, "Bad group ID number: \"%s\", using %u\n",
 
478
                arg, gid);
485
479
      }
486
480
      break;
487
481
    case 132:                   /* --debug */
653
647
      for(char **a = p->argv; *a != NULL; a++){
654
648
        fprintf(stderr, "\tArg: %s\n", *a);
655
649
      }
656
 
      fprintf(stderr, "...and %d environment variables\n", p->envc);
 
650
      fprintf(stderr, "...and %u environment variables\n", p->envc);
657
651
      for(char **a = p->environ; *a != NULL; a++){
658
652
        fprintf(stderr, "\t%s\n", *a);
659
653
      }
966
960
 
967
961
          if(debug){
968
962
            if(WIFEXITED(proc->status)){
969
 
              fprintf(stderr, "Plugin %" PRIdMAX " exited with status"
970
 
                      " %d\n", (intmax_t) (proc->pid),
 
963
              fprintf(stderr, "Plugin %u exited with status %d\n",
 
964
                      (unsigned int) (proc->pid),
971
965
                      WEXITSTATUS(proc->status));
972
966
            } else if(WIFSIGNALED(proc->status)) {
973
 
              fprintf(stderr, "Plugin %" PRIdMAX " killed by signal"
974
 
                      " %d\n", (intmax_t) (proc->pid),
 
967
              fprintf(stderr, "Plugin %u killed by signal %d\n",
 
968
                      (unsigned int) (proc->pid),
975
969
                      WTERMSIG(proc->status));
976
970
            } else if(WCOREDUMP(proc->status)){
977
 
              fprintf(stderr, "Plugin %" PRIdMAX " dumped core\n",
978
 
                      (intmax_t) (proc->pid));
 
971
              fprintf(stderr, "Plugin %u dumped core\n",
 
972
                      (unsigned int) (proc->pid));
979
973
            }
980
974
          }
981
975