[Pkg-gnupg-commit] [libassuan] 50/437: * gpgsm.c (main): Use GNUPG_DEFAULT_HOMEDIR constant.

Eric Dorland eric at moszumanska.debian.org
Fri May 22 05:33:22 UTC 2015


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository libassuan.

commit 6b39e12ea4d8c029e82ee8495355105100af2d28
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jun 27 07:29:51 2002 +0000

    * gpgsm.c (main): Use GNUPG_DEFAULT_HOMEDIR constant.
    
    * call-agent.c (start_agent): Create and pass the list of FD to
    keep in the child to assuan.
    * call-dirmngr.c (start_dirmngr): Ditto.
    
    * scdaemon.c (main): Use GNUPG_DEFAULT_HOMEDIR constant.
    
    * assuan-pipe-connect.c (assuan_pipe_connect): No special handling
    for the log_fd and stderr.  Connect stderr to /dev/null if it
    should not be retained.
---
 src/ChangeLog             |  6 ++++++
 src/assuan-pipe-connect.c | 43 +++++++++++++++++++++++++++++++------------
 2 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 8b9bd3f..0a420fe 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2002-06-27  Werner Koch  <wk at gnupg.org>
+
+	* assuan-pipe-connect.c (assuan_pipe_connect): No special handling
+	for the log_fd and stderr.  Connect stderr to /dev/null if it
+	should not be retained.
+
 2002-06-26  Werner Koch  <wk at gnupg.org>
 
 	* assuan-buffer.c (assuan_write_line): Make sure we never
diff --git a/src/assuan-pipe-connect.c b/src/assuan-pipe-connect.c
index ccfc1f0..40f6b54 100644
--- a/src/assuan-pipe-connect.c
+++ b/src/assuan-pipe-connect.c
@@ -28,6 +28,7 @@
 #include <signal.h>
 #include <unistd.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 
@@ -169,18 +170,16 @@ assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[],
     {
       int i, n;
       char errbuf[512];
-#ifdef HAVE_JNLIB_LOGGING
-      int log_fd = log_get_fd (); 
-#endif
-      /* close all files which will not be duped but keep stderr
-         and log_stream for now */
+      int *fdp;
+
+      /* Close all files which will not be duped and are not in the
+         fd_child_list. */
       n = sysconf (_SC_OPEN_MAX);
       if (n < 0)
         n = MAX_OPEN_FDS;
       for (i=0; i < n; i++)
         {
-	  int *fdp = fd_child_list;
-
+	  fdp = fd_child_list;
 	  if (fdp)
 	    {
 	      while (*fdp != -1 && *fdp != i)
@@ -188,16 +187,36 @@ assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[],
 	    }
 
           if (!(fdp && *fdp != -1)
-	      && i != fileno (stderr) 
-#ifdef HAVE_JNLIB_LOGGING
-              && i != log_fd
-#endif
               && i != rp[1] && i != wp[0])
             close(i);
         }
       errno = 0;
 
-      /* Dup handles and to stdin/stdout and exec */
+      /* Dup stderr to /dev/null unless it is in the list of FDs to be
+         passed to the child. */
+      fdp = fd_child_list;
+      if (fdp)
+        {
+          for (; *fdp != -1 && *fdp != STDERR_FILENO; fdp++)
+            ;
+        }
+      if (!fdp || *fdp == -1)
+        {
+	  int fd = open ("/dev/null", O_WRONLY);
+	  if (fd == -1)
+	    {
+	      LOGERROR1 ("can't open `/dev/null': %s\n", strerror (errno));
+	      _exit (4);
+            }
+          if (dup2 (fd, STDERR_FILENO) == -1)
+            {
+              LOGERROR1 ("dup2(dev/null, 2) failed: %s\n", strerror (errno));
+              _exit (4);
+            }
+	  close (fd);
+        }
+
+      /* Dup handles and to stdin/stdout and exec. */
       if (rp[1] != STDOUT_FILENO)
         {
           if (dup2 (rp[1], STDOUT_FILENO) == -1)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git



More information about the Pkg-gnupg-commit mailing list