/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: 2015-07-02 18:22:22 UTC
  • mto: This revision was merged to the branch mainline in revision 759.
  • Revision ID: teddy@recompile.se-20150702182222-034v03mb8orwhezn
mandos-client: Minor changes to check for more error conditions.

* mandos-client.c (add_remove_local_route): Do TEMP_FAILURE_RETRY
                                            around closing of
                                            /dev/null.  Check return
                                            value when opening helper
                                            directory and helper
                                            executable.
  (run_network_hooks): Cast return value of TEMP_FAILURE_RETRY to int.
                       Do TEMP_FAILURE_RETRY around closing of
                       /dev/null.

Show diffs side-by-side

added added

removed removed

Lines of Context:
760
760
      perror_plus("dup2(devnull, STDIN_FILENO)");
761
761
      _exit(EX_OSERR);
762
762
    }
763
 
    ret = close(devnull);
 
763
    ret = (int)TEMP_FAILURE_RETRY(close(devnull));
764
764
    if(ret == -1){
765
765
      perror_plus("close");
766
766
      _exit(EX_OSERR);
775
775
                                                    | O_DIRECTORY
776
776
                                                    | O_PATH
777
777
                                                    | O_CLOEXEC));
 
778
    if(helperdir_fd == -1){
 
779
      perror_plus("open");
 
780
      _exit(EX_UNAVAILABLE);
 
781
    }
778
782
    int helper_fd = (int)TEMP_FAILURE_RETRY(openat(helperdir_fd,
779
783
                                                   helper, O_RDONLY));
 
784
    if(helper_fd == -1){
 
785
      perror_plus("openat");
 
786
      _exit(EX_UNAVAILABLE);
 
787
    }
780
788
    TEMP_FAILURE_RETRY(close(helperdir_fd));
781
789
#ifdef __GNUC__
782
790
#pragma GCC diagnostic push
1813
1821
          _exit(EX_OSERR);
1814
1822
        }
1815
1823
      }
1816
 
      int hook_fd = TEMP_FAILURE_RETRY(openat(hookdir_fd,
1817
 
                                              direntry->d_name,
1818
 
                                              O_RDONLY));
 
1824
      int hook_fd = (int)TEMP_FAILURE_RETRY(openat(hookdir_fd,
 
1825
                                                   direntry->d_name,
 
1826
                                                   O_RDONLY));
1819
1827
      if(hook_fd == -1){
1820
1828
        perror_plus("openat");
1821
1829
        _exit(EXIT_FAILURE);
1829
1837
        perror_plus("dup2(devnull, STDIN_FILENO)");
1830
1838
        _exit(EX_OSERR);
1831
1839
      }
1832
 
      ret = close(devnull);
 
1840
      ret = (int)TEMP_FAILURE_RETRY(close(devnull));
1833
1841
      if(ret == -1){
1834
1842
        perror_plus("close");
1835
1843
        _exit(EX_OSERR);