/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-02-12 23:17:14 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090212231714-59wxtc7h3w7ss8v6
* plugins.d/mandos-client.c (browse_callback, main): Do not require
                                                     IPv6.
  (main): Removed redundant initialization of "mc".

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  -*- coding: utf-8; mode: c; mode: orgtbl -*- */
 
1
/*  -*- coding: utf-8 -*- */
2
2
/*
3
3
 * Mandos plugin runner - Run Mandos plugins
4
4
 *
38
38
#include <sys/select.h>         /* fd_set, select(), FD_ZERO(),
39
39
                                   FD_SET(), FD_ISSET(), FD_CLR */
40
40
#include <sys/wait.h>           /* wait(), waitpid(), WIFEXITED(),
41
 
                                   WEXITSTATUS(), WTERMSIG(),
42
 
                                   WCOREDUMP() */
 
41
                                   WEXITSTATUS() */
43
42
#include <sys/stat.h>           /* struct stat, stat(), S_ISREG() */
44
43
#include <iso646.h>             /* and, or, not */
45
44
#include <dirent.h>             /* DIR, struct dirent, opendir(),
53
52
                                   close() */
54
53
#include <fcntl.h>              /* fcntl(), F_GETFD, F_SETFD,
55
54
                                   FD_CLOEXEC */
56
 
#include <string.h>             /* strsep, strlen(), asprintf(),
57
 
                                   strsignal() */
 
55
#include <string.h>             /* strsep, strlen(), asprintf() */
58
56
#include <errno.h>              /* errno */
59
57
#include <argp.h>               /* struct argp_option, struct
60
58
                                   argp_state, struct argp,
210
208
/*
211
209
 * Based on the example in the GNU LibC manual chapter 13.13 "File
212
210
 * Descriptor Flags".
213
 
 | [[info:libc:Descriptor%20Flags][File Descriptor Flags]] |
 
211
 * *Note File Descriptor Flags:(libc)Descriptor Flags.
214
212
 */
215
213
static int set_cloexec_flag(int fd){
216
214
  int ret = fcntl(fd, F_GETFD, 0);
459
457
      plugindir = strdup(arg);
460
458
      if(plugindir == NULL){
461
459
        perror("strdup");
462
 
      }
 
460
      }      
463
461
      break;
464
462
    case 129:                   /* --config-file */
465
463
      /* This is already done by parse_opt_config_file() */
529
527
      if(argfile == NULL){
530
528
        perror("strdup");
531
529
      }
532
 
      break;
 
530
      break;      
533
531
    case 130:                   /* --userid */
534
532
    case 131:                   /* --groupid */
535
533
    case 132:                   /* --debug */
564
562
    conffp = fopen(AFILE, "r");
565
563
  } else {
566
564
    conffp = fopen(argfile, "r");
567
 
  }
 
565
  }  
568
566
  if(conffp != NULL){
569
567
    char *org_line = NULL;
570
568
    char *p, *arg, *new_arg, *line;
614
612
          goto fallback;
615
613
        }
616
614
        custom_argv[custom_argc-1] = new_arg;
617
 
        custom_argv[custom_argc] = NULL;
 
615
        custom_argv[custom_argc] = NULL;        
618
616
      }
619
617
    }
620
 
    do{
621
 
      ret = fclose(conffp);
622
 
    }while(ret == EOF and errno == EINTR);
623
 
    if(ret == EOF){
624
 
      perror("fclose");
625
 
      exitstatus = EXIT_FAILURE;
626
 
      goto fallback;
627
 
    }
628
618
    free(org_line);
629
619
  } else {
630
620
    /* Check for harmful errors and go to fallback. Other errors might
983
973
                      WEXITSTATUS(proc->status));
984
974
            } else if(WIFSIGNALED(proc->status)){
985
975
              fprintf(stderr, "Plugin %s [%" PRIdMAX "] killed by"
986
 
                      " signal %d: %s\n", proc->name,
 
976
                      " signal %d\n", proc->name,
987
977
                      (intmax_t) (proc->pid),
988
 
                      WTERMSIG(proc->status),
989
 
                      strsignal(WTERMSIG(proc->status)));
 
978
                      WTERMSIG(proc->status));
990
979
            } else if(WCOREDUMP(proc->status)){
991
980
              fprintf(stderr, "Plugin %s [%" PRIdMAX "] dumped"
992
981
                      " core\n", proc->name, (intmax_t) (proc->pid));