diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/ChangeLog | 23 | ||||
-rw-r--r-- | common/Makefile.am | 2 | ||||
-rw-r--r-- | common/asshelp.c | 25 | ||||
-rw-r--r-- | common/get-passphrase.c | 4 | ||||
-rw-r--r-- | common/iobuf.c | 26 |
5 files changed, 69 insertions, 11 deletions
diff --git a/common/ChangeLog b/common/ChangeLog index 5dfdd0514..c236ae17a 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,3 +1,26 @@ +2010-02-11 Marcus Brinkmann <[email protected]> + + From trunk 2009-10-16, 2009-11-02, 2009-11-05: + + * Makefile.am (libcommon_a_CFLAGS): Use LIBASSUAN_CFLAGS instead + of LIBASSUAN_PTH_CFLAGS. + * get-passphrase.c (default_inq_cb, membuf_data_cb): Change return + type to gpg_error_t. + * asshelp.c (start_new_gpg_agent): Update use of + assuan_socket_connect and assuan_pipe_connect. Convert posix FD + to assuan FD. + [HAVE_W32_SYSTEM]: Add missing argument in assuan_socket_connect + invocation. + * iobuf.c (iobuf_open_fd_or_name): Fix type of FD in function + declaration. + +2009-10-13 Werner Koch <[email protected]> + + From trunk 2009-09-23: + + * asshelp.c (start_new_gpg_agent): Allocate assuan context before + starting server. + 2009-12-21 Marcus Brinkmann <[email protected]> (wk) * Makefile.am (audit-events.h, status.h) [!MAINTAINER_MODE]: No diff --git a/common/Makefile.am b/common/Makefile.am index 03e62ef85..b50223b86 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -87,7 +87,7 @@ libcommonpth_a_SOURCES = $(common_sources) if USE_DNS_SRV libcommonpth_a_SOURCES += srv.c endif -libcommonpth_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_PTH_CFLAGS) $(PTH_CFLAGS) +libcommonpth_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) $(PTH_CFLAGS) libsimple_pwquery_a_SOURCES = \ simple-pwquery.c simple-pwquery.h asshelp.c asshelp.h diff --git a/common/asshelp.c b/common/asshelp.c index b373baf98..b2d13f32b 100644 --- a/common/asshelp.c +++ b/common/asshelp.c @@ -183,6 +183,13 @@ start_new_gpg_agent (assuan_context_t *r_ctx, *r_ctx = NULL; + rc = assuan_new (&ctx); + if (rc) + { + log_error ("error allocating assuan context: %s\n", gpg_strerror (rc)); + return rc; + } + restart: infostr = force_pipe_server? NULL : getenv ("GPG_AGENT_INFO"); if (!infostr || !*infostr) @@ -192,7 +199,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx, /* First check whether we can connect at the standard socket. */ sockname = make_filename (homedir, "S.gpg-agent", NULL); - rc = assuan_socket_connect (&ctx, sockname, 0); + rc = assuan_socket_connect (ctx, sockname, 0, 0); if (rc) { @@ -210,6 +217,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx, log_error ("error flushing pending output: %s\n", strerror (errno)); xfree (sockname); + assuan_release (ctx); return tmperr; } @@ -239,7 +247,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx, /* Give the agent some time to prepare itself. */ gnupg_sleep (3); /* Now try again to connect the agent. */ - rc = assuan_socket_connect (&ctx, sockname, 0); + rc = assuan_socket_connect (ctx, sockname, 0, 0); } } #else /*!HAVE_W32_SYSTEM*/ @@ -260,13 +268,13 @@ start_new_gpg_agent (assuan_context_t *r_ctx, i=0; if (log_get_fd () != -1) - no_close_list[i++] = log_get_fd (); - no_close_list[i++] = fileno (stderr); + no_close_list[i++] = assuan_fd_from_posix_fd (log_get_fd ()); + no_close_list[i++] = assuan_fd_from_posix_fd (fileno (stderr)); no_close_list[i] = -1; /* Connect to the agent and perform initial handshaking. */ - rc = assuan_pipe_connect (&ctx, agent_program, argv, - no_close_list); + rc = assuan_pipe_connect (ctx, agent_program, argv, + no_close_list, NULL, NULL, 0); } #endif /*!HAVE_W32_SYSTEM*/ } @@ -299,7 +307,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx, goto restart; } - rc = assuan_socket_connect (&ctx, infostr, pid); + rc = assuan_socket_connect (ctx, infostr, pid, 0); xfree (infostr); if (gpg_err_code (rc) == GPG_ERR_ASS_CONNECT_FAILED) { @@ -312,6 +320,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx, if (rc) { log_error ("can't connect to the agent: %s\n", gpg_strerror (rc)); + assuan_release (ctx); return gpg_error (GPG_ERR_NO_AGENT); } @@ -326,7 +335,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx, session_env); if (rc) { - assuan_disconnect (ctx); + assuan_release (ctx); return rc; } diff --git a/common/get-passphrase.c b/common/get-passphrase.c index e1a11482e..090079405 100644 --- a/common/get-passphrase.c +++ b/common/get-passphrase.c @@ -103,7 +103,7 @@ start_agent (void) /* This is the default inquiry callback. It merely handles the Pinentry notification. */ -static int +static gpg_error_t default_inq_cb (void *opaque, const char *line) { (void)opaque; @@ -120,7 +120,7 @@ default_inq_cb (void *opaque, const char *line) } -static int +static gpg_error_t membuf_data_cb (void *opaque, const void *buffer, size_t length) { membuf_t *data = opaque; diff --git a/common/iobuf.c b/common/iobuf.c index 4ec151f5f..04b17ff17 100644 --- a/common/iobuf.c +++ b/common/iobuf.c @@ -1260,6 +1260,32 @@ iobuf_is_pipe_filename (const char *fname) return check_special_filename (fname) != -1; } + +/* Either open the file specified by the file descriptor FD or - if FD + is -1, the file with name FNAME. As of now MODE is assumed to be + "rb" if FNAME is used. In contrast to iobuf_fdopen the file + descriptor FD will not be closed during an iobuf_close. */ +iobuf_t +iobuf_open_fd_or_name (gnupg_fd_t fd, const char *fname, const char *mode) +{ + iobuf_t a; + + if (fd == -1) + a = iobuf_open (fname); + else + { + int fd2; + + fd2 = dup (fd); + if (fd2 == -1) + a = NULL; + else + a = iobuf_fdopen (fd2, mode); + } + return a; +} + + /**************** * Create a head iobuf for reading from a file * returns: NULL if an error occures and sets errno |