/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:35:19 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090113043519-0yr39snphoegq8l1
* plugin-runner.c: Only space changes.
* plugins.d/mandos-client.c: - '' -
* plugins.d/password-prompt.c: - '' -

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
 
115
114
  if(name != NULL){
116
115
    copy_name = strdup(name);
117
116
    if(copy_name == NULL){
118
 
      free(new_plugin);
119
117
      return NULL;
120
118
    }
121
119
  }
310
308
  struct dirent *dirst;
311
309
  struct stat st;
312
310
  fd_set rfds_all;
313
 
  int ret, numchars, maxfd = 0;
 
311
  int ret, maxfd = 0;
314
312
  ssize_t sret;
315
 
  intmax_t tmpmax;
316
313
  uid_t uid = 65534;
317
314
  gid_t gid = 65534;
318
315
  bool debug = false;
466
463
      /* This is already done by parse_opt_config_file() */
467
464
      break;
468
465
    case 130:                   /* --userid */
469
 
      ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars);
470
 
      if(ret < 1 or tmpmax != (uid_t)tmpmax
471
 
         or arg[numchars] != '\0'){
472
 
        fprintf(stderr, "Bad user ID number: \"%s\", using %"
473
 
                PRIdMAX "\n", arg, (intmax_t)uid);
474
 
      } else {
475
 
        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);
476
471
      }
477
472
      break;
478
473
    case 131:                   /* --groupid */
479
 
      ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars);
480
 
      if(ret < 1 or tmpmax != (gid_t)tmpmax
481
 
         or arg[numchars] != '\0'){
482
 
        fprintf(stderr, "Bad group ID number: \"%s\", using %"
483
 
                PRIdMAX "\n", arg, (intmax_t)gid);
484
 
      } else {
485
 
        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);
486
479
      }
487
480
      break;
488
481
    case 132:                   /* --debug */
654
647
      for(char **a = p->argv; *a != NULL; a++){
655
648
        fprintf(stderr, "\tArg: %s\n", *a);
656
649
      }
657
 
      fprintf(stderr, "...and %d environment variables\n", p->envc);
 
650
      fprintf(stderr, "...and %u environment variables\n", p->envc);
658
651
      for(char **a = p->environ; *a != NULL; a++){
659
652
        fprintf(stderr, "\t%s\n", *a);
660
653
      }
967
960
 
968
961
          if(debug){
969
962
            if(WIFEXITED(proc->status)){
970
 
              fprintf(stderr, "Plugin %" PRIdMAX " exited with status"
971
 
                      " %d\n", (intmax_t) (proc->pid),
 
963
              fprintf(stderr, "Plugin %u exited with status %d\n",
 
964
                      (unsigned int) (proc->pid),
972
965
                      WEXITSTATUS(proc->status));
973
966
            } else if(WIFSIGNALED(proc->status)) {
974
 
              fprintf(stderr, "Plugin %" PRIdMAX " killed by signal"
975
 
                      " %d\n", (intmax_t) (proc->pid),
 
967
              fprintf(stderr, "Plugin %u killed by signal %d\n",
 
968
                      (unsigned int) (proc->pid),
976
969
                      WTERMSIG(proc->status));
977
970
            } else if(WCOREDUMP(proc->status)){
978
 
              fprintf(stderr, "Plugin %" PRIdMAX " dumped core\n",
979
 
                      (intmax_t) (proc->pid));
 
971
              fprintf(stderr, "Plugin %u dumped core\n",
 
972
                      (unsigned int) (proc->pid));
980
973
            }
981
974
          }
982
975