diff options
author | Werner Koch <[email protected]> | 2004-12-14 14:49:21 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2004-12-14 14:49:21 +0000 |
commit | 2946819dfc8961d8939a6da9ecee01c11164acc4 (patch) | |
tree | a596cf05e685c5395a0e3ecc1626e90913420f13 /agent/gpg-agent.c | |
parent | * w32-pth.h (pth_event_occured): Removed macro. (diff) | |
download | gnupg-2946819dfc8961d8939a6da9ecee01c11164acc4.tar.gz gnupg-2946819dfc8961d8939a6da9ecee01c11164acc4.zip |
More fixes. First successful use; leaks threads, though.
Diffstat (limited to '')
-rw-r--r-- | agent/gpg-agent.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 6801839aa..5ac02645e 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -446,6 +446,9 @@ main (int argc, char **argv ) 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 @@ main (int argc, char **argv ) ; /* NOTREACHED */ else { /* Regular server mode */ -#ifndef HAVE_W32_SYSTEM int fd; pid_t pid; int len; @@ -739,8 +741,10 @@ main (int argc, char **argv ) 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 @@ main (int argc, char **argv ) 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 @@ main (int argc, char **argv ) 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 @@ main (int argc, char **argv ) 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 @@ main (int argc, char **argv ) fflush (NULL); +#ifndef HAVE_W32_SYSTEM pid = fork (); if (pid == (pid_t)-1) { @@ -857,7 +874,6 @@ main (int argc, char **argv ) } /*NEVER REACHED*/ } /* end parent */ - /* This is the child @@ -893,6 +909,8 @@ main (int argc, char **argv ) exit (1); } +#endif /*!HAVE_W32_SYSTEM*/ + #ifdef USE_GNU_PTH if (!disable_pth) @@ -931,7 +949,6 @@ main (int argc, char **argv ) start_command_handler (fd, -1); } close (fd); -#endif } return 0; |