[svn] assuan - r327 - in trunk: . src

svn author marcus cvs at cvs.gnupg.org
Tue Dec 8 05:20:16 CET 2009


Author: marcus
Date: 2009-12-08 05:20:16 +0100 (Tue, 08 Dec 2009)
New Revision: 327

Modified:
   trunk/NEWS
   trunk/src/ChangeLog
   trunk/src/assuan-defs.h
   trunk/src/assuan-pipe-connect.c
   trunk/src/assuan-socket.c
   trunk/src/assuan.h
   trunk/src/system.c
Log:
2009-12-08  Marcus Brinkmann  <marcus at g10code.de>

	* assuan-socket.c (get_nonce): Cast buffer to unsigned.
	(_assuan_sock_connect) [HAVE_W32_SYSTEM]: Drop ctx argument from
	read_port_and_nonce invocation.
	* system.c (assuan_fdopen) [HAVE_W32_SYSTEM]: Fix typo in variable
	name.
	(__assuan_spawn) [HAVE_W32_SYSTEM]: Fix types of fd and fdp.  Use
	ASSUAN_INVALID_FD.  Add missing context argument to _assuan_free,
	and fix call to _assuan_w32_strerror.  Set errno on error.
	(__assuan_socketpair) [HAVE_W32_STRERROR]: Fix type of filedes
	argument.
	* assuan-pipe-connect.c (pipe_connect, assuan_pipe_connect,
	socketpair_connect) [HAVE_W32_SYSTEM]: Fix type of fd_child_list.
	* assuan-defs.h (_assuan_socketpair): Likewise for prototype.
	* assuan.h (assuan_fd_from_posix_fd): New static inline function.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2009-12-03 18:55:16 UTC (rev 326)
+++ trunk/src/ChangeLog	2009-12-08 04:20:16 UTC (rev 327)
@@ -1,3 +1,20 @@
+2009-12-08  Marcus Brinkmann  <marcus at g10code.de>
+
+	* assuan-socket.c (get_nonce): Cast buffer to unsigned.
+	(_assuan_sock_connect) [HAVE_W32_SYSTEM]: Drop ctx argument from
+	read_port_and_nonce invocation.
+	* system.c (assuan_fdopen) [HAVE_W32_SYSTEM]: Fix typo in variable
+	name.
+	(__assuan_spawn) [HAVE_W32_SYSTEM]: Fix types of fd and fdp.  Use
+	ASSUAN_INVALID_FD.  Add missing context argument to _assuan_free,
+	and fix call to _assuan_w32_strerror.  Set errno on error.
+	(__assuan_socketpair) [HAVE_W32_STRERROR]: Fix type of filedes
+	argument.
+	* assuan-pipe-connect.c (pipe_connect, assuan_pipe_connect,
+	socketpair_connect) [HAVE_W32_SYSTEM]: Fix type of fd_child_list.
+	* assuan-defs.h (_assuan_socketpair): Likewise for prototype.
+	* assuan.h (assuan_fd_from_posix_fd): New static inline function.
+
 2009-12-03  Marcus Brinkmann  <marcus at g10code.de>
 
 	* assuan-logging.c: (log_cats): New static variable.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2009-12-03 18:55:16 UTC (rev 326)
+++ trunk/NEWS	2009-12-08 04:20:16 UTC (rev 327)
@@ -52,6 +52,7 @@
 assuan_pipe_connect            CHANGED: Take ctx arg instead of pointer to ctx.
 			       If NAME is NULL, ARGV will contain fork result.
 			       CHANGED: Is now what assuan_pipe_connect_ext was.
+			       CHANGED: Child fds are now assuan_fd_t.
 assuan_pipe_connect_ext	       REMOVED
 assuan_init_pipe_server        CHANGED: Take ctx arg instead of pointer to ctx.
                                CHANGED: Swallows fds (are closed at end).
@@ -90,6 +91,7 @@
 assuan_get_peercred	       CHANGED: Return assuan_peercred_t.
 assuan_client_read_response    NEW
 assuan_client_parse_response   NEW
+assuan_fd_from_posix_fd	       NEW
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 

