/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

* initramfs-tools-hook: Bug fix: Really install user-supplied plugins.
                        Bug fix: Warn about empty plugin directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
230
230
 | [[info:libc:Descriptor%20Flags][File Descriptor Flags]] |
231
231
 */
232
232
static int set_cloexec_flag(int fd){
233
 
  int ret = (int)TEMP_FAILURE_RETRY(fcntl(fd, F_GETFD, 0));
 
233
  int ret = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFD, 0));
234
234
  /* If reading the flags failed, return error indication now. */
235
235
  if(ret < 0){
236
236
    return ret;
237
237
  }
238
238
  /* Store modified flag word in the descriptor. */
239
 
  return (int)TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD,
240
 
                                       ret | FD_CLOEXEC));
 
239
  return TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, ret | FD_CLOEXEC));
241
240
}
242
241
 
243
242
 
789
788
    
790
789
    char *filename;
791
790
    if(plugindir == NULL){
792
 
      ret = (int)TEMP_FAILURE_RETRY(asprintf(&filename, PDIR "/%s",
793
 
                                             dirst->d_name));
 
791
      ret = TEMP_FAILURE_RETRY(asprintf(&filename, PDIR "/%s",
 
792
                                        dirst->d_name));
794
793
    } else {
795
 
      ret = (int)TEMP_FAILURE_RETRY(asprintf(&filename, "%s/%s",
796
 
                                             plugindir,
797
 
                                             dirst->d_name));
 
794
      ret = TEMP_FAILURE_RETRY(asprintf(&filename, "%s/%s", plugindir,
 
795
                                        dirst->d_name));
798
796
    }
799
797
    if(ret < 0){
800
798
      perror("asprintf");
801
799
      continue;
802
800
    }
803
801
    
804
 
    ret = (int)TEMP_FAILURE_RETRY(stat(filename, &st));
 
802
    ret = TEMP_FAILURE_RETRY(stat(filename, &st));
805
803
    if(ret == -1){
806
804
      perror("stat");
807
805
      free(filename);
862
860
    }
863
861
    
864
862
    int pipefd[2];
865
 
    ret = (int)TEMP_FAILURE_RETRY(pipe(pipefd));
 
863
    ret = TEMP_FAILURE_RETRY(pipe(pipefd));
866
864
    if(ret == -1){
867
865
      perror("pipe");
868
866
      exitstatus = EXIT_FAILURE;
882
880
      goto fallback;
883
881
    }
884
882
    /* Block SIGCHLD until process is safely in process list */
885
 
    ret = (int)TEMP_FAILURE_RETRY(sigprocmask(SIG_BLOCK,
886
 
                                              &sigchld_action.sa_mask,
887
 
                                              NULL));
 
883
    ret = TEMP_FAILURE_RETRY(sigprocmask(SIG_BLOCK,
 
884
                                         &sigchld_action.sa_mask,
 
885
                                         NULL));
888
886
    if(ret < 0){
889
887
      perror("sigprocmask");
890
888
      exitstatus = EXIT_FAILURE;
944
942
    plugin *new_plugin = getplugin(dirst->d_name);
945
943
    if(new_plugin == NULL){
946
944
      perror("getplugin");
947
 
      ret = (int)(TEMP_FAILURE_RETRY
948
 
                  (sigprocmask(SIG_UNBLOCK, &sigchld_action.sa_mask,
949
 
                               NULL)));
 
945
      ret = TEMP_FAILURE_RETRY(sigprocmask(SIG_UNBLOCK,
 
946
                                           &sigchld_action.sa_mask,
 
947
                                           NULL));
950
948
      if(ret < 0){
951
949
        perror("sigprocmask");
952
950
      }
959
957
    
960
958
    /* Unblock SIGCHLD so signal handler can be run if this process
961
959
       has already completed */
962
 
    ret = (int)TEMP_FAILURE_RETRY(sigprocmask(SIG_UNBLOCK,
963
 
                                              &sigchld_action.sa_mask,
964
 
                                              NULL));
 
960
    ret = TEMP_FAILURE_RETRY(sigprocmask(SIG_UNBLOCK,
 
961
                                         &sigchld_action.sa_mask,
 
962
                                         NULL));
965
963
    if(ret < 0){
966
964
      perror("sigprocmask");
967
965
      exitstatus = EXIT_FAILURE;
1031
1029
          FD_CLR(proc->fd, &rfds_all);
1032
1030
          
1033
1031
          /* Block signal while modifying process_list */
1034
 
          ret = (int)TEMP_FAILURE_RETRY(sigprocmask
1035
 
                                        (SIG_BLOCK,
1036
 
                                         &sigchld_action.sa_mask,
1037
 
                                         NULL));
 
1032
          ret = TEMP_FAILURE_RETRY(sigprocmask(SIG_BLOCK,
 
1033
                                               &sigchld_action.sa_mask,
 
1034
                                               NULL));
1038
1035
          if(ret < 0){
1039
1036
            perror("sigprocmask");
1040
1037
            exitstatus = EXIT_FAILURE;
1046
1043
          proc = next_plugin;
1047
1044
          
1048
1045
          /* We are done modifying process list, so unblock signal */
1049
 
          ret = (int)(TEMP_FAILURE_RETRY
1050
 
                      (sigprocmask(SIG_UNBLOCK,
1051
 
                                   &sigchld_action.sa_mask, NULL)));
 
1046
          ret = TEMP_FAILURE_RETRY(sigprocmask(SIG_UNBLOCK,
 
1047
                                               &sigchld_action.sa_mask,
 
1048
                                               NULL));
1052
1049
          if(ret < 0){
1053
1050
            perror("sigprocmask");
1054
1051
            exitstatus = EXIT_FAILURE;