summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Brinkmann <mb@g10code.com>2009-09-23 02:01:25 +0200
committerMarcus Brinkmann <mb@g10code.com>2009-09-23 02:01:25 +0200
commit3974488cd1fbe8471ec06b6ed057e56a446616b8 (patch)
treedf568235475e7575f891f072cb68190c85e4f3c0
parentStart a new development branch. (diff)
downloadgnupg2-3974488cd1fbe8471ec06b6ed057e56a446616b8.tar.xz
gnupg2-3974488cd1fbe8471ec06b6ed057e56a446616b8.zip
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.
-rw-r--r--ChangeLog5
-rw-r--r--agent/ChangeLog37
-rw-r--r--agent/call-pinentry.c20
-rw-r--r--agent/call-scd.c40
-rw-r--r--agent/command.c92
-rw-r--r--agent/gpg-agent.c40
-rw-r--r--common/ChangeLog5
-rw-r--r--common/asshelp.c19
-rw-r--r--configure.ac4
-rw-r--r--g10/ChangeLog22
-rw-r--r--g10/call-agent.c20
-rw-r--r--g10/gpg.c10
-rw-r--r--g10/server.c50
-rw-r--r--scd/ChangeLog13
-rw-r--r--scd/command.c71
-rw-r--r--scd/scdaemon.c11
-rw-r--r--sm/ChangeLog21
-rw-r--r--sm/call-dirmngr.c32
-rw-r--r--sm/gpgsm.c9
-rw-r--r--sm/server.c53
-rw-r--r--tools/ChangeLog5
-rw-r--r--tools/gpg-connect-agent.c6
22 files changed, 392 insertions, 193 deletions
diff --git a/ChangeLog b/ChangeLog
index f1a063b3f..ae31a010d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-09-23 Marcus Brinkmann <marcus@g10code.de>
+
+ * configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION):
+ Update to new API (2, 1.1.0).
+
2009-09-21 Werner Koch <wk@g10code.com>
Start a new development branch in the SVN trunk. The stable one
diff --git a/agent/ChangeLog b/agent/ChangeLog
index 9d1a9a03f..2544274a2 100644
--- a/agent/ChangeLog
+++ b/agent/ChangeLog
@@ -1,3 +1,40 @@
+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.
+
2009-09-04 Marcus Brinkmann <marcus@g10code.com>
* command.c (start_command_handler): Add comment about gap in
diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c
index 5e9685f61..172a88914 100644
--- a/agent/call-pinentry.c
+++ b/agent/call-pinentry.c
@@ -32,9 +32,9 @@
# include <signal.h>
#endif
#include <pth.h>
-#include <assuan.h>
#include "agent.h"
+#include <assuan.h>
#include "setenv.h"
#include "i18n.h"
@@ -158,7 +158,7 @@ unlock_pinentry (int rc)
if (!rc)
rc = gpg_error (GPG_ERR_INTERNAL);
}
- assuan_disconnect (ctx);
+ assuan_release (ctx);
return rc;
}
@@ -196,7 +196,7 @@ atfork_cb (void *opaque, int where)
}
-static int
+static gpg_error_t
getinfo_pid_cb (void *opaque, const void *buffer, size_t length)
{
unsigned long *pid = opaque;
@@ -309,16 +309,24 @@ start_pinentry (ctrl_t ctrl)
}
no_close_list[i] = -1;
+ rc = assuan_new (&ctx);
+ if (rc)
+ {
+ log_error ("can't allocate assuan context: %s\n", gpg_strerror (rc));
+ return rc;
+ }
+
/* Connect to the pinentry and perform initial handshaking. Note
that atfork is used to change the environment for pinentry. We
start the server in detached mode to suppress the console window
under Windows. */
- rc = assuan_pipe_connect_ext (&ctx, opt.pinentry_program, argv,
+ rc = assuan_pipe_connect_ext (ctx, opt.pinentry_program, argv,
no_close_list, atfork_cb, ctrl, 128);
if (rc)
{
log_error ("can't connect to the PIN entry module: %s\n",
gpg_strerror (rc));
+ assuan_release (ctx);
return unlock_pinentry (gpg_error (GPG_ERR_NO_PIN_ENTRY));
}
entry_ctx = ctx;
@@ -463,7 +471,7 @@ pinentry_active_p (ctrl_t ctrl, int waitseconds)
}
-static int
+static gpg_error_t
getpin_cb (void *opaque, const void *buffer, size_t length)
{
struct entry_parm_s *parm = opaque;
@@ -553,7 +561,7 @@ estimate_passphrase_quality (const char *pw)
/* Handle the QUALITY inquiry. */
-static int
+static gpg_error_t
inq_quality (void *opaque, const char *line)
{
assuan_context_t ctx = opaque;
diff --git a/agent/call-scd.c b/agent/call-scd.c
index d09812e57..521086848 100644
--- a/agent/call-scd.c
+++ b/agent/call-scd.c
@@ -108,8 +108,8 @@ static int primary_scd_ctx_reusable;
/* Local prototypes. */
-static assuan_error_t membuf_data_cb (void *opaque,
- const void *buffer, size_t length);
+static gpg_error_t membuf_data_cb (void *opaque,
+ const void *buffer, size_t length);
@@ -209,7 +209,7 @@ start_scd (ctrl_t ctrl)
{
gpg_error_t err = 0;
const char *pgmname;
- assuan_context_t ctx;
+ assuan_context_t ctx = NULL;
const char *argv[3];
int no_close_list[3];
int i;
@@ -268,9 +268,17 @@ start_scd (ctrl_t ctrl)
goto leave;
}
+ rc = assuan_new (&ctx);
+ if (rc)
+ {
+ log_error ("can't allocate assuan context: %s\n", gpg_strerror (rc));
+ err = rc;
+ goto leave;
+ }
+
if (socket_name)
{
- rc = assuan_socket_connect (&ctx, socket_name, 0);
+ rc = assuan_socket_connect (ctx, socket_name, 0);
if (rc)
{
log_error ("can't connect to socket `%s': %s\n",
@@ -333,7 +341,7 @@ start_scd (ctrl_t ctrl)
/* Connect to the pinentry and perform initial handshaking. Use
detached flag (128) so that under W32 SCDAEMON does not show up a
new window. */
- rc = assuan_pipe_connect_ext (&ctx, opt.scdaemon_program, argv,
+ rc = assuan_pipe_connect_ext (ctx, opt.scdaemon_program, argv,
no_close_list, atfork_cb, NULL, 128);
if (rc)
{
@@ -399,6 +407,8 @@ start_scd (ctrl_t ctrl)
if (err)
{
unlock_scd (ctrl, err);
+ if (ctx)
+ assuan_release (ctx);
}
else
{
@@ -477,14 +487,14 @@ agent_scd_check_aliveness (void)
struct scd_local_s *sl;
assuan_set_flag (primary_scd_ctx, ASSUAN_NO_WAITPID, 1);
- assuan_disconnect (primary_scd_ctx);
+ assuan_release (primary_scd_ctx);
for (sl=scd_local_list; sl; sl = sl->next_local)
{
if (sl->ctx)
{
if (sl->ctx != primary_scd_ctx)
- assuan_disconnect (sl->ctx);
+ assuan_release (sl->ctx);
sl->ctx = NULL;
}
}
@@ -534,7 +544,7 @@ agent_reset_scd (ctrl_t ctrl)
primary_scd_ctx_reusable = 1;
}
else
- assuan_disconnect (ctrl->scd_local->ctx);
+ assuan_release (ctrl->scd_local->ctx);
ctrl->scd_local->ctx = NULL;
}
@@ -563,7 +573,7 @@ agent_reset_scd (ctrl_t ctrl)
-static int
+static gpg_error_t
learn_status_cb (void *opaque, const char *line)
{
struct learn_parm_s *parm = opaque;
@@ -626,7 +636,7 @@ agent_card_learn (ctrl_t ctrl,
-static int
+static gpg_error_t
get_serialno_cb (void *opaque, const char *line)
{
char **serialno = opaque;
@@ -684,7 +694,7 @@ agent_card_serialno (ctrl_t ctrl, char **r_serialno)
-static assuan_error_t
+static gpg_error_t
membuf_data_cb (void *opaque, const void *buffer, size_t length)
{
membuf_t *data = opaque;
@@ -695,7 +705,7 @@ membuf_data_cb (void *opaque, const void *buffer, size_t length)
}
/* Handle the NEEDPIN inquiry. */
-static int
+static gpg_error_t
inq_needpin (void *opaque, const char *line)
{
struct inq_needpin_s *parm = opaque;
@@ -991,7 +1001,7 @@ struct card_getattr_parm_s {
};
/* Callback function for agent_card_getattr. */
-static assuan_error_t
+static gpg_error_t
card_getattr_cb (void *opaque, const char *line)
{
struct card_getattr_parm_s *parm = opaque;
@@ -1067,7 +1077,7 @@ agent_card_getattr (ctrl_t ctrl, const char *name, char **result)
-static int
+static gpg_error_t
pass_status_thru (void *opaque, const char *line)
{
assuan_context_t ctx = opaque;
@@ -1087,7 +1097,7 @@ pass_status_thru (void *opaque, const char *line)
return 0;
}
-static int
+static gpg_error_t
pass_data_thru (void *opaque, const void *buffer, size_t length)
{
assuan_context_t ctx = opaque;
diff --git a/agent/command.c b/agent/command.c
index e893aea1e..b863a6a8c 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -34,10 +34,9 @@
#include <sys/stat.h>
#include <dirent.h>
+#include "agent.h"
#include <assuan.h>
-
#include "i18n.h"
-#include "agent.h"
/* maximum allowed size of the inquired ciphertext */
#define MAXLEN_CIPHERTEXT 4096
@@ -133,7 +132,7 @@ clear_outbuf (membuf_t *mb)
static gpg_error_t
write_and_clear_outbuf (assuan_context_t ctx, membuf_t *mb)
{
- assuan_error_t ae;
+ gpg_error_t ae;
void *p;
size_t n;
@@ -354,7 +353,7 @@ agent_inq_pinentry_launched (ctrl_t ctrl, unsigned long pid)
KEY - Incremented for added or removed private keys.
CARD - Incremented for changes of the card readers stati.
*/
-static int
+static gpg_error_t
cmd_geteventcounter (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -403,7 +402,7 @@ bump_card_eventcounter (void)
Return OK when we have an entry with this fingerprint in our
trustlist */
-static int
+static gpg_error_t
cmd_istrusted (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -440,7 +439,7 @@ cmd_istrusted (assuan_context_t ctx, char *line)
/* LISTTRUSTED
List all entries from the trustlist */
-static int
+static gpg_error_t
cmd_listtrusted (assuan_context_t ctx, char *line)
{
int rc;
@@ -457,7 +456,7 @@ cmd_listtrusted (assuan_context_t ctx, char *line)
/* MARKTRUSTED <hexstring_with_fingerprint> <flag> <display_name>
Store a new key in into the trustlist*/
-static int
+static gpg_error_t
cmd_marktrusted (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -501,7 +500,7 @@ cmd_marktrusted (assuan_context_t ctx, char *line)
/* HAVEKEY <hexstring_with_keygrip>
Return success when the secret key is available */
-static int
+static gpg_error_t
cmd_havekey (assuan_context_t ctx, char *line)
{
int rc;
@@ -522,7 +521,7 @@ cmd_havekey (assuan_context_t ctx, char *line)
SETKEY <hexstring_with_keygrip>
Set the key used for a sign or decrypt operation */
-static int
+static gpg_error_t
cmd_sigkey (assuan_context_t ctx, char *line)
{
int rc;
@@ -550,7 +549,7 @@ cmd_sigkey (assuan_context_t ctx, char *line)
The description is only valid for the next PKSIGN or PKDECRYPT
operation.
*/
-static int
+static gpg_error_t
cmd_setkeydesc (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -584,7 +583,7 @@ cmd_setkeydesc (assuan_context_t ctx, char *line)
The client can use this command to tell the server about the data
(which usually is a hash) to be signed. */
-static int
+static gpg_error_t
cmd_sethash (assuan_context_t ctx, char *line)
{
int rc;
@@ -662,7 +661,7 @@ cmd_sethash (assuan_context_t ctx, char *line)
Perform the actual sign operation. Neither input nor output are
sensitive to eavesdropping. */
-static int
+static gpg_error_t
cmd_pksign (assuan_context_t ctx, char *line)
{
int rc;
@@ -696,7 +695,7 @@ cmd_pksign (assuan_context_t ctx, char *line)
Perform the actual decrypt operation. Input is not
sensitive to eavesdropping */
-static int
+static gpg_error_t
cmd_pkdecrypt (assuan_context_t ctx, char *line)
{
int rc;
@@ -744,7 +743,7 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line)
S OK key created
*/
-static int
+static gpg_error_t
cmd_genkey (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -779,7 +778,7 @@ cmd_genkey (assuan_context_t ctx, char *line)
/* READKEY <hexstring_with_keygrip>
Return the public key for the given keygrip. */
-static int
+static gpg_error_t
cmd_readkey (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -892,7 +891,7 @@ do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip)
}
-static int
+static gpg_error_t
cmd_keyinfo (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1014,7 +1013,7 @@ send_back_passphrase (assuan_context_t ctx, int via_data, const char *pw)
length has been configured.)
*/
-static int
+static gpg_error_t
cmd_get_passphrase (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1167,7 +1166,7 @@ cmd_get_passphrase (assuan_context_t ctx, char *line)
function returns with OK even when there is no cached passphrase.
*/
-static int
+static gpg_error_t
cmd_clear_passphrase (assuan_context_t ctx, char *line)
{
char *cacheid = NULL;
@@ -1200,7 +1199,7 @@ cmd_clear_passphrase (assuan_context_t ctx, char *line)
as '+'.
*/
-static int
+static gpg_error_t
cmd_get_confirmation (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1241,7 +1240,7 @@ cmd_get_confirmation (assuan_context_t ctx, char *line)
Learn something about the currently inserted smartcard. With
--send the new certificates are send back. */
-static int
+static gpg_error_t
cmd_learn (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1258,7 +1257,7 @@ cmd_learn (assuan_context_t ctx, char *line)
/* PASSWD <hexstring_with_keygrip>
Change the passphrase/PIN for the key identified by keygrip in LINE. */
-static int
+static gpg_error_t
cmd_passwd (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1304,7 +1303,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
the default (currently only a timeout of -1 is allowed, which means
to never expire it). If passwd is not provided, ask for it via the
pinentry module. */
-static int
+static gpg_error_t
cmd_preset_passphrase (assuan_context_t ctx, char *line)
{
int rc;
@@ -1367,7 +1366,7 @@ cmd_preset_passphrase (assuan_context_t ctx, char *line)
This is a general quote command to redirect everything to the
SCDAEMON. */
-static int
+static gpg_error_t
cmd_scd (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1385,7 +1384,7 @@ cmd_scd (assuan_context_t ctx, char *line)
Return the value for KEY from the special environment as created by
PUTVAL.
*/
-static int
+static gpg_error_t
cmd_getval (assuan_context_t ctx, char *line)
{
int rc = 0;
@@ -1442,7 +1441,7 @@ cmd_getval (assuan_context_t ctx, char *line)
restrictions. If that value is not given any value under that KEY
is removed from this special environment.
*/
-static int
+static gpg_error_t
cmd_putval (assuan_context_t ctx, char *line)
{
int rc = 0;
@@ -1517,7 +1516,7 @@ cmd_putval (assuan_context_t ctx, char *line)
session. This command is useful to pull future pinentries to
another screen. It is only required because there is no way in the
ssh-agent protocol to convey this information. */
-static int
+static gpg_error_t
cmd_updatestartuptty (assuan_context_t ctx, char *line)
{
static const char *names[] =
@@ -1576,7 +1575,7 @@ cmd_updatestartuptty (assuan_context_t ctx, char *line)
Under Windows we start the agent on the fly. Thus it also make
sense to allow a client to stop the agent. */
-static int
+static gpg_error_t
cmd_killagent (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1591,7 +1590,7 @@ cmd_killagent (assuan_context_t ctx, char *line)
As signals are inconvenient under Windows, we provide this command
to allow reloading of the configuration. */
-static int
+static gpg_error_t
cmd_reloadagent (assuan_context_t ctx, char *line)
{
(void)ctx;
@@ -1615,10 +1614,10 @@ cmd_reloadagent (assuan_context_t ctx, char *line)
ssh_socket_name - Return the name of the ssh socket.
scd_running - Return OK if the SCdaemon is already running.
- cmd_has_option CMD OPT
+ gpg_error_t
- 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;
@@ -1696,7 +1695,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
-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);
@@ -1766,7 +1765,7 @@ option_handler (assuan_context_t ctx, const char *key, const char *value)
/* Called by libassuan after all commands. ERR is the error from the
last assuan operation and not the one returned from the command. */
static void
-post_cmd_notify (assuan_context_t ctx, int err)
+post_cmd_notify (assuan_context_t ctx, gpg_error_t err)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1782,15 +1781,17 @@ post_cmd_notify (assuan_context_t ctx, int err)
that the debug output won't get cluttered by this primitive
command. */
static unsigned int
-io_monitor (assuan_context_t ctx, int direction,
+io_monitor (assuan_context_t ctx, void *hook, int direction,
const char *line, size_t linelen)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
+ (void) hook;
+
/* Note that we only check for the uppercase name. This allows to
see the logging for debugging if using a non-upercase command
name. */
- if (ctx && !direction
+ if (ctx && direction == ASSUAN_IO_FROM_PEER
&& linelen >= 15
&& !strncmp (line, "GETEVENTCOUNTER", 15)
&& (linelen == 15 || spacep (line+15)))
@@ -1798,7 +1799,7 @@ io_monitor (assuan_context_t ctx, int direction,
ctrl->server_local->pause_io_logging = 1;
}
- return ctrl->server_local->pause_io_logging? 1:0;
+ return ctrl->server_local->pause_io_logging? ASSUAN_IO_MONITOR_NOLOG : 0;
}
@@ -1822,7 +1823,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[] = {
{ "GETEVENTCOUNTER",cmd_geteventcounter },
{ "ISTRUSTED", cmd_istrusted },
@@ -1882,7 +1883,14 @@ void
start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd)
{
int rc;
- assuan_context_t ctx;
+ assuan_context_t ctx = NULL;
+
+ rc = assuan_new (&ctx);
+ if (rc)
+ {
+ log_error ("failed to allocate assuan context: %s\n", gpg_strerror (rc));
+ agent_exit (2);
+ }
if (listen_fd == GNUPG_INVALID_FD && fd == GNUPG_INVALID_FD)
{
@@ -1890,17 +1898,17 @@ start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd)
filedes[0] = 0;
filedes[1] = 1;
- rc = assuan_init_pipe_server (&ctx, filedes);
+ rc = assuan_init_pipe_server (ctx, filedes);
}
else if (listen_fd != GNUPG_INVALID_FD)
{
- rc = assuan_init_socket_server_ext (&ctx, listen_fd, 0);
+ rc = assuan_init_socket_server_ext (ctx, listen_fd, 0);
/* FIXME: Need to call assuan_sock_set_nonce for Windows. But
this branch is currently not used. */
}
else
{
- rc = assuan_init_socket_server_ext (&ctx, fd, 2);
+ rc = assuan_init_socket_server_ext (ctx, fd, 2);
}
if (rc)
{
@@ -1927,7 +1935,7 @@ start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd)
assuan_set_log_stream (ctx, log_get_stream ());
#ifdef HAVE_ASSUAN_SET_IO_MONITOR
- assuan_set_io_monitor (ctx, io_monitor);
+ assuan_set_io_monitor (ctx, io_monitor, NULL);
#endif
for (;;)
@@ -1958,7 +1966,7 @@ start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd)
agent_reset_query (ctrl);
/* Cleanup. */
- assuan_deinit_server (ctx);
+ assuan_release (ctx);
#ifdef HAVE_W32_SYSTEM
if (ctrl->server_local->stopme)
agent_exit (0);
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 2e8156721..4493c7abd 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -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,16 +2065,23 @@ 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));
goto leave;
}
@@ -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;
}
diff --git a/common/ChangeLog b/common/ChangeLog
index 08f30d606..34894effd 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,8 @@
+2009-09-23 Marcus Brinkmann <marcus@g10code.de>
+
+ * asshelp.c (start_new_gpg_agent): Allocate assuan context before
+ starting server.
+
2009-09-03 Werner Koch <wk@g10code.com>
Update from libestream:
diff --git a/common/asshelp.c b/common/asshelp.c
index b373baf98..47b86ee1c 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);
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);
}
}
#else /*!HAVE_W32_SYSTEM*/
@@ -265,7 +273,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
no_close_list[i] = -1;
/* Connect to the agent and perform initial handshaking. */
- rc = assuan_pipe_connect (&ctx, agent_program, argv,
+ rc = assuan_pipe_connect (ctx, agent_program, argv,
no_close_list);
}
#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);
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/configure.ac b/configure.ac
index c5bc6fa6b..4e5783c4c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,8 +42,8 @@ NEED_GPG_ERROR_VERSION=1.4
NEED_LIBGCRYPT_API=1
NEED_LIBGCRYPT_VERSION=1.4.0
-NEED_LIBASSUAN_API=1
-NEED_LIBASSUAN_VERSION=1.0.4
+NEED_LIBASSUAN_API=2
+NEED_LIBASSUAN_VERSION=1.1.0
NEED_KSBA_API=1
NEED_KSBA_VERSION=1.0.2
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 38f64d54b..ea45a315a 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,25 @@
+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.
+
2009-09-04 Werner Koch <wk@g10code.com>
* keyedit.c (menu_select_uid): Use IDX ==-1 t select all.
diff --git a/g10/call-agent.c b/g10/call-agent.c
index 12ecd9d57..5ee7f8e06 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -29,9 +29,9 @@
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
-#include <assuan.h>
#include "gpg.h"
+#include <assuan.h>
#include "util.h"
#include "membuf.h"
#include "options.h"
@@ -77,7 +77,7 @@ struct genkey_parm_s
};
-static int learn_status_cb (void *opaque, const char *line);
+static gpg_error_t learn_status_cb (void *opaque, const char *line);
@@ -230,7 +230,7 @@ store_serialno (const char *line)
/* This is a dummy data line callback. */
-static int
+static gpg_error_t
dummy_data_cb (void *opaque, const void *buffer, size_t length)
{
(void)opaque;
@@ -240,7 +240,7 @@ dummy_data_cb (void *opaque, const void *buffer, size_t length)
}
/* A simple callback used to return the serialnumber of a card. */
-static int
+static gpg_error_t
get_serialno_cb (void *opaque, const char *line)
{
char **serialno = opaque;
@@ -274,7 +274,7 @@ get_serialno_cb (void *opaque, const char *line)
/* This is the default inquiry callback. It mainly handles the
Pinentry notifications. */
-static int
+static gpg_error_t
default_inq_cb (void *opaque, const char *line)
{
(void)opaque;
@@ -312,7 +312,7 @@ agent_release_card_info (struct agent_card_info_s *info)
info->fpr1valid = info->fpr2valid = info->fpr3valid = 0;
}
-static int
+static gpg_error_t
learn_status_cb (void *opaque, const char *line)
{
struct agent_card_info_s *parm = opaque;
@@ -597,7 +597,7 @@ agent_scd_setattr (const char *name,
/* Handle a CERTDATA inquiry. Note, we only send the data,
assuan_transact takes care of flushing and writing the END
command. */
-static int
+static gpg_error_t
inq_writecert_parms (void *opaque, const char *line)
{
int rc;
@@ -645,7 +645,7 @@ agent_scd_writecert (const char *certidstr,
/* Handle a KEYDATA inquiry. Note, we only send the data,
assuan_transact takes care of flushing and writing the end */
-static int
+static gpg_error_t
inq_writekey_parms (void *opaque, const char *line)
{
int rc;
@@ -695,7 +695,7 @@ agent_scd_writekey (int keyno, const char *serialno,
/* Status callback for the SCD GENKEY command. */
-static int
+static gpg_error_t
scd_genkey_cb (void *opaque, const char *line)
{
struct agent_card_genkey_s *parm = opaque;
@@ -882,7 +882,7 @@ select_openpgp (const char *serialno)
-static int
+static gpg_error_t
membuf_data_cb (void *opaque, const void *buffer, size_t length)
{
membuf_t *data = opaque;
diff --git a/g10/gpg.c b/g10/gpg.c
index 640490bda..80072faeb 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -30,13 +30,13 @@
#include <sys/stat.h> /* for stat() */
#endif
#include <fcntl.h>
-#include <assuan.h>
#ifdef HAVE_W32_SYSTEM
#include <windows.h>
#endif
#define INCLUDED_BY_MAIN_MODULE 1
#include "gpg.h"
+#include <assuan.h>
#include "packet.h"
#include "../common/iobuf.h"
#include "util.h"
@@ -1905,6 +1905,7 @@ main (int argc, char **argv)
int fpr_maybe_cmd = 0; /* --fingerprint maybe a command. */
int any_explicit_recipient = 0;
int require_secmem=0,got_secmem=0;
+ struct assuan_malloc_hooks malloc_hooks;
#ifdef __riscos__
opt.lock_once = 1;
@@ -2054,8 +2055,11 @@ main (int argc, char **argv)
/* Okay, we are now working under our real uid */
/* malloc hooks go here ... */
- assuan_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free);
- assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT);
+ malloc_hooks.malloc = gcry_malloc;
+ malloc_hooks.realloc = gcry_realloc;
+ malloc_hooks.free = gcry_free;
+ assuan_set_malloc_hooks (&malloc_hooks);
+ assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
/* Try for a version specific config file first */
diff --git a/g10/server.c b/g10/server.c
index d0e801bd5..cc502e8e3 100644
--- a/g10/server.c
+++ b/g10/server.c
@@ -26,9 +26,9 @@
#include <ctype.h>
#include <unistd.h>
-#include <assuan.h>
#include "gpg.h"
+#include <assuan.h>
#include "util.h"
#include "i18n.h"
#include "options.h"
@@ -64,7 +64,7 @@ close_message_fd (ctrl_t ctrl)
/* Called by libassuan for Assuan options. See the Assuan manual for
details. */
-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); */
@@ -168,7 +168,7 @@ output_notify (assuan_context_t ctx, const char *line)
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)
{
(void)ctx;
@@ -193,7 +193,7 @@ cmd_recipient (assuan_context_t ctx, char *line)
Note that this command returns an INV_RECP status which is a bit
strange, but they are very similar. */
-static int
+static gpg_error_t
cmd_signer (assuan_context_t ctx, char *line)
{
(void)ctx;
@@ -216,7 +216,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)
{
(void)ctx;
@@ -230,7 +230,7 @@ cmd_encrypt (assuan_context_t ctx, char *line)
This performs the decrypt operation after doing some checks on the
internal state (e.g. that only needed data has been set). */
-static int
+static gpg_error_t
cmd_decrypt (assuan_context_t ctx, char *line)
{
(void)ctx;
@@ -249,7 +249,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;
@@ -296,7 +296,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. */
-static int
+static gpg_error_t
cmd_sign (assuan_context_t ctx, char *line)
{
(void)ctx;
@@ -310,7 +310,7 @@ cmd_sign (assuan_context_t ctx, char *line)
Import keys as read from the input-fd, return status message for
each imported one. The import checks the validity of the key. */
-static int
+static gpg_error_t
cmd_import (assuan_context_t ctx, char *line)
{
(void)ctx;
@@ -330,7 +330,7 @@ cmd_import (assuan_context_t ctx, char *line)
Recall that in general the output format is set with the OUTPUT
command.
*/
-static int
+static gpg_error_t
cmd_export (assuan_context_t ctx, char *line)
{
(void)ctx;
@@ -344,7 +344,7 @@ cmd_export (assuan_context_t ctx, char *line)
Fixme
*/
-static int
+static gpg_error_t
cmd_delkeys (assuan_context_t ctx, char *line)
{
(void)ctx;
@@ -358,7 +358,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;
@@ -381,7 +381,7 @@ cmd_message (assuan_context_t ctx, char *line)
fixme
*/
-static int
+static gpg_error_t
do_listkeys (assuan_context_t ctx, char *line, int mode)
{
(void)ctx;
@@ -392,14 +392,14 @@ do_listkeys (assuan_context_t ctx, char *line, int mode)
}
-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_listsecretkeys (assuan_context_t ctx, char *line)
{
return do_listkeys (ctx, line, 2);
@@ -412,7 +412,7 @@ cmd_listsecretkeys (assuan_context_t ctx, char *line)
Read the parameters in native format from the input fd and create a
new OpenPGP key.
*/
-static int
+static gpg_error_t
cmd_genkey (assuan_context_t ctx, char *line)
{
(void)ctx;
@@ -430,7 +430,7 @@ cmd_genkey (assuan_context_t ctx, char *line)
pid - Return the process id of the server.
*/
-static int
+static gpg_error_t
cmd_getinfo (assuan_context_t ctx, char *line)
{
int rc;
@@ -461,7 +461,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 },
@@ -502,7 +502,7 @@ gpg_server (ctrl_t ctrl)
{
int rc;
int filedes[2];
- assuan_context_t ctx;
+ assuan_context_t ctx = NULL;
static const char hello[] = ("GNU Privacy Guard's OpenPGP server "
VERSION " ready");
@@ -511,7 +511,15 @@ gpg_server (ctrl_t ctrl)
called with a socketpair and ignore FILEDES 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 the assuan context: %s\n",
+ gpg_strerror (rc));
+ goto leave;
+ }
+
+ rc = assuan_init_pipe_server (ctx, filedes);
if (rc)
{
log_error ("failed to initialize the server: %s\n", gpg_strerror (rc));
@@ -590,7 +598,7 @@ gpg_server (ctrl_t ctrl)
leave:
xfree (ctrl->server_local);
ctrl->server_local = NULL;
- assuan_deinit_server (ctx);
+ assuan_release (ctx);
return rc;
}
diff --git a/scd/ChangeLog b/scd/ChangeLog
index 3a421ccfb..60f5462ac 100644
--- a/scd/ChangeLog
+++ b/scd/ChangeLog
@@ -1,3 +1,16 @@
+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.
+
2009-09-03 Werner Koch <wk@g10code.com>
* app-openpgp.c (do_decipher): Compute required Le.
diff --git a/scd/command.c b/scd/command.c
index 1fdcf7d51..09c0b8e45 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -30,9 +30,8 @@
# include <pth.h>
#endif
-#include <assuan.h>
-
#include "scdaemon.h"
+#include <assuan.h>
#include <ksba.h>
#include "app-common.h"
#include "apdu.h" /* Required for apdu_*_reader (). */
@@ -348,7 +347,7 @@ reset_notify (assuan_context_t ctx)
}
-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);
@@ -401,7 +400,7 @@ get_reader_slot (void)
/* If the card has not yet been opened, do it. Note that this
function returns an Assuan error, so don't map the error a second
time. */
-static assuan_error_t
+static gpg_error_t
open_card (ctrl_t ctrl, const char *apptype)
{
gpg_error_t err;
@@ -483,7 +482,7 @@ open_card (ctrl_t ctrl, const char *apptype)
changes between operations; i.e. the client can assume that all
operations are done on the same card unless he calls this function.
*/
-static int
+static gpg_error_t
cmd_serialno (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -590,7 +589,7 @@ cmd_serialno (assuan_context_t ctx, char *line)
Note, that this function may even be used on a locked card.
*/
-static int
+static gpg_error_t
cmd_learn (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -662,7 +661,7 @@ cmd_learn (assuan_context_t ctx, char *line)
Note, that this function may even be used on a locked card.
*/
-static int
+static gpg_error_t
cmd_readcert (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -699,7 +698,7 @@ cmd_readcert (assuan_context_t ctx, char *line)
Note, that this function may even be used on a locked card.
*/
-static int
+static gpg_error_t
cmd_readkey (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -780,7 +779,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
The client should use this command to tell us the data he want to
sign. */
-static int
+static gpg_error_t
cmd_setdata (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -878,7 +877,7 @@ pin_cb (void *opaque, const char *info, char **retstr)
The --hash option is optional; the default is SHA1.
*/
-static int
+static gpg_error_t
cmd_pksign (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -948,7 +947,7 @@ cmd_pksign (assuan_context_t ctx, char *line)
/* PKAUTH <hexified_id>
*/
-static int
+static gpg_error_t
cmd_pkauth (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -998,7 +997,7 @@ cmd_pkauth (assuan_context_t ctx, char *line)
/* PKDECRYPT <hexified_id>
*/
-static int
+static gpg_error_t
cmd_pkdecrypt (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1052,7 +1051,7 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line)
Note, that this function may even be used on a locked card.
*/
-static int
+static gpg_error_t
cmd_getattr (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1091,7 +1090,7 @@ cmd_getattr (assuan_context_t ctx, char *line)
A PIN will be requested for most NAMEs. See the corresponding
setattr function of the actually used application (app-*.c) for
details. */
-static int
+static gpg_error_t
cmd_setattr (assuan_context_t ctx, char *orig_line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1142,7 +1141,7 @@ cmd_setattr (assuan_context_t ctx, char *orig_line)
In almost all cases a a PIN will be requested. See the related
writecert function of the actually used application (app-*.c) for
details. */
-static int
+static gpg_error_t
cmd_writecert (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1207,7 +1206,7 @@ cmd_writecert (assuan_context_t ctx, char *line)
A PIN will be requested for most NAMEs. See the corresponding
writekey function of the actually used application (app-*.c) for
details. */
-static int
+static gpg_error_t
cmd_writekey (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1283,7 +1282,7 @@ cmd_writekey (assuan_context_t ctx, char *line)
READKEY command.
*/
-static int
+static gpg_error_t
cmd_genkey (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1342,7 +1341,7 @@ cmd_genkey (assuan_context_t ctx, char *line)
Note, that this function may be even be used on a locked card.
*/
-static int
+static gpg_error_t
cmd_random (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1384,7 +1383,7 @@ cmd_random (assuan_context_t ctx, char *line)
the card holder verfication vector CHVNO. The option --nullpin is
used for TCOS cards to set the initial PIN. The format of CHVNO
depends on the card application. */
-static int
+static gpg_error_t
cmd_passwd (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1461,7 +1460,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
unblock each other.
*/
-static int
+static gpg_error_t
cmd_checkpin (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1504,7 +1503,7 @@ cmd_checkpin (assuan_context_t ctx, char *line)
If the option --wait is given the command will wait until a
lock has been released.
*/
-static int
+static gpg_error_t
cmd_lock (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1542,7 +1541,7 @@ cmd_lock (assuan_context_t ctx, char *line)
Release exclusive card access.
*/
-static int
+static gpg_error_t
cmd_unlock (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1594,7 +1593,7 @@ cmd_unlock (assuan_context_t ctx, char *line)
first field is the name.
*/
-static int
+static gpg_error_t
cmd_getinfo (assuan_context_t ctx, char *line)
{
int rc = 0;
@@ -1685,7 +1684,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
command; i.e. to select another application.
*/
-static int
+static gpg_error_t
cmd_restart (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1711,7 +1710,7 @@ cmd_restart (assuan_context_t ctx, char *line)
Disconnect the card if it is not any longer used by other
connections and the backend supports a disconnect operation.
*/
-static int
+static gpg_error_t
cmd_disconnect (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1743,7 +1742,7 @@ cmd_disconnect (assuan_context_t ctx, char *line)
length up to N bytes. If N is not given a default value is used
(currently 4096).
*/
-static int
+static gpg_error_t
cmd_apdu (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1824,7 +1823,7 @@ cmd_apdu (assuan_context_t ctx, char *line)
/* KILLSCD - Commit suicide. */
-static int
+static gpg_error_t
cmd_killscd (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
@@ -1843,7 +1842,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[] = {
{ "SERIALNO", cmd_serialno },
{ "LEARN", cmd_learn },
@@ -1895,20 +1894,28 @@ int
scd_command_handler (ctrl_t ctrl, int fd)
{
int rc;
- assuan_context_t ctx;
+ assuan_context_t ctx = NULL;
int stopme;
+ rc = assuan_new (&ctx);
+ if (rc)
+ {
+ log_error ("failed to allocate assuan context: %s\n",
+ gpg_strerror (rc));
+ scd_exit (2);
+ }
+
if (fd == -1)
{
int filedes[2];
filedes[0] = 0;
filedes[1] = 1;
- rc = assuan_init_pipe_server (&ctx, filedes);
+ rc = assuan_init_pipe_server (ctx, filedes);
}
else
{
- rc = assuan_init_socket_server_ext (&ctx, INT2FD(fd), 2);
+ rc = assuan_init_socket_server_ext (ctx, INT2FD(fd), 2);
}
if (rc)
{
@@ -1987,7 +1994,7 @@ scd_command_handler (ctrl_t ctrl, int fd)
ctrl->server_local = NULL;
/* Release the Assuan context. */
- assuan_deinit_server (ctx);
+ assuan_release (ctx);
if (stopme)
scd_exit (0);
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index 175729a03..8e353189f 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -370,7 +370,8 @@ main (int argc, char **argv )
const char *config_filename = NULL;
int allow_coredump = 0;
int standard_socket = 0;
-
+ struct assuan_malloc_hooks malloc_hooks;
+
set_strusage (my_strusage);
gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
/* Please note that we may running SUID(ROOT), so be very CAREFUL
@@ -403,10 +404,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);
setup_libgcrypt_logging ();
gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);
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 <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.
+
2009-08-06 Werner Koch <wk@g10code.com>
* 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);
}
diff --git a/tools/ChangeLog b/tools/ChangeLog
index 5714daca9..9e19287d6 100644
--- a/tools/ChangeLog
+++ b/tools/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
2009-07-21 Werner Koch <wk@g10code.com>
* gpgsplit.c (my_strusage): Remove i18n stuff.
diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c
index ac75c3b0e..4be2e6073 100644
--- a/tools/gpg-connect-agent.c
+++ b/tools/gpg-connect-agent.c
@@ -1086,7 +1086,7 @@ do_showopen (void)
-static int
+static gpg_error_t
getinfo_pid_cb (void *opaque, const void *buffer, size_t length)
{
membuf_t *mb = opaque;
@@ -1155,7 +1155,7 @@ main (int argc, char **argv)
i18n_init();
init_common_subsystems ();
- assuan_set_assuan_err_source (0);
+ assuan_set_gpg_err_source (0);
opt.homedir = default_homedir ();
@@ -1883,7 +1883,7 @@ read_and_print_response (assuan_context_t ctx, int *r_goterr)
{
char *line;
size_t linelen;
- assuan_error_t rc;
+ gpg_error_t rc;
int i, j;
int need_lf = 0;