/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 plugins.d/mandos-client.c

  • Committer: Teddy Hogeborn
  • Date: 2014-06-08 02:31:50 UTC
  • Revision ID: teddy@recompile.se-20140608023150-eu8jxll7uddjxter
Bug fix for mandos-client: Run the network hook, not the directory.

* plugins.d/mandos-client.d (set_cloexec_flag): Removed.
  (run_network_hooks): Do not set O_CLOEXEC on "hookdir_fd".
                       Instead, open hook to new "hook_fd" and simply
                       close(hookdir_fd) before fexecve().

Show diffs side-by-side

added added

removed removed

Lines of Context:
1510
1510
__attribute__((nonnull))
1511
1511
void run_network_hooks(const char *mode, const char *interface,
1512
1512
                       const float delay){
1513
 
  struct dirent **direntries = NULL;
 
1513
  struct dirent **direntries;
1514
1514
  if(hookdir_fd == -1){
1515
1515
    hookdir_fd = open(hookdir, O_RDONLY);
1516
1516
    if(hookdir_fd == -1){
1670
1670
                   direntry->d_name);
1671
1671
    }
1672
1672
  }
1673
 
  free(direntries);
1674
1673
  if((int)TEMP_FAILURE_RETRY(close(hookdir_fd)) == -1){
1675
1674
    perror_plus("close");
1676
1675
  } else {
2254
2253
  
2255
2254
  /* If no interfaces were specified, make a list */
2256
2255
  if(mc.interfaces == NULL){
2257
 
    struct dirent **direntries = NULL;
 
2256
    struct dirent **direntries;
2258
2257
    /* Look for any good interfaces */
2259
2258
    ret = scandir(sys_class_net, &direntries, good_interface,
2260
2259
                  alphasort);
2275
2274
      }
2276
2275
      free(direntries);
2277
2276
    } else {
2278
 
      if(ret == 0){
2279
 
        free(direntries);
2280
 
      }
 
2277
      free(direntries);
2281
2278
      fprintf_plus(stderr, "Could not find a network interface\n");
2282
2279
      exitcode = EXIT_FAILURE;
2283
2280
      goto end;
2594
2591
  /* Removes the GPGME temp directory and all files inside */
2595
2592
  if(tempdir != NULL){
2596
2593
    struct dirent **direntries = NULL;
2597
 
    int tempdir_fd = (int)TEMP_FAILURE_RETRY(open(tempdir, O_RDONLY |
2598
 
                                                  O_NOFOLLOW));
 
2594
    int tempdir_fd = (int)TEMP_FAILURE_RETRY(open(tempdir, O_RDONLY));
2599
2595
    if(tempdir_fd == -1){
2600
2596
      perror_plus("open");
2601
2597
    } else {
2611
2607
      int numentries = scandir(tempdir, &direntries, notdotentries,
2612
2608
                               alphasort);
2613
2609
#endif  /* not __GLIBC__ */
2614
 
      if(numentries >= 0){
 
2610
      if(numentries > 0){
2615
2611
        for(int i = 0; i < numentries; i++){
2616
2612
          ret = unlinkat(tempdir_fd, direntries[i]->d_name, 0);
2617
2613
          if(ret == -1){