[git] GPGME - branch, master, updated. gpgme-1.4.3-23-g2bb2618

by Werner Koch cvs at cvs.gnupg.org
Tue Apr 15 12:26:55 CEST 2014


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 "GnuPG Made Easy".

The branch, master has been updated
       via  2bb26185e3b9a048033c559517d6ba7d2eb47066 (commit)
       via  d3bd8fff863f62b6d0e228aea754efbbde861e9a (commit)
      from  4f2d652e60700e03809307a10015ff9003ac3579 (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 2bb26185e3b9a048033c559517d6ba7d2eb47066
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Apr 15 12:25:45 2014 +0200

    Fix possible zombie processes.
    
    * src/posix-io.c (_gpgme_io_waitpid): Protect waitpid agains EINTR.
    (_gpgme_io_dup): Likewise.
    (_gpgme_io_connect): Likewise.
    --
    
    GnuPG-bug-id: 1630

diff --git a/src/posix-io.c b/src/posix-io.c
index 908c1ee..ac823fc 100644
--- a/src/posix-io.c
+++ b/src/posix-io.c
@@ -340,10 +340,15 @@ int
 _gpgme_io_waitpid (int pid, int hang, int *r_status, int *r_signal)
 {
   int status;
+  pid_t ret;
 
   *r_status = 0;
   *r_signal = 0;
-  if (_gpgme_ath_waitpid (pid, &status, hang? 0 : WNOHANG) == pid)
+  do
+    ret = _gpgme_ath_waitpid (pid, &status, hang? 0 : WNOHANG);
+  while (ret == (pid_t)(-1) && errno == EINTR);
+
+  if (ret == pid)
     {
       if (WIFSIGNALED (status))
 	{
@@ -697,7 +702,11 @@ _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags)
 int
 _gpgme_io_dup (int fd)
 {
-  int new_fd = dup (fd);
+  int new_fd;
+
+  do
+    new_fd = dup (fd);
+  while (new_fd == -1 && errno == EINTR);
 
   TRACE1 (DEBUG_SYSIO, "_gpgme_io_dup", fd, "new fd==%i", new_fd);
 
@@ -727,7 +736,9 @@ _gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen)
   TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_connect", fd,
 	      "addr=%p, addrlen=%i", addr, addrlen);
 
-  res = ath_connect (fd, addr, addrlen);
+  do
+    res = ath_connect (fd, addr, addrlen);
+  while (res == -1 && errno == EINTR);
 
   return TRACE_SYSRES (res);
 }

commit d3bd8fff863f62b6d0e228aea754efbbde861e9a
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Apr 10 14:17:19 2014 +0200

    Actually implement flags for gpgme_op_spawn.
    
    * src/spawn.c (gpgme_op_spawn_start, gpgme_op_spawn): Pass FLAGS dow
    to spawn_start and add FLAGS args along the call path.
    * src/engine-spawn.c (engspawn_start): Hack to automagically provide
    argv[0].

diff --git a/doc/gpgme.texi b/doc/gpgme.texi
index 027e1ef..7697ff1 100644
--- a/doc/gpgme.texi
+++ b/doc/gpgme.texi
@@ -5261,12 +5261,13 @@ with the GPGME API.
 
 The function @code{gpgme_op_spawn} runs the program @var{file} with
 the arguments taken from the NULL terminated array @var{argv}.  If no
-arguments are required @var{argv} may be given as @code{NULL} (in that
-case GPGME uses the basename of @var{file} for @code{argv[0]}).  The
-file descriptors @code{stdin}, @code{stdout}, and @code{stderr} are
-connected to the data objects @var{datain}, @var{dataout}, and
- at var{dataerr}.  If NULL is passed for one of these data objects the
-corresponding file descriptor is connected to @file{/dev/null}.
+arguments are required @var{argv} may be given as @code{NULL}.  In the
+latter case or if @code{argv[0]} is the empty string, GPGME uses the
+basename of @var{file} for @code{argv[0]}.  The file descriptors
+ at code{stdin}, @code{stdout}, and @code{stderr} are connected to the
+data objects @var{datain}, @var{dataout}, and @var{dataerr}.  If NULL
+is passed for one of these data objects the corresponding file
+descriptor is connected to @file{/dev/null}.
 
 The value in @var{flags} is a bitwise-or combination of one or
 multiple of the following bit values:
diff --git a/src/engine-backend.h b/src/engine-backend.h
index dbb9e93..b3cc412 100644
--- a/src/engine-backend.h
+++ b/src/engine-backend.h
@@ -130,7 +130,7 @@ struct engine_ops
                             const char *file, const char *argv[],
                             gpgme_data_t datain,
                             gpgme_data_t dataout,
-                            gpgme_data_t dataerr);
+                            gpgme_data_t dataerr, unsigned int flags);
 
 };
 
