/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

  • Committer: Teddy Hogeborn
  • Date: 2008-10-03 09:32:30 UTC
  • Revision ID: teddy@fukt.bsnet.se-20081003093230-rshn19e0c19zz12i
* .bzrignore (plugins.d/askpass-fifo): Added.

* Makefile (FORTIFY): Added "-fstack-protector-all".
  (mandos, mandos-keygen): Use more strict regexps when updating the
                           version number.

* mandos (Client.__init__): Use os.path.expandvars() and
                            os.path.expanduser() on the "secfile"
                            config value.

* plugins.d/splashy.c: Update comments and order of #include's.
  (main): Check user and group when looking for running splashy
          process.  Do not ignore ENOENT from execl().  Use _exit()
          instead of "return" when an error happens in child
          processes.  Bug fix: Only wait for splashy_update
          completion if it was started.  Bug fix: detect failing
          waitpid().  Only kill splashy_update if it is running.  Do
          the killing of the old splashy process before the fork().
          Do setsid() and setuid(geteuid()) before starting the new
          splashy.  Report failing execl().

* plugins.d/usplash.c: Update comments and order of #include's.
  (main): Check user and group when looking for running usplash
          process.  Do not report execv() error if interrupted by a
          signal.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/*
3
3
 * Mandos plugin runner - Run Mandos plugins
4
4
 *
5
 
 * Copyright © 2007-2008 Teddy Hogeborn & Björn Påhlsson
 
5
 * Copyright © 2008 Teddy Hogeborn & Björn Påhlsson
6
6
 * 
7
7
 * This program is free software: you can redistribute it and/or
8
8
 * modify it under the terms of the GNU General Public License as
27
27
#include <stdlib.h>             /* malloc(), exit(), EXIT_FAILURE,
28
28
                                   EXIT_SUCCESS, realloc() */
29
29
#include <stdbool.h>            /* bool, true, false */
30
 
#include <stdio.h>              /* perror, popen(), fileno(),
31
 
                                   fprintf(), stderr, STDOUT_FILENO */
 
30
#include <stdio.h>              /* perror, fileno(), fprintf(),
 
31
                                   stderr, STDOUT_FILENO */
32
32
#include <sys/types.h>          /* DIR, opendir(), stat(), struct
33
33
                                   stat, waitpid(), WIFEXITED(),
34
34
                                   WEXITSTATUS(), wait(), pid_t,
46
46
                                   fcntl(), setuid(), setgid(),
47
47
                                   F_GETFD, F_SETFD, FD_CLOEXEC,
48
48
                                   access(), pipe(), fork(), close()
49
 
                                   dup2, STDOUT_FILENO, _exit(),
 
49
                                   dup2(), STDOUT_FILENO, _exit(),
50
50
                                   execv(), write(), read(),
51
51
                                   close() */
52
52
#include <fcntl.h>              /* fcntl(), F_GETFD, F_SETFD,
69
69
#define PDIR "/lib/mandos/plugins.d"
70
70
#define AFILE "/conf/conf.d/mandos/plugin-runner.conf"
71
71
 
72
 
const char *argp_program_version = "plugin-runner 1.0";
 
72
const char *argp_program_version = "plugin-runner " VERSION;
73
73
const char *argp_program_bug_address = "<mandos@fukt.bsnet.se>";
74
74
 
75
 
struct plugin;
76
 
 
77
75
typedef struct plugin{
78
76
  char *name;                   /* can be NULL or any plugin name */
79
77
  char **argv;
96
94
 
97
95
static plugin *plugin_list = NULL;
98
96
 
99
 
/* Gets a existing plugin based on name,
 
97
/* Gets an existing plugin based on name,
100
98
   or if none is found, creates a new one */
101
99
static plugin *getplugin(char *name){
102
100
  /* Check for exiting plugin with that name */
118
116
      return NULL;
119
117
    }
120
118
  }
121
 
 
 
119
  
122
120
  *new_plugin = (plugin) { .name = copy_name,
123
121
                           .argc = 1,
124
122
                           .disabled = false,
132
130
  }
133
131
  new_plugin->argv[0] = copy_name;
134
132
  new_plugin->argv[1] = NULL;
135
 
 
 
133
  
136
134
  new_plugin->environ = malloc(sizeof(char *));