Modified: trunk/src/assuan-defs.h
===================================================================
--- trunk/src/assuan-defs.h	2009-12-03 18:55:16 UTC (rev 326)
+++ trunk/src/assuan-defs.h	2009-12-08 04:20:16 UTC (rev 327)
@@ -246,7 +246,7 @@
 pid_t  _assuan_waitpid (assuan_context_t ctx, pid_t pid, int nowait,
 			int *status, int options);
 int _assuan_socketpair (assuan_context_t ctx, int namespace, int style,
-			int protocol, int filedes[2]);
+			int protocol, assuan_fd_t filedes[2]);
 
 extern struct assuan_system_hooks _assuan_system_hooks;
 

Modified: trunk/src/assuan-pipe-connect.c
===================================================================
--- trunk/src/assuan-pipe-connect.c	2009-12-03 18:55:16 UTC (rev 326)
+++ trunk/src/assuan-pipe-connect.c	2009-12-08 04:20:16 UTC (rev 327)
@@ -144,7 +144,7 @@
 static gpg_error_t
 pipe_connect (assuan_context_t ctx,
 	      const char *name, const char **argv,
-	      int *fd_child_list,
+	      assuan_fd_t *fd_child_list,
 	      void (*atfork) (void *opaque, int reserved),
 	      void *atforkvalue, unsigned int flags)
 {
@@ -257,7 +257,7 @@
 static gpg_error_t
 socketpair_connect (assuan_context_t ctx,
                     const char *name, const char **argv,
-                    int *fd_child_list,
+                    assuan_fd_t *fd_child_list,
                     void (*atfork) (void *opaque, int reserved),
                     void *atforkvalue)
 {
@@ -388,7 +388,7 @@
 gpg_error_t
 assuan_pipe_connect (assuan_context_t ctx,
 		     const char *name, const char *argv[],
-		     int *fd_child_list,
+		     assuan_fd_t *fd_child_list,
 		     void (*atfork) (void *opaque, int reserved),
 		     void *atforkvalue, unsigned int flags)
 {

Modified: trunk/src/assuan-socket.c
===================================================================
--- trunk/src/assuan-socket.c	2009-12-03 18:55:16 UTC (rev 326)
+++ trunk/src/assuan-socket.c	2009-12-08 04:20:16 UTC (rev 327)
@@ -92,7 +92,7 @@
     errno = ENODEV;
   else 
     {
-      if (!CryptGenRandom (prov, nbytes, buffer))
+      if (!CryptGenRandom (prov, nbytes, (unsigned char *) buffer))
         errno = ENODEV;
       else
         ret = 0;
@@ -178,7 +178,7 @@
       int ret;
       
       unaddr = (struct sockaddr_un *)addr;
-      if (read_port_and_nonce (ctx, unaddr->sun_path, &port, nonce))
+      if (read_port_and_nonce (unaddr->sun_path, &port, nonce))
         return -1;
       
       myaddr.sin_family = AF_INET;
@@ -308,7 +308,7 @@
         }
       nonce->length = 16;
       unaddr = (struct sockaddr_un *)addr;
-      if (read_port_and_nonce (ctx, unaddr->sun_path, &port, nonce->nonce))
+      if (read_port_and_nonce (unaddr->sun_path, &port, nonce->nonce))
         return -1;
     }
   else

Modified: trunk/src/assuan.h
===================================================================
--- trunk/src/assuan.h	2009-12-03 18:55:16 UTC (rev 326)
+++ trunk/src/assuan.h	2009-12-08 04:20:16 UTC (rev 327)
@@ -85,10 +85,20 @@
 typedef void *assuan_fd_t;
 #define ASSUAN_INVALID_FD ((void*)(-1))
 #define ASSUAN_INVALID_PID ((pid_t) -1)
+static inline assuan_fd_t
+assuan_fd_from_posix_fd (int fd)
+{
+  return (assuan_fd_t) _get_osfhandle (fd);
+}
 #else
 typedef int assuan_fd_t;
 #define ASSUAN_INVALID_FD (-1)
 #define ASSUAN_INVALID_PID ((pid_t) -1)
+static inline assuan_fd_t
+assuan_fd_from_posix_fd (int fd)
+{
+  return fd;
+}
 #endif
 
 assuan_fd_t assuan_fdopen (int fd);

Modified: trunk/src/system.c
===================================================================
--- trunk/src/system.c	2009-12-03 18:55:16 UTC (rev 326)
+++ trunk/src/system.c	2009-12-08 04:20:16 UTC (rev 327)
@@ -51,12 +51,12 @@
   assuan_fd_t ifd = (assuan_fd_t) _get_osfhandle (fd);
   assuan_fd_t ofd;
 
-  if (! DuplicateHandle(GetCurrentProcess(), hfd, 
+  if (! DuplicateHandle(GetCurrentProcess(), ifd, 
 			GetCurrentProcess(), &ofd, 0,
 			TRUE, DUPLICATE_SAME_ACCESS))
     {
       errno = EIO;
-      return ASSUAN_INVALID_FD:
+      return ASSUAN_INVALID_FD;
     }
   return ofd;
 #else
@@ -540,8 +540,8 @@
       0          /* Returns tid.  */
     };
   STARTUPINFO si;
-  int fd;
-  int *fdp;
+  assuan_fd_t fd;
+  assuan_fd_t *fdp;
   char *cmdline;
   HANDLE nullfd = INVALID_HANDLE_VALUE;
 
@@ -570,14 +570,14 @@
 
   /* Dup stderr to /dev/null unless it is in the list of FDs to be
      passed to the child. */
-  fd = fileno (stderr);
+  fd = assuan_fd_from_posix_fd (fileno (stderr));
   fdp = fd_child_list;
   if (fdp)
     {
-      for (; *fdp != -1 && *fdp != fd; fdp++)
+      for (; *fdp != ASSUAN_INVALID_FD && *fdp != fd; fdp++)
         ;
     }
-  if (!fdp || *fdp == -1)
+  if (!fdp || *fdp == ASSUAN_INVALID_FD)
     {
       nullfd = CreateFile ("nul", GENERIC_WRITE,
                            FILE_SHARE_READ | FILE_SHARE_WRITE,
@@ -585,14 +585,15 @@
       if (nullfd == INVALID_HANDLE_VALUE)
         {
 	  TRACE1 (ctx, ASSUAN_LOG_SYSIO, "__assuan_spawn", ctx,
-		  "can't open `nul': %s", w32_strerror (ctx, -1));
-          _assuan_free (cmdline);
+		  "can't open `nul': %s", _assuan_w32_strerror (ctx, -1));
+          _assuan_free (ctx, cmdline);
+          errno = EIO;
           return -1;
         }
       si.hStdError = nullfd;
     }
   else
-    si.hStdError = (void*)_get_osfhandle (fd);
+    si.hStdError = fd;
 
 
   /* Note: We inherit all handles flagged as inheritable.  This seems
@@ -616,8 +617,8 @@
                       ))
     {
       TRACE1 (ctx, ASSUAN_LOG_SYSIO, "pipe_connect_w32", ctx,
-	      "CreateProcess failed: %s", w32_strerror (ctx, -1));
-      _assuan_free (cmdline);
+	      "CreateProcess failed: %s", _assuan_w32_strerror (ctx, -1));
+      _assuan_free (ctx, cmdline);
       if (nullfd != INVALID_HANDLE_VALUE)
         CloseHandle (nullfd);
 
@@ -625,7 +626,7 @@
       return -1;
     }
 
-  _assuan_free (cmdline);
+  _assuan_free (ctx, cmdline);
   if (nullfd != INVALID_HANDLE_VALUE)
     CloseHandle (nullfd);
 
@@ -882,7 +883,7 @@
 
 int
 __assuan_socketpair (assuan_context_t ctx, int namespace, int style,
-		     int protocol, int filedes[2])
+		     int protocol, assuan_fd_t filedes[2])
 {
 #if HAVE_W32_SYSTEM
   errno = ENOSYS;




More information about the Gnupg-commits mailing list