GNUPG-1-9-BRANCH gnupg/agent (gpg-agent.c)

cvs user wk cvs at cvs.gnupg.org
Tue Dec 14 15:45:05 CET 2004


    Date: Tuesday, December 14, 2004 @ 15:49:22
  Author: wk
    Path: /cvs/gnupg/gnupg/agent
     Tag: GNUPG-1-9-BRANCH

Modified: gpg-agent.c

More fixes.  First successful use; leaks threads, though.


-------------+
 gpg-agent.c |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)


Index: gnupg/agent/gpg-agent.c
diff -u gnupg/agent/gpg-agent.c:1.31.2.21 gnupg/agent/gpg-agent.c:1.31.2.22
--- gnupg/agent/gpg-agent.c:1.31.2.21	Mon Dec 13 16:49:56 2004
+++ gnupg/agent/gpg-agent.c	Tue Dec 14 15:49:21 2004
@@ -446,6 +446,9 @@
                  gpg_strerror (err));
     }
 #endif /*USE_GNU_PTH && !HAVE_W32_SYSTEM*/
+#ifdef HAVE_W32_SYSTEM
+  pth_init ();
+#endif
 
   /* Check that the libraries are suitable.  Do it here because
      the option parsing may need services of the library. */
@@ -728,7 +731,6 @@
     ; /* NOTREACHED */
   else
     { /* Regular server mode */
-#ifndef HAVE_W32_SYSTEM
       int fd;
       pid_t pid;
       int len;
@@ -739,8 +741,10 @@
          default to a specific display.  There is still a default
          display when gpg-agent weas started using --display or a
          client requested this using an OPTION command. */
+#ifndef HAVE_W32_SYSTEM
       if (!opt.keep_display)
         unsetenv ("DISPLAY");
+#endif
 
       *socket_name = 0;
       snprintf (socket_name, DIM(socket_name)-1,
@@ -750,12 +754,15 @@
       if (!p)
         BUG ();
       *p = 0;;
+
+#ifndef HAVE_W32_SYSTEM
       if (!mkdtemp(socket_name))
         {
           log_error ("can't create directory `%s': %s\n",
 	             socket_name, strerror(errno) );
           exit (1);
         }
+#endif
       *p = '/';
 
       if (strchr (socket_name, ':') )
@@ -769,8 +776,11 @@
           exit (1);
         }
    
-
+#ifdef HAVE_W32_SYSTEM
+      fd = _w32_sock_new (AF_UNIX, SOCK_STREAM, 0);
+#else
       fd = socket (AF_UNIX, SOCK_STREAM, 0);
+#endif
       if (fd == -1)
         {
           log_error ("can't create socket: %s\n", strerror(errno) );
@@ -783,7 +793,13 @@
       len = (offsetof (struct sockaddr_un, sun_path)
              + strlen(serv_addr.sun_path) + 1);
 
-      if (bind (fd, (struct sockaddr*)&serv_addr, len) == -1)
+      if (
+#ifdef HAVE_W32_SYSTEM
+          _w32_sock_bind
+#else
+          bind 
+#endif
+          (fd, (struct sockaddr*)&serv_addr, len) == -1)
         {
           log_error ("error binding socket to `%s': %s\n",
                      serv_addr.sun_path, strerror (errno) );
@@ -803,6 +819,7 @@
 
 
       fflush (NULL);
+#ifndef HAVE_W32_SYSTEM
       pid = fork ();
       if (pid == (pid_t)-1) 
         {
@@ -857,7 +874,6 @@
             }
           /*NEVER REACHED*/
         } /* end parent */
-      
 
       /* 
          This is the child
@@ -893,6 +909,8 @@
           exit (1);
         }
 
+#endif /*!HAVE_W32_SYSTEM*/
+
 
 #ifdef USE_GNU_PTH
       if (!disable_pth)
@@ -931,7 +949,6 @@
           start_command_handler (fd, -1);
         }
       close (fd);
-#endif
     }
   
   return 0;




More information about the Gnupg-commits mailing list