[svn] assuan - r367 - in trunk: doc src

svn author wk cvs at cvs.gnupg.org
Wed Apr 14 11:40:45 CEST 2010


Author: wk
Date: 2010-04-14 11:40:45 +0200 (Wed, 14 Apr 2010)
New Revision: 367

Modified:
   trunk/doc/assuan.texi
   trunk/src/ChangeLog
   trunk/src/assuan-pipe-connect.c
   trunk/src/gpgcedev.c
   trunk/src/gpgcemgr.c
   trunk/src/system-w32.c
   trunk/src/system-w32ce.c
   trunk/src/system.c
Log:
Changes for W32CE


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2010-04-14 00:12:16 UTC (rev 366)
+++ trunk/src/ChangeLog	2010-04-14 09:40:45 UTC (rev 367)
@@ -2,6 +2,20 @@
 
 	* Makefile.am (EXTRA_DIST): Add gpgcedev.def.
 
+2010-04-13  Werner Koch  <wk at g10code.com>
+
+	* gpgcedev.c (get_new_opnctx): Always clear IS_WRITE.
+
+2010-04-08  Werner Koch  <wk at g10code.com>
+
+	* gpgcedev.c (GPG_Read, GPG_Write): If the context is not
+	associated return ERROR_PIPE_NOT_CONNECTED.
+	* system-w32ce.c (__assuan_read, __assuan_write): Return EAGAIN for
+	ERROR_PIPE_NOT_CONNECTED.
+
+	* assuan-pipe-connect.c (pipe_connect): Use
+	_assuan_close_inheritable also in the spawn error case.
+
 2010-04-06  Werner Koch  <wk at g10code.com>
 
 	* posix-includes.inc.h, w32-includes.inc.h: New.

Modified: trunk/doc/assuan.texi
===================================================================
--- trunk/doc/assuan.texi	2010-04-14 00:12:16 UTC (rev 366)
+++ trunk/doc/assuan.texi	2010-04-14 09:40:45 UTC (rev 367)
@@ -948,7 +948,7 @@
 
 @deftypefun void assuan_ctx_set_system_hooks (@w{assuan_context_t @var{ctx}}, @w{assuan_system_hooks_t @var{system_hooks}})
 Set the system hooks for context @var{ctx}.  There is currently no way
-to reset tot the default system hooks, create a new context for that.
+to reset to the default system hooks, create a new context for that.
 @end deftypefun
 
 The following system hook collections are defined by the library for

Modified: trunk/src/assuan-pipe-connect.c
===================================================================
--- trunk/src/assuan-pipe-connect.c	2010-04-14 00:12:16 UTC (rev 366)
+++ trunk/src/assuan-pipe-connect.c	2010-04-14 09:40:45 UTC (rev 367)
@@ -190,8 +190,8 @@
     {
       rc = gpg_err_code_from_syserror ();
       _assuan_close (ctx, rp[0]);
-      _assuan_close (ctx, rp[1]);
-      _assuan_close (ctx, wp[0]);
+      _assuan_close_inheritable (ctx, rp[1]);
+      _assuan_close_inheritable (ctx, wp[0]);
       _assuan_close (ctx, wp[1]);
       return _assuan_error (ctx, rc);
     }

Modified: trunk/src/gpgcedev.c
===================================================================
--- trunk/src/gpgcedev.c	2010-04-14 00:12:16 UTC (rev 366)
+++ trunk/src/gpgcedev.c	2010-04-14 09:40:45 UTC (rev 367)
@@ -169,6 +169,11 @@
   opnctx = opnctx_table + idx;
   opnctx->assoc = NULL;
   opnctx->rvid = create_rendezvous_id ();
+  opnctx->is_write = 0;
+  opnctx->access_code = 0;
+  opnctx->share_mode = 0;
+  InitializeCriticalSection (&opnctx->critsect);
+  opnctx->locked = 0;
   opnctx->buffer_size = 512;
   opnctx->buffer = malloc (opnctx->buffer_size);
   if (!opnctx->buffer)
@@ -182,7 +187,6 @@
   opnctx->space_available = INVALID_HANDLE_VALUE;
 
   opnctx->inuse = 1;
-  InitializeCriticalSection (&opnctx->critsect);
   EnterCriticalSection (&opnctx->critsect);
   opnctx->locked = 1;
   
@@ -437,11 +441,12 @@
   if (rctx->is_write)
     {
       SetLastError (ERROR_INVALID_ACCESS);
+      log_debug ("GPG_Read(%p) -> invalid access\n", (void*)rctx);
       goto leave;
     }
   if (!rctx->assoc)
     {
-      SetLastError (ERROR_BROKEN_PIPE);
+      SetLastError (ERROR_PIPE_NOT_CONNECTED);
       goto leave;
     }
 
@@ -508,11 +513,12 @@
   if (!wctx->is_write)
     {
       SetLastError (ERROR_INVALID_ACCESS);
+      log_debug ("GPG_Write(%p) -> invalid access\n", (void*)wctx);
       goto leave;
     }
   if (!wctx->assoc)
     {
-      SetLastError (ERROR_BROKEN_PIPE);
+      SetLastError (ERROR_PIPE_NOT_CONNECTED);
       goto leave;
     }
   if (!count)
