/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-04 22:15:01 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090104221501-23vutw4cnmb575rq
* debian/mandos.README.Debian: Updated to reflect code changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
309
309
  struct stat st;
310
310
  fd_set rfds_all;
311
311
  int ret, maxfd = 0;
312
 
  ssize_t sret;
313
312
  uid_t uid = 65534;
314
313
  gid_t gid = 65534;
315
314
  bool debug = false;
463
462
      /* This is already done by parse_opt_config_file() */
464
463
      break;
465
464
    case 130:                   /* --userid */
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);
471
 
      }
 
465
      uid = (uid_t)strtol(arg, NULL, 10);
472
466
      break;
473
467
    case 131:                   /* --groupid */
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);
479
 
      }
 
468
      gid = (gid_t)strtol(arg, NULL, 10);
480
469
      break;
481
470
    case 132:                   /* --debug */
482
471
      debug = true;
483
472
      break;
484
 
/*
485
 
 * When adding more options before this line, remember to also add a
486
 
 * "case" to the "parse_opt_config_file" function below.
487
 
 */
488
473
    case ARGP_KEY_ARG:
489
474
      /* Cryptsetup always passes an argument, which is an empty
490
475
         string if "none" was specified in /etc/crypttab.  So if
539
524
                       .args_doc = "",
540
525
                       .doc = "Mandos plugin runner -- Run plugins" };
541
526
  
542
 
  /* Parse using parse_opt_config_file() in order to get the custom
 
527
  /* Parse using the parse_opt_config_file in order to get the custom
543
528
     config file location, if any. */
544
529
  ret = argp_parse (&argp, argc, argv, ARGP_IN_ORDER, 0, NULL);
545
530
  if (ret == ARGP_ERR_UNKNOWN){
561
546
    char *org_line = NULL;
562
547
    char *p, *arg, *new_arg, *line;
563
548
    size_t size = 0;
 
549
    ssize_t sret;
564
550
    const char whitespace_delims[] = " \r\t\f\v\n";
565
551
    const char comment_delim[] = "#";
566
552
 
968
954
                      (unsigned int) (proc->pid),
969
955
                      WTERMSIG(proc->status));
970
956
            } else if(WCOREDUMP(proc->status)){
971
 
              fprintf(stderr, "Plugin %u dumped core\n",
 
957
              fprintf(stderr, "Plugin %d dumped core\n",
972
958
                      (unsigned int) (proc->pid));
973
959
            }
974
960
          }
1033
1019
        proc->buffer_size += BUFFER_SIZE;
1034
1020
      }
1035
1021
      /* Read from the process */
1036
 
      sret = read(proc->fd, proc->buffer + proc->buffer_length,
1037
 
                  BUFFER_SIZE);
1038
 
      if(sret < 0){
 
1022
      ret = read(proc->fd, proc->buffer + proc->buffer_length,
 
1023
                 BUFFER_SIZE);
 
1024
      if(ret < 0){
1039
1025
        /* Read error from this process; ignore the error */
1040
1026
        proc = proc->next;
1041
1027
        continue;
1042
1028
      }
1043
 
      if(sret == 0){
 
1029
      if(ret == 0){
1044
1030
        /* got EOF */
1045
1031
        proc->eof = true;
1046
1032
      } else {
1047
 
        proc->buffer_length += (size_t) sret;
 
1033
        proc->buffer_length += (size_t) ret;
1048
1034
      }
1049
1035
    }
1050
1036
  }