137
135
  if(new_plugin->environ == NULL){
138
136
    free(copy_name);
141
139
    return NULL;
142
140
  }
143
141
  new_plugin->environ[0] = NULL;
144
 
 
 
142
  
145
143
  /* Append the new plugin to the list */
146
144
  plugin_list = new_plugin;
147
145
  return new_plugin;
179
177
}
180
178
 
181
179
/* Add to a plugin's environment */
182
 
static bool add_environment(plugin *p, const char *def){
 
180
static bool add_environment(plugin *p, const char *def, bool replace){
183
181
  if(p == NULL){
184
182
    return false;
185
183
  }
 
184
  /* namelen = length of name of environment variable */
 
185
  size_t namelen = (size_t)(strchrnul(def, '=') - def);
 
186
  /* Search for this environment variable */
 
187
  for(char **e = p->environ; *e != NULL; e++){
 
188
    if(strncmp(*e, def, namelen + 1) == 0){
 
189
      /* It already exists */
 
190
      if(replace){
 
191
        char *new = realloc(*e, strlen(def) + 1);
 
192
        if(new == NULL){
 
193
          return false;
 
194
        }
 
195
        *e = new;
 
196
        strcpy(*e, def);
 
197
      }
 
198
      return true;
 
199
    }
 
200
  }
186
201
  return add_to_char_array(def, &(p->environ), &(p->envc));
187
202
}
188
203
 
191
206
 * Descriptor Flags".
192
207
 * *Note File Descriptor Flags:(libc)Descriptor Flags.
193
208
 */
194
 
static int set_cloexec_flag(int fd)
195
 
{
 
209
static int set_cloexec_flag(int fd){
196
210
  int ret = fcntl(fd, F_GETFD, 0);
197
211
  /* If reading the flags failed, return error indication now. */
198
212
  if(ret < 0){
205
219
 
206
220
/* Mark processes as completed when they exit, and save their exit
207
221
   status. */
208
 
void handle_sigchld(__attribute__((unused)) int sig){
 
222
static void handle_sigchld(__attribute__((unused)) int sig){
209
223
  while(true){
210
224
    plugin *proc = plugin_list;
211
225
    int status;
221
235
      /* No child processes */
222
236
      break;
223
237
    }
224
 
 
 
238
    
225
239
    /* A child exited, find it in process_list */
226
240
    while(proc != NULL and proc->pid != pid){
227
241
      proc = proc->next;
236
250
}
237
251
 
238
252
/* Prints out a password to stdout */
239
 
bool print_out_password(const char *buffer, size_t length){
 
253
static bool print_out_password(const char *buffer, size_t length){
240
254
  ssize_t ret;
241
 
  if(length>0 and buffer[length-1] == '\n'){
242
 
    length--;
243
 
  }
244
255
  for(size_t written = 0; written < length; written += (size_t)ret){
245
256
    ret = TEMP_FAILURE_RETRY(write(STDOUT_FILENO, buffer + written,
246
257
                                   length - written));
327
338
    { .name = "global-options", .key = 'g',
328
339
      .arg = "OPTION[,OPTION[,...]]",
329
340
      .doc = "Options passed to all plugins" },
330
 
    { .name = "global-envs", .key = 'e',
 
341
    { .name = "global-env", .key = 'G',
331
342
      .arg = "VAR=value",
332
343
      .doc = "Environment variable passed to all plugins" },
333
344
    { .name = "options-for", .key = 'o',
334
345
      .arg = "PLUGIN:OPTION[,OPTION[,...]]",
335
346
      .doc = "Options passed only to specified plugin" },
336
 
    { .name = "envs-for", .key = 'f',
 
347
    { .name = "env-for", .key = 'E',
337
348
      .arg = "PLUGIN:ENV=value",
338
349
      .doc = "Environment variable passed to specified plugin" },
339
350
    { .name = "disable", .key = 'd',
340
351
      .arg = "PLUGIN",
341
352
      .doc = "Disable a specific plugin", .group = 1 },
 
353
    { .name = "enable", .key = 'e',
 
354
      .arg = "PLUGIN",
 
355
      .doc = "Enable a specific plugin", .group = 1 },
342
356
    { .name = "plugin-dir", .key = 128,
343
357
      .arg = "DIRECTORY",
344
358
      .doc = "Specify a different plugin directory", .group = 2 },
356
370
    { .name = NULL }
357
371
  };
358
372
  
359
 
  error_t parse_opt (int key, char *arg, __attribute__((unused)) struct argp_state *state) {
360
 
    /* Get the INPUT argument from `argp_parse', which we know is a
361
 
       pointer to our plugin list pointer. */
 
373
  error_t parse_opt (int key, char *arg, __attribute__((unused))
 
374
                     struct argp_state *state) {
362
375
    switch (key) {
363
376
    case 'g':                   /* --global-options */
364
377
      if (arg != NULL){
374
387
        }
375
388
      }
376
389
      break;
377
 
    case 'e':                   /* --global-envs */
 
390
    case 'G':                   /* --global-env */
378
391
      if(arg == NULL){
379
392
        break;
380
393
      }
381
 
      {
382
 
        char *envdef = strdup(arg);
383
 
        if(envdef == NULL){
384
 
          break;
385
 
        }
386
 
        if(not add_environment(getplugin(NULL), envdef)){
387
 
          perror("add_environment");
388
 
        }
 
394
      if(not add_environment(getplugin(NULL), arg, true)){
 
395
        perror("add_environment");
389
396
      }
390
397
      break;
391
398
    case 'o':                   /* --options-for */
392
399
      if (arg != NULL){
393
400
        char *p_name = strsep(&arg, ":");
394
 
        if(p_name[0] == '\0'){
 
401
        if(p_name[0] == '\0' or arg == NULL){
395
402
          break;
396
403
        }
397
404
        char *opt = strsep(&arg, ":");
398
 
        if(opt[0] == '\0'){
 
405
        if(opt[0] == '\0' or opt == NULL){
399
406
          break;
400
407
        }
401
 
        if(opt != NULL){
402
 
          char *p;
403
 
          while((p = strsep(&opt, ",")) != NULL){
404
 
            if(p[0] == '\0'){
405
 
              continue;
406
 
            }
407
 
            if(not add_argument(getplugin(p_name), p)){
408
 
              perror("add_argument");
409
 
              return ARGP_ERR_UNKNOWN;
410
 
            }
 
408
        char *p;
 
409
        while((p = strsep(&opt, ",")) != NULL){
 
410
          if(p[0] == '\0'){
 
411
            continue;
 
412
          }
 
413
          if(not add_argument(getplugin(p_name), p)){
 
414
            perror("add_argument");
 
415
            return ARGP_ERR_UNKNOWN;
411
416
          }
412
417
        }
413
418
      }
414
419
      break;
415
 
    case 'f':                   /* --envs-for */
 
420
    case 'E':                   /* --env-for */
416
421
      if(arg == NULL){
417
422
        break;
418
423
      }
421
426
        if(envdef == NULL){
422
427
          break;
423
428
        }
424
 
        char *p_name = strndup(arg, (size_t) (envdef-arg));
425
 
        if(p_name == NULL){
426
 
          break;
427
 
        }
428
 
        envdef++;
429
 
        if(not add_environment(getplugin(p_name), envdef)){
 
429
        *envdef = '\0';
 
430
        if(not add_environment(getplugin(arg), envdef+1, true)){
430
431
          perror("add_environment");
431
432
        }
432
433
      }
440
441
        p->disabled = true;
441
442
      }
442
443
      break;
 
444
    case 'e':                   /* --enable */
 
445
      if (arg != NULL){
 
446
        plugin *p = getplugin(arg);
 
447
        if(p == NULL){
 
448
          return ARGP_ERR_UNKNOWN;
 
449
        }
 
450
        p->disabled = false;
 
451
      }
 
452
      break;
443
453
    case 128:                   /* --plugin-dir */
 
454
      free(plugindir);
444
455
      plugindir = strdup(arg);
445
456
      if(plugindir == NULL){
446
457
        perror("strdup");
447
458
      }      
448
459
      break;
449
460
    case 129:                   /* --config-file */
 
461
      /* This is already done by parse_opt_config_file() */
 
462
      break;
 
463
    case 130:                   /* --userid */
 
464
      uid = (uid_t)strtol(arg, NULL, 10);
 
465
      break;
 
466
    case 131:                   /* --groupid */
 
467
      gid = (gid_t)strtol(arg, NULL, 10);
 
468
      break;
 
469
    case 132:                   /* --debug */
 
470
      debug = true;
 
471
      break;
 
472
    case ARGP_KEY_ARG:
 
473
      /* Cryptsetup always passes an argument, which is an empty
 
474
         string if "none" was specified in /etc/crypttab.  So if
 
475
         argument was empty, we ignore it silently. */
 
476
      if(arg[0] != '\0'){
 
477
        fprintf(stderr, "Ignoring unknown argument \"%s\"\n", arg);
 
478
      }
 
479
      break;
 
480
    case ARGP_KEY_END:
 
481
      break;
 
482
    default:
 
483
      return ARGP_ERR_UNKNOWN;
 
484
    }
 
485
    return 0;
 
486
  }
 
487
  
 
488
  /* This option parser is the same as parse_opt() above, except it
 
489
     ignores everything but the --config-file option. */
 
490
  error_t parse_opt_config_file (int key, char *arg,
 
491
                                 __attribute__((unused))
 
492
                                 struct argp_state *state) {
 
493
    switch (key) {
 
494
    case 'g':                   /* --global-options */
 
495
    case 'G':                   /* --global-env */
 
496
    case 'o':                   /* --options-for */
 
497
    case 'E':                   /* --env-for */
 
498
    case 'd':                   /* --disable */
 
499
    case 'e':                   /* --enable */
 
500
    case 128:                   /* --plugin-dir */
 
501
      break;
 
502
    case 129:                   /* --config-file */
 
503
      free(argfile);
450
504
      argfile = strdup(arg);
451
505
      if(argfile == NULL){
452
506
        perror("strdup");
453
507
      }
454
508
      break;      
455
509
    case 130:                   /* --userid */
456
 
      uid = (uid_t)strtol(arg, NULL, 10);
457
 
      break;
458
510
    case 131:                   /* --groupid */
459
 
      gid = (gid_t)strtol(arg, NULL, 10);
460
 
      break;
461
511
    case 132:                   /* --debug */
462
 
      debug = true;
463
 
      break;
464
512
    case ARGP_KEY_ARG:
465
 
      fprintf(stderr, "Ignoring unknown argument \"%s\"\n", arg);
466
 
      break;
467
513
    case ARGP_KEY_END:
468
514
      break;
469
515
    default:
472
518
    return 0;
473
519
  }
474
520
  
475
 
  struct argp argp = { .options = options, .parser = parse_opt,
476
 
                       .args_doc = "[+PLUS_SEPARATED_OPTIONS]",
 
521
  struct argp argp = { .options = options,
 
522
                       .parser = parse_opt_config_file,
 
523
                       .args_doc = "",
477
524
                       .doc = "Mandos plugin runner -- Run plugins" };
478
525
  
479
 
  ret = argp_parse (&argp, argc, argv, 0, 0, NULL);
 
526
  /* Parse using the parse_opt_config_file in order to get the custom
 
527
     config file location, if any. */
 
528
  ret = argp_parse (&argp, argc, argv, ARGP_IN_ORDER, 0, NULL);
480
529
  if (ret == ARGP_ERR_UNKNOWN){
481
530
    fprintf(stderr, "Unknown error while parsing arguments\n");
482
531
    exitstatus = EXIT_FAILURE;
483
532
    goto fallback;
484
533
  }
485
 
 
486
 
  /* Opens the configfile if aviable */
 
534
  
 
535
  /* Reset to the normal argument parser */
 
536
  argp.parser = parse_opt;
 
537
  
 
538
  /* Open the configfile if available */
487
539
  if (argfile == NULL){
488
540
    conffp = fopen(AFILE, "r");
489
541
  } else {
507
559
    custom_argv[0] = argv[0];
508
560
    custom_argv[1] = NULL;
509
561
 
510
 
    /* for each line in the config file, strip whitespace and ignore commented text */
 
562
    /* for each line in the config file, strip whitespace and ignore
 
563
       commented text */
511
564
    while(true){
512
565
      sret = getline(&org_line, &size, conffp);
513
566
      if(sret == -1){
542
595
      }
543
596
    }
544
597
    free(org_line);
545
 
  } else{
 
598
  } else {
546
599
    /* Check for harmful errors and go to fallback. Other errors might
547
600
       not affect opening plugins */
548
601
    if (errno == EMFILE or errno == ENFILE or errno == ENOMEM){
554
607
  /* If there was any arguments from configuration file,
555
608
     pass them to parser as command arguments */
556
609
  if(custom_argv != NULL){
557
 
    ret = argp_parse (&argp, custom_argc, custom_argv, 0, 0, NULL);
 
610
    ret = argp_parse (&argp, custom_argc, custom_argv, ARGP_IN_ORDER,
 
611
                      0, NULL);
558
612
    if (ret == ARGP_ERR_UNKNOWN){
559
613
      fprintf(stderr, "Unknown error while parsing arguments\n");
560
614
      exitstatus = EXIT_FAILURE;
562
616
    }
563
617
  }
564
618
  
 
619
  /* Parse actual command line arguments, to let them override the
 
620
     config file */
 
621
  ret = argp_parse (&argp, argc, argv, ARGP_IN_ORDER, 0, NULL);
 
622
  if (ret == ARGP_ERR_UNKNOWN){
 
623
    fprintf(stderr, "Unknown error while parsing arguments\n");
 
624
    exitstatus = EXIT_FAILURE;
 
625
    goto fallback;
 
626
  }
 
627
  
565
628
  if(debug){
566
629
    for(plugin *p = plugin_list; p != NULL; p=p->next){
567
630
      fprintf(stderr, "Plugin: %s has %d arguments\n",
575
638
      }
576
639
    }
577
640
  }
578
 
 
 
641
  
579
642
  /* Strip permissions down to nobody */
580
643
  ret = setuid(uid);
581
644
  if (ret == -1){
585
648
  if (ret == -1){
586
649
    perror("setgid");
587
650
  }
588
 
 
 
651
  
589
652
  if (plugindir == NULL){
590
653
    dir = opendir(PDIR);
591
654
  } else {
612
675
  }
613
676
  
614
677
  FD_ZERO(&rfds_all);
615
 
 
 
678
  
616
679
  /* Read and execute any executable in the plugin directory*/
617
680
  while(true){
618
681
    dirst = readdir(dir);
619
682
    
620
 
    // All directory entries have been processed
 
683
    /* All directory entries have been processed */
621
684
    if(dirst == NULL){
622
685
      if (errno == EBADF){
623
686
        perror("readdir");
629
692
    
630
693
    d_name_len = strlen(dirst->d_name);
631
694
    
632
 
    // Ignore dotfiles, backup files and other junk
 
695
    /* Ignore dotfiles, backup files and other junk */
633
696
    {
634
697
      bool bad_name = false;
635
698
      
673
736
    }
674
737
 
675
738
    char *filename;
676
 
    ret = asprintf(&filename, "%s/%s", plugindir, dirst->d_name);
 
739
    if(plugindir == NULL){
 
740
      ret = asprintf(&filename, PDIR "/%s", dirst->d_name);
 
741
    } else {
 
742
      ret = asprintf(&filename, "%s/%s", plugindir, dirst->d_name);
 
743
    }
677
744
    if(ret < 0){
678
745
      perror("asprintf");
679
746
      continue;
721
788
        }
722
789
        /* Add global environment variables */
723
790
        for(char **e = g->environ; *e != NULL; e++){
724
 
          if(not add_environment(p, *e)){
 
791
          if(not add_environment(p, *e, false)){
725
792
            perror("add_environment");
726
793
          }
727
794
        }
732
799
       process, too. */
733
800
    if(p->environ[0] != NULL){
734
801
      for(char **e = environ; *e != NULL; e++){
735
 
        char *copy = strdup(*e);
736
 
        if(copy == NULL){
737
 
          perror("strdup");
738
 
          continue;
739
 
        }
740
 
        if(not add_environment(p, copy)){
 
802
        if(not add_environment(p, *e, false)){
741
803
          perror("add_environment");
742
804
        }
743
805
      }
770
832
      exitstatus = EXIT_FAILURE;
771
833
      goto fallback;
772
834
    }
773
 
    // Starting a new process to be watched
 
835
    /* Starting a new process to be watched */
774
836
    pid_t pid = fork();
775
837
    if(pid == -1){
776
838
      perror("fork");
784
846
        perror("sigaction");
785
847
        _exit(EXIT_FAILURE);
786
848
      }
787
 
      ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask, NULL);
 
849
      ret = sigprocmask(SIG_UNBLOCK, &sigchld_action.sa_mask, NULL);
788
850
      if(ret < 0){
789
851
        perror("sigprocmask");
790
852
        _exit(EXIT_FAILURE);
791
853
      }
792
 
 
 
854
      
793
855
      ret = dup2(pipefd[1], STDOUT_FILENO); /* replace our stdout */
794
856
      if(ret == -1){
795
857
        perror("dup2");
845
907
    if (maxfd < new_plugin->fd){
846
908
      maxfd = new_plugin->fd;
847
909
    }
848
 
    
849
910
  }
850
911
  
851
912
  closedir(dir);
852
913
  dir = NULL;
853
 
 
 
914
  
854
915
  for(plugin *p = plugin_list; p != NULL; p = p->next){
855
916
    if(p->pid != 0){
856
917
      break;
861
922
      free_plugin_list();
862
923
    }
863
924
  }
864
 
 
 
925
  
865
926
  /* Main loop while running plugins exist */
866
927
  while(plugin_list){
867
928
    fd_set rfds = rfds_all;
873
934
    }
874
935
    /* OK, now either a process completed, or something can be read
875
936
       from one of them */
876
 
    for(plugin *proc = plugin_list; proc != NULL; proc = proc->next){
 
937
    for(plugin *proc = plugin_list; proc != NULL;){
877
938
      /* Is this process completely done? */
878
939
      if(proc->eof and proc->completed){
879
940
        /* Only accept the plugin output if it exited cleanly */
906
967
            exitstatus = EXIT_FAILURE;
907
968
            goto fallback;
908
969
          }
 
970
          
 
971
          plugin *next_plugin = proc->next;
909
972
          free_plugin(proc);
 
973
          proc = next_plugin;
 
974
          
910
975
          /* We are done modifying process list, so unblock signal */
911
976
          ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask,
912
977
                             NULL);
919
984
          if(plugin_list == NULL){
920
985
            break;
921
986
          }
 
987
          
922
988
          continue;
923
989
        }
924
990
        
925
991
        /* This process exited nicely, so print its buffer */
926
 
 
 
992
        
927
993
        bool bret = print_out_password(proc->buffer,
928
994
                                       proc->buffer_length);
929
995
        if(not bret){
936
1002
      /* This process has not completed.  Does it have any output? */
937
1003
      if(proc->eof or not FD_ISSET(proc->fd, &rfds)){
938
1004
        /* This process had nothing to say at this time */
 
1005
        proc = proc->next;
939
1006
        continue;
940
1007
      }
941
1008
      /* Before reading, make the process' data buffer large enough */
954
1021
                 BUFFER_SIZE);
955
1022
      if(ret < 0){
956
1023
        /* Read error from this process; ignore the error */
 
1024
        proc = proc->next;
957
1025
        continue;
958
1026
      }
959
1027
      if(ret == 0){
974
1042
    bool bret;
975
1043
    fprintf(stderr, "Going to fallback mode using getpass(3)\n");
976
1044
    char *passwordbuffer = getpass("Password: ");
977
 
    bret = print_out_password(passwordbuffer, strlen(passwordbuffer));
 
1045
    size_t len = strlen(passwordbuffer);
 
1046
    /* Strip trailing newline */
 
1047
    if(len > 0 and passwordbuffer[len-1] == '\n'){
 
1048
      passwordbuffer[len-1] = '\0'; /* not strictly necessary */
 
1049
      len--;
 
1050
    }
 
1051
    bret = print_out_password(passwordbuffer, len);
978
1052
    if(not bret){
979
1053
      perror("print_out_password");
980
1054
      exitstatus = EXIT_FAILURE;
987
1061
    perror("sigaction");
988
1062
    exitstatus = EXIT_FAILURE;
989
1063
  }
990
 
 
 
1064
  
991
1065
  if(custom_argv != NULL){
992
1066
    for(char **arg = custom_argv+1; *arg != NULL; arg++){
993
1067
      free(*arg);
999
1073
    closedir(dir);
1000
1074
  }
1001
1075
  
1002
 
  /* Free the process list and kill the processes */
 
1076
  /* Kill the processes */
1003
1077
  for(plugin *p = plugin_list; p != NULL; p = p->next){
1004
1078
    if(p->pid != 0){
1005
1079
      close(p->fd);
1018
1092
  if(errno != ECHILD){
1019
1093
    perror("wait");
1020
1094
  }
1021
 
 
 
1095
  
1022
1096
  free_plugin_list();
1023
1097
  
1024
1098
  free(plugindir);