diff options
author | Werner Koch <[email protected]> | 2005-05-20 20:37:08 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2005-05-20 20:37:08 +0000 |
commit | bd644c8d45ff2903625edb8b41bffcb6a8a69b85 (patch) | |
tree | d9a7fedf142c24fb6b48f719d70a90bb3b192cd4 /g10/passphrase.c | |
parent | * gpg.sgml: Document --default-sig-expire and --default-cert-expire, (diff) | |
download | gnupg-bd644c8d45ff2903625edb8b41bffcb6a8a69b85.tar.gz gnupg-bd644c8d45ff2903625edb8b41bffcb6a8a69b85.zip |
(ccid_transceive): Arghhh. The seqno is another
bit in the R-block than in the I block, this was wrong at one
place. Fixes bug #419 and hopefully several others.
Diffstat (limited to 'g10/passphrase.c')
-rw-r--r-- | g10/passphrase.c | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/g10/passphrase.c b/g10/passphrase.c index a68d564fe..030d801b2 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -278,12 +278,13 @@ agent_send_all_options (assuan_context_t ctx) /* * Open a connection to the agent and initializes the connection. - * Returns: -1 on error; on success a file descriptor for that - * connection is returned. + * Returns: -1 on error; on success an Assuan context for that + * connection is returned. With TRY set to true, no error messages + * are printed and the use of the agent won't get disabled on failure. */ #ifdef ENABLE_AGENT_SUPPORT -static assuan_context_t -agent_open (void) +assuan_context_t +agent_open (int try) { int rc; assuan_context_t ctx; @@ -298,8 +299,11 @@ agent_open (void) infostr = getenv ( "GPG_AGENT_INFO" ); if (!infostr || !*infostr) { - log_error (_("gpg-agent is not available in this session\n")); - opt.use_agent = 0; + if (!try) + { + log_error (_("gpg-agent is not available in this session\n")); + opt.use_agent = 0; + } return NULL; } infostr = xstrdup ( infostr ); @@ -307,9 +311,12 @@ agent_open (void) if ( !(p = strchr (infostr, PATHSEP_C)) || p == infostr) { - log_error ( _("malformed GPG_AGENT_INFO environment variable\n")); + if (!try) + { + log_error ( _("malformed GPG_AGENT_INFO environment variable\n")); + opt.use_agent = 0; + } xfree (infostr); - opt.use_agent = 0; return NULL; } *p++ = 0; @@ -319,28 +326,38 @@ agent_open (void) prot = *p? atoi (p+1) : 0; if (prot != 1) { - log_error (_("gpg-agent protocol version %d is not supported\n"), prot); + if (!try) + { + log_error (_("gpg-agent protocol version %d is not supported\n"), + prot); + opt.use_agent = 0; + } xfree (infostr); - opt.use_agent = 0; return NULL; } rc = assuan_socket_connect (&ctx, infostr, pid); if (rc) { - log_error ( _("can't connect to `%s': %s\n"), - infostr, assuan_strerror (rc)); + if (!try) + { + log_error ( _("can't connect to `%s': %s\n"), + infostr, assuan_strerror (rc)); + opt.use_agent = 0; + } xfree (infostr ); - opt.use_agent = 0; return NULL; } xfree (infostr); if (agent_send_all_options (ctx)) { - log_error (_("problem with the agent - disabling agent use\n")); + if (!try) + { + log_error (_("problem with the agent - disabling agent use\n")); + opt.use_agent = 0; + } assuan_disconnect (ctx); - opt.use_agent = 0; return NULL; } @@ -350,7 +367,7 @@ agent_open (void) #ifdef ENABLE_AGENT_SUPPORT -static void +void agent_close (assuan_context_t ctx) { assuan_disconnect (ctx); @@ -474,7 +491,7 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *cacheid, } #endif - if ( !(ctx = agent_open ()) ) + if ( !(ctx = agent_open (0)) ) goto failure; if (custom_description) @@ -672,7 +689,7 @@ passphrase_clear_cache ( u32 *keyid, const char *cacheid, int algo ) else pk = NULL; - if ( !(ctx = agent_open ()) ) + if ( !(ctx = agent_open (0)) ) goto failure; { |