@@ -601,6 +607,7 @@
       if (!(peerctx->access_code & GENERIC_WRITE))
         {
           SetLastError (ERROR_INVALID_ACCESS);
+          log_debug ("  make_pipe(%p) write end -> invalid access\n", ctx);
           goto leave;
         }
       peerctx->space_available = CreateEvent (NULL, FALSE, FALSE, NULL);
@@ -618,6 +625,7 @@
       if (!(peerctx->access_code & GENERIC_READ))
         {
           SetLastError (ERROR_INVALID_ACCESS);
+          log_debug ("  make_pipe(%p) read_end -> invalid access\n", ctx);
           goto leave;
         }
       ctx->space_available = CreateEvent (NULL, FALSE, FALSE, NULL);
@@ -632,6 +640,7 @@
   else
     {
       SetLastError (ERROR_INVALID_ACCESS);
+      log_debug ("  make_pipe(%p) no_access -> invalid access\n", ctx);
       goto leave;
     }
 

Modified: trunk/src/gpgcemgr.c
===================================================================
--- trunk/src/gpgcemgr.c	2010-04-14 00:12:16 UTC (rev 366)
+++ trunk/src/gpgcemgr.c	2010-04-14 09:40:45 UTC (rev 367)
@@ -1,4 +1,4 @@
-/* gpgcempg.c - Manager fopr GPG CE devices
+/* gpgcempr.c - Manager for GPG CE devices
    Copyright (C) 2010 Free Software Foundation, Inc.
 
    This file is part of Assuan.

Modified: trunk/src/system-w32.c
===================================================================
--- trunk/src/system-w32.c	2010-04-14 00:12:16 UTC (rev 366)
+++ trunk/src/system-w32.c	2010-04-14 09:40:45 UTC (rev 367)
@@ -402,7 +402,8 @@
 
   /* Note: We inherit all handles flagged as inheritable.  This seems
      to be a security flaw but there seems to be no way of selecting
-     handles to inherit. */
+     handles to inherit.  A fix for this would be to use a helper
+     process like we have in gpgme.  */
   /*   _assuan_log_printf ("CreateProcess, path=`%s' cmdline=`%s'\n", */
   /*                       name, cmdline); */
   if (!CreateProcess (name,                 /* Program to start.  */

Modified: trunk/src/system-w32ce.c
===================================================================
--- trunk/src/system-w32ce.c	2010-04-14 00:12:16 UTC (rev 366)
+++ trunk/src/system-w32ce.c	2010-04-14 09:40:45 UTC (rev 367)
@@ -301,6 +301,11 @@
 		    gpg_err_set_errno (EPIPE);
 		    break;
 
+                  case ERROR_PIPE_NOT_CONNECTED:
+                  case ERROR_BUSY:
+		    gpg_err_set_errno (EAGAIN);
+		    break;
+
                   default:
 		    gpg_err_set_errno (EIO); 
                   }
@@ -357,6 +362,11 @@
             case ERROR_NO_DATA:
 	      gpg_err_set_errno (EPIPE);
 	      break;
+
+            case ERROR_PIPE_NOT_CONNECTED:
+            case ERROR_BUSY:
+              gpg_err_set_errno (EAGAIN);
+              break;
 	      
             default:
 	      gpg_err_set_errno (EIO);
@@ -505,9 +515,12 @@
      Because an RVID of 0 is an invalid value and HANDLES will never
      have this value either, we test for this as well.  */
 
-  /* FIXME: CHECKOUT WHAT TO DO WITH STDERR HERE.  WE NEED TO DEFINE
-     WHETHER THE FD_CHILD_LIST HAS HANDLES OR RENDEZVOUS IDS.  */
-
+  /* FIXME: As long as we can't decide whether a handle is a real
+     handler or an rendezvous id we can't do anything with the
+     FD_CHILD_LIST.  We can't do much with stderr either, thus we
+     better don't pass stderr to the child at all.  If we would do so
+     and it is not a rendezvous id the client would run into
+     problems.  */
   fd = assuan_fd_from_posix_fd (fileno (stderr));
   fdp = fd_child_list;
   if (fdp)
@@ -517,7 +530,7 @@
     }
   if (!fdp || *fdp == ASSUAN_INVALID_FD)
     fd_err_isnull = 1;
-  fd_err = fd;
+  fd_err = ASSUAN_INVALID_FD;
 
   if (build_w32_commandline (ctx, argv, fd_in, fd_out, fd_err, fd_err_isnull,
                              &cmdline))

Modified: trunk/src/system.c
===================================================================
--- trunk/src/system.c	2010-04-14 00:12:16 UTC (rev 366)
+++ trunk/src/system.c	2010-04-14 09:40:45 UTC (rev 367)
@@ -175,7 +175,7 @@
 int
 _assuan_close_inheritable (assuan_context_t ctx, assuan_fd_t fd)
 {
-  TRACE1 (ctx, ASSUAN_LOG_SYSIO, "_assuan_close", ctx,
+  TRACE1 (ctx, ASSUAN_LOG_SYSIO, "_assuan_close_inheritable", ctx,
 	  "fd=0x%x", fd);
 
 #ifdef HAVE_W32CE_SYSTEM




More information about the Gnupg-commits mailing list