aboutsummaryrefslogtreecommitdiffstats
path: root/g10/server.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--g10/server.c50
1 files changed, 29 insertions, 21 deletions
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;
}