diff --git a/src/engine-spawn.c b/src/engine-spawn.c
index 1e71c1c..bfcad3d 100644
--- a/src/engine-spawn.c
+++ b/src/engine-spawn.c
@@ -231,6 +231,7 @@ engspawn_start (engine_spawn_t esp, const char *file, const char *argv[],
   struct spawn_fd_item_s *fd_list;
   pid_t pid;
   unsigned int spflags;
+  const char *save_argv0 = NULL;
 
   if (!esp || !file || !argv || !argv[0])
     return gpg_error (GPG_ERR_INV_VALUE);
@@ -264,8 +265,15 @@ engspawn_start (engine_spawn_t esp, const char *file, const char *argv[],
   fd_list[n].fd = -1;
   fd_list[n].dup_to = -1;
 
+  if (argv[0] && !*argv[0])
+    {
+      save_argv0 = argv[0];
+      argv[0] = _gpgme_get_basename (file);
+    }
   status = _gpgme_io_spawn (file, (char * const *)argv, spflags,
                             fd_list, NULL, NULL, &pid);
+  if (save_argv0)
+    argv[0] = save_argv0;
   free (fd_list);
   if (status == -1)
     return gpg_error_from_syserror ();
diff --git a/src/engine.c b/src/engine.c
index f503430..ff015c0 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -944,7 +944,8 @@ gpgme_error_t
 _gpgme_engine_op_spawn (engine_t engine,
                         const char *file, const char *argv[],
                         gpgme_data_t datain,
-                        gpgme_data_t dataout, gpgme_data_t dataerr)
+                        gpgme_data_t dataout, gpgme_data_t dataerr,
+                        unsigned int flags)
 {
   if (!engine)
     return gpg_error (GPG_ERR_INV_VALUE);
@@ -953,5 +954,5 @@ _gpgme_engine_op_spawn (engine_t engine,
     return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
 
   return (*engine->ops->opspawn) (engine->engine, file, argv,
-                                  datain, dataout, dataerr);
+                                  datain, dataout, dataerr, flags);
 }
diff --git a/src/engine.h b/src/engine.h
index ade7de1..bbf009d 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -167,7 +167,8 @@ gpgme_error_t _gpgme_engine_op_spawn (engine_t engine,
                                       const char *file, const char *argv[],
                                       gpgme_data_t datain,
                                       gpgme_data_t dataout,
-                                      gpgme_data_t dataerr);
+                                      gpgme_data_t dataerr,
+                                      unsigned int flags);
 
 
 #endif /* ENGINE_H */
diff --git a/src/spawn.c b/src/spawn.c
index e3454f3..7b3b447 100644
--- a/src/spawn.c
+++ b/src/spawn.c
@@ -34,7 +34,8 @@ static gpgme_error_t
 spawn_start (gpgme_ctx_t ctx, int synchronous,
              const char *file, const char *argv[],
              gpgme_data_t datain,
-             gpgme_data_t dataout, gpgme_data_t dataerr)
+             gpgme_data_t dataout, gpgme_data_t dataerr,
+             unsigned int flags)
 {
   gpgme_error_t err;
   const char *tmp_argv[2];
@@ -54,7 +55,7 @@ spawn_start (gpgme_ctx_t ctx, int synchronous,
     }
 
   return _gpgme_engine_op_spawn (ctx->engine, file, argv,
-                                 datain, dataout, dataerr);
+                                 datain, dataout, dataerr, flags);
 }
 
 
@@ -75,7 +76,7 @@ gpgme_op_spawn_start (gpgme_ctx_t ctx, const char *file, const char *argv[],
   if (!ctx)
     return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
 
-  err = spawn_start (ctx, 0, file, argv, datain, dataout, dataerr);
+  err = spawn_start (ctx, 0, file, argv, datain, dataout, dataerr, flags);
   return err;
 }
 
@@ -97,7 +98,7 @@ gpgme_op_spawn (gpgme_ctx_t ctx, const char *file, const char *argv[],
   if (!ctx)
     return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
 
-  err = spawn_start (ctx, 1, file, argv, datain, dataout, dataerr);
+  err = spawn_start (ctx, 1, file, argv, datain, dataout, dataerr, flags);
 
   if (!err)
     err = _gpgme_wait_one (ctx);

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

Summary of changes:
 doc/gpgme.texi       |   13 +++++++------
 src/engine-backend.h |    2 +-
 src/engine-spawn.c   |    8 ++++++++
 src/engine.c         |    5 +++--
 src/engine.h         |    3 ++-
 src/posix-io.c       |   17 ++++++++++++++---
 src/spawn.c          |    9 +++++----
 7 files changed, 40 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list