aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog28
-rw-r--r--g10/call-agent.c20
-rw-r--r--g10/gpg.c10
-rw-r--r--g10/server.c73
4 files changed, 88 insertions, 43 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index f7cca8b5a..f75fb3994 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,31 @@
+2010-02-11 Marcus Brinkmann <[email protected]>
+
+ From trunk 2009-09-23, 2009-11-02, 2009-11-25:
+
+ * 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.
+ (reset_notify, input_notify, output_notify): Update to
+ new assuan interface.
+ (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. Use assuan_handler_t. Add NULL arg to
+ assuan_register_command.
+ (gpg_server): Allocate assuan_context before starting server.
+ Use assuan_fd_t and assuan_fdopen on fds.
+
2010-02-02 Werner Koch <[email protected]>
* card-util.c (card_edit): Change prompt to "gpg/card".
diff --git a/g10/call-agent.c b/g10/call-agent.c
index d4e55e5b2..260cd48a9 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 f22904ef0..3dee35614 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"
@@ -1917,6 +1917,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;
@@ -2066,8 +2067,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..6f3b8818f 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); */
@@ -106,20 +106,23 @@ option_handler (assuan_context_t ctx, const char *key, const char *value)
/* Called by libassuan for RESET commands. */
-static void
-reset_notify (assuan_context_t ctx)
+static gpg_error_t
+reset_notify (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
+ (void)line;
+
close_message_fd (ctrl);
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
+ return 0;
}
/* Called by libassuan for INPUT commands. */
-static void
-input_notify (assuan_context_t ctx, const char *line)
+static gpg_error_t
+input_notify (assuan_context_t ctx, char *line)
{
/* ctrl_t ctrl = assuan_get_pointer (ctx); */
@@ -135,12 +138,13 @@ input_notify (assuan_context_t ctx, const char *line)
{
/* FIXME (autodetect encoding) */
}
+ return 0;
}
/* Called by libassuan for OUTPUT commands. */
-static void
-output_notify (assuan_context_t ctx, const char *line)
+static gpg_error_t
+output_notify (assuan_context_t ctx, char *line)
{
/* ctrl_t ctrl = assuan_get_pointer (ctx); */
@@ -152,6 +156,7 @@ output_notify (assuan_context_t ctx, const char *line)
{
/* FIXME */
}
+ return 0;
}
@@ -168,7 +173,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 +198,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 +221,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 +235,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 +254,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 +301,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 +315,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 +335,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 +349,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 +363,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 +386,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 +397,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 +417,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 +435,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 +466,7 @@ register_commands (assuan_context_t ctx)
static struct
{
const char *name;
- int (*handler)(assuan_context_t, char *line);
+ assuan_handler_t handler;
} table[] = {
{ "RECIPIENT", cmd_recipient },
{ "SIGNER", cmd_signer },
@@ -485,7 +490,7 @@ register_commands (assuan_context_t ctx)
for (i=0; table[i].name; i++)
{
- rc = assuan_register_command (ctx, table[i].name, table[i].handler);
+ rc = assuan_register_command (ctx, table[i].name, table[i].handler, NULL);
if (rc)
return rc;
}
@@ -502,16 +507,24 @@ 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");
/* We use a pipe based server so that we can work from scripts.
assuan_init_pipe_server will automagically detect when we are
called with a socketpair and ignore FILEDES in this case. */
- filedes[0] = 0;
- filedes[1] = 1;
- rc = assuan_init_pipe_server (&ctx, filedes);
+ filedes[0] = assuan_fdopen (0);
+ filedes[1] = assuan_fdopen (1);
+ 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 +603,7 @@ gpg_server (ctrl_t ctrl)
leave:
xfree (ctrl->server_local);
ctrl->server_local = NULL;
- assuan_deinit_server (ctx);
+ assuan_release (ctx);
return rc;
}