/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: 2008-09-06 16:11:50 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080906161150-1umb8yz6a29zxg28
* Makefile (install-client): Add "/etc/plugins.d/README".
  (uninstall-client): Remove "/etc/plugins.d/README".

* etc-plugins.d-README: New file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
394
394
      if(arg == NULL){
395
395
        break;
396
396
      }
397
 
      if(not add_environment(getplugin(NULL), arg, true)){
398
 
        perror("add_environment");
 
397
      {
 
398
        char *envdef = strdup(arg);
 
399
        if(envdef == NULL){
 
400
          break;
 
401
        }
 
402
        if(not add_environment(getplugin(NULL), envdef, true)){
 
403
          perror("add_environment");
 
404
        }
399
405
      }
400
406
      break;
401
407
    case 'o':                   /* --options-for */
429
435
        if(envdef == NULL){
430
436
          break;
431
437
        }
432
 
        *envdef = '\0';
433
 
        if(not add_environment(getplugin(arg), envdef+1, true)){
 
438
        char *p_name = strndup(arg, (size_t) (envdef-arg));
 
439
        if(p_name == NULL){
 
440
          break;
 
441
        }
 
442
        envdef++;
 
443
        if(not add_environment(getplugin(p_name), envdef, true)){
434
444
          perror("add_environment");
435
445
        }
436
446
      }
454
464
      }
455
465
      break;
456
466
    case 128:                   /* --plugin-dir */
457
 
      free(plugindir);
458
467
      plugindir = strdup(arg);
459
468
      if(plugindir == NULL){
460
469
        perror("strdup");
498
507
    case 128:                   /* --plugin-dir */
499
508
      break;
500
509
    case 129:                   /* --config-file */
501
 
      free(argfile);
502
510
      argfile = strdup(arg);
503
511
      if(argfile == NULL){
504
512
        perror("strdup");
933
941
    }
934
942
    /* OK, now either a process completed, or something can be read
935
943
       from one of them */
936
 
    for(plugin *proc = plugin_list; proc != NULL;){
 
944
    for(plugin *proc = plugin_list; proc != NULL; proc = proc->next){
937
945
      /* Is this process completely done? */
938
946
      if(proc->eof and proc->completed){
939
947
        /* Only accept the plugin output if it exited cleanly */
966
974
            exitstatus = EXIT_FAILURE;
967
975
            goto fallback;
968
976
          }
969
 
          
 
977
          free_plugin(proc);
970
978
          /* We are done modifying process list, so unblock signal */
971
979
          ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask,
972
980
                             NULL);
979
987
          if(plugin_list == NULL){
980
988
            break;
981
989
          }
982
 
          
983
 
          plugin *next_plugin = proc->next;
984
 
          free_plugin(proc);
985
 
          proc = next_plugin;
986
990
          continue;
987
991
        }
988
992
        
1000
1004
      /* This process has not completed.  Does it have any output? */
1001
1005
      if(proc->eof or not FD_ISSET(proc->fd, &rfds)){
1002
1006
        /* This process had nothing to say at this time */
1003
 
        proc = proc->next;
1004
1007
        continue;
1005
1008
      }
1006
1009
      /* Before reading, make the process' data buffer large enough */
1019
1022
                 BUFFER_SIZE);
1020
1023
      if(ret < 0){
1021
1024
        /* Read error from this process; ignore the error */
1022
 
        proc = proc->next;
1023
1025
        continue;
1024
1026
      }
1025
1027
      if(ret == 0){