diff --git a/ChangeLog b/ChangeLog index c224aacda..53870a987 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-10-01 Werner Koch + + * configure.ac: Require assuan 1.0.4. + 2007-09-14 Werner Koch * configure.ac (GNUPG_LIBASSUAN_VERSION): New. diff --git a/NEWS b/NEWS index b3e090896..a729ff17b 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,10 @@ Noteworthy changes in version 2.0.8 ------------------------------------------------ + * Make sure that under Windows the file permissions of the socket are + taken into account. This required a change of our the socket + emulation code; thus old GnuPG modules can't be used anymore. + Noteworthy changes in version 2.0.7 (2007-09-10) ------------------------------------------------ diff --git a/agent/ChangeLog b/agent/ChangeLog index 2aa2c1375..7b46155fe 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,17 @@ +2007-10-01 Werner Koch + + * agent.h (struct server_control_s): Remove unused CONNECTION_FD. + + * gpg-agent.c: Remove w32-afunix.h. Include mkdtemp.h. + (socket_nonce, socket_nonce_ssh): New. + (create_server_socket): Use assuan socket wrappers. Remove W32 + specific stuff. Save the server nonce. + (check_nonce): New. + (start_connection_thread, start_connection_thread_ssh): Call it. + (handle_connections): Change args to gnupg_fd_t. + * command.c (start_command_handler): Change LISTEN_FD to gnupg_fd_t. + * command-ssh.c (start_command_handler_ssh): Ditto. + 2007-09-18 Werner Koch * agent.h (struct pin_entry_info_s): Add element WITH_QUALITYBAR. diff --git a/agent/agent.h b/agent/agent.h index 41b44c322..9648ac40a 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -32,7 +32,8 @@ #include #include "../common/util.h" #include "../common/errors.h" -#include "membuf.h" +#include "../common/membuf.h" +#include "../common/sysutils.h" /* (gnupg_fd_t) */ /* To convey some special hash algorithms we use algorithm numbers reserved for application use. */ @@ -131,7 +132,7 @@ struct server_control_s /* Private data used to fire up the connection thread. We use this structure do avoid an extra allocation for just a few bytes. */ struct { - int fd; + gnupg_fd_t fd; } thread_startup; /* Private data of the server (command.c). */ @@ -140,8 +141,6 @@ struct server_control_s /* Private data of the SCdaemon (call-scd.c). */ struct scd_local_s *scd_local; - int connection_fd; /* -1 or an identifier for the current connection. */ - char *display; char *ttyname; char *ttytype; @@ -209,10 +208,10 @@ void agent_sighup_action (void); gpg_error_t agent_write_status (ctrl_t ctrl, const char *keyword, ...); void bump_key_eventcounter (void); void bump_card_eventcounter (void); -void start_command_handler (ctrl_t, int, int); +void start_command_handler (ctrl_t, gnupg_fd_t, gnupg_fd_t); /*-- command-ssh.c --*/ -void start_command_handler_ssh (ctrl_t, int); +void start_command_handler_ssh (ctrl_t, gnupg_fd_t); /*-- findkey.c --*/ int agent_write_private_key (const unsigned char *grip, diff --git a/agent/command-ssh.c b/agent/command-ssh.c index 4fc9d4df5..6b5087830 100644 --- a/agent/command-ssh.c +++ b/agent/command-ssh.c @@ -2818,15 +2818,12 @@ ssh_request_process (ctrl_t ctrl, estream_t stream_sock) /* Start serving client on SOCK_CLIENT. */ void -start_command_handler_ssh (ctrl_t ctrl, int sock_client) +start_command_handler_ssh (ctrl_t ctrl, gnupg_fd_t sock_client) { estream_t stream_sock; gpg_error_t err; int ret; - /* Setup control structure. */ - ctrl->connection_fd = sock_client; - /* Because the ssh protocol does not send us information about the the current TTY setting, we resort here to use those from startup or those explictly set. */ @@ -2843,7 +2840,7 @@ start_command_handler_ssh (ctrl_t ctrl, int sock_client) /* Create stream from socket. */ - stream_sock = es_fdopen (sock_client, "r+"); + stream_sock = es_fdopen (FD2INT(sock_client), "r+"); if (!stream_sock) { err = gpg_error_from_syserror (); diff --git a/agent/command.c b/agent/command.c index 431639b1c..b816fac3e 100644 --- a/agent/command.c +++ b/agent/command.c @@ -1544,12 +1544,12 @@ register_commands (assuan_context_t ctx) control structure for this connection; it has only the basic intialization. */ void -start_command_handler (ctrl_t ctrl, int listen_fd, int fd) +start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd) { int rc; assuan_context_t ctx; - if (listen_fd == -1 && fd == -1) + if (listen_fd == GNUPG_INVALID_FD && fd == GNUPG_INVALID_FD) { int filedes[2]; @@ -1557,14 +1557,13 @@ start_command_handler (ctrl_t ctrl, int listen_fd, int fd) filedes[1] = 1; rc = assuan_init_pipe_server (&ctx, filedes); } - else if (listen_fd != -1) + else if (listen_fd != GNUPG_INVALID_FD) { rc = assuan_init_socket_server_ext (&ctx, listen_fd, 0); } else { rc = assuan_init_socket_server_ext (&ctx, fd, 2); - ctrl->connection_fd = fd; } if (rc) { diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 64424d975..ba98b38aa 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -40,13 +40,11 @@ #define JNLIB_NEED_LOG_LOGV #include "agent.h" -#include /* Malloc hooks */ +#include /* Malloc hooks and socket wrappers. */ #include "i18n.h" +#include "mkdtemp.h" /* Gnulib replacement. */ #include "sysutils.h" -#ifdef HAVE_W32_SYSTEM -# include "../jnlib/w32-afunix.h" -#endif #include "setenv.h" #include "gc-opt-flags.h" @@ -207,6 +205,12 @@ static char *socket_name; /* Name of the communication socket used for ssh-agent-emulation. */ static char *socket_name_ssh; +/* We need to keep track of the server's nonces (these are dummies for + POSIX systems). */ +static assuan_sock_nonce_t socket_nonce; +static assuan_sock_nonce_t socket_nonce_ssh; + + /* Default values for options passed to the pinentry. */ static char *default_display; static char *default_ttyname; @@ -236,13 +240,15 @@ static pid_t parent_pid = (pid_t)(-1); static char *create_socket_name (int use_standard_socket, char *standard_name, char *template); -static int create_server_socket (int is_standard_name, char *name); +static gnupg_fd_t create_server_socket (int is_standard_name, char *name, + assuan_sock_nonce_t *nonce); static void create_directories (void); static void agent_init_default_ctrl (ctrl_t ctrl); static void agent_deinit_default_ctrl (ctrl_t ctrl); -static void handle_connections (int listen_fd, int listen_fd_ssh); +static void handle_connections (gnupg_fd_t listen_fd, + gnupg_fd_t listen_fd_ssh); static int check_for_running_agent (int silent, int mode); /* Pth wrapper function definitions. */ @@ -845,7 +851,7 @@ main (int argc, char **argv ) agent_exit (1); } agent_init_default_ctrl (ctrl); - start_command_handler (ctrl, -1, -1); + start_command_handler (ctrl, GNUPG_INVALID_FD, GNUPG_INVALID_FD); agent_deinit_default_ctrl (ctrl); xfree (ctrl); } @@ -853,8 +859,8 @@ main (int argc, char **argv ) ; /* NOTREACHED */ else { /* Regular server mode */ - int fd; - int fd_ssh; + gnupg_fd_t fd; + gnupg_fd_t fd_ssh; pid_t pid; /* Remove the DISPLAY variable so that a pinentry does not @@ -878,11 +884,13 @@ main (int argc, char **argv ) "S.gpg-agent.ssh", "/tmp/gpg-XXXXXX/S.gpg-agent.ssh"); - fd = create_server_socket (standard_socket, socket_name); + fd = create_server_socket (standard_socket, socket_name, + &socket_nonce); if (opt.ssh_support) - fd_ssh = create_server_socket (standard_socket, socket_name_ssh); + fd_ssh = create_server_socket (standard_socket, socket_name_ssh, + &socket_nonce_ssh); else - fd_ssh = -1; + fd_ssh = GNUPG_INVALID_FD; /* If we are going to exec a program in the parent, we record the PID, so that the child may check whether the program is @@ -1079,8 +1087,8 @@ main (int argc, char **argv ) } #endif /*!HAVE_W32_SYSTEM*/ - handle_connections (fd, opt.ssh_support ? fd_ssh : -1); - close (fd); + handle_connections (fd, opt.ssh_support ? fd_ssh : GNUPG_INVALID_FD); + assuan_sock_close (fd); } return 0; @@ -1109,8 +1117,6 @@ agent_exit (int rc) static void agent_init_default_ctrl (ctrl_t ctrl) { - ctrl->connection_fd = -1; - /* Note we ignore malloc errors because we can't do much about it and the request will fail anyway shortly after this initialization. */ @@ -1269,20 +1275,17 @@ create_socket_name (int use_standard_socket, /* Create a Unix domain socket with NAME. IS_STANDARD_NAME indicates whether a non-random socket is used. Returns the file descriptor or terminates the process in case of an error. */ -static int -create_server_socket (int is_standard_name, char *name) +static gnupg_fd_t +create_server_socket (int is_standard_name, char *name, + assuan_sock_nonce_t *nonce) { struct sockaddr_un *serv_addr; socklen_t len; - int fd; + gnupg_fd_t fd; int rc; -#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) + fd = assuan_sock_new (AF_UNIX, SOCK_STREAM, 0); + if (fd == ASSUAN_INVALID_FD) { log_error (_("can't create socket: %s\n"), strerror (errno)); agent_exit (2); @@ -1291,43 +1294,32 @@ create_server_socket (int is_standard_name, char *name) serv_addr = xmalloc (sizeof (*serv_addr)); memset (serv_addr, 0, sizeof *serv_addr); serv_addr->sun_family = AF_UNIX; - assert (strlen (name) + 1 < sizeof (serv_addr->sun_path)); + if (strlen (name) + 1 >= sizeof (serv_addr->sun_path)) + { + log_error (_("socket name `%s' is too long\n"), name); + agent_exit (2); + } strcpy (serv_addr->sun_path, name); len = (offsetof (struct sockaddr_un, sun_path) + strlen (serv_addr->sun_path) + 1); -#ifdef HAVE_W32_SYSTEM - rc = _w32_sock_bind (fd, (struct sockaddr*) serv_addr, len); - if (is_standard_name && rc == -1 && errno == WSAEADDRINUSE) - { - if (!check_for_running_agent (1, 1)) - { - log_error (_("a gpg-agent is already running - " - "not starting a new one\n")); - *name = 0; /* Inhibit removal of the socket by cleanup(). */ - close (fd); - agent_exit (2); - } - - remove (name); - rc = _w32_sock_bind (fd, (struct sockaddr*) serv_addr, len); - } -#else - rc = bind (fd, (struct sockaddr*) serv_addr, len); + rc = assuan_sock_bind (fd, (struct sockaddr*) serv_addr, len); if (is_standard_name && rc == -1 && errno == EADDRINUSE) { if (!check_for_running_agent (1, 1)) { log_error (_("a gpg-agent is already running - " - "not starting a new one\n")); + "not starting a new one\n")); *name = 0; /* Inhibit removal of the socket by cleanup(). */ - close (fd); + assuan_sock_close (fd); agent_exit (2); } remove (name); - rc = bind (fd, (struct sockaddr*) serv_addr, len); + rc = assuan_sock_bind (fd, (struct sockaddr*) serv_addr, len); } -#endif + if (rc != -1 + && (rc=assuan_sock_get_nonce ((struct sockaddr*)serv_addr, len, nonce))) + log_error (_("error getting nonce for the socket\n")); if (rc == -1) { /* We use gpg_strerror here because it allows us to get strings @@ -1336,16 +1328,16 @@ create_server_socket (int is_standard_name, char *name) serv_addr->sun_path, gpg_strerror (gpg_error_from_errno (errno))); - close (fd); + assuan_sock_close (fd); if (is_standard_name) *name = 0; /* Inhibit removal of the socket by cleanup(). */ agent_exit (2); } - if (listen (fd, 5 ) == -1) + if (listen (FD2INT(fd), 5 ) == -1) { log_error (_("listen() failed: %s\n"), strerror (errno)); - close (fd); + assuan_sock_close (fd); agent_exit (2); } @@ -1538,21 +1530,42 @@ handle_signal (int signo) } +/* Check the nonce on a new connection. This is a NOP unless we we + are using our Unix domain socket emulation under Windows. */ +static int +check_nonce (ctrl_t ctrl, assuan_sock_nonce_t *nonce) +{ + if (assuan_sock_check_nonce (ctrl->thread_startup.fd, nonce)) + { + log_info (_("error reading nonce on fd %d: %s\n"), + FD2INT(ctrl->thread_startup.fd), strerror (errno)); + assuan_sock_close (ctrl->thread_startup.fd); + xfree (ctrl); + return -1; + } + else + return 0; +} + + /* This is the standard connection thread's main function. */ static void * start_connection_thread (void *arg) { ctrl_t ctrl = arg; + if (check_nonce (ctrl, &socket_nonce)) + return NULL; + agent_init_default_ctrl (ctrl); if (opt.verbose) log_info (_("handler 0x%lx for fd %d started\n"), - (long)pth_self (), ctrl->thread_startup.fd); + (long)pth_self (), FD2INT(ctrl->thread_startup.fd)); - start_command_handler (ctrl, -1, ctrl->thread_startup.fd); + start_command_handler (ctrl, GNUPG_INVALID_FD, ctrl->thread_startup.fd); if (opt.verbose) log_info (_("handler 0x%lx for fd %d terminated\n"), - (long)pth_self (), ctrl->thread_startup.fd); + (long)pth_self (), FD2INT(ctrl->thread_startup.fd)); agent_deinit_default_ctrl (ctrl); xfree (ctrl); @@ -1566,15 +1579,18 @@ start_connection_thread_ssh (void *arg) { ctrl_t ctrl = arg; + if (check_nonce (ctrl, &socket_nonce_ssh)) + return NULL; + agent_init_default_ctrl (ctrl); if (opt.verbose) log_info (_("ssh handler 0x%lx for fd %d started\n"), - (long)pth_self (), ctrl->thread_startup.fd); + (long)pth_self (), FD2INT(ctrl->thread_startup.fd)); start_command_handler_ssh (ctrl, ctrl->thread_startup.fd); if (opt.verbose) log_info (_("ssh handler 0x%lx for fd %d terminated\n"), - (long)pth_self (), ctrl->thread_startup.fd); + (long)pth_self (), FD2INT(ctrl->thread_startup.fd)); agent_deinit_default_ctrl (ctrl); xfree (ctrl); @@ -1585,7 +1601,7 @@ start_connection_thread_ssh (void *arg) /* Connection handler loop. Wait for connection requests and spawn a thread after accepting a connection. */ static void -handle_connections (int listen_fd, int listen_fd_ssh) +handle_connections (gnupg_fd_t listen_fd, gnupg_fd_t listen_fd_ssh) { pth_attr_t tattr; pth_event_t ev, time_ev; @@ -1595,7 +1611,7 @@ handle_connections (int listen_fd, int listen_fd_ssh) socklen_t plen; fd_set fdset, read_fdset; int ret; - int fd; + gnupg_fd_t fd; int nfd; tattr = pth_attr_new(); @@ -1620,13 +1636,13 @@ handle_connections (int listen_fd, int listen_fd_ssh) time_ev = NULL; FD_ZERO (&fdset); - FD_SET (listen_fd, &fdset); - nfd = listen_fd; - if (listen_fd_ssh != -1) + FD_SET (FD2INT (listen_fd), &fdset); + nfd = FD2INT (listen_fd); + if (listen_fd_ssh != GNUPG_INVALID_FD) { - FD_SET (listen_fd_ssh, &fdset); - if (listen_fd_ssh > nfd) - nfd = listen_fd_ssh; + FD_SET ( FD2INT(listen_fd_ssh), &fdset); + if (FD2INT (listen_fd_ssh) > nfd) + nfd = FD2INT (listen_fd_ssh); } for (;;) @@ -1701,13 +1717,14 @@ handle_connections (int listen_fd, int listen_fd_ssh) new thread. Thus we need to block those signals. */ pth_sigmask (SIG_BLOCK, &sigs, &oldsigs); - if (FD_ISSET (listen_fd, &read_fdset)) + if (FD_ISSET (FD2INT (listen_fd), &read_fdset)) { ctrl_t ctrl; plen = sizeof paddr; - fd = pth_accept (listen_fd, (struct sockaddr *)&paddr, &plen); - if (fd == -1) + fd = INT2FD (pth_accept (FD2INT(listen_fd), + (struct sockaddr *)&paddr, &plen)); + if (fd == GNUPG_INVALID_FD) { log_error ("accept failed: %s\n", strerror (errno)); } @@ -1715,14 +1732,14 @@ handle_connections (int listen_fd, int listen_fd_ssh) { log_error ("error allocating connection control data: %s\n", strerror (errno) ); - close (fd); + assuan_sock_close (fd); } else { char threadname[50]; snprintf (threadname, sizeof threadname-1, - "conn fd=%d (gpg)", fd); + "conn fd=%d (gpg)", FD2INT(fd)); threadname[sizeof threadname -1] = 0; pth_attr_set (tattr, PTH_ATTR_NAME, threadname); ctrl->thread_startup.fd = fd; @@ -1730,20 +1747,22 @@ handle_connections (int listen_fd, int listen_fd_ssh) { log_error ("error spawning connection handler: %s\n", strerror (errno) ); - close (fd); + assuan_sock_close (fd); xfree (ctrl); } } - fd = -1; + fd = GNUPG_INVALID_FD; } - if (listen_fd_ssh != -1 && FD_ISSET (listen_fd_ssh, &read_fdset)) + if (listen_fd_ssh != GNUPG_INVALID_FD + && FD_ISSET ( FD2INT (listen_fd_ssh), &read_fdset)) { ctrl_t ctrl; plen = sizeof paddr; - fd = pth_accept (listen_fd_ssh, (struct sockaddr *)&paddr, &plen); - if (fd == -1) + fd = INT2FD(pth_accept (FD2INT(listen_fd_ssh), + (struct sockaddr *)&paddr, &plen)); + if (fd == GNUPG_INVALID_FD) { log_error ("accept failed for ssh: %s\n", strerror (errno)); } @@ -1751,7 +1770,7 @@ handle_connections (int listen_fd, int listen_fd_ssh) { log_error ("error allocating connection control data: %s\n", strerror (errno) ); - close (fd); + assuan_sock_close (fd); } else { @@ -1759,7 +1778,7 @@ handle_connections (int listen_fd, int listen_fd_ssh) agent_init_default_ctrl (ctrl); snprintf (threadname, sizeof threadname-1, - "conn fd=%d (ssh)", fd); + "conn fd=%d (ssh)", FD2INT(fd)); threadname[sizeof threadname -1] = 0; pth_attr_set (tattr, PTH_ATTR_NAME, threadname); ctrl->thread_startup.fd = fd; @@ -1767,11 +1786,11 @@ handle_connections (int listen_fd, int listen_fd_ssh) { log_error ("error spawning ssh connection handler: %s\n", strerror (errno) ); - close (fd); + assuan_sock_close (fd); xfree (ctrl); } } - fd = -1; + fd = GNUPG_INVALID_FD; } /* Restore the signal mask. */ diff --git a/common/ChangeLog b/common/ChangeLog index a9b799b4c..577367292 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,3 +1,12 @@ +2007-10-01 Werner Koch + + * sysutils.h (FD2INT, INT2FD): New. + +2007-09-21 Werner Koch + + * homedir.c (default_homedir): Make registry work. Reported by + Marc Mutz. + 2007-08-29 Werner Koch * exechelp.c (gnupg_wait_process): Add arg EXITCODE. Changed all diff --git a/common/homedir.c b/common/homedir.c index 3105aec06..b85f760a0 100644 --- a/common/homedir.c +++ b/common/homedir.c @@ -143,7 +143,7 @@ default_homedir (void) tmp = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", "HomeDir"); - if (tmp && *tmp) + if (tmp && !*tmp) { xfree (tmp); tmp = NULL; diff --git a/common/sysutils.h b/common/sysutils.h index 2a3666882..c053e8fb9 100644 --- a/common/sysutils.h +++ b/common/sysutils.h @@ -27,9 +27,13 @@ #ifdef HAVE_W32_SYSTEM typedef void *gnupg_fd_t; #define GNUPG_INVALID_FD ((void*)(-1)) +#define INT2FD(s) ((void *)(s)) +#define FD2INT(h) ((unsigned int)(h)) #else typedef int gnupg_fd_t; #define GNUPG_INVALID_FD (-1) +#define INT2FD(s) (s) +#define FD2INT(h) (h) #endif diff --git a/configure.ac b/configure.ac index e1608de48..f9ec1597a 100644 --- a/configure.ac +++ b/configure.ac @@ -43,7 +43,7 @@ NEED_LIBGCRYPT_API=1 NEED_LIBGCRYPT_VERSION=1.2.2 NEED_LIBASSUAN_API=1 -NEED_LIBASSUAN_VERSION=1.0.2 +NEED_LIBASSUAN_VERSION=1.0.4 NEED_KSBA_API=1 NEED_KSBA_VERSION=1.0.2 diff --git a/g10/server.c b/g10/server.c index a5793c79a..1c17b9f6e 100644 --- a/g10/server.c +++ b/g10/server.c @@ -32,7 +32,7 @@ #include "util.h" #include "i18n.h" #include "options.h" - +#include "../common/sysutils.h" #define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t)) @@ -44,7 +44,7 @@ struct server_local_s /* Our current Assuan context. */ assuan_context_t assuan_ctx; /* File descriptor as set by the MESSAGE command. */ - int message_fd; + gnupg_fd_t message_fd; }; @@ -53,10 +53,10 @@ struct server_local_s static void close_message_fd (ctrl_t ctrl) { - if (ctrl->server_local->message_fd != -1) + if (ctrl->server_local->message_fd != GNUPG_INVALID_FD) { - close (ctrl->server_local->message_fd); - ctrl->server_local->message_fd = -1; + assuan_sock_close (ctrl->server_local->message_fd); + ctrl->server_local->message_fd = GNUPG_INVALID_FD; } } @@ -229,27 +229,28 @@ cmd_verify (assuan_context_t ctx, char *line) { int rc; ctrl_t ctrl = assuan_get_pointer (ctx); - int fd = assuan_get_input_fd (ctx); - int out_fd = assuan_get_output_fd (ctx); + gnupg_fd_t fd = assuan_get_input_fd (ctx); + gnupg_fd_t out_fd = assuan_get_output_fd (ctx); FILE *out_fp = NULL; - if (fd == -1) + if (fd == GNUPG_INVALID_FD) return gpg_error (GPG_ERR_ASS_NO_INPUT); - if (out_fd != -1) + if (out_fd != GNUPG_INVALID_FD) { - out_fp = fdopen ( dup(out_fd), "w"); + out_fp = fdopen ( dup (FD2INT (out_fd)), "w"); if (!out_fp) return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed"); } - log_debug ("WARNING: The server mode work in progress and not ready for use\n"); + log_debug ("WARNING: The server mode work " + "in progress and not ready for use\n"); /* Need to dup it because it might get closed and libassuan won't know about it then. */ rc = gpg_verify (ctrl, - dup (fd), - dup (ctrl->server_local->message_fd), + dup ( FD2INT (fd)), + dup ( FD2INT (ctrl->server_local->message_fd)), out_fp); if (out_fp) @@ -326,13 +327,13 @@ static int cmd_message (assuan_context_t ctx, char *line) { int rc; - int fd; + gnupg_fd_t fd; ctrl_t ctrl = assuan_get_pointer (ctx); rc = assuan_command_parse_fd (ctx, line, &fd); if (rc) return rc; - if (fd == -1) + if (fd == GNUPG_INVALID_FD) return gpg_error (GPG_ERR_ASS_NO_INPUT); ctrl->server_local->message_fd = fd; return 0; @@ -488,7 +489,7 @@ gpg_server (ctrl_t ctrl) goto leave; } ctrl->server_local->assuan_ctx = ctx; - ctrl->server_local->message_fd = -1; + ctrl->server_local->message_fd = GNUPG_INVALID_FD; if (DBG_ASSUAN) assuan_set_log_stream (ctx, log_get_stream ()); diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog index 42750dc3b..452a99b3f 100644 --- a/jnlib/ChangeLog +++ b/jnlib/ChangeLog @@ -1,3 +1,9 @@ +2007-10-01 Werner Koch + + * w32-afunix.c: Only keep the client related code. + (read_port_and_nonce): New. Taken from Assuan. + (_w32_sock_connect): Rewritten. + 2007-08-29 Werner Koch * argparse.c (initialize): Make strings translatable and remove diff --git a/jnlib/w32-afunix.c b/jnlib/w32-afunix.c index f24c06482..0b03c74b2 100644 --- a/jnlib/w32-afunix.c +++ b/jnlib/w32-afunix.c @@ -1,4 +1,4 @@ -/* w32-afunix.c - AF_UNIX emulation for Windows. +/* w32-afunix.c - AF_UNIX emulation for Windows (Client only). * Copyright (C) 2004, 2006 g10 Code GmbH * * This file is part of JNLIB. @@ -17,8 +17,13 @@ * License along with this program; if not, see . */ +/* Use of this code is preprecated - you better use the sockt wrappers + from libassuan. */ + #ifdef _WIN32 #include +#include +#define WIN32_LEAN_AND_MEAN #include #include #include @@ -27,10 +32,48 @@ #include "w32-afunix.h" -#ifndef S_IRGRP -# define S_IRGRP 0 -# define S_IWGRP 0 -#endif + + +/* The buffer for NONCE needs to be at least 16 bytes. Returns 0 on + success. */ +static int +read_port_and_nonce (const char *fname, unsigned short *port, char *nonce) +{ + FILE *fp; + char buffer[50], *p; + size_t nread; + int aval; + + fp = fopen (fname, "rb"); + if (!fp) + return -1; + nread = fread (buffer, 1, sizeof buffer - 1, fp); + fclose (fp); + if (!nread) + { + errno = ENOFILE; + return -1; + } + buffer[nread] = 0; + aval = atoi (buffer); + if (aval < 1 || aval > 65535) + { + errno = EINVAL; + return -1; + } + *port = (unsigned int)aval; + for (p=buffer; nread && *p != '\n'; p++, nread--) + ; + if (*p != '\n' || nread != 17) + { + errno = EINVAL; + return -1; + } + p++; nread--; + memcpy (nonce, p, 16); + return 0; +} + int @@ -53,97 +96,40 @@ _w32_sock_new (int domain, int type, int proto) int -_w32_sock_connect (int sockfd, struct sockaddr * addr, int addrlen) +_w32_sock_connect (int sockfd, struct sockaddr *addr, int addrlen) { struct sockaddr_in myaddr; - struct sockaddr_un * unaddr; - FILE * fp; - int port; - + struct sockaddr_un *unaddr; + unsigned short port; + char nonce[16]; + int ret; + unaddr = (struct sockaddr_un *)addr; - fp = fopen (unaddr->sun_path, "rb"); - if (!fp) + if (read_port_and_nonce (unaddr->sun_path, &port, nonce)) return -1; - fscanf (fp, "%d", &port); - fclose (fp); - - if (port < 0 || port > 65535) - { - errno = EINVAL; - return -1; - } - + myaddr.sin_family = AF_INET; - myaddr.sin_port = port; + myaddr.sin_port = htons (port); myaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - - /* we need this later. */ + + /* Set return values. */ unaddr->sun_family = myaddr.sin_family; unaddr->sun_port = myaddr.sin_port; unaddr->sun_addr.s_addr = myaddr.sin_addr.s_addr; - return connect (sockfd, (struct sockaddr *)&myaddr, sizeof myaddr); -} - - -int -_w32_sock_bind (int sockfd, struct sockaddr *addr, int addrlen) -{ - if (addr->sa_family == AF_LOCAL || addr->sa_family == AF_UNIX) + ret = connect (sockfd, (struct sockaddr *)&myaddr, sizeof myaddr); + if (!ret) { - struct sockaddr_in myaddr; - struct sockaddr_un *unaddr; - int filefd; - FILE *fp; - int len = sizeof myaddr; - int rc; - - unaddr = (struct sockaddr_un *)addr; - - myaddr.sin_port = 0; - myaddr.sin_family = AF_INET; - myaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - - filefd = open (unaddr->sun_path, - (O_WRONLY|O_CREAT|O_EXCL|O_BINARY), - (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)); - if (filefd == -1) + /* Send the nonce. */ + ret = send (sockfd, nonce, 16, 0); + if (ret >= 0 && ret != 16) { - if (errno == EEXIST) - errno = WSAEADDRINUSE; - return -1; + errno = EIO; + ret = -1; } - fp = fdopen (filefd, "wb"); - if (!fp) - { - int save_e = errno; - close (filefd); - errno = save_e; - return -1; - } - - rc = bind (sockfd, (struct sockaddr *)&myaddr, len); - if (!rc) - rc = getsockname (sockfd, (struct sockaddr *)&myaddr, &len); - if (rc) - { - int save_e = errno; - fclose (fp); - remove (unaddr->sun_path); - errno = save_e; - return rc; - } - fprintf (fp, "%d", myaddr.sin_port); - fclose (fp); - - /* The caller expects these values. */ - unaddr->sun_family = myaddr.sin_family; - unaddr->sun_port = myaddr.sin_port; - unaddr->sun_addr.s_addr = myaddr.sin_addr.s_addr; - - return 0; } - return bind (sockfd, addr, addrlen); + return ret; } + #endif /*_WIN32*/ diff --git a/jnlib/w32-afunix.h b/jnlib/w32-afunix.h index ebb61d80e..6b8f3f954 100644 --- a/jnlib/w32-afunix.h +++ b/jnlib/w32-afunix.h @@ -39,10 +39,11 @@ struct sockaddr_un char sun_path[108-2-4]; /* Path name. */ }; + int _w32_close (int fd); int _w32_sock_new (int domain, int type, int proto); -int _w32_sock_bind (int sockfd, struct sockaddr *addr, int addrlen); int _w32_sock_connect (int sockfd, struct sockaddr *addr, int addrlen); + #endif /*W32AFUNIX_DEFS_H*/ #endif /*_WIN32*/ diff --git a/po/be.po b/po/be.po index d9599c931..13a61e916 100644 --- a/po/be.po +++ b/po/be.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.2.2\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2003-10-30 16:35+0200\n" "Last-Translator: Ales Nyakhaychyk \n" "Language-Team: Belarusian \n" @@ -7509,6 +7509,10 @@ msgstr "|ІМЯ| зашыфраваць для вылучанай асобы" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +msgid "|URL|use keyserver at URL" +msgstr "" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/ca.po b/po/ca.po index e7714610a..2636d4c4a 100644 --- a/po/ca.po +++ b/po/ca.po @@ -27,7 +27,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.4.0\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2005-02-04 02:04+0100\n" "Last-Translator: Jordi Mallach \n" "Language-Team: Catalan \n" @@ -8097,6 +8097,11 @@ msgstr "|NOM|xifra per a NOM" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "no s'ha pogut analitzar sintàcticament la URI del servidor de claus\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/cs.po b/po/cs.po index b86d5069b..751227463 100644 --- a/po/cs.po +++ b/po/cs.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg-1.3.92\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2004-11-26 09:12+0200\n" "Last-Translator: Roman Pavlik \n" "Language-Team: Czech \n" @@ -7779,6 +7779,11 @@ msgstr "|JM msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "nelze zpracovat URL serveru kl\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/da.po b/po/da.po index 334ae2b8a..fa9e87aa7 100644 --- a/po/da.po +++ b/po/da.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.0.0h\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2003-12-03 16:11+0100\n" "Last-Translator: Birger Langkjer \n" "Language-Team: Danish \n" @@ -7663,6 +7663,11 @@ msgstr "|NAME|krypt msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "importr ngler fra en ngleserver: %s\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/el.po b/po/el.po index 86b8bb266..fb974fdd0 100644 --- a/po/el.po +++ b/po/el.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg-1.1.92\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2003-06-27 12:00+0200\n" "Last-Translator: Dokianakis Theofanis \n" "Language-Team: Greek \n" @@ -7951,6 +7951,11 @@ msgstr "| msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr " URI \n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/eo.po b/po/eo.po index 3f013e18a..c5b55cf59 100644 --- a/po/eo.po +++ b/po/eo.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.0.6d\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2002-04-14 14:33+0100\n" "Last-Translator: Edmund GRIMLEY EVANS \n" "Language-Team: Esperanto \n" @@ -7897,6 +7897,11 @@ msgstr "|NOMO| msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "ne povis analizi URI de losilservilo\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/es.po b/po/es.po index c04c81526..88d3bf772 100644 --- a/po/es.po +++ b/po/es.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.4.1\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2007-08-16 11:35+0200\n" "Last-Translator: Jaime Surez \n" "Language-Team: Spanish \n" @@ -7825,6 +7825,11 @@ msgstr "|NOMBRE|cifra para NOMBRE" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "no se puede interpretar la URL del servidor de claves\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/et.po b/po/et.po index 2bdac4ca2..9d48490a4 100644 --- a/po/et.po +++ b/po/et.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.2.2\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2004-06-17 11:04+0300\n" "Last-Translator: Toomas Soome \n" "Language-Team: Estonian \n" @@ -7856,6 +7856,11 @@ msgstr "|NIMI|kr msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "ei saa parsida vtmeserveri URI\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/fi.po b/po/fi.po index 53b90bb7a..299b90f1e 100644 --- a/po/fi.po +++ b/po/fi.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.2.2\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2004-06-16 22:40+0300\n" "Last-Translator: Tommi Vainikainen \n" "Language-Team: Finnish \n" @@ -7935,6 +7935,11 @@ msgstr "|NIMI|salaa vastaanottajalle NIMI" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "avainpalvelimen URI:iä ei voi jäsentää\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/fr.po b/po/fr.po index bf1e69a39..b222d6a08 100644 --- a/po/fr.po +++ b/po/fr.po @@ -11,7 +11,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.4.2rc2\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2005-06-28 00:24+0200\n" "Last-Translator: Gal Quri \n" "Language-Team: French \n" @@ -7983,6 +7983,11 @@ msgstr "|NOM|chiffrer pour NOM" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "impossible d'interprter l'URL du serveur de cls\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/gl.po b/po/gl.po index ddfd2789e..0230d4252 100644 --- a/po/gl.po +++ b/po/gl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.2.4\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2003-12-04 11:39+0100\n" "Last-Translator: Jacobo Tarrio \n" "Language-Team: Galician \n" @@ -7946,6 +7946,11 @@ msgstr "|NOME|cifrar para NOME" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "non se puido analisa-lo URI do servidor de chaves\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/hu.po b/po/hu.po index 6d98fdd54..b79e7173c 100644 --- a/po/hu.po +++ b/po/hu.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.2.5\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2004-06-19 21:53+0200\n" "Last-Translator: Nagy Ferenc Lszl \n" "Language-Team: Hungarian \n" @@ -7897,6 +7897,11 @@ msgstr "|N msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "rtelmezhetetlen a kulcsszerver URI-ja!\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/id.po b/po/id.po index 1e2d322b2..8c62e065f 100644 --- a/po/id.po +++ b/po/id.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg-id\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2004-06-17 16:32+0700\n" "Last-Translator: Tedi Heriyanto \n" "Language-Team: Indonesian \n" @@ -7899,6 +7899,11 @@ msgstr "|NAMA|enkripsi untuk NAMA" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "tidak dapat memparsing URI keyserver\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/it.po b/po/it.po index 51140a3a0..9fe861ad8 100644 --- a/po/it.po +++ b/po/it.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.1.92\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2004-06-16 17:01+0200\n" "Last-Translator: Marco d'Itri \n" "Language-Team: Italian \n" @@ -7945,6 +7945,11 @@ msgstr "|NOME|cifra per NOME" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "impossibile fare il parsing dell'URI del keyserver\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/ja.po b/po/ja.po index 4fa85733b..0efd97335 100644 --- a/po/ja.po +++ b/po/ja.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.3.92\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2004-11-23 11:14+0900\n" "Last-Translator: IIDA Yosiaki \n" "Language-Team: Japanese \n" @@ -7713,6 +7713,11 @@ msgstr "|̾ msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "СURLǽ\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/nb.po b/po/nb.po index 61531c42d..5a421d28e 100644 --- a/po/nb.po +++ b/po/nb.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.4.3\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2006-06-13 20:31+0200\n" "Last-Translator: Trond Endrestl \n" "Language-Team: Norwegian Bokml \n" @@ -7582,6 +7582,11 @@ msgstr "|NAVN|kryptere for NAVN" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "kunne ikke parse nkkelserverens URL\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/pl.po b/po/pl.po index 1d85c728a..ddcdfcc74 100644 --- a/po/pl.po +++ b/po/pl.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg-1.2.2\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2004-06-23 15:54+0200\n" "Last-Translator: Janusz A. Urbanowicz \n" "Language-Team: Polish \n" @@ -7942,6 +7942,11 @@ msgstr "|NAZWA|szyfrowanie dla odbiorcy NAZWA" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "niezrozumay URI serwera kluczy\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/pt.po b/po/pt.po index ec4935c81..5df820133 100644 --- a/po/pt.po +++ b/po/pt.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2002-09-13 18:26+0100\n" "Last-Translator: Pedro Morais \n" "Language-Team: pt \n" @@ -7911,6 +7911,11 @@ msgstr "|NOME|cifrar para NOME" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "no consegui processar a URI do servidor de chaves\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/pt_BR.po b/po/pt_BR.po index 38dd8eb43..420e99fca 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -13,7 +13,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.0\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2007-08-16 11:35+0200\n" "Last-Translator:\n" "Language-Team: ?\n" @@ -7863,6 +7863,11 @@ msgstr "|NOME|criptografar para NOME" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "impossvel escrever para o chaveiro: %s\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/ro.po b/po/ro.po index db9604bd3..89eec3ab4 100644 --- a/po/ro.po +++ b/po/ro.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.4.2rc1\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2005-05-31 22:00-0500\n" "Last-Translator: Laurentiu Buzdugan \n" "Language-Team: Romanian \n" @@ -7806,6 +7806,12 @@ msgstr "|NUME|cifrare pentru NUME" msgid "Configuration for Keyservers" msgstr "" +# +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "nu am putut interpreta URL-ul serverului de chei\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/ru.po b/po/ru.po index 8f905f854..9d48bf0d1 100644 --- a/po/ru.po +++ b/po/ru.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: GnuPG 2.0.0\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2006-11-07 19:31+0300\n" "Last-Translator: Maxim Britov \n" "Language-Team: Russian \n" @@ -7667,6 +7667,11 @@ msgstr "|NAME|зашифровать для получателя NAME" msgid "Configuration for Keyservers" msgstr "Конфигурация серверов ключей" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "не могу проанализировать URL сервера ключей\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/sk.po b/po/sk.po index 350718fdf..c60702e73 100644 --- a/po/sk.po +++ b/po/sk.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.2.5\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2004-07-20 15:52+0200\n" "Last-Translator: Michal Majer \n" "Language-Team: Slovak \n" @@ -7917,6 +7917,11 @@ msgstr "|MENO| msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "nemono poui URI servera kov - chyba analzy URI\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/sv.po b/po/sv.po index 7b367ab03..10edebc09 100644 --- a/po/sv.po +++ b/po/sv.po @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 2.0\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2007-02-17 13:13+0100\n" "Last-Translator: Daniel Nylander \n" "Language-Team: Swedish \n" @@ -7880,6 +7880,11 @@ msgstr "|NAMN|kryptera för NAMN" msgid "Configuration for Keyservers" msgstr "Konfiguration för nyckelservrar" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "kunde inte tolka url till nyckelserver\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "tillåt PKA-uppslag (DNS-förfrågningar)" diff --git a/po/tr.po b/po/tr.po index 099a0ef26..0a7877532 100644 --- a/po/tr.po +++ b/po/tr.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.9.94\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2006-11-04 03:45+0200\n" "Last-Translator: Nilgün Belma Bugüner \n" "Language-Team: Turkish \n" @@ -7755,6 +7755,11 @@ msgstr "|İSİM|İSİM için şifreleme yapar" msgid "Configuration for Keyservers" msgstr "Anahtar sunucular için yapılandırma" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "anahtar sunucusunun adresi çözümlenemedi\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "PKA aramalarına izin verilir (DNS istekleri)" diff --git a/po/zh_CN.po b/po/zh_CN.po index 7727fa245..8275205a8 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.4.4\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2006-07-02 10:58+0800\n" "Last-Translator: Meng Jie \n" "Language-Team: Chinese (simplified) \n" @@ -7615,6 +7615,11 @@ msgstr "|某甲|为收件者“某甲”加密" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "无法解析公钥服务器 URL\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/po/zh_TW.po b/po/zh_TW.po index cc52500f1..2cb01ef09 100644 --- a/po/zh_TW.po +++ b/po/zh_TW.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: gnupg 1.4.2\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2007-09-10 17:28+0200\n" +"POT-Creation-Date: 2007-09-14 13:27+0200\n" "PO-Revision-Date: 2005-07-29 09:49+0800\n" "Last-Translator: Jedi \n" "Language-Team: Chinese (traditional) \n" @@ -7655,6 +7655,11 @@ msgstr "|名字|以「名字」作為加密對象" msgid "Configuration for Keyservers" msgstr "" +#: tools/gpgconf-comp.c:673 +#, fuzzy +msgid "|URL|use keyserver at URL" +msgstr "無法剖析金鑰伺服器 URI\n" + #: tools/gpgconf-comp.c:676 msgid "allow PKA lookups (DNS requests)" msgstr "" diff --git a/scd/ChangeLog b/scd/ChangeLog index 420e41edb..56aca1fb7 100644 --- a/scd/ChangeLog +++ b/scd/ChangeLog @@ -1,3 +1,10 @@ +2007-10-01 Werner Koch + + * scdaemon.c (create_server_socket): Use Assuan socket wrappers + and remove Windows specific code. + (socket_nonce): New. + (start_connection_thread): Check nonce. + 2007-09-14 Marcus Brinkmann * scdaemon.c (main): New variable STANDARD_SOCKET, which is 1 for diff --git a/scd/scdaemon.c b/scd/scdaemon.c index 049d45dfd..41085049b 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -47,9 +47,6 @@ #include "i18n.h" #include "sysutils.h" #include "app-common.h" -#ifdef HAVE_W32_SYSTEM -#include "../jnlib/w32-afunix.h" -#endif #include "ccid-driver.h" #include "mkdtemp.h" #include "gc-opt-flags.h" @@ -170,6 +167,9 @@ static int maybe_setuid = 1; /* Name of the communication socket */ static char *socket_name; +/* We need to keep track of the server's nonces (these are dummies for + POSIX systems). */ +static assuan_sock_nonce_t socket_nonce; /* Debug flag to disable the ticker. The ticker is in fact not disabled but it won't perform any ticker specific actions. */ @@ -179,7 +179,8 @@ static int ticker_disabled; static char *create_socket_name (int use_standard_socket, char *standard_name, char *template); -static int create_server_socket (int is_standard_name, const char *name); +static gnupg_fd_t create_server_socket (int is_standard_name, const char *name, + assuan_sock_nonce_t *nonce); static void *start_connection_thread (void *arg); static void handle_connections (int listen_fd); @@ -631,7 +632,7 @@ main (int argc, char **argv ) "S.scdaemon", "/tmp/gpg-XXXXXX/S.scdaemon"); - fd = create_server_socket (0, socket_name); + fd = FD2INT(create_server_socket (0, socket_name, &socket_nonce)); } tattr = pth_attr_new(); @@ -646,7 +647,7 @@ main (int argc, char **argv ) strerror (errno) ); scd_exit (2); } - ctrl->thread_startup.fd = -1; + ctrl->thread_startup.fd = GNUPG_INVALID_FD; if ( !pth_spawn (tattr, start_connection_thread, ctrl) ) { log_error ("error spawning pipe connection handler: %s\n", @@ -667,15 +668,17 @@ main (int argc, char **argv ) else { /* Regular server mode */ int fd; +#ifndef HAVE_W32_SYSTEM pid_t pid; int i; +#endif /* Create the socket. */ socket_name = create_socket_name (standard_socket, "S.scdaemon", "/tmp/gpg-XXXXXX/S.scdaemon"); - fd = create_server_socket (0, socket_name); + fd = FD2INT (create_server_socket (0, socket_name, &socket_nonce)); fflush (NULL); @@ -936,20 +939,17 @@ create_socket_name (int use_standard_socket, /* Create a Unix domain socket with NAME. IS_STANDARD_NAME indicates whether a non-random socket is used. Returns the file descriptor or terminates the process in case of an error. */ -static int -create_server_socket (int is_standard_name, const char *name) +static gnupg_fd_t +create_server_socket (int is_standard_name, const char *name, + assuan_sock_nonce_t *nonce) { struct sockaddr_un *serv_addr; socklen_t len; - int fd; + gnupg_fd_t fd; int rc; -#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) + fd = assuan_sock_new (AF_UNIX, SOCK_STREAM, 0); + if (fd == GNUPG_INVALID_FD) { log_error (_("can't create socket: %s\n"), strerror (errno)); scd_exit (2); @@ -963,33 +963,27 @@ create_server_socket (int is_standard_name, const char *name) len = (offsetof (struct sockaddr_un, sun_path) + strlen (serv_addr->sun_path) + 1); -#ifdef HAVE_W32_SYSTEM - rc = _w32_sock_bind (fd, (struct sockaddr*) serv_addr, len); - if (is_standard_name && rc == -1 ) - { - remove (name); - rc = bind (fd, (struct sockaddr*) serv_addr, len); - } -#else - rc = bind (fd, (struct sockaddr*) serv_addr, len); + rc = assuan_sock_bind (fd, (struct sockaddr*) serv_addr, len); if (is_standard_name && rc == -1 && errno == EADDRINUSE) { remove (name); - rc = bind (fd, (struct sockaddr*) serv_addr, len); + rc = assuan_sock_bind (fd, (struct sockaddr*) serv_addr, len); } -#endif - if (rc == -1) + if (rc != -1 + && (rc=assuan_sock_get_nonce ((struct sockaddr*)serv_addr, len, nonce))) + log_error (_("error getting nonce for the socket\n")); + if (rc == -1) { log_error (_("error binding socket to `%s': %s\n"), serv_addr->sun_path, strerror (errno)); - close (fd); + assuan_sock_close (fd); scd_exit (2); } - if (listen (fd, 5 ) == -1) + if (listen (FD2INT(fd), 5 ) == -1) { log_error (_("listen() failed: %s\n"), strerror (errno)); - close (fd); + assuan_sock_close (fd); scd_exit (2); } @@ -1007,20 +1001,31 @@ start_connection_thread (void *arg) { ctrl_t ctrl = arg; + if (assuan_sock_check_nonce (ctrl->thread_startup.fd, &socket_nonce)) + { + log_info (_("error reading nonce on fd %d: %s\n"), + FD2INT(ctrl->thread_startup.fd), strerror (errno)); + assuan_sock_close (ctrl->thread_startup.fd); + xfree (ctrl); + return NULL; + } + scd_init_default_ctrl (ctrl); if (opt.verbose) - log_info (_("handler for fd %d started\n"), ctrl->thread_startup.fd); + log_info (_("handler for fd %d started\n"), + FD2INT(ctrl->thread_startup.fd)); - scd_command_handler (ctrl, ctrl->thread_startup.fd); + scd_command_handler (ctrl, FD2INT(ctrl->thread_startup.fd)); if (opt.verbose) - log_info (_("handler for fd %d terminated\n"), ctrl->thread_startup.fd); + log_info (_("handler for fd %d terminated\n"), + FD2INT (ctrl->thread_startup.fd)); /* If this thread is the pipe connection thread, flag that a shutdown is required. With the next ticker event and given that no other connections are running the shutdown will then happen. */ - if (ctrl->thread_startup.fd == -1) + if (ctrl->thread_startup.fd == GNUPG_INVALID_FD) shutdown_pending = 1; scd_deinit_default_ctrl (ctrl); @@ -1166,7 +1171,7 @@ handle_connections (int listen_fd) snprintf (threadname, sizeof threadname-1, "conn fd=%d", fd); threadname[sizeof threadname -1] = 0; pth_attr_set (tattr, PTH_ATTR_NAME, threadname); - ctrl->thread_startup.fd = fd; + ctrl->thread_startup.fd = INT2FD (fd); if (!pth_spawn (tattr, start_connection_thread, ctrl)) { log_error ("error spawning connection handler: %s\n", diff --git a/scd/scdaemon.h b/scd/scdaemon.h index 762ba7457..df4f89034 100644 --- a/scd/scdaemon.h +++ b/scd/scdaemon.h @@ -30,7 +30,7 @@ #include #include "../common/util.h" #include "../common/errors.h" - +#include "../common/sysutils.h" /* To convey some special hash algorithms we use algorithm numbers reserved for application use. */ @@ -91,7 +91,7 @@ struct server_control_s /* Private data used to fire up the connection thread. We use this structure do avoid an extra allocation for just a few bytes. */ struct { - int fd; + gnupg_fd_t fd; } thread_startup; /* Local data of the server; used only in command.c. */ diff --git a/tools/ChangeLog b/tools/ChangeLog index 81bad157b..1b4bad67c 100644 --- a/tools/ChangeLog +++ b/tools/ChangeLog @@ -1,3 +1,12 @@ +2007-10-01 Werner Koch + + * gpg-connect-agent.c (do_sendfd): Use INT2FD for assuan_sendfd. + +2007-09-26 Werner Koch + + * gpg-connect-agent.c (main): Print the first response from the + server. + 2007-09-14 Werner Koch * gpgconf-comp.c: Make a string translatable. diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c index 5322a4fc5..2300b7f88 100644 --- a/tools/gpg-connect-agent.c +++ b/tools/gpg-connect-agent.c @@ -29,7 +29,7 @@ #include "i18n.h" #include "../common/util.h" #include "../common/asshelp.h" - +#include "../common/sysutils.h" /* Constants to identify the commands and options. */ @@ -244,7 +244,7 @@ do_sendfd (assuan_context_t ctx, char *line) log_error ("file `%s' opened in \"%s\" mode, fd=%d\n", name, mode, fd); - rc = assuan_sendfd (ctx, fd); + rc = assuan_sendfd (ctx, INT2FD (fd) ); if (rc) log_error ("sednig descriptor %d failed: %s\n", fd, gpg_strerror (rc)); fclose (fp); @@ -360,6 +360,16 @@ main (int argc, char **argv) } else ctx = start_agent (); + + /* See whether there is a line pending from the server (in case + assuan did not run the initial handshaking). */ + if (assuan_pending_line (ctx)) + { + rc = read_and_print_response (ctx); + if (rc) + log_info (_("receiving line failed: %s\n"), gpg_strerror (rc) ); + } + line = NULL; linesize = 0; for (;;)