mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
2009-09-23 Marcus Brinkmann <marcus@g10code.de>
* configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION): Update to new API (2, 1.1.0). agent/ 2009-09-23 Marcus Brinkmann <marcus@g10code.de> * gpg-agent.c (parse_rereadable_options): Don't set global assuan log file (there ain't one anymore). (main): Update to new API. (check_own_socket_pid_cb): Return gpg_error_t instead of int. (check_own_socket_thread, check_for_running_agent): Create assuan context before connecting to server. * command.c: Include "scdaemon.h" before <assuan.h> because of GPG_ERR_SOURCE_DEFAULT check. (write_and_clear_outbuf): Use gpg_error_t instead of assuan_error_t. (cmd_geteventcounter, cmd_istrusted, cmd_listtrusted) (cmd_marktrusted, cmd_havekey, cmd_sigkey, cmd_setkeydesc) (cmd_sethash, cmd_pksign, cmd_pkdecrypt, cmd_genkey, cmd_readkey) (cmd_keyinfo, cmd_get_passphrase, cmd_clear_passphrase) (cmd_get_confirmation, cmd_learn, cmd_passwd) (cmd_preset_passphrase, cmd_scd, cmd_getval, cmd_putval) (cmd_updatestartuptty, cmd_killagent, cmd_reloadagent) (cmd_getinfo, option_handler): Return gpg_error_t instead of int. (post_cmd_notify): Change type of ERR to gpg_error_t from int. (io_monitor): Add hook argument. Use symbols for constants. (register_commands): Change return type of HANDLER to gpg_error_t. (start_command_handler): Allocate assuan context before starting server. * call-pinentry.c: Include "scdaemon.h" before <assuan.h> because of GPG_ERR_SOURCE_DEFAULT check. (unlock_pinentry): Call assuan_release instead of assuan_disconnect. (getinfo_pid_cb, getpin_cb): Return gpg_error_t instead of int. (start_pinentry): Allocate assuan context before connecting to server. * call-scd.c (membuf_data_cb, learn_status_cb, get_serialno_cb) (membuf_data_cb, inq_needpin, card_getattr_cb, pass_status_thru) (pass_data_thru): Change return type to gpg_error_t. (start_scd): Allocate assuan context before connecting to server. common/ 2009-09-23 Marcus Brinkmann <marcus@g10code.de> * asshelp.c (start_new_gpg_agent): Allocate assuan context before starting server. g10/ 2009-09-23 Marcus Brinkmann <marcus@g10code.de> * call-agent.c: Include "scdaemon.h" before <assuan.h> because of GPG_ERR_SOURCE_DEFAULT check. (learn_status_cb, dummy_data_cb, get_serialno_cb, default_inq_cb) (learn_status_cb, inq_writecert_parms, inq_writekey_parms) (scd_genkey_cb, membuf_data_cb): Return gpg_error_t instead of int. * gpg.c: Include "scdaemon.h" before <assuan.h> because of GPG_ERR_SOURCE_DEFAULT check. (main): Update to new Assuan API. * server.c: Include "scdaemon.h" before <assuan.h> because of GPG_ERR_SOURCE_DEFAULT check. (option_handler, cmd_recipient, cmd_signer, cmd_encrypt) (cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export) (cmd_delkeys, cmd_message, do_listkeys, cmd_listkeys) (cmd_listsecretkeys, cmd_genkey, cmd_getinfo): Return gpg_error_t instead of int. (register_commands): Allocate assuan context before starting server. (gpg_server): Allocate assuan_context before starting server. scd/ 2009-09-23 Marcus Brinkmann <marcus@g10code.de> * command.c: Include "scdaemon.h" before <assuan.h> because of GPG_ERR_SOURCE_DEFAULT check. (option_handler, open_card, cmd_serialno, cmd_lean, cmd_readcert) (cmd_readkey, cmd_setdata, cmd_pksign, cmd_pkauth, cmd_pkdecrypt) (cmd_getattr, cmd_setattr, cmd_writecert, cmd_writekey) (cmd_genkey, cmd_random, cmd_passwd, cmd_checkpin, cmd_lock) (cmd_unlock, cmd_getinfo, cmd_restart, cmd_disconnect, cmd_apdu) (cmd_killscd): Return gpg_error_t instead of int. (scd_command_handler): Allocate assuan context before starting server. * scdaemon.c (main): Update to new Assuan API. sm/ 2009-09-23 Marcus Brinkmann <marcus@g10code.de> * gpgsm.c (main): Update to new assuan API. * server.c: Include "gpgsm.h" before <assuan.h> due to check for GPG_ERR_SOURCE_DEFAULT and assuan.h now including gpg-error.h. (option_handler, cmd_recipient, cmd_signer, cmd_encrypt) (cmd_decrypt, cmd_verify, cmd_sign, cmd_import, cmd_export) (cmd_delkeys, cmd_message, cmd_listkeys, cmd_dumpkeys) (cmd_listsecretkeys, cmd_dumpsecretkeys, cmd_genkey) (cmd_getauditlog, cmd_getinfo): Return gpg_error_t instead of int. (register_commands): Same for member HANDLER in table. (gpgsm_server): Allocate assuan context before starting server. * sm/call-dirmngr.c: * call-dirmngr.c (prepare_dirmngr): Check for CTX and error before setting LDAPSERVER. (start_dirmngr_ext): Allocate assuan context before starting server. (inq_certificate, isvalid_status_cb, lookup_cb, lookup_status_cb) (run_command_cb, run_command_inq_cb, run_command_status_cb): Return gpg_error_t instead of int. tools/ 2009-09-23 Marcus Brinkmann <marcus@g10code.de> * gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response) (main): Update to new Assuan API.
This commit is contained in:
parent
b46c353318
commit
3974488cd1
22 changed files with 393 additions and 194 deletions
|
@ -471,7 +471,6 @@ parse_rereadable_options (ARGPARSE_ARGS *pargs, int reread)
|
|||
|| strcmp (current_logfile, pargs->r.ret_str))
|
||||
{
|
||||
log_set_file (pargs->r.ret_str);
|
||||
assuan_set_assuan_log_stream (log_get_stream ());
|
||||
xfree (current_logfile);
|
||||
current_logfile = xtrystrdup (pargs->r.ret_str);
|
||||
}
|
||||
|
@ -545,7 +544,7 @@ main (int argc, char **argv )
|
|||
int gpgconf_list = 0;
|
||||
gpg_error_t err;
|
||||
const char *env_file_name = NULL;
|
||||
|
||||
struct assuan_malloc_hooks malloc_hooks;
|
||||
|
||||
/* Before we do anything else we save the list of currently open
|
||||
file descriptors and the signal mask. This info is required to
|
||||
|
@ -588,10 +587,12 @@ main (int argc, char **argv )
|
|||
NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
|
||||
}
|
||||
|
||||
assuan_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free);
|
||||
assuan_set_assuan_log_stream (log_get_stream ());
|
||||
malloc_hooks.malloc = gcry_malloc;
|
||||
malloc_hooks.realloc = gcry_realloc;
|
||||
malloc_hooks.free = gcry_free;
|
||||
assuan_set_malloc_hooks (&malloc_hooks);
|
||||
assuan_set_assuan_log_prefix (log_get_prefix (NULL));
|
||||
assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT);
|
||||
assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
|
||||
|
||||
setup_libgcrypt_logging ();
|
||||
gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);
|
||||
|
@ -917,7 +918,6 @@ main (int argc, char **argv )
|
|||
|JNLIB_LOG_WITH_TIME
|
||||
|JNLIB_LOG_WITH_PID));
|
||||
current_logfile = xstrdup (logfile);
|
||||
assuan_set_assuan_log_stream (log_get_stream ());
|
||||
}
|
||||
|
||||
/* Make sure that we have a default ttyname. */
|
||||
|
@ -2048,7 +2048,7 @@ handle_connections (gnupg_fd_t listen_fd, gnupg_fd_t listen_fd_ssh)
|
|||
|
||||
|
||||
/* Helper for check_own_socket. */
|
||||
static int
|
||||
static gpg_error_t
|
||||
check_own_socket_pid_cb (void *opaque, const void *buffer, size_t length)
|
||||
{
|
||||
membuf_t *mb = opaque;
|
||||
|
@ -2065,14 +2065,21 @@ check_own_socket_thread (void *arg)
|
|||
{
|
||||
int rc;
|
||||
char *sockname = arg;
|
||||
assuan_context_t ctx;
|
||||
assuan_context_t ctx = NULL;
|
||||
membuf_t mb;
|
||||
char *buffer;
|
||||
|
||||
check_own_socket_running++;
|
||||
|
||||
rc = assuan_socket_connect (&ctx, sockname, (pid_t)(-1));
|
||||
rc = assuan_new (&ctx);
|
||||
xfree (sockname);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("can't allocate assuan context: %s\n", gpg_strerror (rc));
|
||||
goto leave;
|
||||
}
|
||||
|
||||
rc = assuan_socket_connect (ctx, sockname, (pid_t)(-1));
|
||||
if (rc)
|
||||
{
|
||||
log_error ("can't connect my own socket: %s\n", gpg_strerror (rc));
|
||||
|
@ -2099,9 +2106,10 @@ check_own_socket_thread (void *arg)
|
|||
log_error ("socket is still served by this server\n");
|
||||
|
||||
xfree (buffer);
|
||||
assuan_disconnect (ctx);
|
||||
|
||||
leave:
|
||||
if (ctx)
|
||||
assuan_release (ctx);
|
||||
if (rc)
|
||||
{
|
||||
/* We may not remove the socket as it is now in use by another
|
||||
|
@ -2159,7 +2167,7 @@ check_for_running_agent (int silent, int mode)
|
|||
{
|
||||
int rc;
|
||||
char *infostr, *p;
|
||||
assuan_context_t ctx;
|
||||
assuan_context_t ctx = NULL;
|
||||
int prot, pid;
|
||||
|
||||
if (!mode)
|
||||
|
@ -2207,8 +2215,9 @@ check_for_running_agent (int silent, int mode)
|
|||
pid = (pid_t)(-1);
|
||||
}
|
||||
|
||||
|
||||
rc = assuan_socket_connect (&ctx, infostr, pid);
|
||||
rc = assuan_new (&ctx);
|
||||
if (! rc)
|
||||
rc = assuan_socket_connect (&ctx, infostr, pid);
|
||||
xfree (infostr);
|
||||
if (rc)
|
||||
{
|
||||
|
@ -2217,12 +2226,15 @@ check_for_running_agent (int silent, int mode)
|
|||
|
||||
if (!mode && !silent)
|
||||
log_error ("can't connect to the agent: %s\n", gpg_strerror (rc));
|
||||
|
||||
if (ctx)
|
||||
assuan_release (ctx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!opt.quiet && !silent)
|
||||
log_info ("gpg-agent running and available\n");
|
||||
|
||||
assuan_disconnect (ctx);
|
||||
assuan_release (ctx);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue