/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-11-01 02:26:00 UTC
  • Revision ID: teddy@fukt.bsnet.se-20081101022600-bacs9fxmsliqrah1
* initramfs-tools-hook: Also ignore plugins named "*.dpkg-bak".
* plugin-runner.c: - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
75
typedef struct plugin{
700
700
      
701
701
      const char const *bad_suffixes[] = { "~", "#", ".dpkg-new",
702
702
                                           ".dpkg-old",
 
703
                                           ".dpkg-bak",
703
704
                                           ".dpkg-divert", NULL };
704
705
      for(const char **pre = bad_prefixes; *pre != NULL; pre++){
705
706
        size_t pre_len = strlen(*pre);
846
847
        perror("sigaction");
847
848
        _exit(EXIT_FAILURE);
848
849
      }
849
 
      ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask, NULL);
 
850
      ret = sigprocmask(SIG_UNBLOCK, &sigchld_action.sa_mask, NULL);
850
851
      if(ret < 0){
851
852
        perror("sigprocmask");
852
853
        _exit(EXIT_FAILURE);
853
854
      }
854
 
 
 
855
      
855
856
      ret = dup2(pipefd[1], STDOUT_FILENO); /* replace our stdout */
856
857
      if(ret == -1){
857
858
        perror("dup2");
907
908
    if (maxfd < new_plugin->fd){
908
909
      maxfd = new_plugin->fd;
909
910
    }
910
 
    
911
911
  }
912
912
  
913
913
  closedir(dir);
914
914
  dir = NULL;
915
 
 
 
915
  
916
916
  for(plugin *p = plugin_list; p != NULL; p = p->next){
917
917
    if(p->pid != 0){
918
918
      break;
923
923
      free_plugin_list();
924
924
    }
925
925
  }
926
 
 
 
926
  
927
927
  /* Main loop while running plugins exist */
928
928
  while(plugin_list){
929
929
    fd_set rfds = rfds_all;
969
969
            goto fallback;
970
970
          }
971
971
          
 
972
          plugin *next_plugin = proc->next;
 
973
          free_plugin(proc);
 
974
          proc = next_plugin;
 
975
          
972
976
          /* We are done modifying process list, so unblock signal */
973
977
          ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask,
974
978
                             NULL);
982
986
            break;
983
987
          }
984
988
          
985
 
          plugin *next_plugin = proc->next;
986
 
          free_plugin(proc);
987
 
          proc = next_plugin;
988
989
          continue;
989
990
        }
990
991
        
991
992
        /* This process exited nicely, so print its buffer */
992
 
 
 
993
        
993
994
        bool bret = print_out_password(proc->buffer,
994
995
                                       proc->buffer_length);
995
996
        if(not bret){
1061
1062
    perror("sigaction");
1062
1063
    exitstatus = EXIT_FAILURE;
1063
1064
  }
1064
 
 
 
1065
  
1065
1066
  if(custom_argv != NULL){
1066
1067
    for(char **arg = custom_argv+1; *arg != NULL; arg++){
1067
1068
      free(*arg);
1073
1074
    closedir(dir);
1074
1075
  }
1075
1076
  
1076
 
  /* Free the process list and kill the processes */
 
1077
  /* Kill the processes */
1077
1078
  for(plugin *p = plugin_list; p != NULL; p = p->next){
1078
1079
    if(p->pid != 0){
1079
1080
      close(p->fd);
1092
1093
  if(errno != ECHILD){
1093
1094
    perror("wait");
1094
1095
  }
1095
 
 
 
1096
  
1096
1097
  free_plugin_list();
1097
1098
  
1098
1099
  free(plugindir);