[git] Assuan - branch, master, updated. libassuan-2.0.2-7-gedbe8fd

by Werner Koch cvs at cvs.gnupg.org
Tue Dec 13 19:19:51 CET 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPC library used by GnuPG".

The branch, master has been updated
       via  edbe8fdcea1a2c05999861f58d5f67d2e76610e0 (commit)
       via  ff9a8c2e64ea2345f2ebe85a527b7c43033ba53e (commit)
      from  165a57d29d2ac84159aa48b171b6098c629bc798 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit edbe8fdcea1a2c05999861f58d5f67d2e76610e0
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Dec 13 18:27:06 2011 +0100

    Fix assuan_get_pid for pipe servers.
    
    At some point in the past we introduced a regression in that the
    client of a pipe server received its own pid and not the pid of
    the server.
    
    * src/assuan-pipe-connect.c (struct at_pipe_fork)
    (struct at_socketpair_fork): Add PARENT_PID.
    (at_pipe_fork_cb, at_socketpair_fork): Use PARENT_PID instead of getpid.
    (pipe_connect, socketpair_connect): Set PARENT_PID.

diff --git a/NEWS b/NEWS
index 6514943..9775be2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 Noteworthy changes in version 2.0.3 (unreleased)
 ------------------------------------------------
 
+ * Make assuan_get_pid work correctly for pipe server.
+
  * Interface changes relative to the 2.0.2 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ASSUAN_FORCE_CLOSE       NEW.
diff --git a/src/assuan-pipe-connect.c b/src/assuan-pipe-connect.c
index d8c71e6..edc8dbb 100644
--- a/src/assuan-pipe-connect.c
+++ b/src/assuan-pipe-connect.c
@@ -1,5 +1,6 @@
-/* assuan-pipe-connect.c - Establish a pipe connection (client) 
-   Copyright (C) 2001-2003, 2005-2007, 2009 Free Software Foundation, Inc.
+/* assuan-pipe-connect.c - Establish a pipe connection (client)
+   Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, 2009, 2010,
+                 2011 Free Software Foundation, Inc.
 
    This file is part of Assuan.
 
@@ -26,7 +27,7 @@
 #include <string.h>
 /* On Windows systems signal.h is not needed and even not supported on
    WindowsCE. */
-#ifndef HAVE_DOSISH_SYSTEM 
+#ifndef HAVE_DOSISH_SYSTEM
 # include <signal.h>
 #endif
 #ifdef HAVE_UNISTD_H
@@ -44,7 +45,7 @@
 #else
 # ifdef HAVE_WINSOCK2_H
 #  include <winsock2.h>
-# endif 
+# endif
 # include <windows.h>
 #endif
 
@@ -79,9 +80,9 @@ fix_signals (void)
   static int fixed_signals;
 
   if (!fixed_signals)
