/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

merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
#include <signal.h>             /* struct sigaction, sigemptyset(),
63
63
                                   sigaddset(), sigaction(),
64
64
                                   sigprocmask(), SIG_BLOCK, SIGCHLD,
65
 
                                   SIG_UNBLOCK, kill(), sig_atomic_t
66
 
                                */
 
65
                                   SIG_UNBLOCK, kill() */
67
66
#include <errno.h>              /* errno, EBADF */
68
67
#include <inttypes.h>           /* intmax_t, SCNdMAX, PRIdMAX,  */
69
68
 
383
382
    switch(key){
384
383
    case 'g':                   /* --global-options */
385
384
      if(arg != NULL){
386
 
        char *plugin_option;
387
 
        while((plugin_option = strsep(&arg, ",")) != NULL){
388
 
          if(plugin_option[0] == '\0'){
 
385
        char *p;
 
386
        while((p = strsep(&arg, ",")) != NULL){
 
387
          if(p[0] == '\0'){
389
388
            continue;
390
389
          }
391
 
          if(not add_argument(getplugin(NULL), plugin_option)){
 
390
          if(not add_argument(getplugin(NULL), p)){
392
391
            perror("add_argument");
393
392
            return ARGP_ERR_UNKNOWN;
394
393
          }
405
404
      break;
406
405
    case 'o':                   /* --options-for */
407
406
      if(arg != NULL){
408
 
        char *plugin_name = strsep(&arg, ":");
409
 
        if(plugin_name[0] == '\0'){
410
 
          break;
411
 
        }
412
 
        char *plugin_option;
413
 
        while((plugin_option = strsep(&arg, ",")) != NULL){
414
 
          if(not add_argument(getplugin(plugin_name), plugin_option)){
 
407
        char *p_name = strsep(&arg, ":");
 
408
        if(p_name[0] == '\0' or arg == NULL){
 
409
          break;
 
410
        }
 
411
        char *opt = strsep(&arg, ":");
 
412
        if(opt[0] == '\0' or opt == NULL){
 
413
          break;
 
414
        }
 
415
        char *p;
 
416
        while((p = strsep(&opt, ",")) != NULL){
 
417
          if(p[0] == '\0'){
 
418
            continue;
 
419
          }
 
420
          if(not add_argument(getplugin(p_name), p)){
415
421
            perror("add_argument");
416
422
            return ARGP_ERR_UNKNOWN;
417
423
          }
930
936
  
931
937
  closedir(dir);
932
938
  dir = NULL;
933
 
  free_plugin(getplugin(NULL));
934
939
  
935
940
  for(plugin *p = plugin_list; p != NULL; p = p->next){
936
941
    if(p->pid != 0){
964
969
 
965
970
          if(debug){
966
971
            if(WIFEXITED(proc->status)){
967
 
              fprintf(stderr, "Plugin %s [%" PRIdMAX "] exited with"
968
 
                      " status %d\n", proc->name,
969
 
                      (intmax_t) (proc->pid),
 
972
              fprintf(stderr, "Plugin %" PRIdMAX " exited with status"
 
973
                      " %d\n", (intmax_t) (proc->pid),
970
974
                      WEXITSTATUS(proc->status));
971
975
            } else if(WIFSIGNALED(proc->status)){
972
 
              fprintf(stderr, "Plugin %s [%" PRIdMAX "] killed by"
973
 
                      " signal %d\n", proc->name,
974
 
                      (intmax_t) (proc->pid),
 
976
              fprintf(stderr, "Plugin %" PRIdMAX " killed by signal"
 
977
                      " %d\n", (intmax_t) (proc->pid),
975
978
                      WTERMSIG(proc->status));
976
979
            } else if(WCOREDUMP(proc->status)){
977
 
              fprintf(stderr, "Plugin %s [%" PRIdMAX "] dumped"
978
 
                      " core\n", proc->name, (intmax_t) (proc->pid));
 
980
              fprintf(stderr, "Plugin %" PRIdMAX " dumped core\n",
 
981
                      (intmax_t) (proc->pid));
979
982
            }
980
983
          }
981
984