/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-03-23 20:48:58 UTC
  • Revision ID: teddy@recompile.se-20140323204858-l1x3aiick21oog4y
Improve error message when working around Debian bug #633582.

* plugins-runner.c (main): Improve error message when failing to work
                           around Debian bug #633582.  Also simplify
                           code to always use execve().

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
                                   F_GETFD, F_SETFD, FD_CLOEXEC,
50
50
                                   access(), pipe(), fork(), close()
51
51
                                   dup2(), STDOUT_FILENO, _exit(),
52
 
                                   execv(), write(), read(),
 
52
                                   execve(), write(), read(),
53
53
                                   close() */
54
54
#include <fcntl.h>              /* fcntl(), F_GETFD, F_SETFD,
55
55
                                   FD_CLOEXEC */
779
779
       <http://bugs.debian.org/633582> */
780
780
    int plugindir_fd = open(/* plugindir or */ PDIR, O_RDONLY);
781
781
    if(plugindir_fd == -1){
782
 
      error(0, errno, "open");
 
782
      error(0, errno, "open(\"" PDIR "\")");
783
783
    } else {
784
784
      ret = (int)TEMP_FAILURE_RETRY(fstat(plugindir_fd, &st));
785
785
      if(ret == -1){
1069
1069
           above and must now close it manually here. */
1070
1070
        closedir(dir);
1071
1071
      }
1072
 
      if(p->environ[0] == NULL){
1073
 
        if(execv(filename, p->argv) < 0){
1074
 
          error(0, errno, "execv for %s", filename);
1075
 
          _exit(EX_OSERR);
1076
 
        }
1077
 
      } else {
1078
 
        if(execve(filename, p->argv, p->environ) < 0){
1079
 
          error(0, errno, "execve for %s", filename);
1080
 
          _exit(EX_OSERR);
1081
 
        }
 
1072
      if(execve(filename, p->argv,
 
1073
                (p->environ[0] != NULL) ? p->environ : environ) < 0){
 
1074
        error(0, errno, "execve for %s", filename);
 
1075
        _exit(EX_OSERR);
1082
1076
      }
1083
1077
      /* no return */
1084
1078
    }