/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: 2014-06-14 22:55:11 UTC
  • Revision ID: teddy@recompile.se-20140614225511-0ge6tce2esulf65t
In plugin-runner, do scandirat() or scandir() instead of readdir().

* plugin-runner.c (set_cloexec_flag): Only define if O_CLOEXEC is not
                                      defined, it is not called
                                      otherwise.
  (main): Remove variables "dir" and "dirst"; new variable "dir_fd".
          Use scandirat() if available, scandir() otherwise, both
          using new filter function "good_name".  Removed checking of
          plugin file name patterns; this is now done by "good_name".
          Do not set FD_CLOEXEC flag on plugin_fd, since fexecve()
          will not work with it.  Use pipe2() to set O_CLOEXEC on pipe
          FD's (if possible).
  (main/good_name): New filter function for scandirat() or scandir().

Show diffs side-by-side

added added

removed removed

Lines of Context:
349
349
  char *plugindir = NULL;
350
350
  char *argfile = NULL;
351
351
  FILE *conffp;
352
 
  struct dirent **direntries = NULL;
 
352
  struct dirent **direntries;
353
353
  struct stat st;
354
354
  fd_set rfds_all;
355
355
  int ret, maxfd = 0;
829
829
    ret = set_cloexec_flag(dir_fd);
830
830
    if(ret < 0){
831
831
      error(0, errno, "set_cloexec_flag");
 
832
      TEMP_FAILURE_RETRY(close(dir_fd));
832
833
      exitstatus = EX_OSERR;
833
834
      goto fallback;
834
835
    }
874
875
#endif  /* not __GLIBC__ */
875
876
  if(numplugins == -1){
876
877
    error(0, errno, "Could not scan plugin dir");
877
 
    direntries = NULL;
 
878
    TEMP_FAILURE_RETRY(close(dir_fd));
878
879
    exitstatus = EX_OSERR;
879
880
    goto fallback;
880
881
  }
1091
1092
    }
1092
1093
  }
1093
1094
  
1094
 
  free(direntries);
1095
 
  direntries = NULL;
1096
1095
  TEMP_FAILURE_RETRY(close(dir_fd));
1097
 
  dir_fd = -1;
1098
1096
  free_plugin(getplugin(NULL));
1099
1097
  
1100
1098
  for(plugin *p = plugin_list; p != NULL; p = p->next){
1294
1292
    free(custom_argv);
1295
1293
  }
1296
1294
  
1297
 
  free(direntries);
1298
 
  
1299
1295
  if(dir_fd != -1){
1300
1296
    TEMP_FAILURE_RETRY(close(dir_fd));
1301
1297
  }