2009-10-14 17:06:10 +00:00
|
|
|
|
/* server.c - The G13 Assuan server
|
|
|
|
|
* Copyright (C) 2009 Free Software Foundation, Inc.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
|
*
|
|
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-11-05 12:02:19 +01:00
|
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2009-10-14 17:06:10 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
#include "g13.h"
|
|
|
|
|
#include <assuan.h>
|
2017-03-07 20:21:23 +09:00
|
|
|
|
#include "../common/i18n.h"
|
2009-10-14 17:06:10 +00:00
|
|
|
|
#include "keyblob.h"
|
2009-10-19 09:18:46 +00:00
|
|
|
|
#include "server.h"
|
|
|
|
|
#include "create.h"
|
2016-02-23 14:32:46 +01:00
|
|
|
|
#include "mount.h"
|
|
|
|
|
#include "suspend.h"
|
2016-03-02 14:14:33 +01:00
|
|
|
|
#include "../common/server-help.h"
|
2018-02-14 12:21:23 +01:00
|
|
|
|
#include "../common/asshelp.h"
|
2016-08-13 17:39:28 +02:00
|
|
|
|
#include "../common/call-gpg.h"
|
|
|
|
|
|
2009-10-28 12:02:15 +00:00
|
|
|
|
|
|
|
|
|
/* The filepointer for status message used in non-server mode */
|
|
|
|
|
static FILE *statusfp;
|
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
/* Local data for this server module. A pointer to this is stored in
|
|
|
|
|
the CTRL object of each connection. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
struct server_local_s
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{
|
2017-02-20 16:25:15 -05:00
|
|
|
|
/* The Assuan context we are working on. */
|
2009-10-14 17:06:10 +00:00
|
|
|
|
assuan_context_t assuan_ctx;
|
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
char *containername; /* Malloced active containername. */
|
2009-10-14 17:06:10 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
/* Local prototypes. */
|
2009-10-14 17:06:10 +00:00
|
|
|
|
static int command_has_option (const char *cmd, const char *cmdopt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
/*
|
2011-02-04 12:57:53 +01:00
|
|
|
|
Helper functions.
|
2009-10-15 17:20:41 +00:00
|
|
|
|
*/
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
/* Set an error and a description. */
|
|
|
|
|
#define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t))
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
/* Helper to print a message while leaving a command. */
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
leave_cmd (assuan_context_t ctx, gpg_error_t err)
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{
|
2009-10-15 17:20:41 +00:00
|
|
|
|
if (err)
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{
|
2009-10-15 17:20:41 +00:00
|
|
|
|
const char *name = assuan_get_command_name (ctx);
|
|
|
|
|
if (!name)
|
|
|
|
|
name = "?";
|
|
|
|
|
if (gpg_err_source (err) == GPG_ERR_SOURCE_DEFAULT)
|
|
|
|
|
log_error ("command '%s' failed: %s\n", name,
|
|
|
|
|
gpg_strerror (err));
|
|
|
|
|
else
|
|
|
|
|
log_error ("command '%s' failed: %s <%s>\n", name,
|
|
|
|
|
gpg_strerror (err), gpg_strsource (err));
|
2009-10-14 17:06:10 +00:00
|
|
|
|
}
|
2009-10-15 17:20:41 +00:00
|
|
|
|
return err;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
/* The handler for Assuan OPTION commands. */
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
option_handler (assuan_context_t ctx, const char *key, const char *value)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err = 0;
|
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
(void)ctrl;
|
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
if (!strcmp (key, "putenv"))
|
|
|
|
|
{
|
|
|
|
|
/* Change the session's environment to be used for the
|
|
|
|
|
Pinentry. Valid values are:
|
|
|
|
|
<NAME> Delete envvar NAME
|
|
|
|
|
<KEY>= Set envvar NAME to the empty string
|
|
|
|
|
<KEY>=<VALUE> Set envvar NAME to VALUE
|
|
|
|
|
*/
|
|
|
|
|
err = session_env_putenv (opt.session_env, value);
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "display"))
|
|
|
|
|
{
|
|
|
|
|
err = session_env_setenv (opt.session_env, "DISPLAY", value);
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "ttyname"))
|
|
|
|
|
{
|
|
|
|
|
err = session_env_setenv (opt.session_env, "GPG_TTY", value);
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "ttytype"))
|
|
|
|
|
{
|
|
|
|
|
err = session_env_setenv (opt.session_env, "TERM", value);
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "lc-ctype"))
|
|
|
|
|
{
|
|
|
|
|
xfree (opt.lc_ctype);
|
|
|
|
|
opt.lc_ctype = xtrystrdup (value);
|
|
|
|
|
if (!opt.lc_ctype)
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "lc-messages"))
|
|
|
|
|
{
|
|
|
|
|
xfree (opt.lc_messages);
|
|
|
|
|
opt.lc_messages = xtrystrdup (value);
|
|
|
|
|
if (!opt.lc_messages)
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "xauthority"))
|
|
|
|
|
{
|
|
|
|
|
err = session_env_setenv (opt.session_env, "XAUTHORITY", value);
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "pinentry-user-data"))
|
|
|
|
|
{
|
|
|
|
|
err = session_env_setenv (opt.session_env, "PINENTRY_USER_DATA", value);
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "allow-pinentry-notify"))
|
|
|
|
|
{
|
|
|
|
|
; /* We always allow it. */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
err = gpg_error (GPG_ERR_UNKNOWN_OPTION);
|
|
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The handler for an Assuan RESET command. */
|
agent/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* command.c (reset_notify): Take LINE arg and return error.
(register_commands): Use assuan_handler_t type.
common/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* get-passphrase.c (default_inq_cb, membuf_data_cb): Change return
type to gpg_error_t.
g10/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* server.c (reset_notify, input_notify, output_notify): Update to
new assuan interface.
(register_commands): Use assuan_handler_t.
scd/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* command.c (reset_notify): Take LINE arg and return error.
(register_commands): Use assuan_handler_t type.
sm/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* server.c (reset_notify, input_notify, output_notify): Update to
new assuan interface.
(register_commands): Use assuan_handler_t.
* call-agent.c (membuf_data_cb, default_inq_cb)
(inq_ciphertext_cb, scd_serialno_status_cb)
(scd_keypairinfo_status_cb, istrusted_status_cb)
(learn_status_cb, learn_cb, keyinfo_status_cb): Return gpg_error_t.
2009-11-02 17:47:11 +00:00
|
|
|
|
static gpg_error_t
|
|
|
|
|
reset_notify (assuan_context_t ctx, char *line)
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
|
agent/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* command.c (reset_notify): Take LINE arg and return error.
(register_commands): Use assuan_handler_t type.
common/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* get-passphrase.c (default_inq_cb, membuf_data_cb): Change return
type to gpg_error_t.
g10/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* server.c (reset_notify, input_notify, output_notify): Update to
new assuan interface.
(register_commands): Use assuan_handler_t.
scd/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* command.c (reset_notify): Take LINE arg and return error.
(register_commands): Use assuan_handler_t type.
sm/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* server.c (reset_notify, input_notify, output_notify): Update to
new assuan interface.
(register_commands): Use assuan_handler_t.
* call-agent.c (membuf_data_cb, default_inq_cb)
(inq_ciphertext_cb, scd_serialno_status_cb)
(scd_keypairinfo_status_cb, istrusted_status_cb)
(learn_status_cb, learn_cb, keyinfo_status_cb): Return gpg_error_t.
2009-11-02 17:47:11 +00:00
|
|
|
|
(void)line;
|
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
xfree (ctrl->server_local->containername);
|
|
|
|
|
ctrl->server_local->containername = NULL;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
2016-02-13 17:01:45 +01:00
|
|
|
|
FREE_STRLIST (ctrl->recipients);
|
2009-10-19 09:18:46 +00:00
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
assuan_close_input_fd (ctx);
|
|
|
|
|
assuan_close_output_fd (ctx);
|
agent/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* command.c (reset_notify): Take LINE arg and return error.
(register_commands): Use assuan_handler_t type.
common/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* get-passphrase.c (default_inq_cb, membuf_data_cb): Change return
type to gpg_error_t.
g10/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* server.c (reset_notify, input_notify, output_notify): Update to
new assuan interface.
(register_commands): Use assuan_handler_t.
scd/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* command.c (reset_notify): Take LINE arg and return error.
(register_commands): Use assuan_handler_t type.
sm/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* server.c (reset_notify, input_notify, output_notify): Update to
new assuan interface.
(register_commands): Use assuan_handler_t.
* call-agent.c (membuf_data_cb, default_inq_cb)
(inq_ciphertext_cb, scd_serialno_status_cb)
(scd_keypairinfo_status_cb, istrusted_status_cb)
(learn_status_cb, learn_cb, keyinfo_status_cb): Return gpg_error_t.
2009-11-02 17:47:11 +00:00
|
|
|
|
return 0;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_open[] =
|
2009-11-04 10:06:38 +00:00
|
|
|
|
"OPEN [<options>] <filename>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Open the container FILENAME. FILENAME must be percent-plus\n"
|
|
|
|
|
"escaped. A quick check to see whether this is a suitable G13\n"
|
|
|
|
|
"container file is done. However no cryptographic check or any\n"
|
|
|
|
|
"other check is done. This command is used to define the target for\n"
|
|
|
|
|
"further commands. The filename is reset with the RESET command,\n"
|
|
|
|
|
"another OPEN or the CREATE command.";
|
2009-10-14 17:06:10 +00:00
|
|
|
|
static gpg_error_t
|
2009-10-15 17:20:41 +00:00
|
|
|
|
cmd_open (assuan_context_t ctx, char *line)
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2009-10-15 17:20:41 +00:00
|
|
|
|
gpg_error_t err = 0;
|
|
|
|
|
char *p, *pend;
|
|
|
|
|
size_t len;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
/* In any case reset the active container. */
|
|
|
|
|
xfree (ctrl->server_local->containername);
|
|
|
|
|
ctrl->server_local->containername = NULL;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
/* Parse the line. */
|
|
|
|
|
line = skip_options (line);
|
|
|
|
|
for (p=line; *p && !spacep (p); p++)
|
|
|
|
|
;
|
|
|
|
|
pend = p;
|
|
|
|
|
while (spacep(p))
|
|
|
|
|
p++;
|
|
|
|
|
if (*p || pend == line)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_ASS_SYNTAX);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
*pend = 0;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
/* Unescape the line and check for embedded Nul bytes. */
|
|
|
|
|
len = percent_plus_unescape_inplace (line, 0);
|
|
|
|
|
line[len] = 0;
|
|
|
|
|
if (!len || memchr (line, 0, len))
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_INV_NAME);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
/* Do a basic check. */
|
|
|
|
|
err = g13_is_container (ctrl, line);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
|
|
|
|
|
/* Store the filename. */
|
|
|
|
|
ctrl->server_local->containername = xtrystrdup (line);
|
|
|
|
|
if (!ctrl->server_local->containername)
|
|
|
|
|
err = gpg_error_from_syserror ();
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
leave:
|
2009-10-14 17:06:10 +00:00
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_mount[] =
|
2009-11-04 11:57:26 +00:00
|
|
|
|
"MOUNT [options] [<mountpoint>]\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Mount the currently open file onto MOUNTPOINT. If MOUNTPOINT is not\n"
|
|
|
|
|
"given the system picks an unused mountpoint. MOUNTPOINT must\n"
|
|
|
|
|
"be percent-plus escaped to allow for arbitrary names.";
|
2009-10-14 17:06:10 +00:00
|
|
|
|
static gpg_error_t
|
2009-10-15 17:20:41 +00:00
|
|
|
|
cmd_mount (assuan_context_t ctx, char *line)
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err = 0;
|
|
|
|
|
char *p, *pend;
|
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
|
|
line = skip_options (line);
|
|
|
|
|
for (p=line; *p && !spacep (p); p++)
|
|
|
|
|
;
|
|
|
|
|
pend = p;
|
|
|
|
|
while (spacep(p))
|
|
|
|
|
p++;
|
|
|
|
|
if (*p)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_ASS_SYNTAX);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
*pend = 0;
|
|
|
|
|
|
|
|
|
|
/* Unescape the line and check for embedded Nul bytes. */
|
|
|
|
|
len = percent_plus_unescape_inplace (line, 0);
|
|
|
|
|
line[len] = 0;
|
|
|
|
|
if (memchr (line, 0, len))
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_INV_NAME);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
if (!ctrl->server_local->containername)
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{
|
2009-10-15 17:20:41 +00:00
|
|
|
|
err = gpg_error (GPG_ERR_MISSING_ACTION);
|
|
|
|
|
goto leave;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-15 17:20:41 +00:00
|
|
|
|
/* Perform the mount. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
err = g13_mount_container (ctrl, ctrl->server_local->containername,
|
2009-10-15 17:20:41 +00:00
|
|
|
|
*line? line : NULL);
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_umount[] =
|
2009-11-04 11:57:26 +00:00
|
|
|
|
"UMOUNT [options] [<mountpoint>]\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Unmount the currently open file or the one opened at MOUNTPOINT.\n"
|
|
|
|
|
"MOUNTPOINT must be percent-plus escaped. On success the mountpoint\n"
|
|
|
|
|
"is returned via a \"MOUNTPOINT\" status line.";
|
2009-10-14 17:06:10 +00:00
|
|
|
|
static gpg_error_t
|
2009-10-15 17:20:41 +00:00
|
|
|
|
cmd_umount (assuan_context_t ctx, char *line)
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err = 0;
|
|
|
|
|
char *p, *pend;
|
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
|
|
line = skip_options (line);
|
|
|
|
|
for (p=line; *p && !spacep (p); p++)
|
|
|
|
|
;
|
|
|
|
|
pend = p;
|
|
|
|
|
while (spacep(p))
|
|
|
|
|
p++;
|
2009-10-15 17:20:41 +00:00
|
|
|
|
if (*p)
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_ASS_SYNTAX);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
*pend = 0;
|
|
|
|
|
|
|
|
|
|
/* Unescape the line and check for embedded Nul bytes. */
|
|
|
|
|
len = percent_plus_unescape_inplace (line, 0);
|
|
|
|
|
line[len] = 0;
|
2009-10-15 17:20:41 +00:00
|
|
|
|
if (memchr (line, 0, len))
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_INV_NAME);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2009-10-15 17:20:41 +00:00
|
|
|
|
|
|
|
|
|
/* Perform the unmount. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
err = g13_umount_container (ctrl, ctrl->server_local->containername,
|
2009-10-15 17:20:41 +00:00
|
|
|
|
*line? line : NULL);
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-02-23 14:32:46 +01:00
|
|
|
|
static const char hlp_suspend[] =
|
|
|
|
|
"SUSPEND\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Suspend the currently set device.";
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_suspend (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
|
|
|
|
|
line = skip_options (line);
|
|
|
|
|
if (*line)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_ASS_SYNTAX);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Perform the suspend operation. */
|
|
|
|
|
err = g13_suspend_container (ctrl, ctrl->server_local->containername);
|
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const char hlp_resume[] =
|
|
|
|
|
"RESUME\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Resume the currently set device.";
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_resume (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
|
|
|
|
|
line = skip_options (line);
|
|
|
|
|
if (*line)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_ASS_SYNTAX);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Perform the suspend operation. */
|
|
|
|
|
err = g13_resume_container (ctrl, ctrl->server_local->containername);
|
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_recipient[] =
|
2009-11-04 11:57:26 +00:00
|
|
|
|
"RECIPIENT <userID>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Add USERID to the list of recipients to be used for the next CREATE\n"
|
|
|
|
|
"command. All recipient commands are cumulative until a RESET or an\n"
|
|
|
|
|
"successful create command.";
|
2009-10-15 17:20:41 +00:00
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_recipient (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2009-10-19 09:18:46 +00:00
|
|
|
|
gpg_error_t err = 0;
|
2009-10-15 17:20:41 +00:00
|
|
|
|
|
2009-10-19 09:18:46 +00:00
|
|
|
|
line = skip_options (line);
|
|
|
|
|
|
2016-02-13 17:01:45 +01:00
|
|
|
|
if (!add_to_strlist_try (&ctrl->recipients, line))
|
2009-10-19 09:18:46 +00:00
|
|
|
|
err = gpg_error_from_syserror ();
|
2009-10-15 17:20:41 +00:00
|
|
|
|
|
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-11-04 11:57:26 +00:00
|
|
|
|
static const char hlp_signer[] =
|
|
|
|
|
"SIGNER <userID>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Not yet implemented.";
|
2009-10-15 17:20:41 +00:00
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_signer (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
|
|
|
|
|
(void)ctrl;
|
2009-10-19 09:18:46 +00:00
|
|
|
|
(void)line;
|
2009-10-15 17:20:41 +00:00
|
|
|
|
|
|
|
|
|
err = gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-11-04 11:57:26 +00:00
|
|
|
|
static const char hlp_create[] =
|
|
|
|
|
"CREATE [options] <filename>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Create a new container. On success the OPEN command is \n"
|
|
|
|
|
"implictly done for the new container.";
|
2009-10-15 17:20:41 +00:00
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_create (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err;
|
2009-10-19 09:18:46 +00:00
|
|
|
|
char *p, *pend;
|
|
|
|
|
size_t len;
|
2009-10-15 17:20:41 +00:00
|
|
|
|
|
|
|
|
|
/* First we close the active container. */
|
|
|
|
|
xfree (ctrl->server_local->containername);
|
|
|
|
|
ctrl->server_local->containername = NULL;
|
|
|
|
|
|
2009-10-19 09:18:46 +00:00
|
|
|
|
/* Parse the line. */
|
|
|
|
|
line = skip_options (line);
|
|
|
|
|
for (p=line; *p && !spacep (p); p++)
|
|
|
|
|
;
|
|
|
|
|
pend = p;
|
|
|
|
|
while (spacep(p))
|
|
|
|
|
p++;
|
|
|
|
|
if (*p || pend == line)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_ASS_SYNTAX);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
*pend = 0;
|
|
|
|
|
|
|
|
|
|
/* Unescape the line and check for embedded Nul bytes. */
|
|
|
|
|
len = percent_plus_unescape_inplace (line, 0);
|
|
|
|
|
line[len] = 0;
|
|
|
|
|
if (!len || memchr (line, 0, len))
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_INV_NAME);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2009-10-15 17:20:41 +00:00
|
|
|
|
|
2009-10-19 09:18:46 +00:00
|
|
|
|
/* Create container. */
|
2016-02-13 17:01:45 +01:00
|
|
|
|
err = g13_create_container (ctrl, line);
|
2009-10-15 17:20:41 +00:00
|
|
|
|
|
2009-10-19 09:18:46 +00:00
|
|
|
|
if (!err)
|
|
|
|
|
{
|
2016-02-13 17:01:45 +01:00
|
|
|
|
FREE_STRLIST (ctrl->recipients);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-10-19 09:18:46 +00:00
|
|
|
|
/* Store the filename. */
|
|
|
|
|
ctrl->server_local->containername = xtrystrdup (line);
|
|
|
|
|
if (!ctrl->server_local->containername)
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
leave:
|
2009-10-15 17:20:41 +00:00
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_getinfo[] =
|
2009-11-04 11:57:26 +00:00
|
|
|
|
"GETINFO <what>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Multipurpose function to return a variety of information.\n"
|
|
|
|
|
"Supported values for WHAT are:\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" version - Return the version of the program.\n"
|
|
|
|
|
" pid - Return the process id of the server.\n"
|
|
|
|
|
" cmd_has_option CMD OPT\n"
|
|
|
|
|
" - Return OK if the command CMD implements the option OPT.";
|
2009-10-14 17:06:10 +00:00
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_getinfo (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
gpg_error_t err = 0;
|
|
|
|
|
|
|
|
|
|
if (!strcmp (line, "version"))
|
|
|
|
|
{
|
|
|
|
|
const char *s = PACKAGE_VERSION;
|
|
|
|
|
err = assuan_send_data (ctx, s, strlen (s));
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (line, "pid"))
|
|
|
|
|
{
|
|
|
|
|
char numbuf[50];
|
|
|
|
|
|
|
|
|
|
snprintf (numbuf, sizeof numbuf, "%lu", (unsigned long)getpid ());
|
|
|
|
|
err = assuan_send_data (ctx, numbuf, strlen (numbuf));
|
|
|
|
|
}
|
|
|
|
|
else if (!strncmp (line, "cmd_has_option", 14)
|
|
|
|
|
&& (line[14] == ' ' || line[14] == '\t' || !line[14]))
|
|
|
|
|
{
|
|
|
|
|
char *cmd, *cmdopt;
|
|
|
|
|
line += 14;
|
|
|
|
|
while (*line == ' ' || *line == '\t')
|
|
|
|
|
line++;
|
|
|
|
|
if (!*line)
|
|
|
|
|
err = gpg_error (GPG_ERR_MISSING_VALUE);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cmd = line;
|
|
|
|
|
while (*line && (*line != ' ' && *line != '\t'))
|
|
|
|
|
line++;
|
|
|
|
|
if (!*line)
|
|
|
|
|
err = gpg_error (GPG_ERR_MISSING_VALUE);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*line++ = 0;
|
|
|
|
|
while (*line == ' ' || *line == '\t')
|
|
|
|
|
line++;
|
|
|
|
|
if (!*line)
|
|
|
|
|
err = gpg_error (GPG_ERR_MISSING_VALUE);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cmdopt = line;
|
|
|
|
|
if (!command_has_option (cmd, cmdopt))
|
2019-06-03 16:31:58 +02:00
|
|
|
|
err = gpg_error (GPG_ERR_FALSE);
|
2009-10-14 17:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
|
|
|
|
|
|
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return true if the command CMD implements the option CMDOPT. */
|
|
|
|
|
static int
|
|
|
|
|
command_has_option (const char *cmd, const char *cmdopt)
|
|
|
|
|
{
|
|
|
|
|
(void)cmd;
|
|
|
|
|
(void)cmdopt;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Tell the Assuan library about our commands. */
|
|
|
|
|
static int
|
|
|
|
|
register_commands (assuan_context_t ctx)
|
|
|
|
|
{
|
|
|
|
|
static struct {
|
|
|
|
|
const char *name;
|
agent/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* command.c (reset_notify): Take LINE arg and return error.
(register_commands): Use assuan_handler_t type.
common/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* get-passphrase.c (default_inq_cb, membuf_data_cb): Change return
type to gpg_error_t.
g10/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* server.c (reset_notify, input_notify, output_notify): Update to
new assuan interface.
(register_commands): Use assuan_handler_t.
scd/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* command.c (reset_notify): Take LINE arg and return error.
(register_commands): Use assuan_handler_t type.
sm/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* server.c (reset_notify, input_notify, output_notify): Update to
new assuan interface.
(register_commands): Use assuan_handler_t.
* call-agent.c (membuf_data_cb, default_inq_cb)
(inq_ciphertext_cb, scd_serialno_status_cb)
(scd_keypairinfo_status_cb, istrusted_status_cb)
(learn_status_cb, learn_cb, keyinfo_status_cb): Return gpg_error_t.
2009-11-02 17:47:11 +00:00
|
|
|
|
assuan_handler_t handler;
|
2009-11-04 10:06:38 +00:00
|
|
|
|
const char * const help;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
} table[] = {
|
2009-11-04 11:57:26 +00:00
|
|
|
|
{ "OPEN", cmd_open, hlp_open },
|
|
|
|
|
{ "MOUNT", cmd_mount, hlp_mount},
|
|
|
|
|
{ "UMOUNT", cmd_umount, hlp_umount },
|
2016-02-23 14:32:46 +01:00
|
|
|
|
{ "SUSPEND", cmd_suspend, hlp_suspend },
|
|
|
|
|
{ "RESUME", cmd_resume, hlp_resume },
|
2009-11-04 11:57:26 +00:00
|
|
|
|
{ "RECIPIENT", cmd_recipient, hlp_recipient },
|
|
|
|
|
{ "SIGNER", cmd_signer, hlp_signer },
|
|
|
|
|
{ "CREATE", cmd_create, hlp_create },
|
2011-02-04 12:57:53 +01:00
|
|
|
|
{ "INPUT", NULL },
|
|
|
|
|
{ "OUTPUT", NULL },
|
2009-11-04 11:57:26 +00:00
|
|
|
|
{ "GETINFO", cmd_getinfo,hlp_getinfo },
|
2009-10-14 17:06:10 +00:00
|
|
|
|
{ NULL }
|
|
|
|
|
};
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i=0; table[i].name; i++)
|
|
|
|
|
{
|
2009-11-04 10:06:38 +00:00
|
|
|
|
err = assuan_register_command (ctx, table[i].name, table[i].handler,
|
|
|
|
|
table[i].help);
|
2009-10-14 17:06:10 +00:00
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
}
|
2009-10-14 17:06:10 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Startup the server. DEFAULT_RECPLIST is the list of recipients as
|
|
|
|
|
set from the command line or config file. We only require those
|
|
|
|
|
marked as encrypt-to. */
|
|
|
|
|
gpg_error_t
|
|
|
|
|
g13_server (ctrl_t ctrl)
|
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
2009-11-25 17:58:26 +00:00
|
|
|
|
assuan_fd_t filedes[2];
|
2009-10-14 17:06:10 +00:00
|
|
|
|
assuan_context_t ctx = NULL;
|
|
|
|
|
static const char hello[] = ("GNU Privacy Guard's G13 server "
|
|
|
|
|
PACKAGE_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 FIELDES in this case. */
|
2009-11-25 17:58:26 +00:00
|
|
|
|
filedes[0] = assuan_fdopen (0);
|
|
|
|
|
filedes[1] = assuan_fdopen (1);
|
2009-10-14 17:06:10 +00:00
|
|
|
|
err = assuan_new (&ctx);
|
|
|
|
|
if (err)
|
|
|
|
|
{
|
|
|
|
|
log_error ("failed to allocate an Assuan context: %s\n",
|
|
|
|
|
gpg_strerror (err));
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = assuan_init_pipe_server (ctx, filedes);
|
|
|
|
|
if (err)
|
|
|
|
|
{
|
|
|
|
|
log_error ("failed to initialize the server: %s\n", gpg_strerror (err));
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = register_commands (ctx);
|
|
|
|
|
if (err)
|
|
|
|
|
{
|
|
|
|
|
log_error ("failed to the register commands with Assuan: %s\n",
|
|
|
|
|
gpg_strerror (err));
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assuan_set_pointer (ctx, ctrl);
|
|
|
|
|
|
|
|
|
|
if (opt.verbose || opt.debug)
|
|
|
|
|
{
|
2016-06-07 10:59:46 +02:00
|
|
|
|
char *tmp;
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
|
|
|
|
tmp = xtryasprintf ("Home: %s\n"
|
|
|
|
|
"Config: %s\n"
|
|
|
|
|
"%s",
|
2016-06-07 10:59:46 +02:00
|
|
|
|
gnupg_homedir (),
|
2009-10-14 17:06:10 +00:00
|
|
|
|
opt.config_filename,
|
|
|
|
|
hello);
|
|
|
|
|
if (tmp)
|
|
|
|
|
{
|
|
|
|
|
assuan_set_hello_line (ctx, tmp);
|
|
|
|
|
xfree (tmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
assuan_set_hello_line (ctx, hello);
|
|
|
|
|
|
|
|
|
|
assuan_register_reset_notify (ctx, reset_notify);
|
|
|
|
|
assuan_register_option_handler (ctx, option_handler);
|
|
|
|
|
|
|
|
|
|
ctrl->server_local = xtrycalloc (1, sizeof *ctrl->server_local);
|
|
|
|
|
if (!ctrl->server_local)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
ctrl->server_local->assuan_ctx = ctx;
|
|
|
|
|
|
|
|
|
|
while ( !(err = assuan_accept (ctx)) )
|
|
|
|
|
{
|
|
|
|
|
err = assuan_process (ctx);
|
|
|
|
|
if (err)
|
|
|
|
|
log_info ("Assuan processing failed: %s\n", gpg_strerror (err));
|
|
|
|
|
}
|
|
|
|
|
if (err == -1)
|
|
|
|
|
err = 0;
|
|
|
|
|
else
|
|
|
|
|
log_info ("Assuan accept problem: %s\n", gpg_strerror (err));
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-10-14 17:06:10 +00:00
|
|
|
|
leave:
|
agent/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* command.c (reset_notify): Take LINE arg and return error.
(register_commands): Use assuan_handler_t type.
common/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* get-passphrase.c (default_inq_cb, membuf_data_cb): Change return
type to gpg_error_t.
g10/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* server.c (reset_notify, input_notify, output_notify): Update to
new assuan interface.
(register_commands): Use assuan_handler_t.
scd/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* command.c (reset_notify): Take LINE arg and return error.
(register_commands): Use assuan_handler_t type.
sm/
2009-11-02 Marcus Brinkmann <marcus@g10code.de>
* server.c (reset_notify, input_notify, output_notify): Update to
new assuan interface.
(register_commands): Use assuan_handler_t.
* call-agent.c (membuf_data_cb, default_inq_cb)
(inq_ciphertext_cb, scd_serialno_status_cb)
(scd_keypairinfo_status_cb, istrusted_status_cb)
(learn_status_cb, learn_cb, keyinfo_status_cb): Return gpg_error_t.
2009-11-02 17:47:11 +00:00
|
|
|
|
reset_notify (ctx, NULL); /* Release all items hold by SERVER_LOCAL. */
|
2009-10-14 17:06:10 +00:00
|
|
|
|
if (ctrl->server_local)
|
|
|
|
|
{
|
|
|
|
|
xfree (ctrl->server_local);
|
|
|
|
|
ctrl->server_local = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assuan_release (ctx);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-10-28 12:02:15 +00:00
|
|
|
|
/* Send a status line with status ID NO. The arguments are a list of
|
|
|
|
|
strings terminated by a NULL argument. */
|
|
|
|
|
gpg_error_t
|
|
|
|
|
g13_status (ctrl_t ctrl, int no, ...)
|
|
|
|
|
{
|
|
|
|
|
gpg_error_t err = 0;
|
|
|
|
|
va_list arg_ptr;
|
|
|
|
|
const char *text;
|
|
|
|
|
|
|
|
|
|
va_start (arg_ptr, no);
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
2009-10-28 12:02:15 +00:00
|
|
|
|
if (ctrl->no_server && ctrl->status_fd == -1)
|
|
|
|
|
; /* No status wanted. */
|
|
|
|
|
else if (ctrl->no_server)
|
|
|
|
|
{
|
|
|
|
|
if (!statusfp)
|
|
|
|
|
{
|
|
|
|
|
if (ctrl->status_fd == 1)
|
|
|
|
|
statusfp = stdout;
|
|
|
|
|
else if (ctrl->status_fd == 2)
|
|
|
|
|
statusfp = stderr;
|
|
|
|
|
else
|
|
|
|
|
statusfp = fdopen (ctrl->status_fd, "w");
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-10-28 12:02:15 +00:00
|
|
|
|
if (!statusfp)
|
|
|
|
|
{
|
|
|
|
|
log_fatal ("can't open fd %d for status output: %s\n",
|
|
|
|
|
ctrl->status_fd, strerror(errno));
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-10-28 12:02:15 +00:00
|
|
|
|
fputs ("[GNUPG:] ", statusfp);
|
|
|
|
|
fputs (get_status_string (no), statusfp);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-10-28 12:02:15 +00:00
|
|
|
|
while ( (text = va_arg (arg_ptr, const char*) ))
|
|
|
|
|
{
|
|
|
|
|
putc ( ' ', statusfp );
|
|
|
|
|
for (; *text; text++)
|
|
|
|
|
{
|
|
|
|
|
if (*text == '\n')
|
|
|
|
|
fputs ( "\\n", statusfp );
|
|
|
|
|
else if (*text == '\r')
|
|
|
|
|
fputs ( "\\r", statusfp );
|
|
|
|
|
else
|
|
|
|
|
putc ( *(const byte *)text, statusfp );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
putc ('\n', statusfp);
|
|
|
|
|
fflush (statusfp);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-02-14 12:21:23 +01:00
|
|
|
|
err = vprint_assuan_status_strings (ctrl->server_local->assuan_ctx,
|
|
|
|
|
get_status_string (no), arg_ptr);
|
2009-10-28 12:02:15 +00:00
|
|
|
|
}
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
2009-10-28 12:02:15 +00:00
|
|
|
|
va_end (arg_ptr);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
2009-10-14 17:06:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Helper to notify the client about Pinentry events. Returns an gpg
|
|
|
|
|
error code. */
|
|
|
|
|
gpg_error_t
|
|
|
|
|
g13_proxy_pinentry_notify (ctrl_t ctrl, const unsigned char *line)
|
|
|
|
|
{
|
|
|
|
|
if (!ctrl || !ctrl->server_local)
|
|
|
|
|
return 0;
|
|
|
|
|
return assuan_inquire (ctrl->server_local->assuan_ctx, line, NULL, NULL, 0);
|
|
|
|
|
}
|
2016-08-13 17:39:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Decrypt the keyblob (ENCKEYBLOB,ENCKEYBLOBLEN) and store the result
|
|
|
|
|
* at (R_KEYBLOB, R_KEYBLOBLEN). Returns 0 on success or an error
|
|
|
|
|
* code. On error R_KEYBLOB is set to NULL.
|
|
|
|
|
*
|
|
|
|
|
* This actually does not belong here but for that simple wrapper it
|
|
|
|
|
* does not make sense to add another source file. Note that we do
|
|
|
|
|
* not want to have this in keyblob.c, because that code is also used
|
|
|
|
|
* by the syshelp.
|
|
|
|
|
*/
|
|
|
|
|
gpg_error_t
|
|
|
|
|
g13_keyblob_decrypt (ctrl_t ctrl, const void *enckeyblob, size_t enckeybloblen,
|
|
|
|
|
void **r_keyblob, size_t *r_keybloblen)
|
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
|
|
|
|
|
/* FIXME: For now we only implement OpenPGP. */
|
|
|
|
|
err = gpg_decrypt_blob (ctrl, opt.gpg_program, opt.gpg_arguments,
|
|
|
|
|
enckeyblob, enckeybloblen,
|
|
|
|
|
r_keyblob, r_keybloblen);
|
|
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
}
|