/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:33:54 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080906163354-x2l238fvbs2xashj
* .bzrignore: Rename "password-request" to "mandos-client".

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");
473
482
      debug = true;
474
483
      break;
475
484
    case ARGP_KEY_ARG:
476
 
      /* Cryptsetup always passes an argument, which is an empty
477
 
         string if "none" was specified in /etc/crypttab.  So if
478
 
         argument was empty, we ignore it silently. */
479
 
      if(arg[0] != '\0'){
480
 
        fprintf(stderr, "Ignoring unknown argument \"%s\"\n", arg);
481
 
      }
 
485
      fprintf(stderr, "Ignoring unknown argument \"%s\"\n", arg);
482
486
      break;
483
487
    case ARGP_KEY_END:
484
488
      break;
503
507
    case 128:                   /* --plugin-dir */
504
508
      break;
505
509
    case 129:                   /* --config-file */
506
 
      free(argfile);
507
510
      argfile = strdup(arg);
508
511
      if(argfile == NULL){
509
512
        perror("strdup");
938
941
    }
939
942
    /* OK, now either a process completed, or something can be read
940
943
       from one of them */
941
 
    for(plugin *proc = plugin_list; proc != NULL;){
 
944
    for(plugin *proc = plugin_list; proc != NULL; proc = proc->next){
942
945
      /* Is this process completely done? */
943
946
      if(proc->eof and proc->completed){
944
947
        /* Only accept the plugin output if it exited cleanly */
971
974
            exitstatus = EXIT_FAILURE;
972
975
            goto fallback;
973
976
          }
974
 
          
 
977
          free_plugin(proc);
975
978
          /* We are done modifying process list, so unblock signal */
976
979
          ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask,
977
980
                             NULL);
984
987
          if(plugin_list == NULL){
985
988
            break;
986
989
          }
987
 
          
988
 
          plugin *next_plugin = proc->next;
989
 
          free_plugin(proc);
990
 
          proc = next_plugin;
991
990
          continue;
992
991
        }
993
992
        
1005
1004
      /* This process has not completed.  Does it have any output? */
1006
1005
      if(proc->eof or not FD_ISSET(proc->fd, &rfds)){
1007
1006
        /* This process had nothing to say at this time */
1008
 
        proc = proc->next;
1009
1007
        continue;
1010
1008
      }
1011
1009
      /* Before reading, make the process' data buffer large enough */
1024
1022
                 BUFFER_SIZE);
1025
1023
      if(ret < 0){
1026
1024
        /* Read error from this process; ignore the error */
1027
 
        proc = proc->next;
1028
1025
        continue;
1029
1026
      }
1030
1027
      if(ret == 0){