2011-02-04 12:57:53 +01:00
|
|
|
|
/* server.c - Server mode and main entry point
|
2010-03-08 12:22:18 +00:00
|
|
|
|
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
|
|
|
|
* 2010 Free Software Foundation, Inc.
|
2003-08-05 17:11:04 +00:00
|
|
|
|
*
|
|
|
|
|
* 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
|
2007-07-04 19:49:40 +00:00
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-08-05 17:11:04 +00:00
|
|
|
|
* (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/>.
|
2003-08-05 17:11:04 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include "gpgsm.h"
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
#include <assuan.h>
|
2017-03-07 20:21:23 +09:00
|
|
|
|
#include "../common/sysutils.h"
|
|
|
|
|
#include "../common/server-help.h"
|
2018-02-14 12:21:23 +01:00
|
|
|
|
#include "../common/asshelp.h"
|
2018-03-23 15:07:56 +01:00
|
|
|
|
#include "../common/shareddefs.h"
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2006-09-06 16:35:52 +00:00
|
|
|
|
#define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t))
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The filepointer for status message used in non-server mode */
|
|
|
|
|
static FILE *statusfp;
|
|
|
|
|
|
|
|
|
|
/* Data used to assuciate an Assuan context with local server data */
|
|
|
|
|
struct server_local_s {
|
2003-12-17 17:12:14 +00:00
|
|
|
|
assuan_context_t assuan_ctx;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int message_fd;
|
|
|
|
|
int list_internal;
|
|
|
|
|
int list_external;
|
2006-09-13 15:57:30 +00:00
|
|
|
|
int list_to_output; /* Write keylistings to the output fd. */
|
2007-11-19 16:03:50 +00:00
|
|
|
|
int enable_audit_log; /* Use an audit log. */
|
2003-12-17 17:12:14 +00:00
|
|
|
|
certlist_t recplist;
|
|
|
|
|
certlist_t signerlist;
|
|
|
|
|
certlist_t default_recplist; /* As set by main() - don't release. */
|
2008-02-14 19:50:10 +00:00
|
|
|
|
int allow_pinentry_notify; /* Set if pinentry notifications should
|
|
|
|
|
be passed back to the client. */
|
2009-05-18 17:38:34 +00:00
|
|
|
|
int no_encrypt_to; /* Local version of option. */
|
2003-08-05 17:11:04 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2007-03-19 14:35:04 +00:00
|
|
|
|
/* Cookie definition for assuan data line output. */
|
2015-11-27 18:30:14 +01:00
|
|
|
|
static gpgrt_ssize_t data_line_cookie_write (void *cookie,
|
|
|
|
|
const void *buffer, size_t size);
|
2007-03-19 14:35:04 +00:00
|
|
|
|
static int data_line_cookie_close (void *cookie);
|
|
|
|
|
static es_cookie_io_functions_t data_line_cookie_functions =
|
|
|
|
|
{
|
|
|
|
|
NULL,
|
|
|
|
|
data_line_cookie_write,
|
|
|
|
|
NULL,
|
|
|
|
|
data_line_cookie_close
|
|
|
|
|
};
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2007-03-19 14:35:04 +00:00
|
|
|
|
|
2009-07-07 16:52:12 +00:00
|
|
|
|
|
|
|
|
|
static int command_has_option (const char *cmd, const char *cmdopt);
|
|
|
|
|
|
|
|
|
|
|
2007-03-19 14:35:04 +00:00
|
|
|
|
|
|
|
|
|
|
2003-12-16 11:31:46 +00:00
|
|
|
|
/* Note that it is sufficient to allocate the target string D as
|
2003-08-05 17:11:04 +00:00
|
|
|
|
long as the source string S, i.e.: strlen(s)+1; */
|
|
|
|
|
static void
|
2005-06-16 08:12:03 +00:00
|
|
|
|
strcpy_escaped_plus (char *d, const char *s)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
|
|
|
|
while (*s)
|
|
|
|
|
{
|
|
|
|
|
if (*s == '%' && s[1] && s[2])
|
2011-02-04 12:57:53 +01:00
|
|
|
|
{
|
2003-08-05 17:11:04 +00:00
|
|
|
|
s++;
|
2005-06-16 08:12:03 +00:00
|
|
|
|
*d++ = xtoi_2 (s);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
s += 2;
|
|
|
|
|
}
|
|
|
|
|
else if (*s == '+')
|
|
|
|
|
*d++ = ' ', s++;
|
|
|
|
|
else
|
|
|
|
|
*d++ = *s++;
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
*d = 0;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-03-19 14:35:04 +00:00
|
|
|
|
/* A write handler used by es_fopencookie to write assuan data
|
|
|
|
|
lines. */
|
2015-11-27 18:30:14 +01:00
|
|
|
|
static gpgrt_ssize_t
|
2007-03-19 14:35:04 +00:00
|
|
|
|
data_line_cookie_write (void *cookie, const void *buffer, size_t size)
|
|
|
|
|
{
|
|
|
|
|
assuan_context_t ctx = cookie;
|
|
|
|
|
|
|
|
|
|
if (assuan_send_data (ctx, buffer, size))
|
|
|
|
|
{
|
2010-03-24 12:15:30 +00:00
|
|
|
|
gpg_err_set_errno (EIO);
|
2007-03-19 14:35:04 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-27 18:30:14 +01:00
|
|
|
|
return (gpgrt_ssize_t)size;
|
2007-03-19 14:35:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
data_line_cookie_close (void *cookie)
|
|
|
|
|
{
|
|
|
|
|
assuan_context_t ctx = cookie;
|
|
|
|
|
|
|
|
|
|
if (assuan_send_data (ctx, NULL, 0))
|
|
|
|
|
{
|
2010-03-24 12:15:30 +00:00
|
|
|
|
gpg_err_set_errno (EIO);
|
2007-03-19 14:35:04 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static void
|
2006-09-06 16:35:52 +00:00
|
|
|
|
close_message_fd (ctrl_t ctrl)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
|
|
|
|
if (ctrl->server_local->message_fd != -1)
|
|
|
|
|
{
|
2010-10-26 09:10:29 +00:00
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
2010-06-10 23:17:33 +00:00
|
|
|
|
#warning Is this correct for W32/W32CE?
|
2010-10-26 09:10:29 +00:00
|
|
|
|
#endif
|
2003-08-05 17:11:04 +00:00
|
|
|
|
close (ctrl->server_local->message_fd);
|
|
|
|
|
ctrl->server_local->message_fd = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-19 16:03:50 +00:00
|
|
|
|
/* Start a new audit session if this has been enabled. */
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
start_audit_session (ctrl_t ctrl)
|
|
|
|
|
{
|
|
|
|
|
audit_release (ctrl->audit);
|
|
|
|
|
ctrl->audit = NULL;
|
|
|
|
|
if (ctrl->server_local->enable_audit_log && !(ctrl->audit = audit_new ()) )
|
|
|
|
|
return gpg_error_from_syserror ();
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2007-11-19 16:03:50 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
option_handler (assuan_context_t ctx, const char *key, const char *value)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2009-07-07 10:02:41 +00:00
|
|
|
|
gpg_error_t err = 0;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2009-07-07 10:02:41 +00:00
|
|
|
|
if (!strcmp (key, "putenv"))
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2009-07-07 10:02:41 +00:00
|
|
|
|
/* 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);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
2006-09-06 16:35:52 +00:00
|
|
|
|
else if (!strcmp (key, "display"))
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2009-07-07 10:02:41 +00:00
|
|
|
|
err = session_env_setenv (opt.session_env, "DISPLAY", value);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "ttyname"))
|
|
|
|
|
{
|
2009-07-07 10:02:41 +00:00
|
|
|
|
err = session_env_setenv (opt.session_env, "GPG_TTY", value);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "ttytype"))
|
|
|
|
|
{
|
2009-07-07 10:02:41 +00:00
|
|
|
|
err = session_env_setenv (opt.session_env, "TERM", value);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "lc-ctype"))
|
|
|
|
|
{
|
2009-07-07 10:02:41 +00:00
|
|
|
|
xfree (opt.lc_ctype);
|
|
|
|
|
opt.lc_ctype = xtrystrdup (value);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (!opt.lc_ctype)
|
2009-07-07 10:02:41 +00:00
|
|
|
|
err = gpg_error_from_syserror ();
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "lc-messages"))
|
|
|
|
|
{
|
2009-07-07 10:02:41 +00:00
|
|
|
|
xfree (opt.lc_messages);
|
|
|
|
|
opt.lc_messages = xtrystrdup (value);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (!opt.lc_messages)
|
2009-07-07 10:02:41 +00:00
|
|
|
|
err = gpg_error_from_syserror ();
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
2007-11-19 16:03:50 +00:00
|
|
|
|
else if (!strcmp (key, "xauthority"))
|
|
|
|
|
{
|
2009-07-07 10:02:41 +00:00
|
|
|
|
err = session_env_setenv (opt.session_env, "XAUTHORITY", value);
|
2007-11-19 16:03:50 +00:00
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "pinentry-user-data"))
|
|
|
|
|
{
|
2009-07-07 10:02:41 +00:00
|
|
|
|
err = session_env_setenv (opt.session_env, "PINENTRY_USER_DATA", value);
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "include-certs"))
|
|
|
|
|
{
|
|
|
|
|
int i = *value? atoi (value) : -1;
|
|
|
|
|
if (ctrl->include_certs < -2)
|
|
|
|
|
err = gpg_error (GPG_ERR_ASS_PARAMETER);
|
|
|
|
|
else
|
|
|
|
|
ctrl->include_certs = i;
|
2007-11-19 16:03:50 +00:00
|
|
|
|
}
|
2003-08-05 17:11:04 +00:00
|
|
|
|
else if (!strcmp (key, "list-mode"))
|
|
|
|
|
{
|
|
|
|
|
int i = *value? atoi (value) : 0;
|
|
|
|
|
if (!i || i == 1) /* default and mode 1 */
|
|
|
|
|
{
|
|
|
|
|
ctrl->server_local->list_internal = 1;
|
|
|
|
|
ctrl->server_local->list_external = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (i == 2)
|
|
|
|
|
{
|
|
|
|
|
ctrl->server_local->list_internal = 0;
|
|
|
|
|
ctrl->server_local->list_external = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (i == 3)
|
|
|
|
|
{
|
|
|
|
|
ctrl->server_local->list_internal = 1;
|
|
|
|
|
ctrl->server_local->list_external = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
2009-07-07 10:02:41 +00:00
|
|
|
|
err = gpg_error (GPG_ERR_ASS_PARAMETER);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
2006-09-13 15:57:30 +00:00
|
|
|
|
else if (!strcmp (key, "list-to-output"))
|
|
|
|
|
{
|
|
|
|
|
int i = *value? atoi (value) : 0;
|
|
|
|
|
ctrl->server_local->list_to_output = i;
|
|
|
|
|
}
|
2004-02-17 15:05:04 +00:00
|
|
|
|
else if (!strcmp (key, "with-validation"))
|
|
|
|
|
{
|
2004-02-17 17:21:07 +00:00
|
|
|
|
int i = *value? atoi (value) : 0;
|
|
|
|
|
ctrl->with_validation = i;
|
2004-02-17 15:05:04 +00:00
|
|
|
|
}
|
2014-06-04 08:50:10 +02:00
|
|
|
|
else if (!strcmp (key, "with-secret"))
|
2014-06-03 21:35:59 +02:00
|
|
|
|
{
|
|
|
|
|
int i = *value? atoi (value) : 0;
|
|
|
|
|
ctrl->with_secret = i;
|
|
|
|
|
}
|
2007-08-10 16:52:05 +00:00
|
|
|
|
else if (!strcmp (key, "validation-model"))
|
|
|
|
|
{
|
|
|
|
|
int i = gpgsm_parse_validation_model (value);
|
2011-12-07 16:15:15 +01:00
|
|
|
|
if ( i >= 0 && i <= 2 )
|
2007-08-10 16:52:05 +00:00
|
|
|
|
ctrl->validation_model = i;
|
|
|
|
|
else
|
2009-07-07 10:02:41 +00:00
|
|
|
|
err = gpg_error (GPG_ERR_ASS_PARAMETER);
|
2007-08-10 16:52:05 +00:00
|
|
|
|
}
|
2006-10-02 10:58:08 +00:00
|
|
|
|
else if (!strcmp (key, "with-key-data"))
|
|
|
|
|
{
|
|
|
|
|
opt.with_key_data = 1;
|
|
|
|
|
}
|
2007-11-19 16:03:50 +00:00
|
|
|
|
else if (!strcmp (key, "enable-audit-log"))
|
|
|
|
|
{
|
|
|
|
|
int i = *value? atoi (value) : 0;
|
|
|
|
|
ctrl->server_local->enable_audit_log = i;
|
|
|
|
|
}
|
2008-02-14 19:50:10 +00:00
|
|
|
|
else if (!strcmp (key, "allow-pinentry-notify"))
|
2009-07-07 10:02:41 +00:00
|
|
|
|
{
|
|
|
|
|
ctrl->server_local->allow_pinentry_notify = 1;
|
|
|
|
|
}
|
2009-03-18 11:18:56 +00:00
|
|
|
|
else if (!strcmp (key, "with-ephemeral-keys"))
|
|
|
|
|
{
|
|
|
|
|
int i = *value? atoi (value) : 0;
|
|
|
|
|
ctrl->with_ephemeral_keys = i;
|
|
|
|
|
}
|
2009-05-18 17:38:34 +00:00
|
|
|
|
else if (!strcmp (key, "no-encrypt-to"))
|
|
|
|
|
{
|
|
|
|
|
ctrl->server_local->no_encrypt_to = 1;
|
|
|
|
|
}
|
2015-06-29 11:03:58 +02:00
|
|
|
|
else if (!strcmp (key, "offline"))
|
|
|
|
|
{
|
|
|
|
|
/* We ignore this option if gpgsm has been started with
|
|
|
|
|
--disable-dirmngr (which also sets offline). */
|
|
|
|
|
if (!opt.disable_dirmngr)
|
|
|
|
|
{
|
|
|
|
|
int i = *value? !!atoi (value) : 1;
|
|
|
|
|
ctrl->offline = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-31 11:13:38 +02:00
|
|
|
|
else if (!strcmp (key, "always-trust"))
|
|
|
|
|
{
|
|
|
|
|
/* We ignore this option if gpgsm has been started with
|
|
|
|
|
--always-trust (which also sets offline) and if
|
|
|
|
|
--require-compliance is active */
|
|
|
|
|
if (!opt.always_trust && !opt.require_compliance)
|
|
|
|
|
{
|
|
|
|
|
int i = *value? !!atoi (value) : 1;
|
|
|
|
|
ctrl->always_trust = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-23 15:07:56 +01:00
|
|
|
|
else if (!strcmp (key, "request-origin"))
|
|
|
|
|
{
|
|
|
|
|
if (!opt.request_origin)
|
|
|
|
|
{
|
|
|
|
|
int i = parse_request_origin (value);
|
|
|
|
|
if (i == -1)
|
|
|
|
|
err = gpg_error (GPG_ERR_INV_VALUE);
|
|
|
|
|
else
|
|
|
|
|
opt.request_origin = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-15 12:28:55 +02:00
|
|
|
|
else if (!strcmp (key, "input-size-hint"))
|
|
|
|
|
{
|
|
|
|
|
ctrl->input_size_hint = string_to_u64 (value);
|
|
|
|
|
}
|
2003-08-05 17:11:04 +00:00
|
|
|
|
else
|
2009-07-07 10:02:41 +00:00
|
|
|
|
err = gpg_error (GPG_ERR_UNKNOWN_OPTION);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2009-07-07 10:02:41 +00:00
|
|
|
|
return err;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
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;
|
|
|
|
|
|
2003-08-05 17:11:04 +00:00
|
|
|
|
gpgsm_release_certlist (ctrl->server_local->recplist);
|
|
|
|
|
gpgsm_release_certlist (ctrl->server_local->signerlist);
|
|
|
|
|
ctrl->server_local->recplist = NULL;
|
|
|
|
|
ctrl->server_local->signerlist = NULL;
|
2023-08-31 11:13:38 +02:00
|
|
|
|
ctrl->always_trust = 0;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
close_message_fd (ctrl);
|
|
|
|
|
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;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
input_notify (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
|
|
|
|
ctrl->autodetect_encoding = 0;
|
|
|
|
|
ctrl->is_pem = 0;
|
|
|
|
|
ctrl->is_base64 = 0;
|
|
|
|
|
if (strstr (line, "--armor"))
|
2011-02-04 12:57:53 +01:00
|
|
|
|
ctrl->is_pem = 1;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
else if (strstr (line, "--base64"))
|
2011-02-04 12:57:53 +01:00
|
|
|
|
ctrl->is_base64 = 1;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
else if (strstr (line, "--binary"))
|
|
|
|
|
;
|
|
|
|
|
else
|
|
|
|
|
ctrl->autodetect_encoding = 1;
|
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;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
output_notify (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
|
|
|
|
ctrl->create_pem = 0;
|
|
|
|
|
ctrl->create_base64 = 0;
|
|
|
|
|
if (strstr (line, "--armor"))
|
2011-02-04 12:57:53 +01:00
|
|
|
|
ctrl->create_pem = 1;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
else if (strstr (line, "--base64"))
|
|
|
|
|
ctrl->create_base64 = 1; /* just the raw output */
|
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;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_recipient[] =
|
2009-11-04 15:31:52 +00:00
|
|
|
|
"RECIPIENT <userID>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Set the recipient for the encryption. USERID shall be the\n"
|
|
|
|
|
"internal representation of the key; the server may accept any other\n"
|
|
|
|
|
"way of specification [we will support this]. If this is a valid and\n"
|
|
|
|
|
"trusted recipient the server does respond with OK, otherwise the\n"
|
|
|
|
|
"return is an ERR with the reason why the recipient can't be used,\n"
|
|
|
|
|
"the encryption will then not be done for this recipient. If the\n"
|
|
|
|
|
"policy is not to encrypt at all if not all recipients are valid, the\n"
|
|
|
|
|
"client has to take care of this. All RECIPIENT commands are\n"
|
|
|
|
|
"cumulative until a RESET or an successful ENCRYPT command.";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_recipient (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int rc;
|
|
|
|
|
|
2007-12-12 10:28:30 +00:00
|
|
|
|
if (!ctrl->audit)
|
|
|
|
|
rc = start_audit_session (ctrl);
|
|
|
|
|
else
|
|
|
|
|
rc = 0;
|
|
|
|
|
|
|
|
|
|
if (!rc)
|
|
|
|
|
rc = gpgsm_add_to_certlist (ctrl, line, 0,
|
|
|
|
|
&ctrl->server_local->recplist, 0);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (rc)
|
|
|
|
|
{
|
|
|
|
|
gpgsm_status2 (ctrl, STATUS_INV_RECP,
|
2009-08-06 20:12:00 +00:00
|
|
|
|
get_inv_recpsgnr_code (rc), line, NULL);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return rc;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-11-04 15:31:52 +00:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_signer[] =
|
2009-11-04 15:31:52 +00:00
|
|
|
|
"SIGNER <userID>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Set the signer's keys for the signature creation. USERID should\n"
|
|
|
|
|
"be the internal representation of the key; the server may accept any\n"
|
|
|
|
|
"other way of specification [we will support this]. If this is a\n"
|
|
|
|
|
"valid and usable signing key the server does respond with OK,\n"
|
|
|
|
|
"otherwise it returns an ERR with the reason why the key can't be\n"
|
|
|
|
|
"used, the signing will then not be done for this key. If the policy\n"
|
|
|
|
|
"is not to sign at all if not all signer keys are valid, the client\n"
|
|
|
|
|
"has to take care of this. All SIGNER commands are cumulative until\n"
|
2015-11-16 12:41:46 +01:00
|
|
|
|
"a RESET but they are *not* reset by an SIGN command because it can\n"
|
2009-11-04 15:31:52 +00:00
|
|
|
|
"be expected that set of signers are used for more than one sign\n"
|
|
|
|
|
"operation.";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_signer (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int rc;
|
|
|
|
|
|
2003-12-17 17:12:14 +00:00
|
|
|
|
rc = gpgsm_add_to_certlist (ctrl, line, 1,
|
|
|
|
|
&ctrl->server_local->signerlist, 0);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (rc)
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
gpgsm_status2 (ctrl, STATUS_INV_SGNR,
|
2009-08-06 20:12:00 +00:00
|
|
|
|
get_inv_recpsgnr_code (rc), line, NULL);
|
2017-04-28 10:06:33 +09:00
|
|
|
|
/* For compatibility reasons we also issue the old code after the
|
2009-08-06 20:12:00 +00:00
|
|
|
|
new one. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
gpgsm_status2 (ctrl, STATUS_INV_RECP,
|
2009-08-06 20:12:00 +00:00
|
|
|
|
get_inv_recpsgnr_code (rc), line, NULL);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return rc;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_encrypt[] =
|
2009-11-04 15:31:52 +00:00
|
|
|
|
"ENCRYPT \n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Do the actual encryption process. Takes the plaintext from the INPUT\n"
|
|
|
|
|
"command, writes to the ciphertext to the file descriptor set with\n"
|
|
|
|
|
"the OUTPUT command, take the recipients form all the recipients set\n"
|
|
|
|
|
"so far. If this command fails the clients should try to delete all\n"
|
|
|
|
|
"output currently done or otherwise mark it as invalid. GPGSM does\n"
|
|
|
|
|
"ensure that there won't be any security problem with leftover data\n"
|
|
|
|
|
"on the output in this case.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"This command should in general not fail, as all necessary checks\n"
|
|
|
|
|
"have been done while setting the recipients. The input and output\n"
|
|
|
|
|
"pipes are closed.";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_encrypt (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-12-17 17:12:14 +00:00
|
|
|
|
certlist_t cl;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int inp_fd, out_fd;
|
2010-03-08 12:22:18 +00:00
|
|
|
|
estream_t out_fp;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int rc;
|
|
|
|
|
|
2008-10-20 13:53:23 +00:00
|
|
|
|
(void)line;
|
|
|
|
|
|
2007-07-12 15:28:30 +00:00
|
|
|
|
inp_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (inp_fd == -1)
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
|
2007-07-12 15:28:30 +00:00
|
|
|
|
out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (out_fd == -1)
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2010-03-08 12:22:18 +00:00
|
|
|
|
out_fp = es_fdopen_nc (out_fd, "w");
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (!out_fp)
|
2010-03-08 12:22:18 +00:00
|
|
|
|
return set_error (gpg_err_code_from_syserror (), "fdopen() failed");
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-12-17 17:12:14 +00:00
|
|
|
|
/* Now add all encrypt-to marked recipients from the default
|
|
|
|
|
list. */
|
|
|
|
|
rc = 0;
|
2009-05-18 17:38:34 +00:00
|
|
|
|
if (!opt.no_encrypt_to && !ctrl->server_local->no_encrypt_to)
|
2003-12-17 17:12:14 +00:00
|
|
|
|
{
|
2004-08-16 11:15:55 +00:00
|
|
|
|
for (cl=ctrl->server_local->default_recplist; !rc && cl; cl = cl->next)
|
2003-12-17 17:12:14 +00:00
|
|
|
|
if (cl->is_encrypt_to)
|
|
|
|
|
rc = gpgsm_add_cert_to_certlist (ctrl, cl->cert,
|
|
|
|
|
&ctrl->server_local->recplist, 1);
|
|
|
|
|
}
|
2007-12-12 10:28:30 +00:00
|
|
|
|
if (!rc)
|
|
|
|
|
rc = ctrl->audit? 0 : start_audit_session (ctrl);
|
2003-12-17 17:12:14 +00:00
|
|
|
|
if (!rc)
|
|
|
|
|
rc = gpgsm_encrypt (assuan_get_pointer (ctx),
|
|
|
|
|
ctrl->server_local->recplist,
|
|
|
|
|
inp_fd, out_fp);
|
2010-03-08 12:22:18 +00:00
|
|
|
|
es_fclose (out_fp);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
|
|
|
|
gpgsm_release_certlist (ctrl->server_local->recplist);
|
|
|
|
|
ctrl->server_local->recplist = NULL;
|
2023-08-31 11:13:38 +02:00
|
|
|
|
ctrl->always_trust = 0;
|
2003-12-17 17:12:14 +00:00
|
|
|
|
/* Close and reset the fd */
|
2003-08-05 17:11:04 +00:00
|
|
|
|
close_message_fd (ctrl);
|
|
|
|
|
assuan_close_input_fd (ctx);
|
|
|
|
|
assuan_close_output_fd (ctx);
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return rc;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-12 10:28:30 +00:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_decrypt[] =
|
2009-11-04 15:31:52 +00:00
|
|
|
|
"DECRYPT\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"This performs the decrypt operation after doing some check on the\n"
|
|
|
|
|
"internal state. (e.g. that only needed data has been set). Because\n"
|
|
|
|
|
"it utilizes the GPG-Agent for the session key decryption, there is\n"
|
|
|
|
|
"no need to ask the client for a protecting passphrase - GPG-Agent\n"
|
|
|
|
|
"does take care of this by requesting this from the user.";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_decrypt (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int inp_fd, out_fd;
|
2010-03-08 12:22:18 +00:00
|
|
|
|
estream_t out_fp;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int rc;
|
|
|
|
|
|
2008-10-20 13:53:23 +00:00
|
|
|
|
(void)line;
|
|
|
|
|
|
2007-07-12 15:28:30 +00:00
|
|
|
|
inp_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (inp_fd == -1)
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
|
2007-07-12 15:28:30 +00:00
|
|
|
|
out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (out_fd == -1)
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2010-03-08 12:22:18 +00:00
|
|
|
|
out_fp = es_fdopen_nc (out_fd, "w");
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (!out_fp)
|
2010-03-08 12:22:18 +00:00
|
|
|
|
return set_error (gpg_err_code_from_syserror (), "fdopen() failed");
|
2007-12-12 10:28:30 +00:00
|
|
|
|
|
|
|
|
|
rc = start_audit_session (ctrl);
|
|
|
|
|
if (!rc)
|
2011-02-04 12:57:53 +01:00
|
|
|
|
rc = gpgsm_decrypt (ctrl, inp_fd, out_fp);
|
2010-03-08 12:22:18 +00:00
|
|
|
|
es_fclose (out_fp);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2010-03-08 12:22:18 +00:00
|
|
|
|
/* Close and reset the fds. */
|
2003-08-05 17:11:04 +00:00
|
|
|
|
close_message_fd (ctrl);
|
|
|
|
|
assuan_close_input_fd (ctx);
|
|
|
|
|
assuan_close_output_fd (ctx);
|
|
|
|
|
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return rc;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_verify[] =
|
2009-11-04 15:31:52 +00:00
|
|
|
|
"VERIFY\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"This does a verify operation on the message send to the input FD.\n"
|
|
|
|
|
"The result is written out using status lines. If an output FD was\n"
|
|
|
|
|
"given, the signed text will be written to that.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"If the signature is a detached one, the server will inquire about\n"
|
|
|
|
|
"the signed material and the client must provide it.";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_verify (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
|
|
|
|
int rc;
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2007-07-12 15:28:30 +00:00
|
|
|
|
int fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0);
|
|
|
|
|
int out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
|
2010-03-08 12:22:18 +00:00
|
|
|
|
estream_t out_fp = NULL;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2008-10-20 13:53:23 +00:00
|
|
|
|
(void)line;
|
|
|
|
|
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (fd == -1)
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
|
|
|
|
if (out_fd != -1)
|
|
|
|
|
{
|
2010-03-08 12:22:18 +00:00
|
|
|
|
out_fp = es_fdopen_nc (out_fd, "w");
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (!out_fp)
|
2010-03-08 12:22:18 +00:00
|
|
|
|
return set_error (gpg_err_code_from_syserror (), "fdopen() failed");
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-11-19 16:03:50 +00:00
|
|
|
|
rc = start_audit_session (ctrl);
|
|
|
|
|
if (!rc)
|
|
|
|
|
rc = gpgsm_verify (assuan_get_pointer (ctx), fd,
|
|
|
|
|
ctrl->server_local->message_fd, out_fp);
|
2010-03-08 12:22:18 +00:00
|
|
|
|
es_fclose (out_fp);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2010-03-08 12:22:18 +00:00
|
|
|
|
/* Close and reset the fd. */
|
2003-08-05 17:11:04 +00:00
|
|
|
|
close_message_fd (ctrl);
|
|
|
|
|
assuan_close_input_fd (ctx);
|
|
|
|
|
assuan_close_output_fd (ctx);
|
|
|
|
|
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return rc;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_sign[] =
|
2009-11-04 15:31:52 +00:00
|
|
|
|
"SIGN [--detached]\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Sign the data set with the INPUT command and write it to the sink\n"
|
|
|
|
|
"set by OUTPUT. With \"--detached\", a detached signature is\n"
|
|
|
|
|
"created (surprise).";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_sign (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int inp_fd, out_fd;
|
2010-03-08 12:22:18 +00:00
|
|
|
|
estream_t out_fp;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int detached;
|
|
|
|
|
int rc;
|
|
|
|
|
|
2007-07-12 15:28:30 +00:00
|
|
|
|
inp_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (inp_fd == -1)
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
|
2007-07-12 15:28:30 +00:00
|
|
|
|
out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (out_fd == -1)
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
detached = has_option (line, "--detached");
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2010-03-08 12:22:18 +00:00
|
|
|
|
out_fp = es_fdopen_nc (out_fd, "w");
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (!out_fp)
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed");
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2007-12-12 10:28:30 +00:00
|
|
|
|
rc = start_audit_session (ctrl);
|
|
|
|
|
if (!rc)
|
|
|
|
|
rc = gpgsm_sign (assuan_get_pointer (ctx), ctrl->server_local->signerlist,
|
|
|
|
|
inp_fd, detached, out_fp);
|
2010-03-08 12:22:18 +00:00
|
|
|
|
es_fclose (out_fp);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
|
|
|
|
/* close and reset the fd */
|
|
|
|
|
close_message_fd (ctrl);
|
|
|
|
|
assuan_close_input_fd (ctx);
|
|
|
|
|
assuan_close_output_fd (ctx);
|
|
|
|
|
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return rc;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_import[] =
|
2009-11-04 15:31:52 +00:00
|
|
|
|
"IMPORT [--re-import]\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Import the certificates read form the input-fd, return status\n"
|
|
|
|
|
"message for each imported one. The import checks the validity of\n"
|
|
|
|
|
"the certificate but not of the entire chain. It is possible to\n"
|
|
|
|
|
"import expired certificates.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"With the option --re-import the input data is expected to a be a LF\n"
|
|
|
|
|
"separated list of fingerprints. The command will re-import these\n"
|
|
|
|
|
"certificates, meaning that they are made permanent by removing\n"
|
|
|
|
|
"their ephemeral flag.";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_import (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int rc;
|
2007-07-12 15:28:30 +00:00
|
|
|
|
int fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
int reimport = has_option (line, "--re-import");
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2008-10-20 13:53:23 +00:00
|
|
|
|
(void)line;
|
|
|
|
|
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (fd == -1)
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2009-07-07 16:52:12 +00:00
|
|
|
|
rc = gpgsm_import (assuan_get_pointer (ctx), fd, reimport);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
|
|
|
|
/* close and reset the fd */
|
|
|
|
|
close_message_fd (ctrl);
|
|
|
|
|
assuan_close_input_fd (ctx);
|
|
|
|
|
assuan_close_output_fd (ctx);
|
|
|
|
|
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return rc;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-11-04 15:31:52 +00:00
|
|
|
|
static const char hlp_export[] =
|
2015-08-24 12:43:00 +02:00
|
|
|
|
"EXPORT [--data [--armor|--base64]] [--secret [--(raw|pkcs12)] [--] <pattern>\n"
|
2009-11-04 15:31:52 +00:00
|
|
|
|
"\n"
|
|
|
|
|
"Export the certificates selected by PATTERN. With --data the output\n"
|
|
|
|
|
"is returned using Assuan D lines; the default is to use the sink given\n"
|
|
|
|
|
"by the last \"OUTPUT\" command. The options --armor or --base64 encode \n"
|
|
|
|
|
"the output using the PEM respective a plain base-64 format; the default\n"
|
2015-08-24 12:43:00 +02:00
|
|
|
|
"is a binary format which is only suitable for a single certificate.\n"
|
|
|
|
|
"With --secret the secret key is exported using the PKCS#8 format,\n"
|
|
|
|
|
"with --raw using PKCS#1, and with --pkcs12 as full PKCS#12 container.";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_export (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
char *p;
|
2006-10-02 11:54:35 +00:00
|
|
|
|
strlist_t list, sl;
|
2006-11-14 10:23:21 +00:00
|
|
|
|
int use_data;
|
2015-08-24 12:43:00 +02:00
|
|
|
|
int opt_secret;
|
|
|
|
|
int opt_raw = 0;
|
|
|
|
|
int opt_pkcs12 = 0;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2006-11-14 10:23:21 +00:00
|
|
|
|
use_data = has_option (line, "--data");
|
|
|
|
|
if (use_data)
|
|
|
|
|
{
|
|
|
|
|
/* We need to override any possible setting done by an OUTPUT command. */
|
|
|
|
|
ctrl->create_pem = has_option (line, "--armor");
|
|
|
|
|
ctrl->create_base64 = has_option (line, "--base64");
|
|
|
|
|
}
|
2015-08-24 12:43:00 +02:00
|
|
|
|
opt_secret = has_option (line, "--secret");
|
|
|
|
|
if (opt_secret)
|
|
|
|
|
{
|
|
|
|
|
opt_raw = has_option (line, "--raw");
|
|
|
|
|
opt_pkcs12 = has_option (line, "--pkcs12");
|
|
|
|
|
}
|
2006-11-14 10:23:21 +00:00
|
|
|
|
|
|
|
|
|
line = skip_options (line);
|
|
|
|
|
|
|
|
|
|
/* Break the line down into an strlist_t. */
|
2003-08-05 17:11:04 +00:00
|
|
|
|
list = NULL;
|
|
|
|
|
for (p=line; *p; line = p)
|
|
|
|
|
{
|
|
|
|
|
while (*p && *p != ' ')
|
|
|
|
|
p++;
|
|
|
|
|
if (*p)
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
if (*line)
|
|
|
|
|
{
|
|
|
|
|
sl = xtrymalloc (sizeof *sl + strlen (line));
|
|
|
|
|
if (!sl)
|
|
|
|
|
{
|
|
|
|
|
free_strlist (list);
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return out_of_core ();
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
sl->flags = 0;
|
|
|
|
|
strcpy_escaped_plus (sl->d, line);
|
|
|
|
|
sl->next = list;
|
|
|
|
|
list = sl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-24 12:43:00 +02:00
|
|
|
|
if (opt_secret)
|
|
|
|
|
{
|
2021-05-20 14:51:42 +02:00
|
|
|
|
if (!list)
|
2015-08-24 12:43:00 +02:00
|
|
|
|
return set_error (GPG_ERR_NO_DATA, "No key given");
|
2021-05-20 14:51:42 +02:00
|
|
|
|
if (!*list->d)
|
|
|
|
|
{
|
|
|
|
|
free_strlist (list);
|
|
|
|
|
return set_error (GPG_ERR_NO_DATA, "No key given");
|
|
|
|
|
}
|
2015-08-24 12:43:00 +02:00
|
|
|
|
if (list->next)
|
|
|
|
|
return set_error (GPG_ERR_TOO_MANY, "Only one key allowed");
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-14 10:23:21 +00:00
|
|
|
|
if (use_data)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2007-03-19 15:44:59 +00:00
|
|
|
|
estream_t stream;
|
|
|
|
|
|
|
|
|
|
stream = es_fopencookie (ctx, "w", data_line_cookie_functions);
|
|
|
|
|
if (!stream)
|
2006-11-14 10:23:21 +00:00
|
|
|
|
{
|
|
|
|
|
free_strlist (list);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
return set_error (GPG_ERR_ASS_GENERAL,
|
2007-03-19 15:44:59 +00:00
|
|
|
|
"error setting up a data stream");
|
2006-11-14 10:23:21 +00:00
|
|
|
|
}
|
2015-08-24 12:43:00 +02:00
|
|
|
|
if (opt_secret)
|
|
|
|
|
gpgsm_p12_export (ctrl, list->d, stream,
|
|
|
|
|
opt_raw? 2 : opt_pkcs12 ? 0 : 1);
|
|
|
|
|
else
|
|
|
|
|
gpgsm_export (ctrl, list, stream);
|
2007-03-19 15:44:59 +00:00
|
|
|
|
es_fclose (stream);
|
2006-11-14 10:23:21 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-07-12 15:28:30 +00:00
|
|
|
|
int fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
|
2010-03-08 18:19:21 +00:00
|
|
|
|
estream_t out_fp;
|
2007-03-19 15:44:59 +00:00
|
|
|
|
|
2006-11-14 10:23:21 +00:00
|
|
|
|
if (fd == -1)
|
|
|
|
|
{
|
|
|
|
|
free_strlist (list);
|
|
|
|
|
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
|
|
|
|
|
}
|
2010-03-08 18:19:21 +00:00
|
|
|
|
out_fp = es_fdopen_nc (fd, "w");
|
2006-11-14 10:23:21 +00:00
|
|
|
|
if (!out_fp)
|
|
|
|
|
{
|
|
|
|
|
free_strlist (list);
|
2010-03-08 18:19:21 +00:00
|
|
|
|
return set_error (gpg_err_code_from_syserror (), "fdopen() failed");
|
2006-11-14 10:23:21 +00:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2015-08-24 12:43:00 +02:00
|
|
|
|
if (opt_secret)
|
|
|
|
|
gpgsm_p12_export (ctrl, list->d, out_fp,
|
|
|
|
|
opt_raw? 2 : opt_pkcs12 ? 0 : 1);
|
|
|
|
|
else
|
|
|
|
|
gpgsm_export (ctrl, list, out_fp);
|
2010-03-08 18:19:21 +00:00
|
|
|
|
es_fclose (out_fp);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free_strlist (list);
|
2006-11-14 10:23:21 +00:00
|
|
|
|
/* Close and reset the fds. */
|
2003-08-05 17:11:04 +00:00
|
|
|
|
close_message_fd (ctrl);
|
|
|
|
|
assuan_close_input_fd (ctx);
|
|
|
|
|
assuan_close_output_fd (ctx);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-11-04 15:31:52 +00:00
|
|
|
|
|
|
|
|
|
static const char hlp_delkeys[] =
|
|
|
|
|
"DELKEYS <patterns>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Delete the certificates specified by PATTERNS. Each pattern shall be\n"
|
|
|
|
|
"a percent-plus escaped certificate specification. Usually a\n"
|
|
|
|
|
"fingerprint will be used for this.";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_delkeys (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
char *p;
|
2006-10-02 11:54:35 +00:00
|
|
|
|
strlist_t list, sl;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int rc;
|
|
|
|
|
|
2006-10-02 11:54:35 +00:00
|
|
|
|
/* break the line down into an strlist_t */
|
2003-08-05 17:11:04 +00:00
|
|
|
|
list = NULL;
|
|
|
|
|
for (p=line; *p; line = p)
|
|
|
|
|
{
|
|
|
|
|
while (*p && *p != ' ')
|
|
|
|
|
p++;
|
|
|
|
|
if (*p)
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
if (*line)
|
|
|
|
|
{
|
|
|
|
|
sl = xtrymalloc (sizeof *sl + strlen (line));
|
|
|
|
|
if (!sl)
|
|
|
|
|
{
|
|
|
|
|
free_strlist (list);
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return out_of_core ();
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
sl->flags = 0;
|
|
|
|
|
strcpy_escaped_plus (sl->d, line);
|
|
|
|
|
sl->next = list;
|
|
|
|
|
list = sl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rc = gpgsm_delete (ctrl, list);
|
|
|
|
|
free_strlist (list);
|
|
|
|
|
|
|
|
|
|
/* close and reset the fd */
|
|
|
|
|
close_message_fd (ctrl);
|
|
|
|
|
assuan_close_input_fd (ctx);
|
|
|
|
|
assuan_close_output_fd (ctx);
|
|
|
|
|
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return rc;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-04 15:31:52 +00:00
|
|
|
|
static const char hlp_output[] =
|
|
|
|
|
"OUTPUT FD[=<n>]\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Set the file descriptor to write the output data to N. If N is not\n"
|
|
|
|
|
"given and the operating system supports file descriptor passing, the\n"
|
|
|
|
|
"file descriptor currently in flight will be used. See also the\n"
|
|
|
|
|
"\"INPUT\" and \"MESSAGE\" commands.";
|
|
|
|
|
static const char hlp_input[] =
|
|
|
|
|
"INPUT FD[=<n>]\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Set the file descriptor to read the input data to N. If N is not\n"
|
|
|
|
|
"given and the operating system supports file descriptor passing, the\n"
|
|
|
|
|
"file descriptor currently in flight will be used. See also the\n"
|
|
|
|
|
"\"MESSAGE\" and \"OUTPUT\" commands.";
|
|
|
|
|
static const char hlp_message[] =
|
|
|
|
|
"MESSAGE FD[=<n>]\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Set the file descriptor to read the message for a detached\n"
|
|
|
|
|
"signatures to N. If N is not given and the operating system\n"
|
|
|
|
|
"supports file descriptor passing, the file descriptor currently in\n"
|
|
|
|
|
"flight will be used. See also the \"INPUT\" and \"OUTPUT\" commands.";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_message (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-13 15:57:30 +00:00
|
|
|
|
int rc;
|
2007-07-16 09:53:47 +00:00
|
|
|
|
gnupg_fd_t sysfd;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int fd;
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2007-07-12 15:28:30 +00:00
|
|
|
|
rc = assuan_command_parse_fd (ctx, line, &sysfd);
|
2006-09-13 15:57:30 +00:00
|
|
|
|
if (rc)
|
|
|
|
|
return rc;
|
2010-06-10 23:17:33 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
|
|
|
|
sysfd = _assuan_w32ce_finish_pipe ((int)sysfd, 0);
|
|
|
|
|
if (sysfd == INVALID_HANDLE_VALUE)
|
|
|
|
|
return set_error (gpg_err_code_from_syserror (),
|
|
|
|
|
"rvid conversion failed");
|
|
|
|
|
#endif
|
|
|
|
|
|
2007-07-12 15:28:30 +00:00
|
|
|
|
fd = translate_sys2libc_fd (sysfd, 0);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (fd == -1)
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
ctrl->server_local->message_fd = fd;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-04 15:31:52 +00:00
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_listkeys[] =
|
2009-11-04 15:31:52 +00:00
|
|
|
|
"LISTKEYS [<patterns>]\n"
|
|
|
|
|
"LISTSECRETKEYS [<patterns>]\n"
|
|
|
|
|
"DUMPKEYS [<patterns>]\n"
|
|
|
|
|
"DUMPSECRETKEYS [<patterns>]\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"List all certificates or only those specified by PATTERNS. Each\n"
|
|
|
|
|
"pattern shall be a percent-plus escaped certificate specification.\n"
|
|
|
|
|
"The \"SECRET\" versions of the command filter the output to include\n"
|
|
|
|
|
"only certificates where the secret key is available or a corresponding\n"
|
|
|
|
|
"smartcard has been registered. The \"DUMP\" versions of the command\n"
|
|
|
|
|
"are only useful for debugging. The output format is a percent escaped\n"
|
|
|
|
|
"colon delimited listing as described in the manual.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"These \"OPTION\" command keys effect the output::\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" \"list-mode\" set to 0: List only local certificates (default).\n"
|
|
|
|
|
" 1: Ditto.\n"
|
|
|
|
|
" 2: List only external certificates.\n"
|
|
|
|
|
" 3: List local and external certificates.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" \"with-validation\" set to true: Validate each certificate.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" \"with-ephemeral-key\" set to true: Always include ephemeral\n"
|
|
|
|
|
" certificates.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" \"list-to-output\" set to true: Write output to the file descriptor\n"
|
|
|
|
|
" given by the last \"OUTPUT\" command.";
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static int
|
2006-09-06 16:35:52 +00:00
|
|
|
|
do_listkeys (assuan_context_t ctx, char *line, int mode)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2007-03-19 14:35:04 +00:00
|
|
|
|
estream_t fp;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
char *p;
|
2006-10-02 11:54:35 +00:00
|
|
|
|
strlist_t list, sl;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
unsigned int listmode;
|
2004-02-21 13:05:52 +00:00
|
|
|
|
gpg_error_t err;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2006-10-02 11:54:35 +00:00
|
|
|
|
/* Break the line down into an strlist. */
|
2003-08-05 17:11:04 +00:00
|
|
|
|
list = NULL;
|
|
|
|
|
for (p=line; *p; line = p)
|
|
|
|
|
{
|
|
|
|
|
while (*p && *p != ' ')
|
|
|
|
|
p++;
|
|
|
|
|
if (*p)
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
if (*line)
|
|
|
|
|
{
|
|
|
|
|
sl = xtrymalloc (sizeof *sl + strlen (line));
|
|
|
|
|
if (!sl)
|
|
|
|
|
{
|
|
|
|
|
free_strlist (list);
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return out_of_core ();
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
sl->flags = 0;
|
|
|
|
|
strcpy_escaped_plus (sl->d, line);
|
|
|
|
|
sl->next = list;
|
|
|
|
|
list = sl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-13 15:57:30 +00:00
|
|
|
|
if (ctrl->server_local->list_to_output)
|
|
|
|
|
{
|
2007-07-12 15:28:30 +00:00
|
|
|
|
int outfd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
|
2007-03-19 14:35:04 +00:00
|
|
|
|
|
|
|
|
|
if ( outfd == -1 )
|
2021-05-20 14:51:42 +02:00
|
|
|
|
{
|
|
|
|
|
free_strlist (list);
|
|
|
|
|
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
|
|
|
|
|
}
|
2010-03-08 12:22:18 +00:00
|
|
|
|
fp = es_fdopen_nc (outfd, "w");
|
2006-09-13 15:57:30 +00:00
|
|
|
|
if (!fp)
|
2021-05-20 14:51:42 +02:00
|
|
|
|
{
|
|
|
|
|
free_strlist (list);
|
|
|
|
|
return set_error (gpg_err_code_from_syserror (),
|
|
|
|
|
"es_fdopen() failed");
|
|
|
|
|
}
|
2006-09-13 15:57:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-03-19 14:35:04 +00:00
|
|
|
|
fp = es_fopencookie (ctx, "w", data_line_cookie_functions);
|
2006-09-13 15:57:30 +00:00
|
|
|
|
if (!fp)
|
2021-05-20 14:51:42 +02:00
|
|
|
|
{
|
|
|
|
|
free_strlist (list);
|
|
|
|
|
return set_error (GPG_ERR_ASS_GENERAL,
|
|
|
|
|
"error setting up a data stream");
|
|
|
|
|
}
|
2006-09-13 15:57:30 +00:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 17:11:04 +00:00
|
|
|
|
ctrl->with_colons = 1;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
listmode = mode;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (ctrl->server_local->list_internal)
|
|
|
|
|
listmode |= (1<<6);
|
|
|
|
|
if (ctrl->server_local->list_external)
|
|
|
|
|
listmode |= (1<<7);
|
2004-02-21 13:05:52 +00:00
|
|
|
|
err = gpgsm_list_keys (assuan_get_pointer (ctx), list, fp, listmode);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
free_strlist (list);
|
2007-03-19 14:35:04 +00:00
|
|
|
|
es_fclose (fp);
|
2006-09-13 15:57:30 +00:00
|
|
|
|
if (ctrl->server_local->list_to_output)
|
2007-03-19 14:35:04 +00:00
|
|
|
|
assuan_close_output_fd (ctx);
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return err;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_listkeys (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
|
|
|
|
return do_listkeys (ctx, line, 3);
|
|
|
|
|
}
|
|
|
|
|
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-10-02 10:58:08 +00:00
|
|
|
|
cmd_dumpkeys (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
return do_listkeys (ctx, line, 259);
|
|
|
|
|
}
|
|
|
|
|
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_listsecretkeys (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
|
|
|
|
return do_listkeys (ctx, line, 2);
|
|
|
|
|
}
|
|
|
|
|
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-10-02 10:58:08 +00:00
|
|
|
|
cmd_dumpsecretkeys (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
return do_listkeys (ctx, line, 258);
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2009-11-04 15:31:52 +00:00
|
|
|
|
|
|
|
|
|
static const char hlp_genkey[] =
|
|
|
|
|
"GENKEY\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Read the parameters in native format from the input fd and write a\n"
|
|
|
|
|
"certificate request to the output.";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
cmd_genkey (assuan_context_t ctx, char *line)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int inp_fd, out_fd;
|
2010-03-08 18:19:21 +00:00
|
|
|
|
estream_t in_stream, out_stream;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
int rc;
|
|
|
|
|
|
2008-10-20 13:53:23 +00:00
|
|
|
|
(void)line;
|
|
|
|
|
|
2007-07-12 15:28:30 +00:00
|
|
|
|
inp_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (inp_fd == -1)
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
|
2007-07-12 15:28:30 +00:00
|
|
|
|
out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (out_fd == -1)
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2007-08-22 10:55:07 +00:00
|
|
|
|
in_stream = es_fdopen_nc (inp_fd, "r");
|
|
|
|
|
if (!in_stream)
|
|
|
|
|
return set_error (GPG_ERR_ASS_GENERAL, "es_fdopen failed");
|
|
|
|
|
|
2010-03-08 18:19:21 +00:00
|
|
|
|
out_stream = es_fdopen_nc (out_fd, "w");
|
|
|
|
|
if (!out_stream)
|
2007-08-22 10:55:07 +00:00
|
|
|
|
{
|
|
|
|
|
es_fclose (in_stream);
|
2010-03-08 18:19:21 +00:00
|
|
|
|
return set_error (gpg_err_code_from_syserror (), "fdopen() failed");
|
2007-08-22 10:55:07 +00:00
|
|
|
|
}
|
2010-03-08 18:19:21 +00:00
|
|
|
|
rc = gpgsm_genkey (ctrl, in_stream, out_stream);
|
|
|
|
|
es_fclose (out_stream);
|
|
|
|
|
es_fclose (in_stream);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
|
|
|
|
/* close and reset the fds */
|
|
|
|
|
assuan_close_input_fd (ctx);
|
|
|
|
|
assuan_close_output_fd (ctx);
|
|
|
|
|
|
2006-09-06 16:35:52 +00:00
|
|
|
|
return rc;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-22 16:24:21 +00:00
|
|
|
|
|
2009-11-04 15:31:52 +00:00
|
|
|
|
static const char hlp_getauditlog[] =
|
|
|
|
|
"GETAUDITLOG [--data] [--html]\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"If --data is used, the output is send using D-lines and not to the\n"
|
|
|
|
|
"file descriptor given by an OUTPUT command.\n"
|
|
|
|
|
"\n"
|
2016-08-01 22:19:15 -04:00
|
|
|
|
"If --html is used the output is formatted as an XHTML block. This is\n"
|
2009-11-04 15:31:52 +00:00
|
|
|
|
"designed to be incorporated into a HTML document.";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2007-11-22 16:24:21 +00:00
|
|
|
|
cmd_getauditlog (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
int out_fd;
|
2007-11-26 11:00:39 +00:00
|
|
|
|
estream_t out_stream;
|
2007-12-06 15:55:03 +00:00
|
|
|
|
int opt_data, opt_html;
|
2007-11-22 16:24:21 +00:00
|
|
|
|
int rc;
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
opt_data = has_option (line, "--data");
|
|
|
|
|
opt_html = has_option (line, "--html");
|
2016-01-06 17:51:58 +01:00
|
|
|
|
/* Not needed: line = skip_options (line); */
|
2007-11-26 11:00:39 +00:00
|
|
|
|
|
2007-11-22 16:24:21 +00:00
|
|
|
|
if (!ctrl->audit)
|
|
|
|
|
return gpg_error (GPG_ERR_NO_DATA);
|
|
|
|
|
|
2007-11-26 11:00:39 +00:00
|
|
|
|
if (opt_data)
|
2007-11-22 16:24:21 +00:00
|
|
|
|
{
|
2007-11-26 11:00:39 +00:00
|
|
|
|
out_stream = es_fopencookie (ctx, "w", data_line_cookie_functions);
|
|
|
|
|
if (!out_stream)
|
2011-02-04 12:57:53 +01:00
|
|
|
|
return set_error (GPG_ERR_ASS_GENERAL,
|
2007-11-26 11:00:39 +00:00
|
|
|
|
"error setting up a data stream");
|
2007-11-22 16:24:21 +00:00
|
|
|
|
}
|
2007-11-26 11:00:39 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
|
|
|
|
|
if (out_fd == -1)
|
|
|
|
|
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-11-10 09:04:17 +00:00
|
|
|
|
out_stream = es_fdopen_nc (out_fd, "w");
|
2007-11-26 11:00:39 +00:00
|
|
|
|
if (!out_stream)
|
|
|
|
|
{
|
|
|
|
|
return set_error (GPG_ERR_ASS_GENERAL, "es_fdopen() failed");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-06 15:55:03 +00:00
|
|
|
|
audit_print_result (ctrl->audit, out_stream, opt_html);
|
2007-11-22 16:24:21 +00:00
|
|
|
|
rc = 0;
|
2007-11-26 11:00:39 +00:00
|
|
|
|
|
|
|
|
|
es_fclose (out_stream);
|
2007-11-22 16:24:21 +00:00
|
|
|
|
|
|
|
|
|
/* Close and reset the fd. */
|
2007-11-26 11:00:39 +00:00
|
|
|
|
if (!opt_data)
|
|
|
|
|
assuan_close_output_fd (ctx);
|
2007-11-22 16:24:21 +00:00
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_getinfo[] =
|
2009-11-04 15:31:52 +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"
|
|
|
|
|
" agent-check - Return success if the agent is running.\n"
|
|
|
|
|
" cmd_has_option CMD OPT\n"
|
2015-06-29 11:03:58 +02:00
|
|
|
|
" - Returns OK if the command CMD implements the option OPT.\n"
|
2023-08-31 11:13:38 +02:00
|
|
|
|
" offline - Returns OK if the connection is in offline mode."
|
|
|
|
|
" always-trust- Returns OK if the connection is in always-trust mode.";
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
static gpg_error_t
|
2008-02-13 16:47:14 +00:00
|
|
|
|
cmd_getinfo (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
2015-06-29 11:03:58 +02:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2009-07-07 16:52:12 +00:00
|
|
|
|
int rc = 0;
|
2008-02-13 16:47:14 +00:00
|
|
|
|
|
|
|
|
|
if (!strcmp (line, "version"))
|
|
|
|
|
{
|
|
|
|
|
const char *s = VERSION;
|
|
|
|
|
rc = assuan_send_data (ctx, s, strlen (s));
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (line, "pid"))
|
|
|
|
|
{
|
|
|
|
|
char numbuf[50];
|
|
|
|
|
|
|
|
|
|
snprintf (numbuf, sizeof numbuf, "%lu", (unsigned long)getpid ());
|
|
|
|
|
rc = assuan_send_data (ctx, numbuf, strlen (numbuf));
|
|
|
|
|
}
|
2008-09-30 10:30:20 +00:00
|
|
|
|
else if (!strcmp (line, "agent-check"))
|
|
|
|
|
{
|
|
|
|
|
rc = gpgsm_agent_send_nop (ctrl);
|
|
|
|
|
}
|
2009-07-07 16:52:12 +00:00
|
|
|
|
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)
|
|
|
|
|
rc = gpg_error (GPG_ERR_MISSING_VALUE);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cmd = line;
|
|
|
|
|
while (*line && (*line != ' ' && *line != '\t'))
|
|
|
|
|
line++;
|
|
|
|
|
if (!*line)
|
|
|
|
|
rc = gpg_error (GPG_ERR_MISSING_VALUE);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*line++ = 0;
|
|
|
|
|
while (*line == ' ' || *line == '\t')
|
|
|
|
|
line++;
|
|
|
|
|
if (!*line)
|
|
|
|
|
rc = gpg_error (GPG_ERR_MISSING_VALUE);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cmdopt = line;
|
|
|
|
|
if (!command_has_option (cmd, cmdopt))
|
2019-06-03 16:31:58 +02:00
|
|
|
|
rc = gpg_error (GPG_ERR_FALSE);
|
2009-07-07 16:52:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-29 11:03:58 +02:00
|
|
|
|
else if (!strcmp (line, "offline"))
|
|
|
|
|
{
|
2019-06-03 16:31:58 +02:00
|
|
|
|
rc = ctrl->offline? 0 : gpg_error (GPG_ERR_FALSE);
|
2015-06-29 11:03:58 +02:00
|
|
|
|
}
|
2023-08-31 11:13:38 +02:00
|
|
|
|
else if (!strcmp (line, "always-trust"))
|
|
|
|
|
{
|
|
|
|
|
rc = (ctrl->always_trust || opt.always_trust)? 0
|
|
|
|
|
/**/ : gpg_error (GPG_ERR_FALSE);
|
|
|
|
|
}
|
2008-02-13 16:47:14 +00:00
|
|
|
|
else
|
|
|
|
|
rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
|
2009-07-07 16:52:12 +00:00
|
|
|
|
|
2008-02-13 16:47:14 +00:00
|
|
|
|
return rc;
|
|
|
|
|
}
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
|
|
|
|
|
2009-12-14 12:33:23 +00:00
|
|
|
|
static const char hlp_passwd[] =
|
|
|
|
|
"PASSWD <userID>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Change the passphrase of the secret key for USERID.";
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_passwd (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
ksba_cert_t cert = NULL;
|
|
|
|
|
char *grip = NULL;
|
|
|
|
|
|
|
|
|
|
line = skip_options (line);
|
|
|
|
|
|
2017-10-24 17:29:04 +02:00
|
|
|
|
err = gpgsm_find_cert (ctrl, line, NULL, &cert, 0);
|
2009-12-14 12:33:23 +00:00
|
|
|
|
if (err)
|
|
|
|
|
;
|
|
|
|
|
else if (!(grip = gpgsm_get_keygrip_hexstring (cert)))
|
|
|
|
|
err = gpg_error (GPG_ERR_INTERNAL);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
else
|
2009-12-14 12:33:23 +00:00
|
|
|
|
{
|
|
|
|
|
char *desc = gpgsm_format_keydesc (cert);
|
|
|
|
|
err = gpgsm_agent_passwd (ctrl, grip, desc);
|
|
|
|
|
xfree (desc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xfree (grip);
|
|
|
|
|
ksba_cert_release (cert);
|
|
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2009-07-07 16:52:12 +00:00
|
|
|
|
/* Return true if the command CMD implements the option OPT. */
|
|
|
|
|
static int
|
|
|
|
|
command_has_option (const char *cmd, const char *cmdopt)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp (cmd, "IMPORT"))
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp (cmdopt, "re-import"))
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-07-07 16:52:12 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-05 17:11:04 +00:00
|
|
|
|
/* Tell the assuan library about our commands */
|
|
|
|
|
static int
|
2006-09-06 16:35:52 +00:00
|
|
|
|
register_commands (assuan_context_t ctx)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
|
|
|
|
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 15:31:52 +00:00
|
|
|
|
const char * const help;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
} table[] = {
|
2009-11-04 15:31:52 +00:00
|
|
|
|
{ "RECIPIENT", cmd_recipient, hlp_recipient },
|
|
|
|
|
{ "SIGNER", cmd_signer, hlp_signer },
|
|
|
|
|
{ "ENCRYPT", cmd_encrypt, hlp_encrypt },
|
|
|
|
|
{ "DECRYPT", cmd_decrypt, hlp_decrypt },
|
|
|
|
|
{ "VERIFY", cmd_verify, hlp_verify },
|
|
|
|
|
{ "SIGN", cmd_sign, hlp_sign },
|
|
|
|
|
{ "IMPORT", cmd_import, hlp_import },
|
|
|
|
|
{ "EXPORT", cmd_export, hlp_export },
|
2011-02-04 12:57:53 +01:00
|
|
|
|
{ "INPUT", NULL, hlp_input },
|
|
|
|
|
{ "OUTPUT", NULL, hlp_output },
|
2009-11-04 15:31:52 +00:00
|
|
|
|
{ "MESSAGE", cmd_message, hlp_message },
|
|
|
|
|
{ "LISTKEYS", cmd_listkeys, hlp_listkeys },
|
|
|
|
|
{ "DUMPKEYS", cmd_dumpkeys, hlp_listkeys },
|
|
|
|
|
{ "LISTSECRETKEYS",cmd_listsecretkeys, hlp_listkeys },
|
|
|
|
|
{ "DUMPSECRETKEYS",cmd_dumpsecretkeys, hlp_listkeys },
|
|
|
|
|
{ "GENKEY", cmd_genkey, hlp_genkey },
|
|
|
|
|
{ "DELKEYS", cmd_delkeys, hlp_delkeys },
|
|
|
|
|
{ "GETAUDITLOG", cmd_getauditlog, hlp_getauditlog },
|
|
|
|
|
{ "GETINFO", cmd_getinfo, hlp_getinfo },
|
2009-12-14 12:33:23 +00:00
|
|
|
|
{ "PASSWD", cmd_passwd, hlp_passwd },
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{ NULL }
|
|
|
|
|
};
|
|
|
|
|
int i, rc;
|
|
|
|
|
|
|
|
|
|
for (i=0; table[i].name; i++)
|
|
|
|
|
{
|
2009-11-04 15:31:52 +00:00
|
|
|
|
rc = assuan_register_command (ctx, table[i].name, table[i].handler,
|
|
|
|
|
table[i].help);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (rc)
|
|
|
|
|
return rc;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
}
|
2003-08-05 17:11:04 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-17 17:12:14 +00:00
|
|
|
|
/* 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. */
|
2003-08-05 17:11:04 +00:00
|
|
|
|
void
|
2003-12-17 17:12:14 +00:00
|
|
|
|
gpgsm_server (certlist_t default_recplist)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
|
|
|
|
int rc;
|
2009-11-25 17:58:26 +00:00
|
|
|
|
assuan_fd_t filedes[2];
|
2006-09-06 16:35:52 +00:00
|
|
|
|
assuan_context_t ctx;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
struct server_control_s ctrl;
|
2004-05-11 09:15:56 +00:00
|
|
|
|
static const char hello[] = ("GNU Privacy Guard's S/M server "
|
|
|
|
|
VERSION " ready");
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
|
|
|
|
memset (&ctrl, 0, sizeof ctrl);
|
|
|
|
|
gpgsm_init_default_ctrl (&ctrl);
|
|
|
|
|
|
2006-09-13 15:57:30 +00:00
|
|
|
|
/* We use a pipe based server so that we can work from scripts.
|
|
|
|
|
assuan_init_pipe_server will automagically detect when we are
|
2010-03-22 12:46:05 +00:00
|
|
|
|
called with a socketpair and ignore FILEDES in this case. */
|
2010-06-10 15:08:29 +00:00
|
|
|
|
#ifdef HAVE_W32CE_SYSTEM
|
|
|
|
|
#define SERVER_STDIN es_fileno(es_stdin)
|
|
|
|
|
#define SERVER_STDOUT es_fileno(es_stdout)
|
|
|
|
|
#else
|
|
|
|
|
#define SERVER_STDIN 0
|
|
|
|
|
#define SERVER_STDOUT 1
|
|
|
|
|
#endif
|
|
|
|
|
filedes[0] = assuan_fdopen (SERVER_STDIN);
|
|
|
|
|
filedes[1] = assuan_fdopen (SERVER_STDOUT);
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
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);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (rc)
|
|
|
|
|
{
|
|
|
|
|
log_error ("failed to initialize the server: %s\n",
|
2006-09-06 16:35:52 +00:00
|
|
|
|
gpg_strerror (rc));
|
2003-08-05 17:11:04 +00:00
|
|
|
|
gpgsm_exit (2);
|
|
|
|
|
}
|
|
|
|
|
rc = register_commands (ctx);
|
|
|
|
|
if (rc)
|
|
|
|
|
{
|
|
|
|
|
log_error ("failed to the register commands with Assuan: %s\n",
|
2006-09-06 16:35:52 +00:00
|
|
|
|
gpg_strerror(rc));
|
2003-08-05 17:11:04 +00:00
|
|
|
|
gpgsm_exit (2);
|
|
|
|
|
}
|
2004-05-11 09:54:52 +00:00
|
|
|
|
if (opt.verbose || opt.debug)
|
2004-05-11 09:15:56 +00:00
|
|
|
|
{
|
2016-06-07 10:59:46 +02:00
|
|
|
|
char *tmp;
|
2004-05-11 09:24:09 +00:00
|
|
|
|
|
2014-03-12 19:33:30 +01:00
|
|
|
|
/* Fixme: Use the really used socket name. */
|
2004-05-11 09:15:56 +00:00
|
|
|
|
if (asprintf (&tmp,
|
2004-05-11 09:24:09 +00:00
|
|
|
|
"Home: %s\n"
|
|
|
|
|
"Config: %s\n"
|
|
|
|
|
"DirmngrInfo: %s\n"
|
|
|
|
|
"%s",
|
2016-06-07 10:59:46 +02:00
|
|
|
|
gnupg_homedir (),
|
2004-05-11 09:24:09 +00:00
|
|
|
|
opt.config_filename,
|
2016-08-18 11:23:40 +02:00
|
|
|
|
dirmngr_socket_name (),
|
2004-05-11 09:24:09 +00:00
|
|
|
|
hello) > 0)
|
2004-05-11 09:15:56 +00:00
|
|
|
|
{
|
|
|
|
|
assuan_set_hello_line (ctx, tmp);
|
|
|
|
|
free (tmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
assuan_set_hello_line (ctx, hello);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
|
|
|
|
assuan_register_reset_notify (ctx, reset_notify);
|
|
|
|
|
assuan_register_input_notify (ctx, input_notify);
|
|
|
|
|
assuan_register_output_notify (ctx, output_notify);
|
|
|
|
|
assuan_register_option_handler (ctx, option_handler);
|
|
|
|
|
|
|
|
|
|
assuan_set_pointer (ctx, &ctrl);
|
|
|
|
|
ctrl.server_local = xcalloc (1, sizeof *ctrl.server_local);
|
|
|
|
|
ctrl.server_local->assuan_ctx = ctx;
|
|
|
|
|
ctrl.server_local->message_fd = -1;
|
|
|
|
|
ctrl.server_local->list_internal = 1;
|
|
|
|
|
ctrl.server_local->list_external = 0;
|
2003-12-17 17:12:14 +00:00
|
|
|
|
ctrl.server_local->default_recplist = default_recplist;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
rc = assuan_accept (ctx);
|
|
|
|
|
if (rc == -1)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (rc)
|
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
log_info ("Assuan accept problem: %s\n", gpg_strerror (rc));
|
2003-08-05 17:11:04 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 17:11:04 +00:00
|
|
|
|
rc = assuan_process (ctx);
|
|
|
|
|
if (rc)
|
|
|
|
|
{
|
2006-09-06 16:35:52 +00:00
|
|
|
|
log_info ("Assuan processing failed: %s\n", gpg_strerror (rc));
|
2003-08-05 17:11:04 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gpgsm_release_certlist (ctrl.server_local->recplist);
|
|
|
|
|
ctrl.server_local->recplist = NULL;
|
|
|
|
|
gpgsm_release_certlist (ctrl.server_local->signerlist);
|
|
|
|
|
ctrl.server_local->signerlist = NULL;
|
2006-12-20 22:52:44 +00:00
|
|
|
|
xfree (ctrl.server_local);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
|
2007-11-19 16:03:50 +00:00
|
|
|
|
audit_release (ctrl.audit);
|
|
|
|
|
ctrl.audit = NULL;
|
|
|
|
|
|
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.
2009-09-23 00:01:25 +00:00
|
|
|
|
assuan_release (ctx);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-12-17 14:36:16 +00:00
|
|
|
|
gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
gpgsm_status2 (ctrl_t ctrl, int no, ...)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2004-12-17 14:36:16 +00:00
|
|
|
|
gpg_error_t err = 0;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
va_list arg_ptr;
|
|
|
|
|
const char *text;
|
|
|
|
|
|
|
|
|
|
va_start (arg_ptr, no);
|
|
|
|
|
|
2004-12-17 14:36:16 +00:00
|
|
|
|
if (ctrl->no_server && ctrl->status_fd == -1)
|
|
|
|
|
; /* No status wanted. */
|
|
|
|
|
else if (ctrl->no_server)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
2003-08-05 17:11:04 +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
|
|
|
|
|
2003-08-05 17:11:04 +00:00
|
|
|
|
fputs ("[GNUPG:] ", statusfp);
|
|
|
|
|
fputs (get_status_string (no), statusfp);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 17:11:04 +00:00
|
|
|
|
while ( (text = va_arg (arg_ptr, const char*) ))
|
|
|
|
|
{
|
|
|
|
|
putc ( ' ', statusfp );
|
2011-02-04 12:57:53 +01:00
|
|
|
|
for (; *text; text++)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
|
|
|
|
if (*text == '\n')
|
|
|
|
|
fputs ( "\\n", statusfp );
|
|
|
|
|
else if (*text == '\r')
|
|
|
|
|
fputs ( "\\r", statusfp );
|
2011-02-04 12:57:53 +01:00
|
|
|
|
else
|
2003-08-05 17:11:04 +00:00
|
|
|
|
putc ( *(const byte *)text, statusfp );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
putc ('\n', statusfp);
|
2023-06-15 10:37:07 +02:00
|
|
|
|
if (ferror (statusfp))
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fflush (statusfp);
|
|
|
|
|
if (ferror (statusfp))
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
}
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
else
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2018-02-14 12:21:23 +01:00
|
|
|
|
err = vprint_assuan_status_strings (ctrl->server_local->assuan_ctx,
|
|
|
|
|
get_status_string (no), arg_ptr);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
va_end (arg_ptr);
|
2004-12-17 14:36:16 +00:00
|
|
|
|
return err;
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-17 14:36:16 +00:00
|
|
|
|
gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
gpgsm_status (ctrl_t ctrl, int no, const char *text)
|
2003-08-05 17:11:04 +00:00
|
|
|
|
{
|
2004-12-17 14:36:16 +00:00
|
|
|
|
return gpgsm_status2 (ctrl, no, text, NULL);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-17 14:36:16 +00:00
|
|
|
|
gpg_error_t
|
2006-09-06 16:35:52 +00:00
|
|
|
|
gpgsm_status_with_err_code (ctrl_t ctrl, int no, const char *text,
|
2003-08-05 17:11:04 +00:00
|
|
|
|
gpg_err_code_t ec)
|
|
|
|
|
{
|
|
|
|
|
char buf[30];
|
|
|
|
|
|
2023-05-22 17:00:54 +02:00
|
|
|
|
snprintf (buf, sizeof buf, "%u", (unsigned int)ec);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
if (text)
|
2004-12-17 14:36:16 +00:00
|
|
|
|
return gpgsm_status2 (ctrl, no, text, buf, NULL);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
else
|
2004-12-17 14:36:16 +00:00
|
|
|
|
return gpgsm_status2 (ctrl, no, buf, NULL);
|
2003-08-05 17:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-10 17:01:19 +01:00
|
|
|
|
gpg_error_t
|
|
|
|
|
gpgsm_status_with_error (ctrl_t ctrl, int no, const char *text,
|
|
|
|
|
gpg_error_t err)
|
|
|
|
|
{
|
|
|
|
|
char buf[30];
|
|
|
|
|
|
|
|
|
|
snprintf (buf, sizeof buf, "%u", err);
|
|
|
|
|
if (text)
|
|
|
|
|
return gpgsm_status2 (ctrl, no, text, buf, NULL);
|
|
|
|
|
else
|
|
|
|
|
return gpgsm_status2 (ctrl, no, buf, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-14 19:50:10 +00:00
|
|
|
|
|
2023-06-15 10:37:07 +02:00
|
|
|
|
/* This callback is used to emit progress status lines. */
|
|
|
|
|
gpg_error_t
|
|
|
|
|
gpgsm_progress_cb (ctrl_t ctrl, uint64_t current, uint64_t total)
|
|
|
|
|
{
|
|
|
|
|
char buffer[60];
|
|
|
|
|
char units[] = "BKMGTPEZY?";
|
|
|
|
|
int unitidx = 0;
|
|
|
|
|
|
|
|
|
|
if (total)
|
|
|
|
|
{
|
|
|
|
|
if (current > total)
|
|
|
|
|
current = total;
|
|
|
|
|
|
|
|
|
|
while (total > 1024*1024)
|
|
|
|
|
{
|
|
|
|
|
total /= 1024;
|
|
|
|
|
current /= 1024;
|
|
|
|
|
unitidx++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
while (current > 1024*1024)
|
|
|
|
|
{
|
|
|
|
|
current /= 1024;
|
|
|
|
|
unitidx++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unitidx > 9)
|
|
|
|
|
unitidx = 9;
|
|
|
|
|
|
|
|
|
|
snprintf (buffer, sizeof buffer, "? %lu %lu %c%s",
|
|
|
|
|
(unsigned long)current, (unsigned long)total,
|
|
|
|
|
units[unitidx], unitidx? "iB" : "");
|
|
|
|
|
return gpgsm_status2 (ctrl, STATUS_PROGRESS, "?", buffer, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-14 19:50:10 +00:00
|
|
|
|
/* Helper to notify the client about Pinentry events. Because that
|
|
|
|
|
might disturb some older clients, this is only done when enabled
|
|
|
|
|
via an option. Returns an gpg error code. */
|
|
|
|
|
gpg_error_t
|
|
|
|
|
gpgsm_proxy_pinentry_notify (ctrl_t ctrl, const unsigned char *line)
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (!ctrl || !ctrl->server_local
|
2008-02-14 19:50:10 +00:00
|
|
|
|
|| !ctrl->server_local->allow_pinentry_notify)
|
|
|
|
|
return 0;
|
|
|
|
|
return assuan_inquire (ctrl->server_local->assuan_ctx, line, NULL, NULL, 0);
|
|
|
|
|
}
|