diff options
author | Marcus Brinkmann <[email protected]> | 2009-09-23 00:01:25 +0000 |
---|---|---|
committer | Marcus Brinkmann <[email protected]> | 2009-09-23 00:01:25 +0000 |
commit | 3974488cd1fbe8471ec06b6ed057e56a446616b8 (patch) | |
tree | df568235475e7575f891f072cb68190c85e4f3c0 /sm | |
parent | Start a new development branch. (diff) | |
download | gnupg-3974488cd1fbe8471ec06b6ed057e56a446616b8.tar.gz gnupg-3974488cd1fbe8471ec06b6ed057e56a446616b8.zip |
2009-09-23 Marcus Brinkmann <[email protected]>
* configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION):
Update to new API (2, 1.1.0).
agent/
2009-09-23 Marcus Brinkmann <[email protected]>
* 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 <[email protected]>
* asshelp.c (start_new_gpg_agent): Allocate assuan context before
starting server.
g10/
2009-09-23 Marcus Brinkmann <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response)
(main): Update to new Assuan API.
Diffstat (limited to 'sm')
-rw-r--r-- | sm/ChangeLog | 21 | ||||
-rw-r--r-- | sm/call-dirmngr.c | 32 | ||||
-rw-r--r-- | sm/gpgsm.c | 9 | ||||
-rw-r--r-- | sm/server.c | 53 |
4 files changed, 79 insertions, 36 deletions
diff --git a/sm/ChangeLog b/sm/ChangeLog index 4ac44576e..f26bcd01a 100644 --- a/sm/ChangeLog +++ b/sm/ChangeLog @@ -1,3 +1,24 @@ +2009-09-23 Marcus Brinkmann <[email protected]> + + * 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. + 2009-08-06 Werner Koch <[email protected]> * sign.c (gpgsm_sign): Print INV_SNDR for a bad default key. diff --git a/sm/call-dirmngr.c b/sm/call-dirmngr.c index 33aebdf13..17d557838 100644 --- a/sm/call-dirmngr.c +++ b/sm/call-dirmngr.c @@ -159,6 +159,9 @@ prepare_dirmngr (ctrl_t ctrl, assuan_context_t ctx, gpg_error_t err) } audit_log_ok (ctrl->audit, AUDIT_DIRMNGR_READY, err); + if (!ctx || err) + return; + server = opt.keyserver; while (server) { @@ -188,7 +191,7 @@ start_dirmngr_ext (ctrl_t ctrl, assuan_context_t *ctx_r) { int rc; char *infostr, *p; - assuan_context_t ctx; + assuan_context_t ctx = NULL; int try_default = 0; if (opt.disable_dirmngr) @@ -216,6 +219,14 @@ start_dirmngr_ext (ctrl_t ctrl, assuan_context_t *ctx_r) infostr = xstrdup (dirmngr_socket_name ()); try_default = 1; } + + rc = assuan_new (&ctx); + if (rc) + { + log_error ("can't allocate assuan context: %s\n", gpg_strerror (rc)); + return rc; + } + if (!infostr) { const char *pgmname; @@ -252,7 +263,7 @@ start_dirmngr_ext (ctrl_t ctrl, assuan_context_t *ctx_r) no_close_list[i] = -1; /* connect to the agent and perform initial handshaking */ - rc = assuan_pipe_connect (&ctx, opt.dirmngr_program, argv, + rc = assuan_pipe_connect (ctx, opt.dirmngr_program, argv, no_close_list); } else @@ -286,7 +297,7 @@ start_dirmngr_ext (ctrl_t ctrl, assuan_context_t *ctx_r) else pid = -1; - rc = assuan_socket_connect (&ctx, infostr, pid); + rc = assuan_socket_connect (ctx, infostr, pid); #ifdef HAVE_W32_SYSTEM if (rc) log_debug ("connecting dirmngr at `%s' failed\n", infostr); @@ -307,6 +318,7 @@ start_dirmngr_ext (ctrl_t ctrl, assuan_context_t *ctx_r) if (rc) { + assuan_release (ctx); log_error ("can't connect to the dirmngr: %s\n", gpg_strerror (rc)); return gpg_error (GPG_ERR_NO_DIRMNGR); } @@ -376,7 +388,7 @@ release_dirmngr2 (ctrl_t ctrl) /* Handle a SENDCERT inquiry. */ -static int +static gpg_error_t inq_certificate (void *opaque, const char *line) { struct inq_certificate_parm_s *parm = opaque; @@ -504,7 +516,7 @@ unhexify_fpr (const char *hexstr, unsigned char *fpr) } -static assuan_error_t +static gpg_error_t isvalid_status_cb (void *opaque, const char *line) { struct isvalid_status_parm_s *parm = opaque; @@ -677,7 +689,7 @@ gpgsm_dirmngr_isvalid (ctrl_t ctrl, /* Lookup helpers*/ -static int +static gpg_error_t lookup_cb (void *opaque, const void *buffer, size_t length) { struct lookup_parm_s *parm = opaque; @@ -783,7 +795,7 @@ pattern_from_strlist (strlist_t names) return pattern; } -static int +static gpg_error_t lookup_status_cb (void *opaque, const char *line) { struct lookup_parm_s *parm = opaque; @@ -889,7 +901,7 @@ gpgsm_dirmngr_lookup (ctrl_t ctrl, strlist_t names, int cache_only, /* Run Command helpers*/ /* Fairly simple callback to write all output of dirmngr to stdout. */ -static int +static gpg_error_t run_command_cb (void *opaque, const void *buffer, size_t length) { (void)opaque; @@ -903,7 +915,7 @@ run_command_cb (void *opaque, const void *buffer, size_t length) } /* Handle inquiries from the dirmngr COMMAND. */ -static int +static gpg_error_t run_command_inq_cb (void *opaque, const char *line) { struct run_command_parm_s *parm = opaque; @@ -950,7 +962,7 @@ run_command_inq_cb (void *opaque, const char *line) return rc; } -static int +static gpg_error_t run_command_status_cb (void *opaque, const char *line) { ctrl_t ctrl = opaque; diff --git a/sm/gpgsm.c b/sm/gpgsm.c index 042e5d389..d2f813574 100644 --- a/sm/gpgsm.c +++ b/sm/gpgsm.c @@ -853,6 +853,7 @@ main ( int argc, char **argv) int do_not_setup_keys = 0; int recp_required = 0; estream_t auditfp = NULL; + struct assuan_malloc_hooks malloc_hooks; /*mtrace();*/ @@ -939,10 +940,12 @@ main ( int argc, char **argv) ksba_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free ); - 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); keybox_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free); diff --git a/sm/server.c b/sm/server.c index b88dc69e9..c2c4330dc 100644 --- a/sm/server.c +++ b/sm/server.c @@ -27,9 +27,8 @@ #include <ctype.h> #include <unistd.h> -#include <assuan.h> - #include "gpgsm.h" +#include <assuan.h> #include "sysutils.h" #define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t)) @@ -183,7 +182,7 @@ start_audit_session (ctrl_t ctrl) } -static int +static gpg_error_t option_handler (assuan_context_t ctx, const char *key, const char *value) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -368,7 +367,7 @@ output_notify (assuan_context_t ctx, const char *line) policy is not to encrypt at all if not all recipients are valid, the client has to take care of this. All RECIPIENT commands are cumulative until a RESET or an successful ENCRYPT command. */ -static int +static gpg_error_t cmd_recipient (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -404,7 +403,7 @@ cmd_recipient (assuan_context_t ctx, char *line) a RESET but they are *not* reset by an SIGN command becuase it can be expected that set of signers are used for more than one sign operation. */ -static int +static gpg_error_t cmd_signer (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -438,7 +437,7 @@ cmd_signer (assuan_context_t ctx, char *line) This command should in general not fail, as all necessary checks have been done while setting the recipients. The input and output pipes are closed. */ -static int +static gpg_error_t cmd_encrypt (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -495,7 +494,7 @@ cmd_encrypt (assuan_context_t ctx, char *line) it utilizes the GPG-Agent for the session key decryption, there is no need to ask the client for a protecting passphrase - GpgAgent does take care of this by requesting this from the user. */ -static int +static gpg_error_t cmd_decrypt (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -539,7 +538,7 @@ cmd_decrypt (assuan_context_t ctx, char *line) If the signature is a detached one, the server will inquire about the signed material and the client must provide it. */ -static int +static gpg_error_t cmd_verify (assuan_context_t ctx, char *line) { int rc; @@ -581,7 +580,7 @@ cmd_verify (assuan_context_t ctx, char *line) Sign the data set with the INPUT command and write it to the sink set by OUTPUT. With "--detached" specified, a detached signature is created (surprise). */ -static int +static gpg_error_t cmd_sign (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -629,7 +628,7 @@ cmd_sign (assuan_context_t ctx, char *line) separated list of fingerprints. The command will re-import these certificates, meaning that they are made permanent by removing their ephemeral flag. */ -static int +static gpg_error_t cmd_import (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -657,7 +656,7 @@ cmd_import (assuan_context_t ctx, char *line) */ -static int +static gpg_error_t cmd_export (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -743,7 +742,7 @@ cmd_export (assuan_context_t ctx, char *line) } -static int +static gpg_error_t cmd_delkeys (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -791,7 +790,7 @@ cmd_delkeys (assuan_context_t ctx, char *line) Set the file descriptor to read a message which is used with detached signatures */ -static int +static gpg_error_t cmd_message (assuan_context_t ctx, char *line) { int rc; @@ -879,25 +878,25 @@ do_listkeys (assuan_context_t ctx, char *line, int mode) return err; } -static int +static gpg_error_t cmd_listkeys (assuan_context_t ctx, char *line) { return do_listkeys (ctx, line, 3); } -static int +static gpg_error_t cmd_dumpkeys (assuan_context_t ctx, char *line) { return do_listkeys (ctx, line, 259); } -static int +static gpg_error_t cmd_listsecretkeys (assuan_context_t ctx, char *line) { return do_listkeys (ctx, line, 2); } -static int +static gpg_error_t cmd_dumpsecretkeys (assuan_context_t ctx, char *line) { return do_listkeys (ctx, line, 258); @@ -909,7 +908,7 @@ cmd_dumpsecretkeys (assuan_context_t ctx, char *line) Read the parameters in native format from the input fd and write a certificate request to the output. */ -static int +static gpg_error_t cmd_genkey (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -959,7 +958,7 @@ cmd_genkey (assuan_context_t ctx, char *line) If --html is used the output is formated as an XHTML block. This is designed to be incorporated into a HTML document. */ -static int +static gpg_error_t cmd_getauditlog (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -1019,7 +1018,7 @@ cmd_getauditlog (assuan_context_t ctx, char *line) - Returns OK if the command CMD implements the option OPT. */ -static int +static gpg_error_t cmd_getinfo (assuan_context_t ctx, char *line) { int rc = 0; @@ -1101,7 +1100,7 @@ register_commands (assuan_context_t ctx) { static struct { const char *name; - int (*handler)(assuan_context_t, char *line); + gpg_error_t (*handler)(assuan_context_t, char *line); } table[] = { { "RECIPIENT", cmd_recipient }, { "SIGNER", cmd_signer }, @@ -1156,7 +1155,15 @@ gpgsm_server (certlist_t default_recplist) called with a socketpair and ignore FIELDES in this case. */ filedes[0] = 0; filedes[1] = 1; - rc = assuan_init_pipe_server (&ctx, filedes); + rc = assuan_new (&ctx); + if (rc) + { + log_error ("failed to allocate assuan context: %s\n", + gpg_strerror (rc)); + gpgsm_exit (2); + } + + rc = assuan_init_pipe_server (ctx, filedes); if (rc) { log_error ("failed to initialize the server: %s\n", @@ -1241,7 +1248,7 @@ gpgsm_server (certlist_t default_recplist) audit_release (ctrl.audit); ctrl.audit = NULL; - assuan_deinit_server (ctx); + assuan_release (ctx); } |