-    { 
+    {
       struct sigaction act;
-        
+
       sigaction (SIGPIPE, NULL, &act);
       if (act.sa_handler == SIG_DFL)
 	{
@@ -104,7 +105,7 @@ initial_handshake (assuan_context_t ctx)
   assuan_response_t response;
   int off;
   gpg_error_t err;
-  
+
   err = _assuan_read_from_server (ctx, &response, &off, 0);
   if (err)
     TRACE1 (ctx, ASSUAN_LOG_SYSIO, "initial_handshake", ctx,
@@ -124,6 +125,7 @@ struct at_pipe_fork
 {
   void (*user_atfork) (void *opaque, int reserved);
   void *user_atforkvalue;
+  pid_t parent_pid;
 };
 
 
@@ -131,19 +133,19 @@ static void
 at_pipe_fork_cb (void *opaque, int reserved)
 {
   struct at_pipe_fork *atp = opaque;
-          
+
   if (atp->user_atfork)
     atp->user_atfork (atp->user_atforkvalue, reserved);
 
 #ifndef HAVE_W32_SYSTEM
   {
     char mypidstr[50];
-    
+
     /* We store our parents pid in the environment so that the execed
        assuan server is able to read the actual pid of the client.
        The server can't use getppid because it might have been double
        forked before the assuan server has been initialized. */
-    sprintf (mypidstr, "%lu", (unsigned long) getpid ());
+    sprintf (mypidstr, "%lu", (unsigned long) atp->parent_pid);
     setenv ("_assuan_pipe_connect_pid", mypidstr, 1);
 
     /* Make sure that we never pass a connection fd variable when
@@ -171,6 +173,7 @@ pipe_connect (assuan_context_t ctx,
 
   atp.user_atfork = atfork;
   atp.user_atforkvalue = atforkvalue;
+  atp.parent_pid = getpid ();
 
   if (!ctx || !name || !argv || !argv[0])
     return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
@@ -180,14 +183,14 @@ pipe_connect (assuan_context_t ctx,
 
   if (_assuan_pipe (ctx, rp, 1) < 0)
     return _assuan_error (ctx, gpg_err_code_from_syserror ());
-  
+
   if (_assuan_pipe (ctx, wp, 0) < 0)
     {
       _assuan_close (ctx, rp[0]);
       _assuan_close_inheritable (ctx, rp[1]);
       return _assuan_error (ctx, gpg_err_code_from_syserror ());
     }
-  
+
   spawn_flags = 0;
   if (flags & ASSUAN_PIPE_CONNECT_DETACHED)
     spawn_flags |= ASSUAN_SPAWN_DETACHED;
@@ -238,6 +241,7 @@ struct at_socketpair_fork
   assuan_fd_t peer_fd;
   void (*user_atfork) (void *opaque, int reserved);
   void *user_atforkvalue;
+  pid_t parent_pid;
 };
 
 
@@ -245,19 +249,19 @@ static void
 at_socketpair_fork_cb (void *opaque, int reserved)
 {
   struct at_socketpair_fork *atp = opaque;
-          
+
   if (atp->user_atfork)
     atp->user_atfork (atp->user_atforkvalue, reserved);
 
 #ifndef HAVE_W32_SYSTEM
   {
     char mypidstr[50];
-    
+
     /* We store our parents pid in the environment so that the execed
        assuan server is able to read the actual pid of the client.
        The server can't use getppid because it might have been double
        forked before the assuan server has been initialized. */
-    sprintf (mypidstr, "%lu", (unsigned long) getpid ());
+    sprintf (mypidstr, "%lu", (unsigned long) atp->parent_pid);
     setenv ("_assuan_pipe_connect_pid", mypidstr, 1);
 
     /* Now set the environment variable used to convey the
@@ -295,6 +299,7 @@ socketpair_connect (assuan_context_t ctx,
 
   atp.user_atfork = atfork;
   atp.user_atforkvalue = atforkvalue;
+  atp.parent_pid = getpid ();
 
   if (!ctx
       || (name && (!argv || !argv[0]))
@@ -315,7 +320,7 @@ socketpair_connect (assuan_context_t ctx,
   child_fds[1] = ASSUAN_INVALID_FD;
   if (fd_child_list)
     memcpy (&child_fds[1], fd_child_list, (child_fds_cnt + 1) * sizeof (int));
-  
+
   if (_assuan_socketpair (ctx, AF_LOCAL, SOCK_STREAM, 0, fds))
     {
       TRACE_LOG1 ("socketpair failed: %s", strerror (errno));
@@ -362,10 +367,10 @@ socketpair_connect (assuan_context_t ctx,
   ctx->engine.release = _assuan_client_release;
   ctx->finish_handler = _assuan_client_finish;
   ctx->max_accepts = 1;
-  ctx->inbound.fd  = fds[0]; 
-  ctx->outbound.fd = fds[0]; 
+  ctx->inbound.fd  = fds[0];
+  ctx->outbound.fd = fds[0];
   _assuan_init_uds_io (ctx);
-  
+
   err = initial_handshake (ctx);
   if (err)
     _assuan_reset (ctx);

commit ff9a8c2e64ea2345f2ebe85a527b7c43033ba53e
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Dec 13 18:22:22 2011 +0100

    vasprintf.c: Improve test code.
    
    * src/vasprintf.c (checkit): Set flag for a test failure.
    (main): Return error on any failure.

diff --git a/src/vasprintf.c b/src/vasprintf.c
index e55408a..bacb71c 100644
--- a/src/vasprintf.c
+++ b/src/vasprintf.c
@@ -33,10 +33,10 @@ Boston, MA 02111-1307, USA.  */
 #define va_copy(d, s) (*(d) = *(s))
 #elif defined (MUST_COPY_VA_BYVAL)
 #define va_copy(d, s) ((d) = (s))
-#else 
+#else
 #define va_copy(d, s) memcpy ((d), (s), sizeof (va_list))
-#endif 
-#endif 
+#endif
+#endif
 
 
 #ifdef TEST
@@ -175,6 +175,7 @@ _assuan_asprintf (char **buf, const char *fmt, ...)
 
 #define asprintf  _assuan_asprintf
 #define vasprintf _assuan_vasprintf
+static int any_failed;
 
 void
 checkit (const char* format, ...)
@@ -187,7 +188,10 @@ checkit (const char* format, ...)
   if (strlen (result) < global_total_width)
     printf ("PASS: ");
   else
-    printf ("FAIL: ");
+    {
+      any_failed = 1;
+      printf ("FAIL: ");
+    }
   printf ("%d %s\n", global_total_width, result);
 }
 
@@ -201,5 +205,7 @@ main (void)
   checkit ("%s", "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
 777777777777777777333333333333366666666666622222222222777777777777733333");
   checkit ("%f%s%d%s", 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx");
+  checkit ("%2$f%4$s%3$d%1$s", "asdjffffffffffffffiiiiiiiiiiixxxxx", 1.0, 77, "foo");
+  return any_failed;
 }
 #endif /* TEST */

-----------------------------------------------------------------------

Summary of changes:
 NEWS                      |    2 ++
 src/assuan-pipe-connect.c |   43 ++++++++++++++++++++++++-------------------
 src/vasprintf.c           |   14 ++++++++++----
 3 files changed, 36 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
IPC library used by GnuPG
http://git.gnupg.org




More information about the Gnupg-commits mailing list