/mandos/release

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

« back to all changes in this revision

Viewing changes to plugin-runner.c

* debian/rules (install-indep): Removed "--no-start" from
                                dh_installinit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
  size_t buffer_size;
90
90
  size_t buffer_length;
91
91
  bool eof;
92
 
  volatile sig_atomic_t completed;
93
 
  int status;
 
92
  volatile bool completed;
 
93
  volatile int status;
94
94
  struct plugin *next;
95
95
} plugin;
96
96
 
120
120
    }
121
121
  }
122
122
  
123
 
  *new_plugin = (plugin){ .name = copy_name,
124
 
                          .argc = 1,
125
 
                          .disabled = false,
126
 
                          .next = plugin_list };
 
123
  *new_plugin = (plugin) { .name = copy_name,
 
124
                           .argc = 1,
 
125
                           .disabled = false,
 
126
                           .next = plugin_list };
127
127
  
128
128
  new_plugin->argv = malloc(sizeof(char *) * 2);
129
129
  if(new_plugin->argv == NULL){
223
223
/* Mark processes as completed when they exit, and save their exit
224
224
   status. */
225
225
static void handle_sigchld(__attribute__((unused)) int sig){
226
 
  int old_errno = errno;
227
226
  while(true){
228
227
    plugin *proc = plugin_list;
229
228
    int status;
233
232
      break;
234
233
    }
235
234
    if(pid == -1){
236
 
      if(errno == ECHILD){
237
 
        /* No child processes */
238
 
        break;
 
235
      if(errno != ECHILD){
 
236
        perror("waitpid");
239
237
      }
240
 
      perror("waitpid");
 
238
      /* No child processes */
 
239
      break;
241
240
    }
242
241
    
243
242
    /* A child exited, find it in process_list */
249
248
      continue;
250
249
    }
251
250
    proc->status = status;
252
 
    proc->completed = 1;
 
251
    proc->completed = true;
253
252
  }
254
 
  errno = old_errno;
255
253
}
256
254
 
257
255
/* Prints out a password to stdout */
378
376
  };
379
377
  
380
378
  error_t parse_opt(int key, char *arg, __attribute__((unused))
381
 
                    struct argp_state *state){
382
 
    switch(key){
 
379
                    struct argp_state *state) {
 
380
    switch(key) {
383
381
    case 'g':                   /* --global-options */
384
382
      if(arg != NULL){
385
383
        char *p;
514
512
     ignores everything but the --config-file option. */
515
513
  error_t parse_opt_config_file(int key, char *arg,
516
514
                                __attribute__((unused))
517
 
                                struct argp_state *state){
518
 
    switch(key){
 
515
                                struct argp_state *state) {
 
516
    switch(key) {
519
517
    case 'g':                   /* --global-options */
520
518
    case 'G':                   /* --global-env */
521
519
    case 'o':                   /* --options-for */
664
662
  }
665
663
  
666
664
  /* Strip permissions down to nobody */
 
665
  ret = setuid(uid);
 
666
  if(ret == -1){
 
667
    perror("setuid");
 
668
  }  
667
669
  setgid(gid);
668
670
  if(ret == -1){
669
671
    perror("setgid");
670
672
  }
671
 
  ret = setuid(uid);
672
 
  if(ret == -1){
673
 
    perror("setuid");
674
 
  }
675
673
  
676
674
  if(plugindir == NULL){
677
675
    dir = opendir(PDIR);
936
934
  
937
935
  closedir(dir);
938
936
  dir = NULL;
939
 
  free_plugin(getplugin(NULL));
940
937
  
941
938
  for(plugin *p = plugin_list; p != NULL; p = p->next){
942
939
    if(p->pid != 0){
962
959
       from one of them */
963
960
    for(plugin *proc = plugin_list; proc != NULL;){
964
961
      /* Is this process completely done? */
965
 
      if(proc->completed and proc->eof){
 
962
      if(proc->eof and proc->completed){
966
963
        /* Only accept the plugin output if it exited cleanly */
967
964
        if(not WIFEXITED(proc->status)
968
965
           or WEXITSTATUS(proc->status) != 0){
973
970
              fprintf(stderr, "Plugin %" PRIdMAX " exited with status"
974
971
                      " %d\n", (intmax_t) (proc->pid),
975
972
                      WEXITSTATUS(proc->status));
976
 
            } else if(WIFSIGNALED(proc->status)){
 
973
            } else if(WIFSIGNALED(proc->status)) {
977
974
              fprintf(stderr, "Plugin %" PRIdMAX " killed by signal"
978
975
                      " %d\n", (intmax_t) (proc->pid),
979
976
                      WTERMSIG(proc->status));