2003-08-05 19:11:04 +02:00
|
|
|
|
/* command.c - gpg-agent command handler
|
2014-11-04 16:28:03 +01:00
|
|
|
|
* Copyright (C) 2001-2011 Free Software Foundation, Inc.
|
|
|
|
|
* Copyright (C) 2001-2013 Werner Koch
|
2021-05-19 02:32:19 +02:00
|
|
|
|
* Copyright (C) 2015-2021 g10 Code GmbH.
|
2003-08-05 19:11:04 +02: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 21:49:40 +02:00
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-08-05 19:11:04 +02: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 19:11:04 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* FIXME: we should not use the default assuan buffering but setup
|
|
|
|
|
some buffering in secure mempory to protect session keys etc. */
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
2005-02-23 22:06:32 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <unistd.h>
|
2009-03-06 18:31:27 +01:00
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <dirent.h>
|
2003-08-05 19:11:04 +02: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 02:01:25 +02:00
|
|
|
|
#include "agent.h"
|
2003-08-05 19:11:04 +02:00
|
|
|
|
#include <assuan.h>
|
agent: Resolve conflict of util.h.
* agent/Makefile.am (AM_CPPFLAGS): Remove -I$(top_srcdir)/common.
* agent/call-pinentry.c, agent/call-scd.c: Follow the change.
* agent/command-ssh.c, agent/command.c, agent/cvt-openpgp.c: Ditto.
* agent/divert-scd.c, agent/findkey.c, agent/genkey.c: Ditto.
* agent/gpg-agent.c, agent/pksign.c, agent/preset-passphrase.c: Ditto.
* agent/protect-tool.c, agent/protect.c, agent/trustlist.c: Ditto.
* agent/w32main.c: Ditto.
--
For openpty function, we need to include util.h on some OS.
We also have util.h in common/, so this change is needed.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-03-07 11:22:48 +01:00
|
|
|
|
#include "../common/i18n.h"
|
2010-08-31 17:58:39 +02:00
|
|
|
|
#include "cvt-openpgp.h"
|
2011-07-20 21:13:24 +02:00
|
|
|
|
#include "../common/ssh-utils.h"
|
2012-02-06 21:04:22 +01:00
|
|
|
|
#include "../common/asshelp.h"
|
2016-03-02 14:14:33 +01:00
|
|
|
|
#include "../common/server-help.h"
|
2010-06-21 12:01:24 +02:00
|
|
|
|
|
|
|
|
|
|
2010-06-17 17:44:44 +02:00
|
|
|
|
/* Maximum allowed size of the inquired ciphertext. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
#define MAXLEN_CIPHERTEXT 4096
|
2010-06-17 17:44:44 +02:00
|
|
|
|
/* Maximum allowed size of the key parameters. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
#define MAXLEN_KEYPARAM 1024
|
2010-06-17 17:44:44 +02:00
|
|
|
|
/* Maximum allowed size of key data as used in inquiries (bytes). */
|
2016-08-16 19:06:28 +02:00
|
|
|
|
#define MAXLEN_KEYDATA 8192
|
2018-07-02 21:24:15 +02:00
|
|
|
|
/* Maximum length of a secret to store under one key. */
|
|
|
|
|
#define MAXLEN_PUT_SECRET 4096
|
2010-06-17 17:44:44 +02:00
|
|
|
|
/* The size of the import/export KEK key (in bytes). */
|
|
|
|
|
#define KEYWRAP_KEYSIZE (128/8)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* A shortcut to call assuan_set_error using an gpg_err_code_t and a
|
|
|
|
|
text string. */
|
2006-09-06 18:35:52 +02:00
|
|
|
|
#define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t))
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Check that the maximum digest length we support has at least the
|
|
|
|
|
length of the keygrip. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
#if MAX_DIGEST_LEN < 20
|
|
|
|
|
#error MAX_DIGEST_LEN shorter than keygrip
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Data used to associate an Assuan context with local server data.
|
|
|
|
|
This is this modules local part of the server_control_s struct. */
|
2006-09-04 10:07:12 +02:00
|
|
|
|
struct server_local_s
|
|
|
|
|
{
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Our Assuan context. */
|
2006-09-04 10:07:12 +02:00
|
|
|
|
assuan_context_t assuan_ctx;
|
2011-12-05 10:54:59 +01:00
|
|
|
|
|
|
|
|
|
/* If this flag is true, the passphrase cache is used for signing
|
|
|
|
|
operations. It defaults to true but may be set on a per
|
|
|
|
|
connection base. The global option opt.ignore_cache_for_signing
|
|
|
|
|
takes precedence over this flag. */
|
2016-09-05 14:43:42 +02:00
|
|
|
|
unsigned int use_cache_for_signing : 1;
|
2011-12-05 10:54:59 +01:00
|
|
|
|
|
2016-09-05 16:13:41 +02:00
|
|
|
|
/* Flag to suppress I/O logging during a command. */
|
2016-09-05 14:43:42 +02:00
|
|
|
|
unsigned int pause_io_logging : 1;
|
2011-12-05 10:54:59 +01:00
|
|
|
|
|
2016-09-05 16:13:41 +02:00
|
|
|
|
/* Flag indicating that the connection is from ourselves. */
|
|
|
|
|
unsigned int connect_from_self : 1;
|
|
|
|
|
|
|
|
|
|
/* Helper flag for io_monitor to allow suppressing of our own
|
|
|
|
|
* greeting in some cases. See io_monitor for details. */
|
|
|
|
|
unsigned int greeting_seen : 1;
|
|
|
|
|
|
2016-09-05 14:43:42 +02:00
|
|
|
|
/* If this flag is set to true the agent will be terminated after
|
2011-12-05 10:54:59 +01:00
|
|
|
|
the end of the current session. */
|
2016-09-05 14:43:42 +02:00
|
|
|
|
unsigned int stopme : 1;
|
2011-12-05 10:54:59 +01:00
|
|
|
|
|
|
|
|
|
/* Flag indicating whether pinentry notifications shall be done. */
|
2016-09-05 14:43:42 +02:00
|
|
|
|
unsigned int allow_pinentry_notify : 1;
|
|
|
|
|
|
|
|
|
|
/* An allocated description for the next key operation. This is
|
|
|
|
|
used if a pinnetry needs to be popped up. */
|
|
|
|
|
char *keydesc;
|
2011-12-05 10:54:59 +01:00
|
|
|
|
|
|
|
|
|
/* Malloced KEK (Key-Encryption-Key) for the import_key command. */
|
|
|
|
|
void *import_key;
|
|
|
|
|
|
|
|
|
|
/* Malloced KEK for the export_key command. */
|
|
|
|
|
void *export_key;
|
|
|
|
|
|
|
|
|
|
/* Client is aware of the error code GPG_ERR_FULLY_CANCELED. */
|
|
|
|
|
int allow_fully_canceled;
|
|
|
|
|
|
|
|
|
|
/* Last CACHE_NONCE sent as status (malloced). */
|
|
|
|
|
char *last_cache_nonce;
|
|
|
|
|
|
|
|
|
|
/* Last PASSWD_NONCE sent as status (malloced). */
|
|
|
|
|
char *last_passwd_nonce;
|
2020-01-13 16:27:12 +01:00
|
|
|
|
|
|
|
|
|
/* Per connection cache of the keyinfo from the cards. The
|
|
|
|
|
* eventcounters for cards at the time the info was fetched is
|
|
|
|
|
* stored here as a freshness indicator. */
|
|
|
|
|
struct {
|
|
|
|
|
struct card_key_info_s *ki;
|
|
|
|
|
unsigned int eventno;
|
|
|
|
|
unsigned int maybe_key_change;
|
|
|
|
|
} last_card_keyinfo;
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2006-09-04 10:07:12 +02:00
|
|
|
|
/* An entry for the getval/putval commands. */
|
|
|
|
|
struct putval_item_s
|
|
|
|
|
{
|
|
|
|
|
struct putval_item_s *next;
|
|
|
|
|
size_t off; /* Offset to the value into DATA. */
|
|
|
|
|
size_t len; /* Length of the value. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
char d[1]; /* Key | Nul | value. */
|
2006-09-04 10:07:12 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* A list of key value pairs fpr the getval/putval commands. */
|
|
|
|
|
static struct putval_item_s *putval_list;
|
|
|
|
|
|
|
|
|
|
|
2006-11-14 15:53:42 +01:00
|
|
|
|
|
2008-10-17 21:18:46 +02:00
|
|
|
|
/* To help polling clients, we keep track of the number of certain
|
2006-11-14 15:53:42 +01:00
|
|
|
|
events. This structure keeps those counters. The counters are
|
|
|
|
|
integers and there should be no problem if they are overflowing as
|
|
|
|
|
callers need to check only whether a counter changed. The actual
|
|
|
|
|
values are not meaningful. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
struct
|
2006-11-14 15:53:42 +01:00
|
|
|
|
{
|
|
|
|
|
/* Incremented if any of the other counters below changed. */
|
|
|
|
|
unsigned int any;
|
|
|
|
|
|
|
|
|
|
/* Incremented if a key is added or removed from the internal privat
|
|
|
|
|
key database. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
unsigned int key;
|
2006-11-14 15:53:42 +01:00
|
|
|
|
|
|
|
|
|
/* Incremented if a change of the card readers stati has been
|
|
|
|
|
detected. */
|
|
|
|
|
unsigned int card;
|
|
|
|
|
|
2020-01-13 16:27:12 +01:00
|
|
|
|
/* Internal counter to track possible changes to a key.
|
|
|
|
|
* FIXME: This should be replaced by generic notifications from scd.
|
|
|
|
|
*/
|
|
|
|
|
unsigned int maybe_key_change;
|
|
|
|
|
|
2006-11-14 15:53:42 +01:00
|
|
|
|
} eventcounter;
|
|
|
|
|
|
|
|
|
|
|
2009-03-17 18:59:36 +01:00
|
|
|
|
|
|
|
|
|
/* Local prototypes. */
|
|
|
|
|
static int command_has_option (const char *cmd, const char *cmdopt);
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-12-20 09:32:56 +01:00
|
|
|
|
/* Release the memory buffer MB but first wipe out the used memory. */
|
|
|
|
|
static void
|
|
|
|
|
clear_outbuf (membuf_t *mb)
|
|
|
|
|
{
|
|
|
|
|
void *p;
|
|
|
|
|
size_t n;
|
|
|
|
|
|
|
|
|
|
p = get_membuf (mb, &n);
|
|
|
|
|
if (p)
|
|
|
|
|
{
|
2012-11-06 18:51:47 +01:00
|
|
|
|
wipememory (p, n);
|
2004-12-20 09:32:56 +01:00
|
|
|
|
xfree (p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Write the content of memory buffer MB as assuan data to CTX and
|
|
|
|
|
wipe the buffer out afterwards. */
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
write_and_clear_outbuf (assuan_context_t ctx, membuf_t *mb)
|
|
|
|
|
{
|
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 02:01:25 +02:00
|
|
|
|
gpg_error_t ae;
|
2004-12-20 09:32:56 +01:00
|
|
|
|
void *p;
|
|
|
|
|
size_t n;
|
|
|
|
|
|
|
|
|
|
p = get_membuf (mb, &n);
|
|
|
|
|
if (!p)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return out_of_core ();
|
2004-12-20 09:32:56 +01:00
|
|
|
|
ae = assuan_send_data (ctx, p, n);
|
|
|
|
|
memset (p, 0, n);
|
|
|
|
|
xfree (p);
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return ae;
|
2004-12-20 09:32:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Clear the nonces used to enable the passphrase cache for certain
|
|
|
|
|
multi-command command sequences. */
|
2010-10-26 11:10:29 +02:00
|
|
|
|
static void
|
|
|
|
|
clear_nonce_cache (ctrl_t ctrl)
|
|
|
|
|
{
|
|
|
|
|
if (ctrl->server_local->last_cache_nonce)
|
|
|
|
|
{
|
2018-03-27 08:40:58 +02:00
|
|
|
|
agent_put_cache (ctrl, ctrl->server_local->last_cache_nonce,
|
2010-10-26 11:10:29 +02:00
|
|
|
|
CACHE_MODE_NONCE, NULL, 0);
|
|
|
|
|
xfree (ctrl->server_local->last_cache_nonce);
|
|
|
|
|
ctrl->server_local->last_cache_nonce = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (ctrl->server_local->last_passwd_nonce)
|
|
|
|
|
{
|
2018-03-27 08:40:58 +02:00
|
|
|
|
agent_put_cache (ctrl, ctrl->server_local->last_passwd_nonce,
|
2010-10-26 11:10:29 +02:00
|
|
|
|
CACHE_MODE_NONCE, NULL, 0);
|
|
|
|
|
xfree (ctrl->server_local->last_passwd_nonce);
|
|
|
|
|
ctrl->server_local->last_passwd_nonce = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-06-02 21:21:08 +02:00
|
|
|
|
/* This function is called by Libassuan whenever the client sends a
|
2011-12-05 10:54:59 +01:00
|
|
|
|
reset. It has been registered similar to the other Assuan
|
|
|
|
|
commands. */
|
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 18:47:11 +01:00
|
|
|
|
static gpg_error_t
|
|
|
|
|
reset_notify (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2004-02-13 18:06:34 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 19:11:04 +02: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 18:47:11 +01:00
|
|
|
|
(void) line;
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
memset (ctrl->keygrip, 0, 20);
|
|
|
|
|
ctrl->have_keygrip = 0;
|
|
|
|
|
ctrl->digest.valuelen = 0;
|
2020-05-18 19:24:41 +02:00
|
|
|
|
xfree (ctrl->digest.data);
|
|
|
|
|
ctrl->digest.data = NULL;
|
2004-02-13 18:06:34 +01:00
|
|
|
|
|
|
|
|
|
xfree (ctrl->server_local->keydesc);
|
|
|
|
|
ctrl->server_local->keydesc = NULL;
|
2010-10-26 11:10:29 +02:00
|
|
|
|
|
|
|
|
|
clear_nonce_cache (ctrl);
|
|
|
|
|
|
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 18:47:11 +01:00
|
|
|
|
return 0;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Replace all '+' by a blank in the string S. */
|
2004-02-13 18:06:34 +01:00
|
|
|
|
static void
|
|
|
|
|
plus_to_blank (char *s)
|
|
|
|
|
{
|
|
|
|
|
for (; *s; s++)
|
|
|
|
|
{
|
|
|
|
|
if (*s == '+')
|
|
|
|
|
*s = ' ';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
/* Parse a hex string. Return an Assuan error code or 0 on success and the
|
|
|
|
|
length of the parsed string in LEN. */
|
|
|
|
|
static int
|
2006-09-06 18:35:52 +02:00
|
|
|
|
parse_hexstring (assuan_context_t ctx, const char *string, size_t *len)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
|
|
|
|
const char *p;
|
|
|
|
|
size_t n;
|
|
|
|
|
|
|
|
|
|
/* parse the hash value */
|
|
|
|
|
for (p=string, n=0; hexdigitp (p); p++, n++)
|
|
|
|
|
;
|
2004-12-21 20:05:15 +01:00
|
|
|
|
if (*p != ' ' && *p != '\t' && *p)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "invalid hexstring");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if ((n&1))
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "odd number of digits");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
*len = n;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
/* Parse the keygrip in STRING into the provided buffer BUF. BUF must
|
2011-12-05 10:54:59 +01:00
|
|
|
|
provide space for 20 bytes. BUF is not changed if the function
|
2003-08-05 19:11:04 +02:00
|
|
|
|
returns an error. */
|
|
|
|
|
static int
|
2006-09-06 18:35:52 +02:00
|
|
|
|
parse_keygrip (assuan_context_t ctx, const char *string, unsigned char *buf)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
|
|
|
|
int rc;
|
2009-11-04 12:58:06 +01:00
|
|
|
|
size_t n = 0;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
rc = parse_hexstring (ctx, string, &n);
|
|
|
|
|
if (rc)
|
|
|
|
|
return rc;
|
|
|
|
|
n /= 2;
|
|
|
|
|
if (n != 20)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "invalid length of keygrip");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2008-09-03 11:37:32 +02:00
|
|
|
|
if (hex2bin (string, buf, 20) < 0)
|
|
|
|
|
return set_error (GPG_ERR_BUG, "hex2bin");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-07-02 21:24:15 +02:00
|
|
|
|
/* Parse the TTL from STRING. Leading and trailing spaces are
|
|
|
|
|
* skipped. The value is constrained to -1 .. MAXINT. On error 0 is
|
|
|
|
|
* returned, else the number of bytes scanned. */
|
|
|
|
|
static size_t
|
|
|
|
|
parse_ttl (const char *string, int *r_ttl)
|
|
|
|
|
{
|
|
|
|
|
const char *string_orig = string;
|
|
|
|
|
long ttl;
|
|
|
|
|
char *pend;
|
|
|
|
|
|
|
|
|
|
ttl = strtol (string, &pend, 10);
|
|
|
|
|
string = pend;
|
|
|
|
|
if (string == string_orig || !(spacep (string) || !*string)
|
|
|
|
|
|| ttl < -1L || (int)ttl != (long)ttl)
|
|
|
|
|
{
|
|
|
|
|
*r_ttl = 0;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
while (spacep (string) || *string== '\n')
|
|
|
|
|
string++;
|
|
|
|
|
*r_ttl = (int)ttl;
|
|
|
|
|
return string - string_orig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Write an Assuan status line. KEYWORD is the first item on the
|
2018-02-14 12:21:23 +01:00
|
|
|
|
* status line. The following arguments are all separated by a space
|
|
|
|
|
* in the output. The last argument must be a NULL. Linefeeds and
|
|
|
|
|
* carriage returns characters (which are not allowed in an Assuan
|
|
|
|
|
* status line) are silently quoted in C-style. */
|
2006-09-25 20:29:20 +02:00
|
|
|
|
gpg_error_t
|
|
|
|
|
agent_write_status (ctrl_t ctrl, const char *keyword, ...)
|
|
|
|
|
{
|
2018-02-14 12:21:23 +01:00
|
|
|
|
gpg_error_t err;
|
2006-09-25 20:29:20 +02:00
|
|
|
|
va_list arg_ptr;
|
|
|
|
|
assuan_context_t ctx = ctrl->server_local->assuan_ctx;
|
|
|
|
|
|
|
|
|
|
va_start (arg_ptr, keyword);
|
2018-02-14 12:21:23 +01:00
|
|
|
|
err = vprint_assuan_status_strings (ctx, keyword, arg_ptr);
|
2006-09-25 20:29:20 +02:00
|
|
|
|
va_end (arg_ptr);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2006-09-25 20:29:20 +02:00
|
|
|
|
|
2012-02-07 12:46:32 +01:00
|
|
|
|
/* This function is similar to print_assuan_status but takes a CTRL
|
|
|
|
|
arg instead of an assuan context as first argument. */
|
|
|
|
|
gpg_error_t
|
|
|
|
|
agent_print_status (ctrl_t ctrl, const char *keyword, const char *format, ...)
|
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
va_list arg_ptr;
|
|
|
|
|
assuan_context_t ctx = ctrl->server_local->assuan_ctx;
|
|
|
|
|
|
|
|
|
|
va_start (arg_ptr, format);
|
|
|
|
|
err = vprint_assuan_status (ctx, keyword, format, arg_ptr);
|
|
|
|
|
va_end (arg_ptr);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-20 16:31:43 +01:00
|
|
|
|
/* Helper to notify the client about a launched Pinentry. Because
|
|
|
|
|
that might disturb some older clients, this is only done if enabled
|
|
|
|
|
via an option. Returns an gpg error code. */
|
2008-02-14 20:50:10 +01:00
|
|
|
|
gpg_error_t
|
2016-11-03 20:07:56 +01:00
|
|
|
|
agent_inq_pinentry_launched (ctrl_t ctrl, unsigned long pid, const char *extra)
|
2008-02-14 20:50:10 +01:00
|
|
|
|
{
|
2016-11-03 20:07:56 +01:00
|
|
|
|
char line[256];
|
2008-02-14 20:50:10 +01:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (!ctrl || !ctrl->server_local
|
2008-02-14 20:50:10 +01:00
|
|
|
|
|| !ctrl->server_local->allow_pinentry_notify)
|
|
|
|
|
return 0;
|
2016-11-03 20:07:56 +01:00
|
|
|
|
snprintf (line, DIM(line), "PINENTRY_LAUNCHED %lu%s%s",
|
|
|
|
|
pid, extra?" ":"", extra? extra:"");
|
2008-02-14 20:50:10 +01:00
|
|
|
|
return assuan_inquire (ctrl->server_local->assuan_ctx, line, NULL, NULL, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-01-25 11:20:23 +01:00
|
|
|
|
/* An agent progress callback for Libgcrypt. This has been registered
|
|
|
|
|
* to be called via the progress dispatcher mechanism from
|
|
|
|
|
* gpg-agent.c */
|
|
|
|
|
static void
|
|
|
|
|
progress_cb (ctrl_t ctrl, const char *what, int printchar,
|
|
|
|
|
int current, int total)
|
|
|
|
|
{
|
|
|
|
|
if (!ctrl || !ctrl->server_local || !ctrl->server_local->assuan_ctx)
|
|
|
|
|
;
|
|
|
|
|
else if (printchar == '\n' && what && !strcmp (what, "primegen"))
|
|
|
|
|
agent_print_status (ctrl, "PROGRESS", "%.20s X 100 100", what);
|
|
|
|
|
else
|
|
|
|
|
agent_print_status (ctrl, "PROGRESS", "%.20s %c %d %d",
|
|
|
|
|
what, printchar=='\n'?'X':printchar, current, total);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-10-24 12:55:21 +02:00
|
|
|
|
/* Helper to print a message while leaving a command. Note that this
|
|
|
|
|
* function does not call assuan_set_error; the caller may do this
|
|
|
|
|
* prior to calling us. */
|
2010-06-17 17:44:44 +02:00
|
|
|
|
static gpg_error_t
|
|
|
|
|
leave_cmd (assuan_context_t ctx, gpg_error_t err)
|
|
|
|
|
{
|
|
|
|
|
if (err)
|
|
|
|
|
{
|
|
|
|
|
const char *name = assuan_get_command_name (ctx);
|
|
|
|
|
if (!name)
|
|
|
|
|
name = "?";
|
2010-08-31 17:58:39 +02:00
|
|
|
|
|
2010-10-13 17:57:08 +02:00
|
|
|
|
/* Not all users of gpg-agent know about the fully canceled
|
|
|
|
|
error code; map it back if needed. */
|
|
|
|
|
if (gpg_err_code (err) == GPG_ERR_FULLY_CANCELED)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
|
|
|
|
|
if (!ctrl->server_local->allow_fully_canceled)
|
|
|
|
|
err = gpg_err_make (gpg_err_source (err), GPG_ERR_CANCELED);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-31 17:58:39 +02:00
|
|
|
|
/* Most code from common/ does not know the error source, thus
|
|
|
|
|
we fix this here. */
|
|
|
|
|
if (gpg_err_source (err) == GPG_ERR_SOURCE_UNKNOWN)
|
|
|
|
|
err = gpg_err_make (GPG_ERR_SOURCE_DEFAULT, gpg_err_code (err));
|
|
|
|
|
|
2010-06-17 17:44:44 +02:00
|
|
|
|
if (gpg_err_source (err) == GPG_ERR_SOURCE_DEFAULT)
|
|
|
|
|
log_error ("command '%s' failed: %s\n", name,
|
|
|
|
|
gpg_strerror (err));
|
|
|
|
|
else
|
|
|
|
|
log_error ("command '%s' failed: %s <%s>\n", name,
|
|
|
|
|
gpg_strerror (err), gpg_strsource (err));
|
|
|
|
|
}
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-05-19 02:32:19 +02:00
|
|
|
|
/* Take the keyinfo for cards from our local cache. Actually this
|
|
|
|
|
* cache could be a global one but then we would need to employ
|
|
|
|
|
* reference counting. */
|
|
|
|
|
struct card_key_info_s *
|
|
|
|
|
get_keyinfo_on_cards (ctrl_t ctrl)
|
|
|
|
|
{
|
|
|
|
|
struct card_key_info_s *keyinfo_on_cards;
|
|
|
|
|
|
|
|
|
|
if (ctrl->server_local->last_card_keyinfo.ki
|
|
|
|
|
&& ctrl->server_local->last_card_keyinfo.eventno == eventcounter.card
|
|
|
|
|
&& (ctrl->server_local->last_card_keyinfo.maybe_key_change
|
|
|
|
|
== eventcounter.maybe_key_change))
|
|
|
|
|
{
|
|
|
|
|
keyinfo_on_cards = ctrl->server_local->last_card_keyinfo.ki;
|
|
|
|
|
}
|
|
|
|
|
else if (!agent_card_keyinfo (ctrl, NULL, 0, &keyinfo_on_cards))
|
|
|
|
|
{
|
|
|
|
|
agent_card_free_keyinfo (ctrl->server_local->last_card_keyinfo.ki);
|
|
|
|
|
ctrl->server_local->last_card_keyinfo.ki = keyinfo_on_cards;
|
|
|
|
|
ctrl->server_local->last_card_keyinfo.eventno = eventcounter.card;
|
|
|
|
|
ctrl->server_local->last_card_keyinfo.maybe_key_change
|
|
|
|
|
= eventcounter.maybe_key_change;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return keyinfo_on_cards;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-14 15:53:42 +01:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_geteventcounter[] =
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"GETEVENTCOUNTER\n"
|
|
|
|
|
"\n"
|
2017-02-20 22:19:50 +01:00
|
|
|
|
"Return a status line named EVENTCOUNTER with the current values\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"of all event counters. The values are decimal numbers in the range\n"
|
|
|
|
|
"0 to UINT_MAX and wrapping around to 0. The actual values should\n"
|
|
|
|
|
"not be relied upon, they shall only be used to detect a change.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"The currently defined counters are:\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"ANY - Incremented with any change of any of the other counters.\n"
|
|
|
|
|
"KEY - Incremented for added or removed private keys.\n"
|
|
|
|
|
"CARD - Incremented for changes of the card readers stati.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-11-14 15:53:42 +01:00
|
|
|
|
cmd_geteventcounter (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
|
2008-10-20 15:53:23 +02:00
|
|
|
|
(void)line;
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2012-02-07 13:51:47 +01:00
|
|
|
|
return agent_print_status (ctrl, "EVENTCOUNTER", "%u %u %u",
|
|
|
|
|
eventcounter.any,
|
|
|
|
|
eventcounter.key,
|
|
|
|
|
eventcounter.card);
|
2006-11-14 15:53:42 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This function should be called once for all key removals or
|
2007-11-27 09:01:19 +01:00
|
|
|
|
additions. This function is assured not to do any context
|
2006-11-14 15:53:42 +01:00
|
|
|
|
switches. */
|
|
|
|
|
void
|
|
|
|
|
bump_key_eventcounter (void)
|
|
|
|
|
{
|
|
|
|
|
eventcounter.key++;
|
|
|
|
|
eventcounter.any++;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
|
2006-11-14 15:53:42 +01:00
|
|
|
|
/* This function should be called for all card reader status
|
2007-11-27 09:01:19 +01:00
|
|
|
|
changes. This function is assured not to do any context
|
2006-11-14 15:53:42 +01:00
|
|
|
|
switches. */
|
|
|
|
|
void
|
|
|
|
|
bump_card_eventcounter (void)
|
|
|
|
|
{
|
|
|
|
|
eventcounter.card++;
|
|
|
|
|
eventcounter.any++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-25 20:29:20 +02:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_istrusted[] =
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"ISTRUSTED <hexstring_with_fingerprint>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Return OK when we have an entry with this fingerprint in our\n"
|
|
|
|
|
"trustlist";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_istrusted (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2006-09-25 20:29:20 +02:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
int rc, n, i;
|
|
|
|
|
char *p;
|
|
|
|
|
char fpr[41];
|
|
|
|
|
|
2006-09-15 20:53:37 +02:00
|
|
|
|
/* Parse the fingerprint value. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
for (p=line,n=0; hexdigitp (p); p++, n++)
|
|
|
|
|
;
|
|
|
|
|
if (*p || !(n == 40 || n == 32))
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "invalid fingerprint");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
i = 0;
|
|
|
|
|
if (n==32)
|
|
|
|
|
{
|
|
|
|
|
strcpy (fpr, "00000000");
|
|
|
|
|
i += 8;
|
|
|
|
|
}
|
|
|
|
|
for (p=line; i < 40; p++, i++)
|
|
|
|
|
fpr[i] = *p >= 'a'? (*p & 0xdf): *p;
|
|
|
|
|
fpr[i] = 0;
|
2009-03-19 11:21:51 +01:00
|
|
|
|
rc = agent_istrusted (ctrl, fpr, NULL);
|
2006-09-06 18:35:52 +02:00
|
|
|
|
if (!rc || gpg_err_code (rc) == GPG_ERR_NOT_TRUSTED)
|
|
|
|
|
return rc;
|
|
|
|
|
else if (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF )
|
|
|
|
|
return gpg_error (GPG_ERR_NOT_TRUSTED);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
else
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, rc);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_listtrusted[] =
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"LISTTRUSTED\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"List all entries from the trustlist.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_listtrusted (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2014-11-27 20:41:37 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2008-10-20 15:53:23 +02:00
|
|
|
|
int rc;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2008-10-20 15:53:23 +02:00
|
|
|
|
(void)line;
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2008-10-20 15:53:23 +02:00
|
|
|
|
rc = agent_listtrusted (ctx);
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, rc);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_martrusted[] =
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"MARKTRUSTED <hexstring_with_fingerprint> <flag> <display_name>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Store a new key in into the trustlist.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_marktrusted (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2004-02-13 18:06:34 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
int rc, n, i;
|
|
|
|
|
char *p;
|
|
|
|
|
char fpr[41];
|
|
|
|
|
int flag;
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
/* parse the fingerprint value */
|
|
|
|
|
for (p=line,n=0; hexdigitp (p); p++, n++)
|
|
|
|
|
;
|
|
|
|
|
if (!spacep (p) || !(n == 40 || n == 32))
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "invalid fingerprint");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
i = 0;
|
|
|
|
|
if (n==32)
|
|
|
|
|
{
|
|
|
|
|
strcpy (fpr, "00000000");
|
|
|
|
|
i += 8;
|
|
|
|
|
}
|
|
|
|
|
for (p=line; i < 40; p++, i++)
|
|
|
|
|
fpr[i] = *p >= 'a'? (*p & 0xdf): *p;
|
|
|
|
|
fpr[i] = 0;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
while (spacep (p))
|
|
|
|
|
p++;
|
|
|
|
|
flag = *p++;
|
|
|
|
|
if ( (flag != 'S' && flag != 'P') || !spacep (p) )
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "invalid flag - must be P or S");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
while (spacep (p))
|
|
|
|
|
p++;
|
|
|
|
|
|
|
|
|
|
rc = agent_marktrusted (ctrl, p, fpr, flag);
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, rc);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-04 12:58:06 +01:00
|
|
|
|
static const char hlp_havekey[] =
|
2010-10-01 22:33:53 +02:00
|
|
|
|
"HAVEKEY <hexstrings_with_keygrips>\n"
|
2021-05-19 02:32:19 +02:00
|
|
|
|
"HAVEKEY --list[=<limit>]\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
2010-10-01 22:33:53 +02:00
|
|
|
|
"Return success if at least one of the secret keys with the given\n"
|
2021-05-19 02:32:19 +02:00
|
|
|
|
"keygrips is available. With --list return all availabale keygrips\n"
|
|
|
|
|
"as binary data; with <limit> bail out at this number of keygrips";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_havekey (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2021-05-19 02:32:19 +02:00
|
|
|
|
ctrl_t ctrl;
|
2010-10-01 22:33:53 +02:00
|
|
|
|
gpg_error_t err;
|
2021-05-19 02:32:19 +02:00
|
|
|
|
unsigned char grip[20];
|
|
|
|
|
char *p;
|
|
|
|
|
int list_mode; /* Less than 0 for no limit. */
|
|
|
|
|
int counter;
|
|
|
|
|
char *dirname;
|
|
|
|
|
gnupg_dir_t dir;
|
|
|
|
|
gnupg_dirent_t dir_entry;
|
|
|
|
|
char hexgrip[41];
|
|
|
|
|
struct card_key_info_s *keyinfo_on_cards, *l;
|
|
|
|
|
|
|
|
|
|
if (has_option_name (line, "--list"))
|
|
|
|
|
{
|
|
|
|
|
if ((p = option_value (line, "--list")))
|
|
|
|
|
list_mode = atoi (p);
|
|
|
|
|
else
|
|
|
|
|
list_mode = -1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
list_mode = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!list_mode)
|
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
err = parse_keygrip (ctx, line, grip);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
if (!agent_key_available (grip))
|
|
|
|
|
return 0; /* Found. */
|
|
|
|
|
|
|
|
|
|
while (*line && *line != ' ' && *line != '\t')
|
|
|
|
|
line++;
|
|
|
|
|
while (*line == ' ' || *line == '\t')
|
|
|
|
|
line++;
|
|
|
|
|
}
|
|
|
|
|
while (*line);
|
|
|
|
|
|
|
|
|
|
/* No leave_cmd() here because errors are expected and would clutter
|
|
|
|
|
* the log. */
|
|
|
|
|
return gpg_error (GPG_ERR_NO_SECKEY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* List mode. */
|
|
|
|
|
dir = NULL;
|
|
|
|
|
dirname = NULL;
|
|
|
|
|
ctrl = assuan_get_pointer (ctx);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2021-05-19 02:32:19 +02:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_FORBIDDEN);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dirname = make_filename_try (gnupg_homedir (),
|
|
|
|
|
GNUPG_PRIVATE_KEYS_DIR, NULL);
|
|
|
|
|
if (!dirname)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
dir = gnupg_opendir (dirname);
|
|
|
|
|
if (!dir)
|
2010-10-01 22:33:53 +02:00
|
|
|
|
{
|
2021-05-19 02:32:19 +02:00
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
counter = 0;
|
|
|
|
|
while ((dir_entry = gnupg_readdir (dir)))
|
|
|
|
|
{
|
|
|
|
|
if (strlen (dir_entry->d_name) != 44
|
|
|
|
|
|| strcmp (dir_entry->d_name + 40, ".key"))
|
|
|
|
|
continue;
|
|
|
|
|
strncpy (hexgrip, dir_entry->d_name, 40);
|
|
|
|
|
hexgrip[40] = 0;
|
|
|
|
|
|
|
|
|
|
if ( hex2bin (hexgrip, grip, 20) < 0 )
|
|
|
|
|
continue; /* Bad hex string. */
|
|
|
|
|
|
|
|
|
|
if (list_mode > 0 && ++counter > list_mode)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_TRUNCATED);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = assuan_send_data (ctx, grip, 20);
|
2010-10-01 22:33:53 +02:00
|
|
|
|
if (err)
|
2021-05-19 02:32:19 +02:00
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2021-05-19 02:32:19 +02:00
|
|
|
|
/* And now the keys from the current cards. If they already got a
|
|
|
|
|
* stub, they are listed twice but we don't care. */
|
|
|
|
|
keyinfo_on_cards = get_keyinfo_on_cards (ctrl);
|
|
|
|
|
for (l = keyinfo_on_cards; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
if ( hex2bin (l->keygrip, grip, 20) < 0 )
|
|
|
|
|
continue; /* Bad hex string. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2021-05-19 02:32:19 +02:00
|
|
|
|
if (list_mode > 0 && ++counter > list_mode)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_TRUNCATED);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = assuan_send_data (ctx, grip, 20);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
2010-10-01 22:33:53 +02:00
|
|
|
|
}
|
2021-05-19 02:32:19 +02:00
|
|
|
|
err = 0;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2021-05-19 02:32:19 +02:00
|
|
|
|
leave:
|
|
|
|
|
gnupg_closedir (dir);
|
|
|
|
|
xfree (dirname);
|
|
|
|
|
return leave_cmd (ctx, err);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-11-04 12:58:06 +01:00
|
|
|
|
static const char hlp_sigkey[] =
|
|
|
|
|
"SIGKEY <hexstring_with_keygrip>\n"
|
|
|
|
|
"SETKEY <hexstring_with_keygrip>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Set the key used for a sign or decrypt 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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_sigkey (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
|
|
|
|
int rc;
|
2004-02-13 18:06:34 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
rc = parse_keygrip (ctx, line, ctrl->keygrip);
|
|
|
|
|
if (rc)
|
|
|
|
|
return rc;
|
|
|
|
|
ctrl->have_keygrip = 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_setkeydesc[] =
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"SETKEYDESC plus_percent_escaped_string\n"
|
|
|
|
|
"\n"
|
2010-08-31 17:58:39 +02:00
|
|
|
|
"Set a description to be used for the next PKSIGN, PKDECRYPT, IMPORT_KEY\n"
|
|
|
|
|
"or EXPORT_KEY operation if this operation requires a passphrase. If\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"this command is not used a default text will be used. Note, that\n"
|
Spelling cleanup.
No functional changes, just fixing minor spelling issues.
---
Most of these were identified from the command line by running:
codespell \
--ignore-words-list fpr,stati,keyserver,keyservers,asign,cas,iff,ifset \
--skip '*.po,ChangeLog*,help.*.txt,*.jpg,*.eps,*.pdf,*.png,*.gpg,*.asc' \
doc g13 g10 kbx agent artwork scd tests tools am common dirmngr sm \
NEWS README README.maint TODO
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-02-18 15:34:42 +01:00
|
|
|
|
"this description implicitly selects the label used for the entry\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"box; if the string contains the string PIN (which in general will\n"
|
|
|
|
|
"not be translated), \"PIN\" is used, otherwise the translation of\n"
|
|
|
|
|
"\"passphrase\" is used. The description string should not contain\n"
|
|
|
|
|
"blanks unless they are percent or '+' escaped.\n"
|
|
|
|
|
"\n"
|
2010-08-31 17:58:39 +02:00
|
|
|
|
"The description is only valid for the next PKSIGN, PKDECRYPT,\n"
|
2014-04-15 16:40:48 +02:00
|
|
|
|
"IMPORT_KEY, EXPORT_KEY, or DELETE_KEY 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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2004-02-13 18:06:34 +01:00
|
|
|
|
cmd_setkeydesc (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
char *desc, *p;
|
|
|
|
|
|
|
|
|
|
for (p=line; *p == ' '; p++)
|
|
|
|
|
;
|
|
|
|
|
desc = p;
|
|
|
|
|
p = strchr (desc, ' ');
|
|
|
|
|
if (p)
|
|
|
|
|
*p = 0; /* We ignore any garbage; we might late use it for other args. */
|
|
|
|
|
|
2015-03-15 13:11:44 +01:00
|
|
|
|
if (!*desc)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "no description given");
|
2004-02-13 18:06:34 +01:00
|
|
|
|
|
|
|
|
|
/* Note, that we only need to replace the + characters and should
|
|
|
|
|
leave the other escaping in place because the escaped string is
|
|
|
|
|
send verbatim to the pinentry which does the unescaping (but not
|
|
|
|
|
the + replacing) */
|
|
|
|
|
plus_to_blank (desc);
|
|
|
|
|
|
|
|
|
|
xfree (ctrl->server_local->keydesc);
|
2014-11-27 20:41:37 +01:00
|
|
|
|
|
|
|
|
|
if (ctrl->restricted)
|
2015-06-11 09:36:27 +02:00
|
|
|
|
{
|
|
|
|
|
ctrl->server_local->keydesc = strconcat
|
|
|
|
|
((ctrl->restricted == 2
|
|
|
|
|
? _("Note: Request from the web browser.")
|
|
|
|
|
: _("Note: Request from a remote site.") ), "%0A%0A", desc, NULL);
|
|
|
|
|
}
|
2014-11-27 20:41:37 +01:00
|
|
|
|
else
|
|
|
|
|
ctrl->server_local->keydesc = xtrystrdup (desc);
|
2004-02-13 18:06:34 +01:00
|
|
|
|
if (!ctrl->server_local->keydesc)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return out_of_core ();
|
2004-02-13 18:06:34 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-11-04 12:58:06 +01:00
|
|
|
|
static const char hlp_sethash[] =
|
2020-05-18 19:24:41 +02:00
|
|
|
|
"SETHASH (--hash=<name>)|(<algonumber>) <hexstring>]\n"
|
2020-08-10 10:01:03 +02:00
|
|
|
|
"SETHASH [--pss] --inquire\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
|
|
|
|
"The client can use this command to tell the server about the data\n"
|
2020-05-18 19:24:41 +02:00
|
|
|
|
"(which usually is a hash) to be signed. The option --inquire is\n"
|
2020-08-10 10:01:03 +02:00
|
|
|
|
"used to ask back for to-be-signed data in case of PureEdDSA or\n"
|
|
|
|
|
"with --pss for pre-formatted rsaPSS.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_sethash (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2020-05-18 19:24:41 +02:00
|
|
|
|
gpg_error_t err;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
size_t n;
|
|
|
|
|
char *p;
|
2004-02-13 18:06:34 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
unsigned char *buf;
|
|
|
|
|
char *endp;
|
|
|
|
|
int algo;
|
2020-08-10 10:01:03 +02:00
|
|
|
|
int opt_inquire, opt_pss;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2006-10-06 12:58:18 +02:00
|
|
|
|
/* Parse the alternative hash options which may be used instead of
|
|
|
|
|
the algo number. */
|
|
|
|
|
if (has_option_name (line, "--hash"))
|
|
|
|
|
{
|
|
|
|
|
if (has_option (line, "--hash=sha1"))
|
|
|
|
|
algo = GCRY_MD_SHA1;
|
2009-03-26 20:27:04 +01:00
|
|
|
|
else if (has_option (line, "--hash=sha224"))
|
|
|
|
|
algo = GCRY_MD_SHA224;
|
2006-10-06 12:58:18 +02:00
|
|
|
|
else if (has_option (line, "--hash=sha256"))
|
|
|
|
|
algo = GCRY_MD_SHA256;
|
2009-03-26 20:27:04 +01:00
|
|
|
|
else if (has_option (line, "--hash=sha384"))
|
|
|
|
|
algo = GCRY_MD_SHA384;
|
|
|
|
|
else if (has_option (line, "--hash=sha512"))
|
|
|
|
|
algo = GCRY_MD_SHA512;
|
2006-10-06 12:58:18 +02:00
|
|
|
|
else if (has_option (line, "--hash=rmd160"))
|
|
|
|
|
algo = GCRY_MD_RMD160;
|
|
|
|
|
else if (has_option (line, "--hash=md5"))
|
|
|
|
|
algo = GCRY_MD_MD5;
|
|
|
|
|
else if (has_option (line, "--hash=tls-md5sha1"))
|
2008-09-29 17:02:55 +02:00
|
|
|
|
algo = MD_USER_TLS_MD5SHA1;
|
2020-08-10 10:01:03 +02:00
|
|
|
|
else if (has_option (line, "--hash=none"))
|
|
|
|
|
algo = 0;
|
2006-10-06 12:58:18 +02:00
|
|
|
|
else
|
2020-05-18 19:24:41 +02:00
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER, "invalid hash algorithm");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2006-10-06 12:58:18 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
algo = 0;
|
|
|
|
|
|
2020-08-10 10:01:03 +02:00
|
|
|
|
opt_pss = has_option (line, "--pss");
|
2020-05-18 19:24:41 +02:00
|
|
|
|
opt_inquire = has_option (line, "--inquire");
|
2006-10-06 12:58:18 +02:00
|
|
|
|
line = skip_options (line);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2020-05-18 19:24:41 +02:00
|
|
|
|
if (!algo && !opt_inquire)
|
2006-10-06 12:58:18 +02:00
|
|
|
|
{
|
|
|
|
|
/* No hash option has been given: require an algo number instead */
|
|
|
|
|
algo = (int)strtoul (line, &endp, 10);
|
|
|
|
|
for (line = endp; *line == ' ' || *line == '\t'; line++)
|
|
|
|
|
;
|
|
|
|
|
if (!algo || gcry_md_test_algo (algo))
|
2020-05-18 19:24:41 +02:00
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_UNSUPPORTED_ALGORITHM, NULL);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2006-10-06 12:58:18 +02:00
|
|
|
|
}
|
2020-05-18 19:24:41 +02:00
|
|
|
|
xfree (ctrl->digest.data);
|
|
|
|
|
ctrl->digest.data = NULL;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
ctrl->digest.algo = algo;
|
2010-04-21 18:26:17 +02:00
|
|
|
|
ctrl->digest.raw_value = 0;
|
2020-08-10 10:01:03 +02:00
|
|
|
|
ctrl->digest.is_pss = opt_pss;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2020-05-18 19:24:41 +02:00
|
|
|
|
if (opt_inquire)
|
|
|
|
|
{
|
|
|
|
|
/* We limit the to-be-signed data to some reasonable size which
|
|
|
|
|
* may eventually allow us to pass that even to smartcards. */
|
|
|
|
|
size_t maxlen = 2048;
|
|
|
|
|
|
|
|
|
|
if (algo)
|
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER,
|
|
|
|
|
"both --inquire and an algo are specified");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%zu", maxlen);
|
|
|
|
|
if (!err)
|
|
|
|
|
err = assuan_inquire (ctx, "TBSDATA", &buf, &n, maxlen);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
|
|
|
|
|
ctrl->digest.data = buf;
|
|
|
|
|
ctrl->digest.valuelen = n;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Parse the hash value. */
|
|
|
|
|
n = 0;
|
|
|
|
|
err = parse_hexstring (ctx, line, &n);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
n /= 2;
|
|
|
|
|
if (algo == MD_USER_TLS_MD5SHA1 && n == 36)
|
|
|
|
|
;
|
|
|
|
|
else if (n != 16 && n != 20 && n != 24
|
|
|
|
|
&& n != 28 && n != 32 && n != 48 && n != 64)
|
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER, "unsupported length of hash");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (n > MAX_DIGEST_LEN)
|
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER, "hash value to long");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buf = ctrl->digest.value;
|
|
|
|
|
ctrl->digest.valuelen = n;
|
|
|
|
|
for (p=line, n=0; n < ctrl->digest.valuelen; p += 2, n++)
|
|
|
|
|
buf[n] = xtoi_2 (p);
|
|
|
|
|
for (; n < ctrl->digest.valuelen; n++)
|
|
|
|
|
buf[n] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
return leave_cmd (ctx, err);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_pksign[] =
|
2010-09-01 13:07:16 +02:00
|
|
|
|
"PKSIGN [<options>] [<cache_nonce>]\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
|
|
|
|
"Perform the actual sign operation. Neither input nor output are\n"
|
|
|
|
|
"sensitive to eavesdropping.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_pksign (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2017-07-28 10:37:33 +02:00
|
|
|
|
gpg_error_t err;
|
2005-06-07 21:09:18 +02:00
|
|
|
|
cache_mode_t cache_mode = CACHE_MODE_NORMAL;
|
2004-02-13 18:06:34 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2004-12-20 09:32:56 +01:00
|
|
|
|
membuf_t outbuf;
|
2010-09-01 13:07:16 +02:00
|
|
|
|
char *cache_nonce = NULL;
|
|
|
|
|
char *p;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2010-09-01 13:07:16 +02:00
|
|
|
|
line = skip_options (line);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2010-09-01 13:07:16 +02:00
|
|
|
|
for (p=line; *p && *p != ' ' && *p != '\t'; p++)
|
|
|
|
|
;
|
|
|
|
|
*p = '\0';
|
|
|
|
|
if (*line)
|
|
|
|
|
cache_nonce = xtrystrdup (line);
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (opt.ignore_cache_for_signing)
|
2005-06-07 21:09:18 +02:00
|
|
|
|
cache_mode = CACHE_MODE_IGNORE;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
else if (!ctrl->server_local->use_cache_for_signing)
|
2005-06-07 21:09:18 +02:00
|
|
|
|
cache_mode = CACHE_MODE_IGNORE;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2004-12-20 09:32:56 +01:00
|
|
|
|
init_membuf (&outbuf, 512);
|
|
|
|
|
|
2017-07-28 10:37:33 +02:00
|
|
|
|
err = agent_pksign (ctrl, cache_nonce, ctrl->server_local->keydesc,
|
|
|
|
|
&outbuf, cache_mode);
|
|
|
|
|
if (err)
|
2004-12-20 09:32:56 +01:00
|
|
|
|
clear_outbuf (&outbuf);
|
|
|
|
|
else
|
2017-07-28 10:37:33 +02:00
|
|
|
|
err = write_and_clear_outbuf (ctx, &outbuf);
|
2010-09-01 13:07:16 +02:00
|
|
|
|
|
|
|
|
|
xfree (cache_nonce);
|
2004-02-13 18:06:34 +01:00
|
|
|
|
xfree (ctrl->server_local->keydesc);
|
|
|
|
|
ctrl->server_local->keydesc = NULL;
|
2017-07-28 10:37:33 +02:00
|
|
|
|
return leave_cmd (ctx, err);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_pkdecrypt[] =
|
2010-09-01 13:07:16 +02:00
|
|
|
|
"PKDECRYPT [<options>]\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
|
|
|
|
"Perform the actual decrypt operation. Input is not\n"
|
|
|
|
|
"sensitive to eavesdropping.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_pkdecrypt (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
|
|
|
|
int rc;
|
2004-02-13 18:06:34 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-11-12 16:17:44 +01:00
|
|
|
|
unsigned char *value;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
size_t valuelen;
|
2004-12-20 09:32:56 +01:00
|
|
|
|
membuf_t outbuf;
|
2013-08-26 17:29:54 +02:00
|
|
|
|
int padding;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2008-10-20 15:53:23 +02:00
|
|
|
|
(void)line;
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
/* First inquire the data to decrypt */
|
2012-02-06 21:04:22 +01:00
|
|
|
|
rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%u", MAXLEN_CIPHERTEXT);
|
2012-02-03 23:50:22 +01:00
|
|
|
|
if (!rc)
|
|
|
|
|
rc = assuan_inquire (ctx, "CIPHERTEXT",
|
|
|
|
|
&value, &valuelen, MAXLEN_CIPHERTEXT);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (rc)
|
|
|
|
|
return rc;
|
|
|
|
|
|
2004-12-20 09:32:56 +01:00
|
|
|
|
init_membuf (&outbuf, 512);
|
|
|
|
|
|
2004-02-13 18:06:34 +01:00
|
|
|
|
rc = agent_pkdecrypt (ctrl, ctrl->server_local->keydesc,
|
2013-08-26 17:29:54 +02:00
|
|
|
|
value, valuelen, &outbuf, &padding);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
xfree (value);
|
2004-12-20 09:32:56 +01:00
|
|
|
|
if (rc)
|
|
|
|
|
clear_outbuf (&outbuf);
|
|
|
|
|
else
|
2013-08-26 17:29:54 +02:00
|
|
|
|
{
|
|
|
|
|
if (padding != -1)
|
|
|
|
|
rc = print_assuan_status (ctx, "PADDING", "%d", padding);
|
|
|
|
|
else
|
|
|
|
|
rc = 0;
|
|
|
|
|
if (!rc)
|
|
|
|
|
rc = write_and_clear_outbuf (ctx, &outbuf);
|
|
|
|
|
}
|
2004-02-13 18:06:34 +01:00
|
|
|
|
xfree (ctrl->server_local->keydesc);
|
|
|
|
|
ctrl->server_local->keydesc = NULL;
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, rc);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_genkey[] =
|
2020-08-17 14:21:00 +02:00
|
|
|
|
"GENKEY [--no-protection] [--preset] [--timestamp=<isodate>]\n"
|
|
|
|
|
" [--inq-passwd] [--passwd-nonce=<s>] [<cache_nonce>]\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
|
|
|
|
"Generate a new key, store the secret part and return the public\n"
|
|
|
|
|
"part. Here is an example transaction:\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" C: GENKEY\n"
|
|
|
|
|
" S: INQUIRE KEYPARAM\n"
|
2017-09-08 00:41:10 +02:00
|
|
|
|
" C: D (genkey (rsa (nbits 3072)))\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
" C: END\n"
|
|
|
|
|
" S: D (public-key\n"
|
|
|
|
|
" S: D (rsa (n 326487324683264) (e 10001)))\n"
|
|
|
|
|
" S: OK key created\n"
|
2011-04-10 15:37:18 +02:00
|
|
|
|
"\n"
|
2020-08-17 14:21:00 +02:00
|
|
|
|
"If the --preset option is used the passphrase for the generated\n"
|
|
|
|
|
"key will be added to the cache. If --inq-passwd is used an inquire\n"
|
2015-01-21 11:31:20 +01:00
|
|
|
|
"with the keyword NEWPASSWD is used to request the passphrase for the\n"
|
2020-08-17 14:21:00 +02:00
|
|
|
|
"new key. If a --passwd-nonce is used, the corresponding cached\n"
|
|
|
|
|
"passphrase is used to protect the new key. If --timestamp is given\n"
|
|
|
|
|
"its value is recorded as the key's creation time; the value is\n"
|
|
|
|
|
"expected in ISO format (e.g. \"20030316T120000\").";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_genkey (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2004-02-13 18:06:34 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
int rc;
|
2010-10-14 18:34:31 +02:00
|
|
|
|
int no_protection;
|
2018-10-24 20:16:26 +02:00
|
|
|
|
unsigned char *value = NULL;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
size_t valuelen;
|
2015-01-21 11:31:20 +01:00
|
|
|
|
unsigned char *newpasswd = NULL;
|
2004-12-20 09:32:56 +01:00
|
|
|
|
membuf_t outbuf;
|
2010-09-01 11:48:35 +02:00
|
|
|
|
char *cache_nonce = NULL;
|
2016-06-02 21:21:08 +02:00
|
|
|
|
char *passwd_nonce = NULL;
|
2011-04-10 15:37:18 +02:00
|
|
|
|
int opt_preset;
|
2015-01-21 11:31:20 +01:00
|
|
|
|
int opt_inq_passwd;
|
|
|
|
|
size_t n;
|
2016-06-02 21:21:08 +02:00
|
|
|
|
char *p, *pend;
|
2020-08-17 14:21:00 +02:00
|
|
|
|
const char *s;
|
|
|
|
|
time_t opt_timestamp;
|
2016-06-02 21:21:08 +02:00
|
|
|
|
int c;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2010-10-14 18:34:31 +02:00
|
|
|
|
no_protection = has_option (line, "--no-protection");
|
2015-01-21 11:31:20 +01:00
|
|
|
|
opt_preset = has_option (line, "--preset");
|
|
|
|
|
opt_inq_passwd = has_option (line, "--inq-passwd");
|
2016-06-02 21:21:08 +02:00
|
|
|
|
passwd_nonce = option_value (line, "--passwd-nonce");
|
|
|
|
|
if (passwd_nonce)
|
|
|
|
|
{
|
|
|
|
|
for (pend = passwd_nonce; *pend && !spacep (pend); pend++)
|
|
|
|
|
;
|
|
|
|
|
c = *pend;
|
|
|
|
|
*pend = '\0';
|
|
|
|
|
passwd_nonce = xtrystrdup (passwd_nonce);
|
|
|
|
|
*pend = c;
|
|
|
|
|
if (!passwd_nonce)
|
|
|
|
|
{
|
|
|
|
|
rc = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-17 14:21:00 +02:00
|
|
|
|
if ((s=has_option_name (line, "--timestamp")))
|
|
|
|
|
{
|
|
|
|
|
if (*s != '=')
|
|
|
|
|
{
|
|
|
|
|
rc = set_error (GPG_ERR_ASS_PARAMETER, "missing value for option");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
opt_timestamp = isotime2epoch (s+1);
|
|
|
|
|
if (opt_timestamp < 1)
|
|
|
|
|
{
|
|
|
|
|
rc = set_error (GPG_ERR_ASS_PARAMETER, "invalid time value");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
opt_timestamp = 0;
|
2010-10-14 18:34:31 +02:00
|
|
|
|
line = skip_options (line);
|
|
|
|
|
|
2010-09-01 11:48:35 +02:00
|
|
|
|
for (p=line; *p && *p != ' ' && *p != '\t'; p++)
|
|
|
|
|
;
|
|
|
|
|
*p = '\0';
|
|
|
|
|
if (*line)
|
|
|
|
|
cache_nonce = xtrystrdup (line);
|
2008-10-20 15:53:23 +02:00
|
|
|
|
|
2020-01-13 16:27:12 +01:00
|
|
|
|
eventcounter.maybe_key_change++;
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
/* First inquire the parameters */
|
2012-02-06 21:04:22 +01:00
|
|
|
|
rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%u", MAXLEN_KEYPARAM);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (rc)
|
2021-05-20 10:13:51 +02:00
|
|
|
|
goto leave;
|
|
|
|
|
rc = assuan_inquire (ctx, "KEYPARAM", &value, &valuelen, MAXLEN_KEYPARAM);
|
|
|
|
|
if (rc)
|
|
|
|
|
goto leave;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2004-12-20 09:32:56 +01:00
|
|
|
|
init_membuf (&outbuf, 512);
|
|
|
|
|
|
2015-01-21 11:31:20 +01:00
|
|
|
|
/* If requested, ask for the password to be used for the key. If
|
|
|
|
|
this is not used the regular Pinentry mechanism is used. */
|
|
|
|
|
if (opt_inq_passwd && !no_protection)
|
|
|
|
|
{
|
|
|
|
|
/* (N is used as a dummy) */
|
|
|
|
|
assuan_begin_confidential (ctx);
|
|
|
|
|
rc = assuan_inquire (ctx, "NEWPASSWD", &newpasswd, &n, 256);
|
|
|
|
|
assuan_end_confidential (ctx);
|
|
|
|
|
if (rc)
|
|
|
|
|
goto leave;
|
|
|
|
|
if (!*newpasswd)
|
|
|
|
|
{
|
|
|
|
|
/* Empty password given - switch to no-protection mode. */
|
|
|
|
|
xfree (newpasswd);
|
|
|
|
|
newpasswd = NULL;
|
|
|
|
|
no_protection = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2016-06-02 21:21:08 +02:00
|
|
|
|
else if (passwd_nonce)
|
2018-03-27 08:40:58 +02:00
|
|
|
|
newpasswd = agent_get_cache (ctrl, passwd_nonce, CACHE_MODE_NONCE);
|
2015-01-21 11:31:20 +01:00
|
|
|
|
|
2020-08-17 14:21:00 +02:00
|
|
|
|
rc = agent_genkey (ctrl, cache_nonce, opt_timestamp,
|
|
|
|
|
(char*)value, valuelen, no_protection,
|
2015-01-21 11:31:20 +01:00
|
|
|
|
newpasswd, opt_preset, &outbuf);
|
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
if (newpasswd)
|
|
|
|
|
{
|
|
|
|
|
/* Assuan_inquire does not allow us to read into secure memory
|
|
|
|
|
thus we need to wipe it ourself. */
|
|
|
|
|
wipememory (newpasswd, strlen (newpasswd));
|
|
|
|
|
xfree (newpasswd);
|
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
xfree (value);
|
2004-12-20 09:32:56 +01:00
|
|
|
|
if (rc)
|
|
|
|
|
clear_outbuf (&outbuf);
|
|
|
|
|
else
|
|
|
|
|
rc = write_and_clear_outbuf (ctx, &outbuf);
|
2010-09-01 11:48:35 +02:00
|
|
|
|
xfree (cache_nonce);
|
2016-06-02 21:21:08 +02:00
|
|
|
|
xfree (passwd_nonce);
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, rc);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-02-23 22:06:32 +01:00
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_readkey[] =
|
2021-04-23 08:47:06 +02:00
|
|
|
|
"READKEY [--no-data] <hexstring_with_keygrip>\n"
|
|
|
|
|
" --card <keyid>\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
2016-10-20 05:05:15 +02:00
|
|
|
|
"Return the public key for the given keygrip or keyid.\n"
|
|
|
|
|
"With --card, private key file with card information will be created.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2005-02-23 22:06:32 +01:00
|
|
|
|
cmd_readkey (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
int rc;
|
|
|
|
|
unsigned char grip[20];
|
|
|
|
|
gcry_sexp_t s_pkey = NULL;
|
2016-10-20 05:05:15 +02:00
|
|
|
|
unsigned char *pkbuf = NULL;
|
2016-10-24 12:55:21 +02:00
|
|
|
|
char *serialno = NULL;
|
2021-04-23 08:47:06 +02:00
|
|
|
|
char *keyidbuf = NULL;
|
2016-10-20 05:05:15 +02:00
|
|
|
|
size_t pkbuflen;
|
2021-04-23 08:47:06 +02:00
|
|
|
|
int opt_card, opt_no_data;
|
2005-02-23 22:06:32 +01:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2021-04-23 08:47:06 +02:00
|
|
|
|
opt_no_data = has_option (line, "--no-data");
|
2020-11-19 07:40:16 +01:00
|
|
|
|
opt_card = has_option (line, "--card");
|
2016-10-24 12:55:21 +02:00
|
|
|
|
line = skip_options (line);
|
2016-10-20 05:05:15 +02:00
|
|
|
|
|
2016-10-24 12:55:21 +02:00
|
|
|
|
if (opt_card)
|
|
|
|
|
{
|
2020-11-19 07:40:16 +01:00
|
|
|
|
const char *keyid = line;
|
2016-10-20 05:05:15 +02:00
|
|
|
|
|
2020-01-13 08:43:53 +01:00
|
|
|
|
rc = agent_card_getattr (ctrl, "SERIALNO", &serialno, NULL);
|
2016-10-20 05:05:15 +02:00
|
|
|
|
if (rc)
|
|
|
|
|
{
|
|
|
|
|
log_error (_("error getting serial number of card: %s\n"),
|
|
|
|
|
gpg_strerror (rc));
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-23 08:47:06 +02:00
|
|
|
|
/* Hack to create the shadow key for the OpenPGP standard keys. */
|
|
|
|
|
if ((!strcmp (keyid, "$SIGNKEYID") || !strcmp (keyid, "$ENCRKEYID"))
|
|
|
|
|
&& !agent_card_getattr (ctrl, keyid, &keyidbuf, NULL))
|
|
|
|
|
keyid = keyidbuf;
|
|
|
|
|
|
2020-02-13 11:45:41 +01:00
|
|
|
|
rc = agent_card_readkey (ctrl, keyid, &pkbuf, NULL);
|
2016-10-20 05:05:15 +02:00
|
|
|
|
if (rc)
|
|
|
|
|
goto leave;
|
2016-10-20 13:01:46 +02:00
|
|
|
|
pkbuflen = gcry_sexp_canon_len (pkbuf, 0, NULL, NULL);
|
2016-10-20 05:05:15 +02:00
|
|
|
|
rc = gcry_sexp_sscan (&s_pkey, NULL, (char*)pkbuf, pkbuflen);
|
|
|
|
|
if (rc)
|
|
|
|
|
goto leave;
|
|
|
|
|
|
|
|
|
|
if (!gcry_pk_get_keygrip (s_pkey, grip))
|
|
|
|
|
{
|
|
|
|
|
rc = gcry_pk_testkey (s_pkey);
|
|
|
|
|
if (rc == 0)
|
|
|
|
|
rc = gpg_error (GPG_ERR_INTERNAL);
|
|
|
|
|
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-21 21:00:28 +02:00
|
|
|
|
if (agent_key_available (grip))
|
|
|
|
|
{
|
|
|
|
|
/* (Shadow)-key is not available in our key storage. */
|
|
|
|
|
rc = agent_write_shadow_key (grip, serialno, keyid, pkbuf, 0);
|
|
|
|
|
if (rc)
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2016-10-20 05:05:15 +02:00
|
|
|
|
|
2021-04-23 08:47:06 +02:00
|
|
|
|
rc = opt_no_data? 0 : assuan_send_data (ctx, pkbuf, pkbuflen);
|
2016-10-20 05:05:15 +02:00
|
|
|
|
}
|
2016-10-24 12:55:21 +02:00
|
|
|
|
else
|
2005-02-23 22:06:32 +01:00
|
|
|
|
{
|
2016-10-24 12:55:21 +02:00
|
|
|
|
rc = parse_keygrip (ctx, line, grip);
|
|
|
|
|
if (rc)
|
|
|
|
|
goto leave;
|
|
|
|
|
|
|
|
|
|
rc = agent_public_key_from_file (ctrl, grip, &s_pkey);
|
|
|
|
|
if (!rc)
|
2005-02-23 22:06:32 +01:00
|
|
|
|
{
|
2016-10-24 12:55:21 +02:00
|
|
|
|
pkbuflen = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, NULL, 0);
|
|
|
|
|
log_assert (pkbuflen);
|
|
|
|
|
pkbuf = xtrymalloc (pkbuflen);
|
|
|
|
|
if (!pkbuf)
|
|
|
|
|
rc = gpg_error_from_syserror ();
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-02-07 10:52:37 +01:00
|
|
|
|
pkbuflen = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON,
|
|
|
|
|
pkbuf, pkbuflen);
|
2021-04-23 08:47:06 +02:00
|
|
|
|
rc = opt_no_data? 0 : assuan_send_data (ctx, pkbuf, pkbuflen);
|
2016-10-24 12:55:21 +02:00
|
|
|
|
}
|
2005-02-23 22:06:32 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-24 12:55:21 +02:00
|
|
|
|
leave:
|
2021-04-23 08:47:06 +02:00
|
|
|
|
xfree (keyidbuf);
|
2016-10-24 12:55:21 +02:00
|
|
|
|
xfree (serialno);
|
|
|
|
|
xfree (pkbuf);
|
|
|
|
|
gcry_sexp_release (s_pkey);
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, rc);
|
2005-02-23 22:06:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-03-06 18:31:27 +01:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_keyinfo[] =
|
2019-03-26 09:02:19 +01:00
|
|
|
|
"KEYINFO [--[ssh-]list] [--data] [--ssh-fpr[=algo]] [--with-ssh] <keygrip>\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
|
|
|
|
"Return information about the key specified by the KEYGRIP. If the\n"
|
|
|
|
|
"key is not available GPG_ERR_NOT_FOUND is returned. If the option\n"
|
|
|
|
|
"--list is given the keygrip is ignored and information about all\n"
|
2013-08-08 21:22:38 +02:00
|
|
|
|
"available keys are returned. If --ssh-list is given information\n"
|
|
|
|
|
"about all keys listed in the sshcontrol are returned. With --with-ssh\n"
|
|
|
|
|
"information from sshcontrol is always added to the info. Unless --data\n"
|
|
|
|
|
"is given, the information is returned as a status line using the format:\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
2011-07-20 21:13:24 +02:00
|
|
|
|
" KEYINFO <keygrip> <type> <serialno> <idstr> <cached> <protection> <fpr>\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
|
|
|
|
"KEYGRIP is the keygrip.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"TYPE is describes the type of the key:\n"
|
|
|
|
|
" 'D' - Regular key stored on disk,\n"
|
2010-04-21 18:26:17 +02:00
|
|
|
|
" 'T' - Key is stored on a smartcard (token),\n"
|
2013-08-08 21:22:38 +02:00
|
|
|
|
" 'X' - Unknown type,\n"
|
|
|
|
|
" '-' - Key is missing.\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
|
|
|
|
"SERIALNO is an ASCII string with the serial number of the\n"
|
|
|
|
|
" smartcard. If the serial number is not known a single\n"
|
|
|
|
|
" dash '-' is used instead.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"IDSTR is the IDSTR used to distinguish keys on a smartcard. If it\n"
|
|
|
|
|
" is not known a dash is used instead.\n"
|
|
|
|
|
"\n"
|
2011-03-02 09:50:12 +01:00
|
|
|
|
"CACHED is 1 if the passphrase for the key was found in the key cache.\n"
|
|
|
|
|
" If not, a '-' is used instead.\n"
|
2011-03-02 02:29:08 +01:00
|
|
|
|
"\n"
|
2011-04-07 01:23:05 +02:00
|
|
|
|
"PROTECTION describes the key protection type:\n"
|
|
|
|
|
" 'P' - The key is protected with a passphrase,\n"
|
|
|
|
|
" 'C' - The key is not protected,\n"
|
|
|
|
|
" '-' - Unknown protection.\n"
|
|
|
|
|
"\n"
|
2011-07-20 21:13:24 +02:00
|
|
|
|
"FPR returns the formatted ssh-style fingerprint of the key. It is only\n"
|
2019-03-26 09:02:19 +01:00
|
|
|
|
" printed if the option --ssh-fpr has been used. If ALGO is not given\n"
|
|
|
|
|
" to that option the default ssh fingerprint algo is used. Without the\n"
|
|
|
|
|
" option a '-' is printed.\n"
|
2013-08-08 21:22:38 +02:00
|
|
|
|
"\n"
|
|
|
|
|
"TTL is the TTL in seconds for that key or '-' if n/a.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"FLAGS is a word consisting of one-letter flags:\n"
|
|
|
|
|
" 'D' - The key has been disabled,\n"
|
|
|
|
|
" 'S' - The key is listed in sshcontrol (requires --with-ssh),\n"
|
|
|
|
|
" 'c' - Use of the key needs to be confirmed,\n"
|
2019-05-29 09:19:46 +02:00
|
|
|
|
" 'A' - The key is available on card,\n"
|
2013-08-08 21:22:38 +02:00
|
|
|
|
" '-' - No flags given.\n"
|
2011-07-20 21:13:24 +02:00
|
|
|
|
"\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"More information may be added in the future.";
|
2009-03-06 18:31:27 +01:00
|
|
|
|
static gpg_error_t
|
2011-03-02 03:18:45 +01:00
|
|
|
|
do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip, assuan_context_t ctx,
|
2013-08-08 21:22:38 +02:00
|
|
|
|
int data, int with_ssh_fpr, int in_ssh,
|
2019-05-29 09:19:46 +02:00
|
|
|
|
int ttl, int disabled, int confirm, int on_card)
|
2009-03-06 18:31:27 +01:00
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
char hexgrip[40+1];
|
2011-07-20 21:13:24 +02:00
|
|
|
|
char *fpr = NULL;
|
2009-03-06 18:31:27 +01:00
|
|
|
|
int keytype;
|
|
|
|
|
unsigned char *shadow_info = NULL;
|
2020-06-14 19:26:45 +02:00
|
|
|
|
unsigned char *shadow_info_type = NULL;
|
2009-03-06 18:31:27 +01:00
|
|
|
|
char *serialno = NULL;
|
|
|
|
|
char *idstr = NULL;
|
|
|
|
|
const char *keytypestr;
|
2011-03-02 09:50:12 +01:00
|
|
|
|
const char *cached;
|
2011-04-07 01:23:05 +02:00
|
|
|
|
const char *protectionstr;
|
2011-03-02 02:29:08 +01:00
|
|
|
|
char *pw;
|
2013-08-08 21:22:38 +02:00
|
|
|
|
int missing_key = 0;
|
|
|
|
|
char ttlbuf[20];
|
|
|
|
|
char flagsbuf[5];
|
2009-03-06 18:31:27 +01:00
|
|
|
|
|
2020-06-14 19:26:45 +02:00
|
|
|
|
err = agent_key_info_from_file (ctrl, grip, &keytype, &shadow_info,
|
|
|
|
|
&shadow_info_type);
|
2009-03-06 18:31:27 +01:00
|
|
|
|
if (err)
|
2013-08-08 21:22:38 +02:00
|
|
|
|
{
|
|
|
|
|
if (in_ssh && gpg_err_code (err) == GPG_ERR_NOT_FOUND)
|
|
|
|
|
missing_key = 1;
|
|
|
|
|
else
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2009-03-06 18:31:27 +01:00
|
|
|
|
|
|
|
|
|
/* Reformat the grip so that we use uppercase as good style. */
|
|
|
|
|
bin2hex (grip, 20, hexgrip);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2013-08-08 21:22:38 +02:00
|
|
|
|
if (ttl > 0)
|
|
|
|
|
snprintf (ttlbuf, sizeof ttlbuf, "%d", ttl);
|
|
|
|
|
else
|
|
|
|
|
strcpy (ttlbuf, "-");
|
|
|
|
|
|
|
|
|
|
*flagsbuf = 0;
|
|
|
|
|
if (disabled)
|
|
|
|
|
strcat (flagsbuf, "D");
|
|
|
|
|
if (in_ssh)
|
|
|
|
|
strcat (flagsbuf, "S");
|
|
|
|
|
if (confirm)
|
|
|
|
|
strcat (flagsbuf, "c");
|
2019-05-29 09:19:46 +02:00
|
|
|
|
if (on_card)
|
|
|
|
|
strcat (flagsbuf, "A");
|
2013-08-08 21:22:38 +02:00
|
|
|
|
if (!*flagsbuf)
|
|
|
|
|
strcpy (flagsbuf, "-");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (missing_key)
|
|
|
|
|
{
|
|
|
|
|
protectionstr = "-"; keytypestr = "-";
|
|
|
|
|
}
|
|
|
|
|
else
|
2011-04-07 01:23:05 +02:00
|
|
|
|
{
|
2013-08-08 21:22:38 +02:00
|
|
|
|
switch (keytype)
|
|
|
|
|
{
|
2015-01-29 16:26:07 +01:00
|
|
|
|
case PRIVATE_KEY_CLEAR:
|
|
|
|
|
case PRIVATE_KEY_OPENPGP_NONE:
|
|
|
|
|
protectionstr = "C"; keytypestr = "D";
|
2013-08-08 21:22:38 +02:00
|
|
|
|
break;
|
|
|
|
|
case PRIVATE_KEY_PROTECTED: protectionstr = "P"; keytypestr = "D";
|
|
|
|
|
break;
|
|
|
|
|
case PRIVATE_KEY_SHADOWED: protectionstr = "-"; keytypestr = "T";
|
|
|
|
|
break;
|
|
|
|
|
default: protectionstr = "-"; keytypestr = "X";
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-04-07 01:23:05 +02:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2011-07-20 21:13:24 +02:00
|
|
|
|
/* Compute the ssh fingerprint if requested. */
|
|
|
|
|
if (with_ssh_fpr)
|
|
|
|
|
{
|
|
|
|
|
gcry_sexp_t key;
|
|
|
|
|
|
|
|
|
|
if (!agent_raw_key_from_file (ctrl, grip, &key))
|
|
|
|
|
{
|
2019-03-26 09:02:19 +01:00
|
|
|
|
ssh_get_fingerprint_string (key, with_ssh_fpr, &fpr);
|
2011-07-20 21:13:24 +02:00
|
|
|
|
gcry_sexp_release (key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-02 09:50:12 +01:00
|
|
|
|
/* Here we have a little race by doing the cache check separately
|
|
|
|
|
from the retrieval function. Given that the cache flag is only a
|
|
|
|
|
hint, it should not really matter. */
|
2018-03-27 08:40:58 +02:00
|
|
|
|
pw = agent_get_cache (ctrl, hexgrip, CACHE_MODE_NORMAL);
|
2011-03-02 02:29:08 +01:00
|
|
|
|
cached = pw ? "1" : "-";
|
|
|
|
|
xfree (pw);
|
|
|
|
|
|
2009-03-06 18:31:27 +01:00
|
|
|
|
if (shadow_info)
|
|
|
|
|
{
|
2020-06-14 19:26:45 +02:00
|
|
|
|
if (strcmp (shadow_info_type, "t1-v1") == 0)
|
|
|
|
|
{
|
|
|
|
|
err = parse_shadow_info (shadow_info, &serialno, &idstr, NULL);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2021-03-09 22:50:29 +01:00
|
|
|
|
else if (strcmp (shadow_info_type, "tpm2-v1") == 0)
|
|
|
|
|
{
|
|
|
|
|
serialno = xstrdup("TPM-Protected");
|
|
|
|
|
idstr = NULL;
|
|
|
|
|
}
|
2020-06-14 19:26:45 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
log_error ("unrecognised shadow key type %s\n", shadow_info_type);
|
|
|
|
|
err = GPG_ERR_BAD_KEY;
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2009-03-06 18:31:27 +01:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2011-03-02 03:18:45 +01:00
|
|
|
|
if (!data)
|
|
|
|
|
err = agent_write_status (ctrl, "KEYINFO",
|
|
|
|
|
hexgrip,
|
|
|
|
|
keytypestr,
|
|
|
|
|
serialno? serialno : "-",
|
|
|
|
|
idstr? idstr : "-",
|
|
|
|
|
cached,
|
2011-04-07 01:23:05 +02:00
|
|
|
|
protectionstr,
|
2011-07-20 21:13:24 +02:00
|
|
|
|
fpr? fpr : "-",
|
2013-08-08 21:22:38 +02:00
|
|
|
|
ttlbuf,
|
|
|
|
|
flagsbuf,
|
2011-03-02 03:18:45 +01:00
|
|
|
|
NULL);
|
2011-03-02 09:50:12 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char *string;
|
|
|
|
|
|
2013-08-08 21:22:38 +02:00
|
|
|
|
string = xtryasprintf ("%s %s %s %s %s %s %s %s %s\n",
|
2011-03-02 09:50:12 +01:00
|
|
|
|
hexgrip, keytypestr,
|
|
|
|
|
serialno? serialno : "-",
|
2011-07-20 21:13:24 +02:00
|
|
|
|
idstr? idstr : "-", cached, protectionstr,
|
2013-08-08 21:22:38 +02:00
|
|
|
|
fpr? fpr : "-",
|
|
|
|
|
ttlbuf,
|
|
|
|
|
flagsbuf);
|
2011-03-02 09:50:12 +01:00
|
|
|
|
if (!string)
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
else
|
|
|
|
|
err = assuan_send_data (ctx, string, strlen(string));
|
|
|
|
|
xfree (string);
|
|
|
|
|
}
|
2011-03-02 03:18:45 +01:00
|
|
|
|
|
2009-03-06 18:31:27 +01:00
|
|
|
|
leave:
|
2011-07-20 21:13:24 +02:00
|
|
|
|
xfree (fpr);
|
2020-06-14 19:26:45 +02:00
|
|
|
|
xfree (shadow_info_type);
|
2009-03-06 18:31:27 +01:00
|
|
|
|
xfree (shadow_info);
|
|
|
|
|
xfree (serialno);
|
|
|
|
|
xfree (idstr);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-05-09 14:49:59 +02:00
|
|
|
|
/* Entry into the command KEYINFO. This function handles the
|
|
|
|
|
* command option processing. For details see hlp_keyinfo above. */
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2009-03-06 18:31:27 +01:00
|
|
|
|
cmd_keyinfo (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
int err;
|
|
|
|
|
unsigned char grip[20];
|
2020-10-21 16:59:38 +02:00
|
|
|
|
gnupg_dir_t dir = NULL;
|
2009-03-06 18:31:27 +01:00
|
|
|
|
int list_mode;
|
2013-08-08 21:22:38 +02:00
|
|
|
|
int opt_data, opt_ssh_fpr, opt_with_ssh;
|
|
|
|
|
ssh_control_file_t cf = NULL;
|
|
|
|
|
char hexgrip[41];
|
|
|
|
|
int disabled, ttl, confirm, is_ssh;
|
2019-05-29 09:19:46 +02:00
|
|
|
|
struct card_key_info_s *keyinfo_on_cards;
|
|
|
|
|
struct card_key_info_s *l;
|
|
|
|
|
int on_card;
|
2009-03-06 18:31:27 +01:00
|
|
|
|
|
2013-08-08 21:22:38 +02:00
|
|
|
|
if (has_option (line, "--ssh-list"))
|
|
|
|
|
list_mode = 2;
|
|
|
|
|
else
|
|
|
|
|
list_mode = has_option (line, "--list");
|
2011-03-02 03:18:45 +01:00
|
|
|
|
opt_data = has_option (line, "--data");
|
2019-03-26 09:02:19 +01:00
|
|
|
|
|
|
|
|
|
if (has_option_name (line, "--ssh-fpr"))
|
|
|
|
|
{
|
|
|
|
|
if (has_option (line, "--ssh-fpr=md5"))
|
|
|
|
|
opt_ssh_fpr = GCRY_MD_MD5;
|
|
|
|
|
else if (has_option (line, "--ssh-fpr=sha1"))
|
|
|
|
|
opt_ssh_fpr = GCRY_MD_SHA1;
|
|
|
|
|
else if (has_option (line, "--ssh-fpr=sha256"))
|
|
|
|
|
opt_ssh_fpr = GCRY_MD_SHA256;
|
|
|
|
|
else
|
|
|
|
|
opt_ssh_fpr = opt.ssh_fingerprint_digest;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
opt_ssh_fpr = 0;
|
|
|
|
|
|
2013-08-08 21:22:38 +02:00
|
|
|
|
opt_with_ssh = has_option (line, "--with-ssh");
|
2009-03-06 18:31:27 +01:00
|
|
|
|
line = skip_options (line);
|
2005-02-23 22:06:32 +01:00
|
|
|
|
|
2013-08-08 21:22:38 +02:00
|
|
|
|
if (opt_with_ssh || list_mode == 2)
|
|
|
|
|
cf = ssh_open_control_file ();
|
|
|
|
|
|
2021-05-19 02:32:19 +02:00
|
|
|
|
keyinfo_on_cards = get_keyinfo_on_cards (ctrl);
|
2019-05-29 09:19:46 +02:00
|
|
|
|
|
2013-08-08 21:22:38 +02:00
|
|
|
|
if (list_mode == 2)
|
|
|
|
|
{
|
2020-09-18 03:29:54 +02:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2013-08-08 21:22:38 +02:00
|
|
|
|
if (cf)
|
|
|
|
|
{
|
|
|
|
|
while (!ssh_read_control_file (cf, hexgrip,
|
|
|
|
|
&disabled, &ttl, &confirm))
|
|
|
|
|
{
|
|
|
|
|
if (hex2bin (hexgrip, grip, 20) < 0 )
|
|
|
|
|
continue; /* Bad hex string. */
|
2019-05-29 09:19:46 +02:00
|
|
|
|
|
|
|
|
|
on_card = 0;
|
|
|
|
|
for (l = keyinfo_on_cards; l; l = l->next)
|
|
|
|
|
if (!memcmp (l->keygrip, hexgrip, 40))
|
|
|
|
|
on_card = 1;
|
|
|
|
|
|
2013-08-08 21:22:38 +02:00
|
|
|
|
err = do_one_keyinfo (ctrl, grip, ctx, opt_data, opt_ssh_fpr, 1,
|
2019-05-29 09:19:46 +02:00
|
|
|
|
ttl, disabled, confirm, on_card);
|
2013-08-08 21:22:38 +02:00
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
err = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (list_mode)
|
2009-03-06 18:31:27 +01:00
|
|
|
|
{
|
|
|
|
|
char *dirname;
|
2020-10-21 16:59:38 +02:00
|
|
|
|
gnupg_dirent_t dir_entry;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2020-09-18 03:29:54 +02:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2016-06-07 10:59:46 +02:00
|
|
|
|
dirname = make_filename_try (gnupg_homedir (),
|
|
|
|
|
GNUPG_PRIVATE_KEYS_DIR, NULL);
|
2009-03-06 18:31:27 +01:00
|
|
|
|
if (!dirname)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2020-10-21 16:59:38 +02:00
|
|
|
|
dir = gnupg_opendir (dirname);
|
2009-03-06 18:31:27 +01:00
|
|
|
|
if (!dir)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
xfree (dirname);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
xfree (dirname);
|
|
|
|
|
|
2020-10-21 16:59:38 +02:00
|
|
|
|
while ( (dir_entry = gnupg_readdir (dir)) )
|
2009-03-06 18:31:27 +01:00
|
|
|
|
{
|
|
|
|
|
if (strlen (dir_entry->d_name) != 44
|
|
|
|
|
|| strcmp (dir_entry->d_name + 40, ".key"))
|
|
|
|
|
continue;
|
|
|
|
|
strncpy (hexgrip, dir_entry->d_name, 40);
|
|
|
|
|
hexgrip[40] = 0;
|
|
|
|
|
|
|
|
|
|
if ( hex2bin (hexgrip, grip, 20) < 0 )
|
|
|
|
|
continue; /* Bad hex string. */
|
|
|
|
|
|
2013-08-08 21:22:38 +02:00
|
|
|
|
disabled = ttl = confirm = is_ssh = 0;
|
|
|
|
|
if (opt_with_ssh)
|
|
|
|
|
{
|
|
|
|
|
err = ssh_search_control_file (cf, hexgrip,
|
|
|
|
|
&disabled, &ttl, &confirm);
|
|
|
|
|
if (!err)
|
|
|
|
|
is_ssh = 1;
|
|
|
|
|
else if (gpg_err_code (err) != GPG_ERR_NOT_FOUND)
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-29 09:19:46 +02:00
|
|
|
|
on_card = 0;
|
|
|
|
|
for (l = keyinfo_on_cards; l; l = l->next)
|
|
|
|
|
if (!memcmp (l->keygrip, hexgrip, 40))
|
|
|
|
|
on_card = 1;
|
|
|
|
|
|
2013-08-08 21:22:38 +02:00
|
|
|
|
err = do_one_keyinfo (ctrl, grip, ctx, opt_data, opt_ssh_fpr, is_ssh,
|
2019-05-29 09:19:46 +02:00
|
|
|
|
ttl, disabled, confirm, on_card);
|
2009-03-06 18:31:27 +01:00
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
err = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
err = parse_keygrip (ctx, line, grip);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
2013-08-08 21:22:38 +02:00
|
|
|
|
disabled = ttl = confirm = is_ssh = 0;
|
|
|
|
|
if (opt_with_ssh)
|
|
|
|
|
{
|
|
|
|
|
err = ssh_search_control_file (cf, line,
|
|
|
|
|
&disabled, &ttl, &confirm);
|
|
|
|
|
if (!err)
|
|
|
|
|
is_ssh = 1;
|
|
|
|
|
else if (gpg_err_code (err) != GPG_ERR_NOT_FOUND)
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-29 09:19:46 +02:00
|
|
|
|
on_card = 0;
|
|
|
|
|
for (l = keyinfo_on_cards; l; l = l->next)
|
|
|
|
|
if (!memcmp (l->keygrip, line, 40))
|
|
|
|
|
on_card = 1;
|
|
|
|
|
|
2013-08-08 21:22:38 +02:00
|
|
|
|
err = do_one_keyinfo (ctrl, grip, ctx, opt_data, opt_ssh_fpr, is_ssh,
|
2019-05-29 09:19:46 +02:00
|
|
|
|
ttl, disabled, confirm, on_card);
|
2009-03-06 18:31:27 +01:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-03-06 18:31:27 +01:00
|
|
|
|
leave:
|
2013-08-08 21:22:38 +02:00
|
|
|
|
ssh_close_control_file (cf);
|
2020-10-21 16:59:38 +02:00
|
|
|
|
gnupg_closedir (dir);
|
2009-03-06 18:31:27 +01:00
|
|
|
|
if (err && gpg_err_code (err) != GPG_ERR_NOT_FOUND)
|
2010-06-17 17:44:44 +02:00
|
|
|
|
leave_cmd (ctx, err);
|
2009-03-06 18:31:27 +01:00
|
|
|
|
return err;
|
|
|
|
|
}
|
2005-02-23 22:06:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Helper for cmd_get_passphrase. */
|
2006-10-04 18:45:04 +02:00
|
|
|
|
static int
|
|
|
|
|
send_back_passphrase (assuan_context_t ctx, int via_data, const char *pw)
|
|
|
|
|
{
|
|
|
|
|
size_t n;
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
assuan_begin_confidential (ctx);
|
|
|
|
|
n = strlen (pw);
|
|
|
|
|
if (via_data)
|
|
|
|
|
rc = assuan_send_data (ctx, pw, n);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char *p = xtrymalloc_secure (n*2+1);
|
|
|
|
|
if (!p)
|
|
|
|
|
rc = gpg_error_from_syserror ();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bin2hex (pw, n, p);
|
|
|
|
|
rc = assuan_set_okay_line (ctx, p);
|
|
|
|
|
xfree (p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-07-08 14:20:01 +02:00
|
|
|
|
/* Callback function to compare the first entered PIN with the one
|
|
|
|
|
currently being entered. */
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
reenter_passphrase_cmp_cb (struct pin_entry_info_s *pi)
|
|
|
|
|
{
|
|
|
|
|
const char *pin1 = pi->check_cb_arg;
|
|
|
|
|
|
|
|
|
|
if (!strcmp (pin1, pi->pin))
|
|
|
|
|
return 0; /* okay */
|
|
|
|
|
return gpg_error (GPG_ERR_BAD_PASSPHRASE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_get_passphrase[] =
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"GET_PASSPHRASE [--data] [--check] [--no-ask] [--repeat[=N]]\n"
|
2020-07-08 14:20:01 +02:00
|
|
|
|
" [--qualitybar] [--newsymkey] <cache_id>\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
" [<error_message> <prompt> <description>]\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"This function is usually used to ask for a passphrase to be used\n"
|
|
|
|
|
"for conventional encryption, but may also be used by programs which\n"
|
|
|
|
|
"need specal handling of passphrases. This command uses a syntax\n"
|
|
|
|
|
"which helps clients to use the agent with minimum effort. The\n"
|
|
|
|
|
"agent either returns with an error or with a OK followed by the hex\n"
|
|
|
|
|
"encoded passphrase. Note that the length of the strings is\n"
|
|
|
|
|
"implicitly limited by the maximum length of a command.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"If the option \"--data\" is used the passphrase is returned by usual\n"
|
|
|
|
|
"data lines and not on the okay line.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"If the option \"--check\" is used the passphrase constraints checks as\n"
|
|
|
|
|
"implemented by gpg-agent are applied. A check is not done if the\n"
|
|
|
|
|
"passphrase has been found in the cache.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"If the option \"--no-ask\" is used and the passphrase is not in the\n"
|
|
|
|
|
"cache the user will not be asked to enter a passphrase but the error\n"
|
|
|
|
|
"code GPG_ERR_NO_DATA is returned. \n"
|
|
|
|
|
"\n"
|
2020-07-08 14:20:01 +02:00
|
|
|
|
"If the option\"--newsymkey\" is used the agent asks for a new passphrase\n"
|
|
|
|
|
"to be used in symmetric-only encryption. This must not be empty.\n"
|
|
|
|
|
"\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"If the option \"--qualitybar\" is used a visual indication of the\n"
|
|
|
|
|
"entered passphrase quality is shown. (Unless no minimum passphrase\n"
|
|
|
|
|
"length has been configured.)";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_get_passphrase (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2004-02-13 18:06:34 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
int rc;
|
2010-09-02 12:46:23 +02:00
|
|
|
|
char *pw;
|
2020-07-08 14:20:01 +02:00
|
|
|
|
char *response = NULL;
|
|
|
|
|
char *response2 = NULL;
|
|
|
|
|
char *cacheid = NULL; /* May point into LINE. */
|
|
|
|
|
char *desc = NULL; /* Ditto */
|
|
|
|
|
char *prompt = NULL; /* Ditto */
|
|
|
|
|
char *errtext = NULL; /* Ditto */
|
2009-03-17 13:13:32 +01:00
|
|
|
|
const char *desc2 = _("Please re-enter this passphrase");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
char *p;
|
2020-07-08 14:20:01 +02:00
|
|
|
|
int opt_data, opt_check, opt_no_ask, opt_qualbar, opt_newsymkey;
|
2009-05-15 13:16:28 +02:00
|
|
|
|
int opt_repeat = 0;
|
2015-06-18 05:10:47 +02:00
|
|
|
|
char *entry_errtext = NULL;
|
2020-07-08 14:20:01 +02:00
|
|
|
|
struct pin_entry_info_s *pi = NULL;
|
|
|
|
|
struct pin_entry_info_s *pi2 = NULL;
|
2021-08-18 18:24:35 +02:00
|
|
|
|
int is_generated;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2006-10-04 18:45:04 +02:00
|
|
|
|
opt_data = has_option (line, "--data");
|
2007-01-25 09:30:47 +01:00
|
|
|
|
opt_check = has_option (line, "--check");
|
2008-12-10 13:41:15 +01:00
|
|
|
|
opt_no_ask = has_option (line, "--no-ask");
|
2009-03-17 13:13:32 +01:00
|
|
|
|
if (has_option_name (line, "--repeat"))
|
|
|
|
|
{
|
|
|
|
|
p = option_value (line, "--repeat");
|
|
|
|
|
if (p)
|
|
|
|
|
opt_repeat = atoi (p);
|
|
|
|
|
else
|
|
|
|
|
opt_repeat = 1;
|
|
|
|
|
}
|
2009-05-15 13:16:28 +02:00
|
|
|
|
opt_qualbar = has_option (line, "--qualitybar");
|
2020-07-08 14:20:01 +02:00
|
|
|
|
opt_newsymkey = has_option (line, "--newsymkey");
|
2006-10-04 18:45:04 +02:00
|
|
|
|
line = skip_options (line);
|
|
|
|
|
|
|
|
|
|
cacheid = line;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
p = strchr (cacheid, ' ');
|
|
|
|
|
if (p)
|
|
|
|
|
{
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
while (*p == ' ')
|
|
|
|
|
p++;
|
|
|
|
|
errtext = p;
|
|
|
|
|
p = strchr (errtext, ' ');
|
|
|
|
|
if (p)
|
|
|
|
|
{
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
while (*p == ' ')
|
|
|
|
|
p++;
|
|
|
|
|
prompt = p;
|
|
|
|
|
p = strchr (prompt, ' ');
|
|
|
|
|
if (p)
|
|
|
|
|
{
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
while (*p == ' ')
|
|
|
|
|
p++;
|
|
|
|
|
desc = p;
|
|
|
|
|
p = strchr (desc, ' ');
|
|
|
|
|
if (p)
|
2007-01-25 09:30:47 +01:00
|
|
|
|
*p = 0; /* Ignore trailing garbage. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-15 13:11:44 +01:00
|
|
|
|
if (!*cacheid || strlen (cacheid) > 50)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "invalid length of cacheID");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (!desc)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "no description given");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
if (!strcmp (cacheid, "X"))
|
|
|
|
|
cacheid = NULL;
|
|
|
|
|
if (!strcmp (errtext, "X"))
|
|
|
|
|
errtext = NULL;
|
|
|
|
|
if (!strcmp (prompt, "X"))
|
|
|
|
|
prompt = NULL;
|
|
|
|
|
if (!strcmp (desc, "X"))
|
|
|
|
|
desc = NULL;
|
|
|
|
|
|
2018-03-27 08:40:58 +02:00
|
|
|
|
pw = cacheid ? agent_get_cache (ctrl, cacheid, CACHE_MODE_USER) : NULL;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (pw)
|
|
|
|
|
{
|
2006-10-04 18:45:04 +02:00
|
|
|
|
rc = send_back_passphrase (ctx, opt_data, pw);
|
2010-09-02 12:46:23 +02:00
|
|
|
|
xfree (pw);
|
2020-07-08 14:20:01 +02:00
|
|
|
|
goto leave;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
2008-12-10 13:41:15 +01:00
|
|
|
|
else if (opt_no_ask)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2020-07-08 14:20:01 +02:00
|
|
|
|
rc = gpg_error (GPG_ERR_NO_DATA);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Note, that we only need to replace the + characters and should
|
|
|
|
|
* leave the other escaping in place because the escaped string is
|
|
|
|
|
* send verbatim to the pinentry which does the unescaping (but not
|
|
|
|
|
* the + replacing) */
|
|
|
|
|
if (errtext)
|
|
|
|
|
plus_to_blank (errtext);
|
|
|
|
|
if (prompt)
|
|
|
|
|
plus_to_blank (prompt);
|
|
|
|
|
if (desc)
|
|
|
|
|
plus_to_blank (desc);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2020-08-20 09:34:41 +02:00
|
|
|
|
/* If opt_repeat is 2 or higher we can't use our pin_entry_info_s
|
|
|
|
|
* based method but fallback to the old simple method. It is
|
|
|
|
|
* anyway questionable whether this extra repeat count makes any
|
|
|
|
|
* real sense. */
|
|
|
|
|
if (opt_newsymkey && opt_repeat < 2)
|
2020-07-08 14:20:01 +02:00
|
|
|
|
{
|
|
|
|
|
/* We do not want to break any existing usage of this command
|
|
|
|
|
* and thus we introduced the option --newsymkey to make this
|
|
|
|
|
* command more useful to query the passphrase for symmetric
|
|
|
|
|
* encryption. */
|
|
|
|
|
pi = gcry_calloc_secure (1, sizeof (*pi) + MAX_PASSPHRASE_LEN + 1);
|
|
|
|
|
if (!pi)
|
|
|
|
|
{
|
|
|
|
|
rc = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
pi2 = gcry_calloc_secure (1, sizeof (*pi2) + MAX_PASSPHRASE_LEN + 1);
|
|
|
|
|
if (!pi2)
|
|
|
|
|
{
|
|
|
|
|
rc = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
pi->max_length = MAX_PASSPHRASE_LEN + 1;
|
|
|
|
|
pi->max_tries = 3;
|
|
|
|
|
pi->with_qualitybar = opt_qualbar;
|
|
|
|
|
pi->with_repeat = opt_repeat;
|
2021-08-13 13:42:31 +02:00
|
|
|
|
pi->constraints_flags = (CHECK_CONSTRAINTS_NOT_EMPTY
|
|
|
|
|
| CHECK_CONSTRAINTS_NEW_SYMKEY);
|
2020-07-08 14:20:01 +02:00
|
|
|
|
pi2->max_length = MAX_PASSPHRASE_LEN + 1;
|
|
|
|
|
pi2->max_tries = 3;
|
|
|
|
|
pi2->check_cb = reenter_passphrase_cmp_cb;
|
|
|
|
|
pi2->check_cb_arg = pi->pin;
|
|
|
|
|
|
|
|
|
|
for (;;) /* (degenerated for-loop) */
|
|
|
|
|
{
|
|
|
|
|
xfree (response);
|
|
|
|
|
response = NULL;
|
|
|
|
|
rc = agent_get_passphrase (ctrl, &response,
|
|
|
|
|
desc,
|
|
|
|
|
prompt,
|
|
|
|
|
entry_errtext? entry_errtext:errtext,
|
|
|
|
|
opt_qualbar, cacheid, CACHE_MODE_USER,
|
|
|
|
|
pi);
|
|
|
|
|
if (rc)
|
|
|
|
|
goto leave;
|
|
|
|
|
xfree (entry_errtext);
|
|
|
|
|
entry_errtext = NULL;
|
2021-08-18 18:24:35 +02:00
|
|
|
|
is_generated = !!(pi->status & PINENTRY_STATUS_PASSWORD_GENERATED);
|
|
|
|
|
|
2020-07-08 14:20:01 +02:00
|
|
|
|
/* We don't allow an empty passpharse in this mode. */
|
2021-08-18 18:24:35 +02:00
|
|
|
|
if (!is_generated
|
|
|
|
|
&& check_passphrase_constraints (ctrl, pi->pin,
|
|
|
|
|
pi->constraints_flags,
|
|
|
|
|
&entry_errtext))
|
2020-07-08 14:20:01 +02:00
|
|
|
|
{
|
|
|
|
|
pi->failed_tries = 0;
|
|
|
|
|
pi2->failed_tries = 0;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2020-07-13 14:30:14 +02:00
|
|
|
|
if (*pi->pin && !pi->repeat_okay
|
2020-08-20 09:34:41 +02:00
|
|
|
|
&& ctrl->pinentry_mode != PINENTRY_MODE_LOOPBACK
|
|
|
|
|
&& opt_repeat)
|
2020-07-08 14:20:01 +02:00
|
|
|
|
{
|
|
|
|
|
/* The passphrase is empty and the pinentry did not
|
|
|
|
|
* already run the repetition check, do it here. This
|
2020-07-13 14:30:14 +02:00
|
|
|
|
* is only called when using an old and simple pinentry.
|
|
|
|
|
* It is neither called in loopback mode because the
|
2020-08-20 09:34:41 +02:00
|
|
|
|
* caller does any passphrase repetition by herself nor if
|
|
|
|
|
* no repetition was requested. */
|
2020-07-08 14:20:01 +02:00
|
|
|
|
xfree (response);
|
|
|
|
|
response = NULL;
|
|
|
|
|
rc = agent_get_passphrase (ctrl, &response,
|
|
|
|
|
L_("Please re-enter this passphrase"),
|
|
|
|
|
prompt,
|
|
|
|
|
entry_errtext? entry_errtext:errtext,
|
|
|
|
|
opt_qualbar, cacheid, CACHE_MODE_USER,
|
|
|
|
|
pi2);
|
|
|
|
|
if (gpg_err_code (rc) == GPG_ERR_BAD_PASSPHRASE)
|
|
|
|
|
{ /* The re-entered passphrase one did not match and
|
|
|
|
|
* the user did not hit cancel. */
|
|
|
|
|
entry_errtext = xtrystrdup (L_("does not match - try again"));
|
|
|
|
|
if (!entry_errtext)
|
|
|
|
|
{
|
|
|
|
|
rc = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (!rc && *pi->pin)
|
|
|
|
|
{
|
|
|
|
|
/* Return the passphrase. */
|
|
|
|
|
if (cacheid)
|
|
|
|
|
agent_put_cache (ctrl, cacheid, CACHE_MODE_USER, pi->pin, 0);
|
|
|
|
|
rc = send_back_passphrase (ctx, opt_data, pi->pin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-03-17 13:13:32 +01:00
|
|
|
|
next_try:
|
2020-07-08 14:20:01 +02:00
|
|
|
|
xfree (response);
|
|
|
|
|
response = NULL;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
rc = agent_get_passphrase (ctrl, &response, desc, prompt,
|
2015-06-18 05:10:47 +02:00
|
|
|
|
entry_errtext? entry_errtext:errtext,
|
2020-07-08 14:20:01 +02:00
|
|
|
|
opt_qualbar, cacheid, CACHE_MODE_USER, NULL);
|
2015-06-18 05:10:47 +02:00
|
|
|
|
xfree (entry_errtext);
|
|
|
|
|
entry_errtext = NULL;
|
2021-09-07 08:57:44 +02:00
|
|
|
|
is_generated = 0;
|
2021-08-18 18:24:35 +02:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (!rc)
|
|
|
|
|
{
|
2009-03-17 13:13:32 +01:00
|
|
|
|
int i;
|
|
|
|
|
|
2015-06-18 05:10:47 +02:00
|
|
|
|
if (opt_check
|
2021-08-18 18:24:35 +02:00
|
|
|
|
&& !is_generated
|
2021-08-13 13:42:31 +02:00
|
|
|
|
&& check_passphrase_constraints
|
|
|
|
|
(ctrl, response,
|
|
|
|
|
(opt_newsymkey? CHECK_CONSTRAINTS_NEW_SYMKEY:0),
|
|
|
|
|
&entry_errtext))
|
2009-03-17 13:13:32 +01:00
|
|
|
|
{
|
|
|
|
|
goto next_try;
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < opt_repeat; i++)
|
|
|
|
|
{
|
2015-08-16 19:46:59 +02:00
|
|
|
|
if (ctrl->pinentry_mode == PINENTRY_MODE_LOOPBACK)
|
|
|
|
|
break;
|
|
|
|
|
|
2020-07-08 14:20:01 +02:00
|
|
|
|
xfree (response2);
|
|
|
|
|
response2 = NULL;
|
2009-03-17 13:13:32 +01:00
|
|
|
|
rc = agent_get_passphrase (ctrl, &response2, desc2, prompt,
|
2015-05-19 14:58:04 +02:00
|
|
|
|
errtext, 0,
|
2020-07-08 14:20:01 +02:00
|
|
|
|
cacheid, CACHE_MODE_USER, NULL);
|
2009-03-17 13:13:32 +01:00
|
|
|
|
if (rc)
|
|
|
|
|
break;
|
|
|
|
|
if (strcmp (response2, response))
|
|
|
|
|
{
|
2015-06-18 05:10:47 +02:00
|
|
|
|
entry_errtext = try_percent_escape
|
2009-03-17 18:59:36 +01:00
|
|
|
|
(_("does not match - try again"), NULL);
|
2015-06-18 05:10:47 +02:00
|
|
|
|
if (!entry_errtext)
|
2009-03-17 18:59:36 +01:00
|
|
|
|
{
|
|
|
|
|
rc = gpg_error_from_syserror ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-03-17 13:13:32 +01:00
|
|
|
|
goto next_try;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!rc)
|
|
|
|
|
{
|
|
|
|
|
if (cacheid)
|
2018-03-27 08:40:58 +02:00
|
|
|
|
agent_put_cache (ctrl, cacheid, CACHE_MODE_USER, response, 0);
|
2009-03-17 13:13:32 +01:00
|
|
|
|
rc = send_back_passphrase (ctx, opt_data, response);
|
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-08 14:20:01 +02:00
|
|
|
|
leave:
|
|
|
|
|
xfree (response);
|
|
|
|
|
xfree (response2);
|
|
|
|
|
xfree (entry_errtext);
|
|
|
|
|
xfree (pi2);
|
|
|
|
|
xfree (pi);
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, rc);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_clear_passphrase[] =
|
2011-03-02 09:11:40 +01:00
|
|
|
|
"CLEAR_PASSPHRASE [--mode=normal] <cache_id>\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
|
|
|
|
"may be used to invalidate the cache entry for a passphrase. The\n"
|
2011-02-27 14:35:16 +01:00
|
|
|
|
"function returns with OK even when there is no cached passphrase.\n"
|
2011-03-02 09:11:40 +01:00
|
|
|
|
"The --mode=normal option is used to clear an entry for a cacheid\n"
|
2019-01-25 04:08:09 +01:00
|
|
|
|
"added by the agent. The --mode=ssh option is used for a cacheid\n"
|
|
|
|
|
"added for ssh.\n";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_clear_passphrase (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2014-11-27 20:41:37 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
char *cacheid = NULL;
|
|
|
|
|
char *p;
|
2019-01-25 04:08:09 +01:00
|
|
|
|
cache_mode_t cache_mode = CACHE_MODE_USER;
|
2011-02-27 14:35:16 +01:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2019-01-25 04:08:09 +01:00
|
|
|
|
if (has_option (line, "--mode=normal"))
|
|
|
|
|
cache_mode = CACHE_MODE_NORMAL;
|
|
|
|
|
else if (has_option (line, "--mode=ssh"))
|
|
|
|
|
cache_mode = CACHE_MODE_SSH;
|
|
|
|
|
|
2011-02-27 14:35:16 +01:00
|
|
|
|
line = skip_options (line);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
|
|
|
|
/* parse the stuff */
|
|
|
|
|
for (p=line; *p == ' '; p++)
|
|
|
|
|
;
|
|
|
|
|
cacheid = p;
|
|
|
|
|
p = strchr (cacheid, ' ');
|
|
|
|
|
if (p)
|
|
|
|
|
*p = 0; /* ignore garbage */
|
2015-03-15 13:11:44 +01:00
|
|
|
|
if (!*cacheid || strlen (cacheid) > 50)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "invalid length of cacheID");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2019-01-25 04:08:09 +01:00
|
|
|
|
agent_put_cache (ctrl, cacheid, cache_mode, NULL, 0);
|
2015-05-19 15:00:16 +02:00
|
|
|
|
|
2019-01-25 04:08:09 +01:00
|
|
|
|
agent_clear_passphrase (ctrl, cacheid, cache_mode);
|
2015-05-19 15:00:16 +02:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-31 13:11:48 +01:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_get_confirmation[] =
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"GET_CONFIRMATION <description>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"This command may be used to ask for a simple confirmation.\n"
|
|
|
|
|
"DESCRIPTION is displayed along with a Okay and Cancel button. This\n"
|
|
|
|
|
"command uses a syntax which helps clients to use the agent with\n"
|
|
|
|
|
"minimum effort. The agent either returns with an error or with a\n"
|
|
|
|
|
"OK. Note, that the length of DESCRIPTION is implicitly limited by\n"
|
|
|
|
|
"the maximum length of a command. DESCRIPTION should not contain\n"
|
|
|
|
|
"any spaces, those must be encoded either percent escaped or simply\n"
|
|
|
|
|
"as '+'.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_get_confirmation (assuan_context_t ctx, char *line)
|
2003-10-31 13:11:48 +01:00
|
|
|
|
{
|
2004-02-13 18:06:34 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2003-10-31 13:11:48 +01:00
|
|
|
|
int rc;
|
|
|
|
|
char *desc = NULL;
|
|
|
|
|
char *p;
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2003-10-31 13:11:48 +01:00
|
|
|
|
/* parse the stuff */
|
|
|
|
|
for (p=line; *p == ' '; p++)
|
|
|
|
|
;
|
|
|
|
|
desc = p;
|
|
|
|
|
p = strchr (desc, ' ');
|
|
|
|
|
if (p)
|
|
|
|
|
*p = 0; /* We ignore any garbage -may be later used for other args. */
|
|
|
|
|
|
2015-03-15 13:11:44 +01:00
|
|
|
|
if (!*desc)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "no description given");
|
2003-10-31 13:11:48 +01:00
|
|
|
|
|
|
|
|
|
if (!strcmp (desc, "X"))
|
|
|
|
|
desc = NULL;
|
|
|
|
|
|
|
|
|
|
/* Note, that we only need to replace the + characters and should
|
|
|
|
|
leave the other escaping in place because the escaped string is
|
|
|
|
|
send verbatim to the pinentry which does the unescaping (but not
|
|
|
|
|
the + replacing) */
|
|
|
|
|
if (desc)
|
|
|
|
|
plus_to_blank (desc);
|
|
|
|
|
|
2009-06-17 12:19:50 +02:00
|
|
|
|
rc = agent_get_confirmation (ctrl, desc, NULL, NULL, 0);
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, rc);
|
2003-10-31 13:11:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2009-11-04 12:58:06 +01:00
|
|
|
|
static const char hlp_learn[] =
|
2015-04-03 10:33:11 +02:00
|
|
|
|
"LEARN [--send] [--sendinfo] [--force]\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
|
|
|
|
"Learn something about the currently inserted smartcard. With\n"
|
2014-12-12 12:35:45 +01:00
|
|
|
|
"--sendinfo information about the card is returned; with --send\n"
|
2015-04-03 10:33:11 +02:00
|
|
|
|
"the available certificates are returned as D lines; with --force\n"
|
|
|
|
|
"private key storage will be updated by the result.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_learn (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2004-01-29 21:17:27 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2014-12-12 12:35:45 +01:00
|
|
|
|
gpg_error_t err;
|
2015-04-03 10:33:11 +02:00
|
|
|
|
int send, sendinfo, force;
|
2014-12-12 12:35:45 +01:00
|
|
|
|
|
|
|
|
|
send = has_option (line, "--send");
|
|
|
|
|
sendinfo = send? 1 : has_option (line, "--sendinfo");
|
2015-04-03 10:33:11 +02:00
|
|
|
|
force = has_option (line, "--force");
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2015-04-03 10:33:11 +02:00
|
|
|
|
err = agent_handle_learn (ctrl, send, sendinfo? ctx : NULL, force);
|
2014-12-12 12:35:45 +01:00
|
|
|
|
return leave_cmd (ctx, err);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_passwd[] =
|
2015-06-29 12:50:16 +02:00
|
|
|
|
"PASSWD [--cache-nonce=<c>] [--passwd-nonce=<s>] [--preset]\n"
|
|
|
|
|
" [--verify] <hexkeygrip>\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
2015-06-29 12:50:16 +02:00
|
|
|
|
"Change the passphrase/PIN for the key identified by keygrip in LINE. If\n"
|
|
|
|
|
"--preset is used then the new passphrase will be added to the cache.\n"
|
|
|
|
|
"If --verify is used the command asks for the passphrase and verifies\n"
|
|
|
|
|
"that the passphrase valid.\n";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_passwd (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2004-02-13 18:06:34 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2010-10-26 11:10:29 +02:00
|
|
|
|
gpg_error_t err;
|
|
|
|
|
int c;
|
|
|
|
|
char *cache_nonce = NULL;
|
|
|
|
|
char *passwd_nonce = NULL;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
unsigned char grip[20];
|
|
|
|
|
gcry_sexp_t s_skey = NULL;
|
|
|
|
|
unsigned char *shadow_info = NULL;
|
2010-10-26 11:10:29 +02:00
|
|
|
|
char *passphrase = NULL;
|
|
|
|
|
char *pend;
|
2015-06-29 12:50:16 +02:00
|
|
|
|
int opt_preset, opt_verify;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2011-04-10 22:06:18 +02:00
|
|
|
|
opt_preset = has_option (line, "--preset");
|
2010-10-26 11:10:29 +02:00
|
|
|
|
cache_nonce = option_value (line, "--cache-nonce");
|
2015-06-29 12:50:16 +02:00
|
|
|
|
opt_verify = has_option (line, "--verify");
|
2010-10-26 11:10:29 +02:00
|
|
|
|
if (cache_nonce)
|
|
|
|
|
{
|
|
|
|
|
for (pend = cache_nonce; *pend && !spacep (pend); pend++)
|
|
|
|
|
;
|
|
|
|
|
c = *pend;
|
|
|
|
|
*pend = '\0';
|
|
|
|
|
cache_nonce = xtrystrdup (cache_nonce);
|
|
|
|
|
*pend = c;
|
|
|
|
|
if (!cache_nonce)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
passwd_nonce = option_value (line, "--passwd-nonce");
|
|
|
|
|
if (passwd_nonce)
|
|
|
|
|
{
|
|
|
|
|
for (pend = passwd_nonce; *pend && !spacep (pend); pend++)
|
|
|
|
|
;
|
|
|
|
|
c = *pend;
|
|
|
|
|
*pend = '\0';
|
|
|
|
|
passwd_nonce = xtrystrdup (passwd_nonce);
|
|
|
|
|
*pend = c;
|
|
|
|
|
if (!passwd_nonce)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
line = skip_options (line);
|
|
|
|
|
|
|
|
|
|
err = parse_keygrip (ctx, line, grip);
|
|
|
|
|
if (err)
|
2007-01-25 09:30:47 +01:00
|
|
|
|
goto leave;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2007-08-28 19:48:13 +02:00
|
|
|
|
ctrl->in_passwd++;
|
2015-06-29 12:50:16 +02:00
|
|
|
|
err = agent_key_from_file (ctrl,
|
|
|
|
|
opt_verify? NULL : cache_nonce,
|
|
|
|
|
ctrl->server_local->keydesc,
|
2011-02-04 12:57:53 +01:00
|
|
|
|
grip, &shadow_info, CACHE_MODE_IGNORE, NULL,
|
2010-10-26 11:10:29 +02:00
|
|
|
|
&s_skey, &passphrase);
|
|
|
|
|
if (err)
|
2010-10-13 17:57:08 +02:00
|
|
|
|
;
|
2014-03-04 03:54:59 +01:00
|
|
|
|
else if (shadow_info)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
|
|
|
|
log_error ("changing a smartcard PIN is not yet supported\n");
|
2010-10-26 11:10:29 +02:00
|
|
|
|
err = gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
2015-06-29 12:50:16 +02:00
|
|
|
|
else if (opt_verify)
|
|
|
|
|
{
|
|
|
|
|
/* All done. */
|
2016-06-02 21:21:08 +02:00
|
|
|
|
if (passphrase)
|
|
|
|
|
{
|
|
|
|
|
if (!passwd_nonce)
|
|
|
|
|
{
|
|
|
|
|
char buf[12];
|
|
|
|
|
gcry_create_nonce (buf, 12);
|
|
|
|
|
passwd_nonce = bin2hex (buf, 12, NULL);
|
|
|
|
|
}
|
|
|
|
|
if (passwd_nonce
|
2018-03-27 08:40:58 +02:00
|
|
|
|
&& !agent_put_cache (ctrl, passwd_nonce, CACHE_MODE_NONCE,
|
2016-06-02 21:21:08 +02:00
|
|
|
|
passphrase, CACHE_TTL_NONCE))
|
|
|
|
|
{
|
|
|
|
|
assuan_write_status (ctx, "PASSWD_NONCE", passwd_nonce);
|
|
|
|
|
xfree (ctrl->server_local->last_passwd_nonce);
|
|
|
|
|
ctrl->server_local->last_passwd_nonce = passwd_nonce;
|
|
|
|
|
passwd_nonce = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-29 12:50:16 +02:00
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
else
|
2010-10-26 11:10:29 +02:00
|
|
|
|
{
|
|
|
|
|
char *newpass = NULL;
|
|
|
|
|
|
|
|
|
|
if (passwd_nonce)
|
2018-03-27 08:40:58 +02:00
|
|
|
|
newpass = agent_get_cache (ctrl, passwd_nonce, CACHE_MODE_NONCE);
|
2010-10-26 11:10:29 +02:00
|
|
|
|
err = agent_protect_and_store (ctrl, s_skey, &newpass);
|
|
|
|
|
if (!err && passphrase)
|
|
|
|
|
{
|
|
|
|
|
/* A passphrase existed on the old key and the change was
|
|
|
|
|
successful. Return a nonce for that old passphrase to
|
|
|
|
|
let the caller try to unprotect the other subkeys with
|
|
|
|
|
the same key. */
|
|
|
|
|
if (!cache_nonce)
|
|
|
|
|
{
|
|
|
|
|
char buf[12];
|
|
|
|
|
gcry_create_nonce (buf, 12);
|
|
|
|
|
cache_nonce = bin2hex (buf, 12, NULL);
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (cache_nonce
|
2018-03-27 08:40:58 +02:00
|
|
|
|
&& !agent_put_cache (ctrl, cache_nonce, CACHE_MODE_NONCE,
|
2011-04-12 18:20:46 +02:00
|
|
|
|
passphrase, CACHE_TTL_NONCE))
|
2010-10-26 11:10:29 +02:00
|
|
|
|
{
|
|
|
|
|
assuan_write_status (ctx, "CACHE_NONCE", cache_nonce);
|
|
|
|
|
xfree (ctrl->server_local->last_cache_nonce);
|
|
|
|
|
ctrl->server_local->last_cache_nonce = cache_nonce;
|
|
|
|
|
cache_nonce = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (newpass)
|
|
|
|
|
{
|
|
|
|
|
/* If we have a new passphrase (which might be empty) we
|
|
|
|
|
store it under a passwd nonce so that the caller may
|
|
|
|
|
send that nonce again to use it for another key. */
|
|
|
|
|
if (!passwd_nonce)
|
|
|
|
|
{
|
|
|
|
|
char buf[12];
|
|
|
|
|
gcry_create_nonce (buf, 12);
|
|
|
|
|
passwd_nonce = bin2hex (buf, 12, NULL);
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (passwd_nonce
|
2018-03-27 08:40:58 +02:00
|
|
|
|
&& !agent_put_cache (ctrl, passwd_nonce, CACHE_MODE_NONCE,
|
2011-04-12 18:20:46 +02:00
|
|
|
|
newpass, CACHE_TTL_NONCE))
|
2010-10-26 11:10:29 +02:00
|
|
|
|
{
|
|
|
|
|
assuan_write_status (ctx, "PASSWD_NONCE", passwd_nonce);
|
|
|
|
|
xfree (ctrl->server_local->last_passwd_nonce);
|
|
|
|
|
ctrl->server_local->last_passwd_nonce = passwd_nonce;
|
|
|
|
|
passwd_nonce = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-04-17 22:48:44 +02:00
|
|
|
|
if (!err && opt_preset)
|
2015-01-29 16:26:07 +01:00
|
|
|
|
{
|
2011-04-13 02:02:05 +02:00
|
|
|
|
char hexgrip[40+1];
|
|
|
|
|
bin2hex(grip, 20, hexgrip);
|
2018-03-27 08:40:58 +02:00
|
|
|
|
err = agent_put_cache (ctrl, hexgrip, CACHE_MODE_ANY, newpass,
|
2011-04-21 15:40:48 +02:00
|
|
|
|
ctrl->cache_ttl_opt_preset);
|
2015-01-29 16:26:07 +01:00
|
|
|
|
}
|
2010-10-26 11:10:29 +02:00
|
|
|
|
xfree (newpass);
|
|
|
|
|
}
|
2007-08-28 19:48:13 +02:00
|
|
|
|
ctrl->in_passwd--;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2004-02-21 14:05:22 +01:00
|
|
|
|
xfree (ctrl->server_local->keydesc);
|
|
|
|
|
ctrl->server_local->keydesc = NULL;
|
2007-01-25 09:30:47 +01:00
|
|
|
|
|
|
|
|
|
leave:
|
2010-10-26 11:10:29 +02:00
|
|
|
|
xfree (passphrase);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
gcry_sexp_release (s_skey);
|
|
|
|
|
xfree (shadow_info);
|
2010-10-26 11:10:29 +02:00
|
|
|
|
xfree (cache_nonce);
|
2016-06-02 21:21:08 +02:00
|
|
|
|
xfree (passwd_nonce);
|
2010-10-26 11:10:29 +02:00
|
|
|
|
return leave_cmd (ctx, err);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-11-04 12:58:06 +01:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_preset_passphrase[] =
|
2011-03-04 04:20:08 +01:00
|
|
|
|
"PRESET_PASSPHRASE [--inquire] <string_or_keygrip> <timeout> [<hexstring>]\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"\n"
|
|
|
|
|
"Set the cached passphrase/PIN for the key identified by the keygrip\n"
|
|
|
|
|
"to passwd for the given time, where -1 means infinite and 0 means\n"
|
|
|
|
|
"the default (currently only a timeout of -1 is allowed, which means\n"
|
|
|
|
|
"to never expire it). If passwd is not provided, ask for it via the\n"
|
2011-03-04 04:20:08 +01:00
|
|
|
|
"pinentry module unless --inquire is passed in which case the passphrase\n"
|
|
|
|
|
"is retrieved from the client via a server inquire.\n";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_preset_passphrase (assuan_context_t ctx, char *line)
|
2004-12-21 20:05:15 +01:00
|
|
|
|
{
|
2014-11-27 20:41:37 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2004-12-21 20:05:15 +01:00
|
|
|
|
int rc;
|
|
|
|
|
char *grip_clear = NULL;
|
2011-03-04 04:20:08 +01:00
|
|
|
|
unsigned char *passphrase = NULL;
|
2004-12-21 20:05:15 +01:00
|
|
|
|
int ttl;
|
2006-07-29 18:40:54 +02:00
|
|
|
|
size_t len;
|
2011-03-04 04:20:08 +01:00
|
|
|
|
int opt_inquire;
|
2004-12-21 20:05:15 +01:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2004-12-21 20:05:15 +01:00
|
|
|
|
if (!opt.allow_preset_passphrase)
|
2008-09-03 11:37:32 +02:00
|
|
|
|
return set_error (GPG_ERR_NOT_SUPPORTED, "no --allow-preset-passphrase");
|
2004-12-21 20:05:15 +01:00
|
|
|
|
|
2011-03-04 04:20:08 +01:00
|
|
|
|
opt_inquire = has_option (line, "--inquire");
|
|
|
|
|
line = skip_options (line);
|
2004-12-21 20:05:15 +01:00
|
|
|
|
grip_clear = line;
|
|
|
|
|
while (*line && (*line != ' ' && *line != '\t'))
|
|
|
|
|
line++;
|
|
|
|
|
if (!*line)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return gpg_error (GPG_ERR_MISSING_VALUE);
|
2004-12-21 20:05:15 +01:00
|
|
|
|
*line = '\0';
|
|
|
|
|
line++;
|
|
|
|
|
while (*line && (*line == ' ' || *line == '\t'))
|
|
|
|
|
line++;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2004-12-21 20:05:15 +01:00
|
|
|
|
/* Currently, only infinite timeouts are allowed. */
|
|
|
|
|
ttl = -1;
|
|
|
|
|
if (line[0] != '-' || line[1] != '1')
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
2004-12-21 20:05:15 +01:00
|
|
|
|
line++;
|
|
|
|
|
line++;
|
|
|
|
|
while (!(*line != ' ' && *line != '\t'))
|
|
|
|
|
line++;
|
|
|
|
|
|
2006-07-29 18:40:54 +02:00
|
|
|
|
/* Syntax check the hexstring. */
|
2009-11-04 12:58:06 +01:00
|
|
|
|
len = 0;
|
2006-07-29 18:40:54 +02:00
|
|
|
|
rc = parse_hexstring (ctx, line, &len);
|
|
|
|
|
if (rc)
|
|
|
|
|
return rc;
|
|
|
|
|
line[len] = '\0';
|
|
|
|
|
|
2004-12-21 20:05:15 +01:00
|
|
|
|
/* If there is a passphrase, use it. Currently, a passphrase is
|
|
|
|
|
required. */
|
|
|
|
|
if (*line)
|
2008-09-03 11:37:32 +02:00
|
|
|
|
{
|
2011-03-04 04:20:08 +01:00
|
|
|
|
if (opt_inquire)
|
|
|
|
|
{
|
|
|
|
|
rc = set_error (GPG_ERR_ASS_PARAMETER,
|
|
|
|
|
"both --inquire and passphrase specified");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-03 11:37:32 +02:00
|
|
|
|
/* Do in-place conversion. */
|
|
|
|
|
passphrase = line;
|
|
|
|
|
if (!hex2str (passphrase, passphrase, strlen (passphrase)+1, NULL))
|
|
|
|
|
rc = set_error (GPG_ERR_ASS_PARAMETER, "invalid hexstring");
|
|
|
|
|
}
|
2011-03-04 04:20:08 +01:00
|
|
|
|
else if (opt_inquire)
|
|
|
|
|
{
|
|
|
|
|
/* Note that the passphrase will be truncated at any null byte and the
|
|
|
|
|
* limit is 480 characters. */
|
2012-02-02 03:38:13 +01:00
|
|
|
|
size_t maxlen = 480;
|
|
|
|
|
|
2013-08-22 09:35:21 +02:00
|
|
|
|
rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%zu", maxlen);
|
2012-02-02 03:38:13 +01:00
|
|
|
|
if (!rc)
|
|
|
|
|
rc = assuan_inquire (ctx, "PASSPHRASE", &passphrase, &len, maxlen);
|
2011-03-04 04:20:08 +01:00
|
|
|
|
}
|
2004-12-21 20:05:15 +01:00
|
|
|
|
else
|
2008-09-03 11:37:32 +02:00
|
|
|
|
rc = set_error (GPG_ERR_NOT_IMPLEMENTED, "passphrase is required");
|
2004-12-21 20:05:15 +01:00
|
|
|
|
|
2008-09-03 11:37:32 +02:00
|
|
|
|
if (!rc)
|
2011-03-04 04:20:08 +01:00
|
|
|
|
{
|
2018-03-27 08:40:58 +02:00
|
|
|
|
rc = agent_put_cache (ctrl, grip_clear, CACHE_MODE_ANY, passphrase, ttl);
|
2011-03-04 04:20:08 +01:00
|
|
|
|
if (opt_inquire)
|
|
|
|
|
xfree (passphrase);
|
|
|
|
|
}
|
2004-12-21 20:05:15 +01:00
|
|
|
|
|
2011-03-04 04:20:08 +01:00
|
|
|
|
leave:
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, rc);
|
2004-12-21 20:05:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-11-04 12:58:06 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_scd[] =
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"SCD <commands to pass to the scdaemon>\n"
|
|
|
|
|
" \n"
|
|
|
|
|
"This is a general quote command to redirect everything to the\n"
|
|
|
|
|
"SCdaemon.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
cmd_scd (assuan_context_t ctx, char *line)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
|
|
|
|
int rc;
|
2017-10-26 04:24:39 +02:00
|
|
|
|
#ifdef BUILD_WITH_SCDAEMON
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2020-09-18 03:29:54 +02:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
2020-09-18 03:29:54 +02:00
|
|
|
|
{
|
|
|
|
|
const char *argv[5];
|
|
|
|
|
int argc;
|
|
|
|
|
char *l;
|
|
|
|
|
|
|
|
|
|
l = xtrystrdup (line);
|
|
|
|
|
if (!l)
|
|
|
|
|
return gpg_error_from_syserror ();
|
|
|
|
|
|
|
|
|
|
argc = split_fields (l, argv, DIM (argv));
|
|
|
|
|
|
|
|
|
|
/* These commands are allowed. */
|
|
|
|
|
if ((argc == 1 && !strcmp (argv[0], "SERIALNO"))
|
|
|
|
|
|| (argc == 2
|
|
|
|
|
&& !strcmp (argv[0], "GETINFO")
|
|
|
|
|
&& !strcmp (argv[1], "version"))
|
|
|
|
|
|| (argc == 2
|
|
|
|
|
&& !strcmp (argv[0], "GETATTR")
|
|
|
|
|
&& !strcmp (argv[1], "KEY-FPR"))
|
|
|
|
|
|| (argc == 2
|
|
|
|
|
&& !strcmp (argv[0], "KEYINFO")
|
|
|
|
|
&& !strcmp (argv[1], "--list=encr")))
|
|
|
|
|
xfree (l);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
xfree (l);
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-11-27 20:41:37 +01:00
|
|
|
|
|
2020-01-13 16:27:12 +01:00
|
|
|
|
/* All SCD prefixed commands may change a key. */
|
|
|
|
|
eventcounter.maybe_key_change++;
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
rc = divert_generic_cmd (ctrl, line, ctx);
|
2017-10-26 04:24:39 +02:00
|
|
|
|
#else
|
|
|
|
|
(void)ctx; (void)line;
|
|
|
|
|
rc = gpg_error (GPG_ERR_NOT_SUPPORTED);
|
|
|
|
|
#endif
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return rc;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-06-17 17:44:44 +02:00
|
|
|
|
|
|
|
|
|
static const char hlp_keywrap_key[] =
|
|
|
|
|
"KEYWRAP_KEY [--clear] <mode>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Return a key to wrap another key. For now the key is returned\n"
|
2017-02-20 22:19:50 +01:00
|
|
|
|
"verbatim and thus makes not much sense because an eavesdropper on\n"
|
2010-06-17 17:44:44 +02:00
|
|
|
|
"the gpg-agent connection will see the key as well as the wrapped key.\n"
|
|
|
|
|
"However, this function may either be equipped with a public key\n"
|
|
|
|
|
"mechanism or not used at all if the key is a pre-shared key. In any\n"
|
|
|
|
|
"case wrapping the import and export of keys is a requirement for\n"
|
|
|
|
|
"certain cryptographic validations and thus useful. The key persists\n"
|
2015-10-27 22:09:40 +01:00
|
|
|
|
"until a RESET command but may be cleared using the option --clear.\n"
|
2010-06-17 17:44:44 +02:00
|
|
|
|
"\n"
|
|
|
|
|
"Supported modes are:\n"
|
|
|
|
|
" --import - Return a key to import a key into gpg-agent\n"
|
|
|
|
|
" --export - Return a key to export a key from gpg-agent";
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_keywrap_key (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err = 0;
|
|
|
|
|
int clearopt = has_option (line, "--clear");
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
2010-06-17 17:44:44 +02:00
|
|
|
|
|
|
|
|
|
assuan_begin_confidential (ctx);
|
|
|
|
|
if (has_option (line, "--import"))
|
|
|
|
|
{
|
|
|
|
|
xfree (ctrl->server_local->import_key);
|
|
|
|
|
if (clearopt)
|
|
|
|
|
ctrl->server_local->import_key = NULL;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
else if (!(ctrl->server_local->import_key =
|
2010-06-17 17:44:44 +02:00
|
|
|
|
gcry_random_bytes (KEYWRAP_KEYSIZE, GCRY_STRONG_RANDOM)))
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
else
|
|
|
|
|
err = assuan_send_data (ctx, ctrl->server_local->import_key,
|
|
|
|
|
KEYWRAP_KEYSIZE);
|
|
|
|
|
}
|
|
|
|
|
else if (has_option (line, "--export"))
|
|
|
|
|
{
|
|
|
|
|
xfree (ctrl->server_local->export_key);
|
|
|
|
|
if (clearopt)
|
|
|
|
|
ctrl->server_local->export_key = NULL;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
else if (!(ctrl->server_local->export_key =
|
2010-06-17 17:44:44 +02:00
|
|
|
|
gcry_random_bytes (KEYWRAP_KEYSIZE, GCRY_STRONG_RANDOM)))
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
else
|
|
|
|
|
err = assuan_send_data (ctx, ctrl->server_local->export_key,
|
|
|
|
|
KEYWRAP_KEYSIZE);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for MODE");
|
|
|
|
|
assuan_end_confidential (ctx);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const char hlp_import_key[] =
|
2020-08-17 14:21:00 +02:00
|
|
|
|
"IMPORT_KEY [--unattended] [--force] [--timestamp=<isodate>]\n"
|
|
|
|
|
" [<cache_nonce>]\n"
|
2010-06-17 17:44:44 +02:00
|
|
|
|
"\n"
|
|
|
|
|
"Import a secret key into the key store. The key is expected to be\n"
|
|
|
|
|
"encrypted using the current session's key wrapping key (cf. command\n"
|
|
|
|
|
"KEYWRAP_KEY) using the AESWRAP-128 algorithm. This function takes\n"
|
|
|
|
|
"no arguments but uses the inquiry \"KEYDATA\" to ask for the actual\n"
|
2013-05-22 10:50:12 +02:00
|
|
|
|
"key data. The unwrapped key must be a canonical S-expression. The\n"
|
|
|
|
|
"option --unattended tries to import the key as-is without any\n"
|
2020-08-17 14:21:00 +02:00
|
|
|
|
"re-encryption. An existing key can be overwritten with --force.\n"
|
|
|
|
|
"If --timestamp is given its value is recorded as the key's creation\n"
|
|
|
|
|
"time; the value is expected in ISO format (e.g. \"20030316T120000\").";
|
2010-06-17 17:44:44 +02:00
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_import_key (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err;
|
2013-05-22 10:50:12 +02:00
|
|
|
|
int opt_unattended;
|
2020-08-17 14:21:00 +02:00
|
|
|
|
time_t opt_timestamp;
|
2015-12-24 01:51:16 +01:00
|
|
|
|
int force;
|
2010-06-17 17:44:44 +02:00
|
|
|
|
unsigned char *wrappedkey = NULL;
|
|
|
|
|
size_t wrappedkeylen;
|
|
|
|
|
gcry_cipher_hd_t cipherhd = NULL;
|
|
|
|
|
unsigned char *key = NULL;
|
|
|
|
|
size_t keylen, realkeylen;
|
|
|
|
|
char *passphrase = NULL;
|
|
|
|
|
unsigned char *finalkey = NULL;
|
|
|
|
|
size_t finalkeylen;
|
|
|
|
|
unsigned char grip[20];
|
2010-08-31 17:58:39 +02:00
|
|
|
|
gcry_sexp_t openpgp_sexp = NULL;
|
2010-09-01 11:48:35 +02:00
|
|
|
|
char *cache_nonce = NULL;
|
|
|
|
|
char *p;
|
2020-08-17 14:21:00 +02:00
|
|
|
|
const char *s;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2010-06-17 17:44:44 +02:00
|
|
|
|
if (!ctrl->server_local->import_key)
|
|
|
|
|
{
|
2010-06-21 12:01:24 +02:00
|
|
|
|
err = gpg_error (GPG_ERR_MISSING_KEY);
|
2010-06-17 17:44:44 +02:00
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-22 10:50:12 +02:00
|
|
|
|
opt_unattended = has_option (line, "--unattended");
|
2015-12-24 01:51:16 +01:00
|
|
|
|
force = has_option (line, "--force");
|
2020-08-17 14:21:00 +02:00
|
|
|
|
if ((s=has_option_name (line, "--timestamp")))
|
|
|
|
|
{
|
|
|
|
|
if (*s != '=')
|
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER, "missing value for option");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
opt_timestamp = isotime2epoch (s+1);
|
|
|
|
|
if (opt_timestamp < 1)
|
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER, "invalid time value");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
opt_timestamp = 0;
|
2013-05-22 10:50:12 +02:00
|
|
|
|
line = skip_options (line);
|
|
|
|
|
|
2010-09-01 11:48:35 +02:00
|
|
|
|
for (p=line; *p && *p != ' ' && *p != '\t'; p++)
|
|
|
|
|
;
|
|
|
|
|
*p = '\0';
|
|
|
|
|
if (*line)
|
|
|
|
|
cache_nonce = xtrystrdup (line);
|
|
|
|
|
|
2020-01-13 16:27:12 +01:00
|
|
|
|
eventcounter.maybe_key_change++;
|
|
|
|
|
|
2010-06-17 17:44:44 +02:00
|
|
|
|
assuan_begin_confidential (ctx);
|
|
|
|
|
err = assuan_inquire (ctx, "KEYDATA",
|
|
|
|
|
&wrappedkey, &wrappedkeylen, MAXLEN_KEYDATA);
|
|
|
|
|
assuan_end_confidential (ctx);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
if (wrappedkeylen < 24)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_INV_LENGTH);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
keylen = wrappedkeylen - 8;
|
|
|
|
|
key = xtrymalloc_secure (keylen);
|
|
|
|
|
if (!key)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = gcry_cipher_open (&cipherhd, GCRY_CIPHER_AES128,
|
|
|
|
|
GCRY_CIPHER_MODE_AESWRAP, 0);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
err = gcry_cipher_setkey (cipherhd,
|
|
|
|
|
ctrl->server_local->import_key, KEYWRAP_KEYSIZE);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
err = gcry_cipher_decrypt (cipherhd, key, keylen, wrappedkey, wrappedkeylen);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
gcry_cipher_close (cipherhd);
|
|
|
|
|
cipherhd = NULL;
|
|
|
|
|
xfree (wrappedkey);
|
|
|
|
|
wrappedkey = NULL;
|
|
|
|
|
|
|
|
|
|
realkeylen = gcry_sexp_canon_len (key, keylen, NULL, &err);
|
|
|
|
|
if (!realkeylen)
|
|
|
|
|
goto leave; /* Invalid canonical encoded S-expression. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2010-06-17 17:44:44 +02:00
|
|
|
|
err = keygrip_from_canon_sexp (key, realkeylen, grip);
|
|
|
|
|
if (err)
|
|
|
|
|
{
|
2010-08-31 17:58:39 +02:00
|
|
|
|
/* This might be due to an unsupported S-expression format.
|
|
|
|
|
Check whether this is openpgp-private-key and trigger that
|
|
|
|
|
import code. */
|
|
|
|
|
if (!gcry_sexp_sscan (&openpgp_sexp, NULL, key, realkeylen))
|
|
|
|
|
{
|
|
|
|
|
const char *tag;
|
|
|
|
|
size_t taglen;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2010-08-31 17:58:39 +02:00
|
|
|
|
tag = gcry_sexp_nth_data (openpgp_sexp, 0, &taglen);
|
|
|
|
|
if (tag && taglen == 19 && !memcmp (tag, "openpgp-private-key", 19))
|
|
|
|
|
;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gcry_sexp_release (openpgp_sexp);
|
|
|
|
|
openpgp_sexp = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!openpgp_sexp)
|
|
|
|
|
goto leave; /* Note that ERR is still set. */
|
2010-06-17 17:44:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-31 17:58:39 +02:00
|
|
|
|
if (openpgp_sexp)
|
|
|
|
|
{
|
|
|
|
|
/* In most cases the key is encrypted and thus the conversion
|
|
|
|
|
function from the OpenPGP format to our internal format will
|
|
|
|
|
ask for a passphrase. That passphrase will be returned and
|
|
|
|
|
used to protect the key using the same code as for regular
|
|
|
|
|
key import. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2011-04-20 11:33:09 +02:00
|
|
|
|
xfree (key);
|
|
|
|
|
key = NULL;
|
2015-12-24 06:19:53 +01:00
|
|
|
|
err = convert_from_openpgp (ctrl, openpgp_sexp, force, grip,
|
2010-10-01 22:33:53 +02:00
|
|
|
|
ctrl->server_local->keydesc, cache_nonce,
|
2013-05-22 10:50:12 +02:00
|
|
|
|
&key, opt_unattended? NULL : &passphrase);
|
2010-08-31 17:58:39 +02:00
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
2013-05-21 14:00:16 +02:00
|
|
|
|
realkeylen = gcry_sexp_canon_len (key, 0, NULL, &err);
|
2010-08-31 17:58:39 +02:00
|
|
|
|
if (!realkeylen)
|
|
|
|
|
goto leave; /* Invalid canonical encoded S-expression. */
|
2010-09-01 11:48:35 +02:00
|
|
|
|
if (passphrase)
|
|
|
|
|
{
|
2019-05-14 10:31:46 +02:00
|
|
|
|
log_assert (!opt_unattended);
|
2010-09-01 11:48:35 +02:00
|
|
|
|
if (!cache_nonce)
|
|
|
|
|
{
|
|
|
|
|
char buf[12];
|
|
|
|
|
gcry_create_nonce (buf, 12);
|
|
|
|
|
cache_nonce = bin2hex (buf, 12, NULL);
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (cache_nonce
|
2018-03-27 08:40:58 +02:00
|
|
|
|
&& !agent_put_cache (ctrl, cache_nonce, CACHE_MODE_NONCE,
|
2011-04-12 18:20:46 +02:00
|
|
|
|
passphrase, CACHE_TTL_NONCE))
|
2010-09-01 11:48:35 +02:00
|
|
|
|
assuan_write_status (ctx, "CACHE_NONCE", cache_nonce);
|
|
|
|
|
}
|
2010-08-31 17:58:39 +02:00
|
|
|
|
}
|
2013-05-22 10:50:12 +02:00
|
|
|
|
else if (opt_unattended)
|
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER,
|
|
|
|
|
"\"--unattended\" may only be used with OpenPGP keys");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2010-08-31 17:58:39 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2015-12-24 01:51:16 +01:00
|
|
|
|
if (!force && !agent_key_available (grip))
|
2010-08-31 17:58:39 +02:00
|
|
|
|
err = gpg_error (GPG_ERR_EEXIST);
|
|
|
|
|
else
|
2013-11-18 14:09:47 +01:00
|
|
|
|
{
|
|
|
|
|
char *prompt = xtryasprintf
|
|
|
|
|
(_("Please enter the passphrase to protect the "
|
|
|
|
|
"imported object within the %s system."), GNUPG_NAME);
|
|
|
|
|
if (!prompt)
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
else
|
|
|
|
|
err = agent_ask_new_passphrase (ctrl, prompt, &passphrase);
|
|
|
|
|
xfree (prompt);
|
|
|
|
|
}
|
2010-08-31 17:58:39 +02:00
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2010-06-17 17:44:44 +02:00
|
|
|
|
|
|
|
|
|
if (passphrase)
|
|
|
|
|
{
|
2011-06-29 02:35:13 +02:00
|
|
|
|
err = agent_protect (key, passphrase, &finalkey, &finalkeylen,
|
2016-04-12 14:37:26 +02:00
|
|
|
|
ctrl->s2k_count, -1);
|
2010-06-17 17:44:44 +02:00
|
|
|
|
if (!err)
|
2019-05-03 15:54:54 +02:00
|
|
|
|
err = agent_write_private_key (grip, finalkey, finalkeylen, force,
|
2020-08-17 14:21:00 +02:00
|
|
|
|
NULL, NULL, opt_timestamp);
|
2010-06-17 17:44:44 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2020-08-17 14:21:00 +02:00
|
|
|
|
err = agent_write_private_key (grip, key, realkeylen, force, NULL, NULL,
|
|
|
|
|
opt_timestamp);
|
2010-06-17 17:44:44 +02:00
|
|
|
|
|
|
|
|
|
leave:
|
2010-08-31 17:58:39 +02:00
|
|
|
|
gcry_sexp_release (openpgp_sexp);
|
2010-06-17 17:44:44 +02:00
|
|
|
|
xfree (finalkey);
|
|
|
|
|
xfree (passphrase);
|
|
|
|
|
xfree (key);
|
|
|
|
|
gcry_cipher_close (cipherhd);
|
|
|
|
|
xfree (wrappedkey);
|
2010-09-01 11:48:35 +02:00
|
|
|
|
xfree (cache_nonce);
|
2010-08-31 17:58:39 +02:00
|
|
|
|
xfree (ctrl->server_local->keydesc);
|
|
|
|
|
ctrl->server_local->keydesc = NULL;
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const char hlp_export_key[] =
|
2010-10-01 22:33:53 +02:00
|
|
|
|
"EXPORT_KEY [--cache-nonce=<nonce>] [--openpgp] <hexstring_with_keygrip>\n"
|
2010-06-21 12:01:24 +02:00
|
|
|
|
"\n"
|
|
|
|
|
"Export a secret key from the key store. The key will be encrypted\n"
|
|
|
|
|
"using the current session's key wrapping key (cf. command KEYWRAP_KEY)\n"
|
|
|
|
|
"using the AESWRAP-128 algorithm. The caller needs to retrieve that key\n"
|
2016-06-10 22:15:34 +02:00
|
|
|
|
"prior to using this command. The function takes the keygrip as argument.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"If --openpgp is used, the secret key material will be exported in RFC 4880\n"
|
|
|
|
|
"compatible passphrase-protected form. Without --openpgp, the secret key\n"
|
|
|
|
|
"material will be exported in the clear (after prompting the user to unlock\n"
|
|
|
|
|
"it, if needed).\n";
|
2010-06-17 17:44:44 +02:00
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_export_key (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
2010-06-21 12:01:24 +02:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
unsigned char grip[20];
|
|
|
|
|
gcry_sexp_t s_skey = NULL;
|
|
|
|
|
unsigned char *key = NULL;
|
|
|
|
|
size_t keylen;
|
|
|
|
|
gcry_cipher_hd_t cipherhd = NULL;
|
|
|
|
|
unsigned char *wrappedkey = NULL;
|
|
|
|
|
size_t wrappedkeylen;
|
2010-10-01 22:33:53 +02:00
|
|
|
|
int openpgp;
|
|
|
|
|
char *cache_nonce;
|
|
|
|
|
char *passphrase = NULL;
|
2014-03-04 03:54:59 +01:00
|
|
|
|
unsigned char *shadow_info = NULL;
|
2014-11-02 17:51:30 +01:00
|
|
|
|
char *pend;
|
|
|
|
|
int c;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2010-10-01 22:33:53 +02:00
|
|
|
|
openpgp = has_option (line, "--openpgp");
|
|
|
|
|
cache_nonce = option_value (line, "--cache-nonce");
|
|
|
|
|
if (cache_nonce)
|
|
|
|
|
{
|
2014-11-02 17:51:30 +01:00
|
|
|
|
for (pend = cache_nonce; *pend && !spacep (pend); pend++)
|
2010-10-01 22:33:53 +02:00
|
|
|
|
;
|
2014-11-02 17:51:30 +01:00
|
|
|
|
c = *pend;
|
|
|
|
|
*pend = '\0';
|
2010-10-01 22:33:53 +02:00
|
|
|
|
cache_nonce = xtrystrdup (cache_nonce);
|
2014-11-02 17:51:30 +01:00
|
|
|
|
*pend = c;
|
2010-10-01 22:33:53 +02:00
|
|
|
|
if (!cache_nonce)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
line = skip_options (line);
|
2010-06-21 12:01:24 +02:00
|
|
|
|
|
|
|
|
|
if (!ctrl->server_local->export_key)
|
|
|
|
|
{
|
2014-04-15 16:40:48 +02:00
|
|
|
|
err = set_error (GPG_ERR_MISSING_KEY, "did you run KEYWRAP_KEY ?");
|
2010-06-21 12:01:24 +02:00
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = parse_keygrip (ctx, line, grip);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
|
|
|
|
|
if (agent_key_available (grip))
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_NO_SECKEY);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-01 22:33:53 +02:00
|
|
|
|
/* Get the key from the file. With the openpgp flag we also ask for
|
|
|
|
|
the passphrase so that we can use it to re-encrypt it. */
|
2014-11-02 17:51:30 +01:00
|
|
|
|
err = agent_key_from_file (ctrl, cache_nonce,
|
|
|
|
|
ctrl->server_local->keydesc, grip,
|
2014-03-04 03:54:59 +01:00
|
|
|
|
&shadow_info, CACHE_MODE_IGNORE, NULL, &s_skey,
|
2010-10-01 22:33:53 +02:00
|
|
|
|
openpgp ? &passphrase : NULL);
|
2010-06-21 12:01:24 +02:00
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
2014-03-04 03:54:59 +01:00
|
|
|
|
if (shadow_info)
|
2010-06-21 12:01:24 +02:00
|
|
|
|
{
|
2014-03-04 03:54:59 +01:00
|
|
|
|
/* Key is on a smartcard. */
|
2010-06-21 12:01:24 +02:00
|
|
|
|
err = gpg_error (GPG_ERR_UNUSABLE_SECKEY);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2010-10-01 22:33:53 +02:00
|
|
|
|
if (openpgp)
|
|
|
|
|
{
|
|
|
|
|
/* The openpgp option changes the key format into the OpenPGP
|
|
|
|
|
key transfer format. The result is already a padded
|
|
|
|
|
canonical S-expression. */
|
|
|
|
|
if (!passphrase)
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
err = agent_ask_new_passphrase
|
2010-10-01 22:33:53 +02:00
|
|
|
|
(ctrl, _("This key (or subkey) is not protected with a passphrase."
|
|
|
|
|
" Please enter a new passphrase to export it."),
|
2010-10-13 17:57:08 +02:00
|
|
|
|
&passphrase);
|
2010-10-01 22:33:53 +02:00
|
|
|
|
if (err)
|
2010-10-13 17:57:08 +02:00
|
|
|
|
goto leave;
|
2010-10-01 22:33:53 +02:00
|
|
|
|
}
|
|
|
|
|
err = convert_to_openpgp (ctrl, s_skey, passphrase, &key, &keylen);
|
2014-11-02 17:51:30 +01:00
|
|
|
|
if (!err && passphrase)
|
|
|
|
|
{
|
|
|
|
|
if (!cache_nonce)
|
|
|
|
|
{
|
|
|
|
|
char buf[12];
|
|
|
|
|
gcry_create_nonce (buf, 12);
|
|
|
|
|
cache_nonce = bin2hex (buf, 12, NULL);
|
|
|
|
|
}
|
|
|
|
|
if (cache_nonce
|
2018-03-27 08:40:58 +02:00
|
|
|
|
&& !agent_put_cache (ctrl, cache_nonce, CACHE_MODE_NONCE,
|
2014-11-02 17:51:30 +01:00
|
|
|
|
passphrase, CACHE_TTL_NONCE))
|
|
|
|
|
{
|
|
|
|
|
assuan_write_status (ctx, "CACHE_NONCE", cache_nonce);
|
|
|
|
|
xfree (ctrl->server_local->last_cache_nonce);
|
|
|
|
|
ctrl->server_local->last_cache_nonce = cache_nonce;
|
|
|
|
|
cache_nonce = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-10-01 22:33:53 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Convert into a canonical S-expression and wrap that. */
|
|
|
|
|
err = make_canon_sexp_pad (s_skey, 1, &key, &keylen);
|
|
|
|
|
}
|
2010-06-21 12:01:24 +02:00
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
gcry_sexp_release (s_skey);
|
|
|
|
|
s_skey = NULL;
|
|
|
|
|
|
|
|
|
|
err = gcry_cipher_open (&cipherhd, GCRY_CIPHER_AES128,
|
|
|
|
|
GCRY_CIPHER_MODE_AESWRAP, 0);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
err = gcry_cipher_setkey (cipherhd,
|
|
|
|
|
ctrl->server_local->export_key, KEYWRAP_KEYSIZE);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
2010-06-17 17:44:44 +02:00
|
|
|
|
|
2010-06-21 12:01:24 +02:00
|
|
|
|
wrappedkeylen = keylen + 8;
|
|
|
|
|
wrappedkey = xtrymalloc (wrappedkeylen);
|
|
|
|
|
if (!wrappedkey)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2010-06-17 17:44:44 +02:00
|
|
|
|
|
2010-06-21 12:01:24 +02:00
|
|
|
|
err = gcry_cipher_encrypt (cipherhd, wrappedkey, wrappedkeylen, key, keylen);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
xfree (key);
|
|
|
|
|
key = NULL;
|
|
|
|
|
gcry_cipher_close (cipherhd);
|
|
|
|
|
cipherhd = NULL;
|
|
|
|
|
|
|
|
|
|
assuan_begin_confidential (ctx);
|
|
|
|
|
err = assuan_send_data (ctx, wrappedkey, wrappedkeylen);
|
|
|
|
|
assuan_end_confidential (ctx);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2010-06-21 12:01:24 +02:00
|
|
|
|
|
|
|
|
|
leave:
|
2010-10-26 11:10:29 +02:00
|
|
|
|
xfree (cache_nonce);
|
2010-10-01 22:33:53 +02:00
|
|
|
|
xfree (passphrase);
|
2010-06-21 12:01:24 +02:00
|
|
|
|
xfree (wrappedkey);
|
|
|
|
|
gcry_cipher_close (cipherhd);
|
|
|
|
|
xfree (key);
|
|
|
|
|
gcry_sexp_release (s_skey);
|
|
|
|
|
xfree (ctrl->server_local->keydesc);
|
|
|
|
|
ctrl->server_local->keydesc = NULL;
|
2014-03-04 03:54:59 +01:00
|
|
|
|
xfree (shadow_info);
|
2010-10-01 22:33:53 +02:00
|
|
|
|
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
2014-04-15 16:40:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const char hlp_delete_key[] =
|
2017-03-24 09:02:02 +01:00
|
|
|
|
"DELETE_KEY [--force|--stub-only] <hexstring_with_keygrip>\n"
|
2014-04-15 16:40:48 +02:00
|
|
|
|
"\n"
|
2016-05-10 11:01:42 +02:00
|
|
|
|
"Delete a secret key from the key store. If --force is used\n"
|
|
|
|
|
"and a loopback pinentry is allowed, the agent will not ask\n"
|
2017-03-24 09:02:02 +01:00
|
|
|
|
"the user for confirmation. If --stub-only is used the key will\n"
|
|
|
|
|
"only be deleted if it is a reference to a token.";
|
2014-04-15 16:40:48 +02:00
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_delete_key (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err;
|
2017-03-24 09:02:02 +01:00
|
|
|
|
int force, stub_only;
|
2014-04-15 16:40:48 +02:00
|
|
|
|
unsigned char grip[20];
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2015-08-07 12:55:29 +02:00
|
|
|
|
force = has_option (line, "--force");
|
2017-03-24 09:02:02 +01:00
|
|
|
|
stub_only = has_option (line, "--stub-only");
|
2014-04-15 16:40:48 +02:00
|
|
|
|
line = skip_options (line);
|
|
|
|
|
|
2020-01-13 16:27:12 +01:00
|
|
|
|
eventcounter.maybe_key_change++;
|
|
|
|
|
|
2016-05-10 11:01:42 +02:00
|
|
|
|
/* If the use of a loopback pinentry has been disabled, we assume
|
|
|
|
|
* that a silent deletion of keys shall also not be allowed. */
|
|
|
|
|
if (!opt.allow_loopback_pinentry)
|
|
|
|
|
force = 0;
|
|
|
|
|
|
2014-04-15 16:40:48 +02:00
|
|
|
|
err = parse_keygrip (ctx, line, grip);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
|
2017-03-24 09:02:02 +01:00
|
|
|
|
err = agent_delete_key (ctrl, ctrl->server_local->keydesc, grip,
|
|
|
|
|
force, stub_only);
|
2014-04-15 16:40:48 +02:00
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
xfree (ctrl->server_local->keydesc);
|
|
|
|
|
ctrl->server_local->keydesc = NULL;
|
|
|
|
|
|
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-02-06 06:00:05 +01:00
|
|
|
|
|
2017-04-10 08:04:57 +02:00
|
|
|
|
#if SIZEOF_TIME_T > SIZEOF_UNSIGNED_LONG
|
|
|
|
|
#define KEYTOCARD_TIMESTAMP_FORMAT "(10:created-at10:%010llu))"
|
|
|
|
|
#else
|
|
|
|
|
#define KEYTOCARD_TIMESTAMP_FORMAT "(10:created-at10:%010lu))"
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-02-06 06:00:05 +01:00
|
|
|
|
static const char hlp_keytocard[] =
|
2019-03-05 12:08:27 +01:00
|
|
|
|
"KEYTOCARD [--force] <hexgrip> <serialno> <keyref> [<timestamp>]\n"
|
|
|
|
|
"\n"
|
2019-03-05 15:49:20 +01:00
|
|
|
|
"TIMESTAMP is required for OpenPGP and defaults to the Epoch. The\n"
|
|
|
|
|
"SERIALNO is used for checking; use \"-\" to disable the check.";
|
2013-02-06 06:00:05 +01:00
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_keytocard (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
int force;
|
|
|
|
|
gpg_error_t err = 0;
|
common,agent,dirmngr,g10,tools: Fix split_fields API.
* common/stringhelp.h (split_fields): Use const * for the strings in
the ARRAY.
(split_fields_colon): Likewise.
* common/stringhelp.c (split_fields, split_fields_colon): Fix
the implementation.
* agent/call-scd.c, agent/command.c: Follow the change.
* common/t-stringhelp.c, dirmngr/loadswdb.c: Likewise.
* g10/call-agent.c, tools/card-call-scd.c: Likewise.
* tools/card-yubikey.c, tools/gpg-card.c: Likewise.
* tools/gpg-card.h, tools/gpg-wks-client.c: Likewise.
* tools/gpgconf-comp.c, tools/gpgconf.c: Likewise.
* tools/wks-util.c: Likewise.
--
The strings in the ARRAY don't need to be released by caller, as those
are references. It's easier to follow the code when it's explicitly
const *.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-09-18 03:20:23 +02:00
|
|
|
|
const char *argv[5];
|
2019-03-05 12:08:27 +01:00
|
|
|
|
int argc;
|
2013-02-06 06:00:05 +01:00
|
|
|
|
unsigned char grip[20];
|
2019-03-05 12:08:27 +01:00
|
|
|
|
const char *serialno, *timestamp_str, *keyref;
|
2013-02-06 06:00:05 +01:00
|
|
|
|
gcry_sexp_t s_skey = NULL;
|
|
|
|
|
unsigned char *keydata;
|
2017-03-02 12:29:31 +01:00
|
|
|
|
size_t keydatalen;
|
2014-03-04 03:54:59 +01:00
|
|
|
|
unsigned char *shadow_info = NULL;
|
2013-02-06 06:00:05 +01:00
|
|
|
|
time_t timestamp;
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2013-02-06 06:00:05 +01:00
|
|
|
|
force = has_option (line, "--force");
|
|
|
|
|
line = skip_options (line);
|
|
|
|
|
|
2019-03-05 12:08:27 +01:00
|
|
|
|
argc = split_fields (line, argv, DIM (argv));
|
|
|
|
|
if (argc < 3)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_MISSING_VALUE);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = parse_keygrip (ctx, argv[0], grip);
|
2013-02-06 06:00:05 +01:00
|
|
|
|
if (err)
|
2017-03-02 12:29:31 +01:00
|
|
|
|
goto leave;
|
2013-02-06 06:00:05 +01:00
|
|
|
|
|
|
|
|
|
if (agent_key_available (grip))
|
2017-03-02 12:29:31 +01:00
|
|
|
|
{
|
|
|
|
|
err =gpg_error (GPG_ERR_NO_SECKEY);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2013-02-06 06:00:05 +01:00
|
|
|
|
|
2019-03-05 15:49:20 +01:00
|
|
|
|
/* Note that checking of the s/n is currently not implemented but we
|
|
|
|
|
* want to provide a clean interface if we ever implement it. */
|
2019-03-05 12:08:27 +01:00
|
|
|
|
serialno = argv[1];
|
2019-03-05 15:49:20 +01:00
|
|
|
|
if (!strcmp (serialno, "-"))
|
|
|
|
|
serialno = NULL;
|
|
|
|
|
|
2019-03-05 12:08:27 +01:00
|
|
|
|
keyref = argv[2];
|
2019-03-05 15:49:20 +01:00
|
|
|
|
|
|
|
|
|
/* FIXME: Default to the creation time as stored in the private
|
|
|
|
|
* key. The parameter is here so that gpg can make sure that the
|
|
|
|
|
* timestamp as used for key creation (and thus the openPGP
|
|
|
|
|
* fingerprint) is used. */
|
2019-03-05 12:08:27 +01:00
|
|
|
|
timestamp_str = argc > 3? argv[3] : "19700101T000000";
|
2017-03-02 12:29:31 +01:00
|
|
|
|
|
|
|
|
|
if ((timestamp = isotime2epoch (timestamp_str)) == (time_t)(-1))
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_INV_TIME);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2013-02-06 06:00:05 +01:00
|
|
|
|
|
|
|
|
|
err = agent_key_from_file (ctrl, NULL, ctrl->server_local->keydesc, grip,
|
2014-03-04 03:54:59 +01:00
|
|
|
|
&shadow_info, CACHE_MODE_IGNORE, NULL,
|
|
|
|
|
&s_skey, NULL);
|
2013-02-06 06:00:05 +01:00
|
|
|
|
if (err)
|
2019-03-05 12:08:27 +01:00
|
|
|
|
goto leave;
|
2014-03-04 03:54:59 +01:00
|
|
|
|
if (shadow_info)
|
|
|
|
|
{
|
2019-03-05 12:08:27 +01:00
|
|
|
|
/* Key is already on a smartcard - we can't extract it. */
|
2017-03-02 12:29:31 +01:00
|
|
|
|
err = gpg_error (GPG_ERR_UNUSABLE_SECKEY);
|
|
|
|
|
goto leave;
|
2014-03-04 03:54:59 +01:00
|
|
|
|
}
|
2013-02-06 06:00:05 +01:00
|
|
|
|
|
2019-03-05 12:08:27 +01:00
|
|
|
|
/* Note: We can't use make_canon_sexp because we need to allocate a
|
|
|
|
|
* few extra bytes for our hack below. */
|
|
|
|
|
keydatalen = gcry_sexp_sprint (s_skey, GCRYSEXP_FMT_CANON, NULL, 0);
|
2013-02-06 06:00:05 +01:00
|
|
|
|
keydata = xtrymalloc_secure (keydatalen + 30);
|
|
|
|
|
if (keydata == NULL)
|
|
|
|
|
{
|
2017-03-02 12:29:31 +01:00
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
2013-02-06 06:00:05 +01:00
|
|
|
|
}
|
|
|
|
|
gcry_sexp_sprint (s_skey, GCRYSEXP_FMT_CANON, keydata, keydatalen);
|
|
|
|
|
gcry_sexp_release (s_skey);
|
2019-03-05 12:08:27 +01:00
|
|
|
|
s_skey = NULL;
|
2013-02-22 04:55:11 +01:00
|
|
|
|
keydatalen--; /* Decrement for last '\0'. */
|
2019-03-05 12:08:27 +01:00
|
|
|
|
/* Hack to insert the timestamp "created-at" into the private key. */
|
2017-04-10 08:04:57 +02:00
|
|
|
|
snprintf (keydata+keydatalen-1, 30, KEYTOCARD_TIMESTAMP_FORMAT, timestamp);
|
2013-02-06 06:00:05 +01:00
|
|
|
|
keydatalen += 10 + 19 - 1;
|
2019-03-05 12:08:27 +01:00
|
|
|
|
|
|
|
|
|
err = divert_writekey (ctrl, force, serialno, keyref, keydata, keydatalen);
|
2013-02-06 06:00:05 +01:00
|
|
|
|
xfree (keydata);
|
|
|
|
|
|
2017-03-02 12:29:31 +01:00
|
|
|
|
leave:
|
2019-03-05 12:08:27 +01:00
|
|
|
|
gcry_sexp_release (s_skey);
|
|
|
|
|
xfree (shadow_info);
|
2013-02-06 06:00:05 +01:00
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
2014-11-27 20:41:37 +01:00
|
|
|
|
|
|
|
|
|
|
2018-07-02 21:24:15 +02:00
|
|
|
|
|
|
|
|
|
static const char hlp_get_secret[] =
|
|
|
|
|
"GET_SECRET <key>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Return the secret value stored under KEY\n";
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_get_secret (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
char *p, *key;
|
|
|
|
|
char *value = NULL;
|
|
|
|
|
size_t valuelen;
|
|
|
|
|
|
|
|
|
|
/* For now we allow this only for local connections. */
|
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_FORBIDDEN);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
line = skip_options (line);
|
|
|
|
|
|
|
|
|
|
for (p=line; *p == ' '; p++)
|
|
|
|
|
;
|
|
|
|
|
key = p;
|
|
|
|
|
p = strchr (key, ' ');
|
|
|
|
|
if (p)
|
|
|
|
|
{
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
for (; *p == ' '; p++)
|
|
|
|
|
;
|
|
|
|
|
if (*p)
|
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER, "too many arguments");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!*key)
|
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER, "no key given");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
value = agent_get_cache (ctrl, key, CACHE_MODE_DATA);
|
|
|
|
|
if (!value)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_NO_DATA);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
valuelen = percent_unescape_inplace (value, 0);
|
|
|
|
|
err = assuan_send_data (ctx, value, valuelen);
|
|
|
|
|
wipememory (value, valuelen);
|
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
xfree (value);
|
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const char hlp_put_secret[] =
|
|
|
|
|
"PUT_SECRET [--clear] <key> <ttl> [<percent_escaped_value>]\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"This commands stores a secret under KEY in gpg-agent's in-memory\n"
|
|
|
|
|
"cache. The TTL must be explicitly given by TTL and the options\n"
|
|
|
|
|
"from the configuration file are not used. The value is either given\n"
|
|
|
|
|
"percent-escaped as 3rd argument or if not given inquired by gpg-agent\n"
|
|
|
|
|
"using the keyword \"SECRET\".\n"
|
|
|
|
|
"The option --clear removes the secret from the cache."
|
|
|
|
|
"";
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_put_secret (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err = 0;
|
|
|
|
|
int opt_clear;
|
|
|
|
|
unsigned char *value = NULL;
|
|
|
|
|
size_t valuelen = 0;
|
|
|
|
|
size_t n;
|
|
|
|
|
char *p, *key, *ttlstr;
|
|
|
|
|
unsigned char *valstr;
|
|
|
|
|
int ttl;
|
|
|
|
|
char *string = NULL;
|
|
|
|
|
|
|
|
|
|
/* For now we allow this only for local connections. */
|
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_FORBIDDEN);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
opt_clear = has_option (line, "--clear");
|
|
|
|
|
line = skip_options (line);
|
|
|
|
|
|
|
|
|
|
for (p=line; *p == ' '; p++)
|
|
|
|
|
;
|
|
|
|
|
key = p;
|
|
|
|
|
ttlstr = NULL;
|
|
|
|
|
valstr = NULL;
|
|
|
|
|
p = strchr (key, ' ');
|
|
|
|
|
if (p)
|
|
|
|
|
{
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
for (; *p == ' '; p++)
|
|
|
|
|
;
|
|
|
|
|
if (*p)
|
|
|
|
|
{
|
|
|
|
|
ttlstr = p;
|
|
|
|
|
p = strchr (ttlstr, ' ');
|
|
|
|
|
if (p)
|
|
|
|
|
{
|
|
|
|
|
*p++ = 0;
|
|
|
|
|
for (; *p == ' '; p++)
|
|
|
|
|
;
|
|
|
|
|
if (*p)
|
|
|
|
|
valstr = p;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!*key)
|
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER, "no key given");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
if (!ttlstr || !*ttlstr || !(n = parse_ttl (ttlstr, &ttl)))
|
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER, "no or invalid TTL given");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
if (valstr && opt_clear)
|
|
|
|
|
{
|
|
|
|
|
err = set_error (GPG_ERR_ASS_PARAMETER,
|
|
|
|
|
"value not expected with --clear");
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (valstr)
|
|
|
|
|
{
|
|
|
|
|
valuelen = percent_unescape_inplace (valstr, 0);
|
|
|
|
|
value = NULL;
|
|
|
|
|
}
|
|
|
|
|
else /* Inquire the value to store */
|
|
|
|
|
{
|
|
|
|
|
err = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%u",MAXLEN_PUT_SECRET);
|
|
|
|
|
if (!err)
|
|
|
|
|
err = assuan_inquire (ctx, "SECRET",
|
|
|
|
|
&value, &valuelen, MAXLEN_PUT_SECRET);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Our cache expects strings and thus we need to turn the buffer
|
|
|
|
|
* into a string. Instead of resorting to base64 encoding we use a
|
|
|
|
|
* special percent escaping which only quoted the Nul and the
|
|
|
|
|
* percent character. */
|
2019-01-24 10:02:52 +01:00
|
|
|
|
string = percent_data_escape (0, NULL, value? value : valstr, valuelen);
|
2018-07-02 21:24:15 +02:00
|
|
|
|
if (!string)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
err = agent_put_cache (ctrl, key, CACHE_MODE_DATA, string, ttl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
if (string)
|
|
|
|
|
{
|
|
|
|
|
wipememory (string, strlen (string));
|
|
|
|
|
xfree (string);
|
|
|
|
|
}
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
wipememory (value, valuelen);
|
|
|
|
|
xfree (value);
|
|
|
|
|
}
|
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-03-09 22:50:30 +01:00
|
|
|
|
|
|
|
|
|
static const char hlp_keytotpm[] =
|
|
|
|
|
"KEYTOTPM <hexstring_with_keygrip>\n"
|
|
|
|
|
"\n";
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
cmd_keytotpm (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
gpg_error_t err = 0;
|
|
|
|
|
unsigned char grip[20];
|
|
|
|
|
gcry_sexp_t s_skey;
|
|
|
|
|
unsigned char *shadow_info = NULL;
|
|
|
|
|
|
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
|
|
|
|
err = parse_keygrip (ctx, line, grip);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
|
|
|
|
|
if (agent_key_available (grip))
|
|
|
|
|
{
|
|
|
|
|
err =gpg_error (GPG_ERR_NO_SECKEY);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = agent_key_from_file (ctrl, NULL, ctrl->server_local->keydesc, grip,
|
|
|
|
|
&shadow_info, CACHE_MODE_IGNORE, NULL,
|
|
|
|
|
&s_skey, NULL);
|
|
|
|
|
if (err)
|
|
|
|
|
{
|
|
|
|
|
xfree (shadow_info);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
if (shadow_info)
|
|
|
|
|
{
|
|
|
|
|
/* Key is on a TPM or smartcard already. */
|
|
|
|
|
xfree (shadow_info);
|
|
|
|
|
gcry_sexp_release (s_skey);
|
|
|
|
|
err = gpg_error (GPG_ERR_UNUSABLE_SECKEY);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = divert_tpm2_writekey (ctrl, grip, s_skey);
|
|
|
|
|
gcry_sexp_release (s_skey);
|
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
return leave_cmd (ctx, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-04 10:07:12 +02:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_getval[] =
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"GETVAL <key>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Return the value for KEY from the special environment as created by\n"
|
|
|
|
|
"PUTVAL.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-04 10:07:12 +02:00
|
|
|
|
cmd_getval (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
2014-11-27 20:41:37 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2006-09-04 10:07:12 +02:00
|
|
|
|
int rc = 0;
|
|
|
|
|
char *key = NULL;
|
|
|
|
|
char *p;
|
|
|
|
|
struct putval_item_s *vl;
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2006-09-04 10:07:12 +02:00
|
|
|
|
for (p=line; *p == ' '; p++)
|
|
|
|
|
;
|
|
|
|
|
key = p;
|
|
|
|
|
p = strchr (key, ' ');
|
|
|
|
|
if (p)
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
*p++ = 0;
|
2006-09-04 10:07:12 +02:00
|
|
|
|
for (; *p == ' '; p++)
|
|
|
|
|
;
|
|
|
|
|
if (*p)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "too many arguments");
|
2006-09-04 10:07:12 +02:00
|
|
|
|
}
|
2015-03-15 13:11:44 +01:00
|
|
|
|
if (!*key)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "no key given");
|
2006-09-04 10:07:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (vl=putval_list; vl; vl = vl->next)
|
|
|
|
|
if ( !strcmp (vl->d, key) )
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (vl) /* Got an entry. */
|
2006-09-06 18:35:52 +02:00
|
|
|
|
rc = assuan_send_data (ctx, vl->d+vl->off, vl->len);
|
2006-09-04 10:07:12 +02:00
|
|
|
|
else
|
|
|
|
|
return gpg_error (GPG_ERR_NO_DATA);
|
|
|
|
|
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, rc);
|
2006-09-04 10:07:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_putval[] =
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"PUTVAL <key> [<percent_escaped_value>]\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"The gpg-agent maintains a kind of environment which may be used to\n"
|
|
|
|
|
"store key/value pairs in it, so that they can be retrieved later.\n"
|
|
|
|
|
"This may be used by helper daemons to daemonize themself on\n"
|
|
|
|
|
"invocation and register them with gpg-agent. Callers of the\n"
|
|
|
|
|
"daemon's service may now first try connect to get the information\n"
|
|
|
|
|
"for that service from gpg-agent through the GETVAL command and then\n"
|
|
|
|
|
"try to connect to that daemon. Only if that fails they may start\n"
|
|
|
|
|
"an own instance of the service daemon. \n"
|
|
|
|
|
"\n"
|
2017-02-20 22:19:50 +01:00
|
|
|
|
"KEY is an arbitrary symbol with the same syntax rules as keys\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"for shell environment variables. PERCENT_ESCAPED_VALUE is the\n"
|
2015-11-16 12:41:46 +01:00
|
|
|
|
"corresponding value; they should be similar to the values of\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"envronment variables but gpg-agent does not enforce any\n"
|
|
|
|
|
"restrictions. If that value is not given any value under that KEY\n"
|
|
|
|
|
"is removed from this special environment.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-04 10:07:12 +02:00
|
|
|
|
cmd_putval (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
2014-11-27 20:41:37 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2006-09-04 10:07:12 +02:00
|
|
|
|
int rc = 0;
|
|
|
|
|
char *key = NULL;
|
|
|
|
|
char *value = NULL;
|
|
|
|
|
size_t valuelen = 0;
|
|
|
|
|
char *p;
|
|
|
|
|
struct putval_item_s *vl, *vlprev;
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2006-09-04 10:07:12 +02:00
|
|
|
|
for (p=line; *p == ' '; p++)
|
|
|
|
|
;
|
|
|
|
|
key = p;
|
|
|
|
|
p = strchr (key, ' ');
|
|
|
|
|
if (p)
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
*p++ = 0;
|
2006-09-04 10:07:12 +02:00
|
|
|
|
for (; *p == ' '; p++)
|
|
|
|
|
;
|
|
|
|
|
if (*p)
|
|
|
|
|
{
|
|
|
|
|
value = p;
|
|
|
|
|
p = strchr (value, ' ');
|
|
|
|
|
if (p)
|
|
|
|
|
*p = 0;
|
2009-04-01 12:51:53 +02:00
|
|
|
|
valuelen = percent_plus_unescape_inplace (value, 0);
|
2006-09-04 10:07:12 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-15 13:11:44 +01:00
|
|
|
|
if (!*key)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return set_error (GPG_ERR_ASS_PARAMETER, "no key given");
|
2006-09-04 10:07:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (vl=putval_list,vlprev=NULL; vl; vlprev=vl, vl = vl->next)
|
|
|
|
|
if ( !strcmp (vl->d, key) )
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (vl) /* Delete old entry. */
|
|
|
|
|
{
|
|
|
|
|
if (vlprev)
|
|
|
|
|
vlprev->next = vl->next;
|
|
|
|
|
else
|
|
|
|
|
putval_list = vl->next;
|
|
|
|
|
xfree (vl);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (valuelen) /* Add entry. */
|
2006-09-04 10:07:12 +02:00
|
|
|
|
{
|
|
|
|
|
vl = xtrymalloc (sizeof *vl + strlen (key) + valuelen);
|
|
|
|
|
if (!vl)
|
2006-09-14 18:50:33 +02:00
|
|
|
|
rc = gpg_error_from_syserror ();
|
2006-09-04 10:07:12 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
vl->len = valuelen;
|
|
|
|
|
vl->off = strlen (key) + 1;
|
|
|
|
|
strcpy (vl->d, key);
|
|
|
|
|
memcpy (vl->d + vl->off, value, valuelen);
|
|
|
|
|
vl->next = putval_list;
|
|
|
|
|
putval_list = vl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-17 17:44:44 +02:00
|
|
|
|
return leave_cmd (ctx, rc);
|
2006-09-04 10:07:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-03 15:57:24 +02:00
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_updatestartuptty[] =
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"UPDATESTARTUPTTY\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Set startup TTY and X11 DISPLAY variables to the values of this\n"
|
|
|
|
|
"session. This command is useful to pull future pinentries to\n"
|
|
|
|
|
"another screen. It is only required because there is no way in the\n"
|
|
|
|
|
"ssh-agent protocol to convey this information.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2005-06-03 15:57:24 +02:00
|
|
|
|
cmd_updatestartuptty (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2009-07-07 12:02:41 +02:00
|
|
|
|
gpg_error_t err = 0;
|
|
|
|
|
session_env_t se;
|
|
|
|
|
char *lc_ctype = NULL;
|
|
|
|
|
char *lc_messages = NULL;
|
2016-07-13 02:24:26 +02:00
|
|
|
|
int iterator;
|
|
|
|
|
const char *name;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2008-10-20 15:53:23 +02:00
|
|
|
|
(void)line;
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2009-07-07 12:02:41 +02:00
|
|
|
|
se = session_env_new ();
|
|
|
|
|
if (!se)
|
|
|
|
|
err = gpg_error_from_syserror ();
|
2005-06-03 15:57:24 +02:00
|
|
|
|
|
2016-07-13 02:24:26 +02:00
|
|
|
|
iterator = 0;
|
|
|
|
|
while (!err && (name = session_env_list_stdenvnames (&iterator, NULL)))
|
2009-07-07 12:02:41 +02:00
|
|
|
|
{
|
2016-07-13 02:24:26 +02:00
|
|
|
|
const char *value = session_env_getenv (ctrl->session_env, name);
|
2009-07-07 12:02:41 +02:00
|
|
|
|
if (value)
|
2016-07-13 02:24:26 +02:00
|
|
|
|
err = session_env_setenv (se, name, value);
|
2009-07-07 12:02:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
if (!err && ctrl->lc_ctype)
|
2009-07-07 12:02:41 +02:00
|
|
|
|
if (!(lc_ctype = xtrystrdup (ctrl->lc_ctype)))
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
|
|
|
|
|
if (!err && ctrl->lc_messages)
|
|
|
|
|
if (!(lc_messages = xtrystrdup (ctrl->lc_messages)))
|
|
|
|
|
err = gpg_error_from_syserror ();
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-07-07 12:02:41 +02:00
|
|
|
|
if (err)
|
|
|
|
|
{
|
|
|
|
|
session_env_release (se);
|
|
|
|
|
xfree (lc_ctype);
|
|
|
|
|
xfree (lc_messages);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
session_env_release (opt.startup_env);
|
|
|
|
|
opt.startup_env = se;
|
|
|
|
|
xfree (opt.startup_lc_ctype);
|
|
|
|
|
opt.startup_lc_ctype = lc_ctype;
|
|
|
|
|
xfree (opt.startup_lc_messages);
|
|
|
|
|
opt.startup_lc_messages = lc_messages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err;
|
2005-06-03 15:57:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-06-18 12:33:12 +02:00
|
|
|
|
|
2009-11-04 12:58:06 +01:00
|
|
|
|
static const char hlp_killagent[] =
|
|
|
|
|
"KILLAGENT\n"
|
|
|
|
|
"\n"
|
2014-10-03 11:58:58 +02:00
|
|
|
|
"Stop the agent.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2007-06-18 12:33:12 +02:00
|
|
|
|
cmd_killagent (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2008-11-11 09:22:06 +01:00
|
|
|
|
|
|
|
|
|
(void)line;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2007-06-18 12:33:12 +02:00
|
|
|
|
ctrl->server_local->stopme = 1;
|
2011-08-10 11:47:04 +02:00
|
|
|
|
assuan_set_flag (ctx, ASSUAN_FORCE_CLOSE, 1);
|
|
|
|
|
return 0;
|
2007-06-18 12:33:12 +02:00
|
|
|
|
}
|
2007-07-04 11:34:28 +02:00
|
|
|
|
|
|
|
|
|
|
2009-11-04 12:58:06 +01:00
|
|
|
|
static const char hlp_reloadagent[] =
|
|
|
|
|
"RELOADAGENT\n"
|
|
|
|
|
"\n"
|
2010-05-11 20:00:31 +02:00
|
|
|
|
"This command is an alternative to SIGHUP\n"
|
|
|
|
|
"to reload the configuration.";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2007-07-04 11:34:28 +02:00
|
|
|
|
cmd_reloadagent (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
2014-11-27 20:41:37 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
|
|
|
|
|
2008-11-11 09:22:06 +01:00
|
|
|
|
(void)line;
|
|
|
|
|
|
2014-11-27 20:41:37 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
|
|
|
|
|
2007-07-04 11:34:28 +02:00
|
|
|
|
agent_sighup_action ();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2007-06-18 12:33:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
|
static const char hlp_getinfo[] =
|
2009-11-04 12:58:06 +01:00
|
|
|
|
"GETINFO <what>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Multipurpose function to return a variety of information.\n"
|
|
|
|
|
"Supported values for WHAT are:\n"
|
|
|
|
|
"\n"
|
2017-11-06 14:20:03 +01:00
|
|
|
|
" version - Return the version of the program.\n"
|
|
|
|
|
" pid - Return the process id of the server.\n"
|
|
|
|
|
" socket_name - Return the name of the socket.\n"
|
2009-11-04 12:58:06 +01:00
|
|
|
|
" ssh_socket_name - Return the name of the ssh socket.\n"
|
2017-11-06 14:20:03 +01:00
|
|
|
|
" scd_running - Return OK if the SCdaemon is already running.\n"
|
|
|
|
|
" s2k_time - Return the time in milliseconds required for S2K.\n"
|
|
|
|
|
" s2k_count - Return the standard S2K count.\n"
|
|
|
|
|
" s2k_count_cal - Return the calibrated S2K count.\n"
|
2015-06-08 18:38:00 +02:00
|
|
|
|
" std_env_names - List the names of the standard environment.\n"
|
2010-05-11 20:00:31 +02:00
|
|
|
|
" std_session_env - List the standard session environment.\n"
|
|
|
|
|
" std_startup_env - List the standard startup environment.\n"
|
2018-04-12 11:24:54 +02:00
|
|
|
|
" getenv NAME - Return value of envvar NAME.\n"
|
2017-11-06 14:20:03 +01:00
|
|
|
|
" connections - Return number of active connections.\n"
|
|
|
|
|
" jent_active - Returns OK if Libgcrypt's JENT is active.\n"
|
|
|
|
|
" restricted - Returns OK if the connection is in restricted mode.\n"
|
|
|
|
|
" cmd_has_option CMD OPT\n"
|
|
|
|
|
" - Returns OK if command CMD has option OPT.\n";
|
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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2007-06-18 12:33:12 +02:00
|
|
|
|
cmd_getinfo (assuan_context_t ctx, char *line)
|
|
|
|
|
{
|
2010-05-11 20:00:31 +02:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2007-06-18 12:33:12 +02:00
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
|
|
if (!strcmp (line, "version"))
|
|
|
|
|
{
|
|
|
|
|
const char *s = VERSION;
|
|
|
|
|
rc = assuan_send_data (ctx, s, strlen (s));
|
|
|
|
|
}
|
2014-11-27 20:41:37 +01: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);
|
2014-11-27 20:41:37 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (line, "s2k_count"))
|
|
|
|
|
{
|
|
|
|
|
char numbuf[50];
|
|
|
|
|
|
|
|
|
|
snprintf (numbuf, sizeof numbuf, "%lu", get_standard_s2k_count ());
|
|
|
|
|
rc = assuan_send_data (ctx, numbuf, strlen (numbuf));
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (line, "restricted"))
|
|
|
|
|
{
|
2019-06-03 16:31:58 +02:00
|
|
|
|
rc = ctrl->restricted? 0 : gpg_error (GPG_ERR_FALSE);
|
2014-11-27 20:41:37 +01:00
|
|
|
|
}
|
|
|
|
|
else if (ctrl->restricted)
|
|
|
|
|
{
|
|
|
|
|
rc = gpg_error (GPG_ERR_FORBIDDEN);
|
|
|
|
|
}
|
|
|
|
|
/* All sub-commands below are not allowed in restricted mode. */
|
2007-10-02 18:30:58 +02:00
|
|
|
|
else if (!strcmp (line, "pid"))
|
|
|
|
|
{
|
|
|
|
|
char numbuf[50];
|
|
|
|
|
|
|
|
|
|
snprintf (numbuf, sizeof numbuf, "%lu", (unsigned long)getpid ());
|
|
|
|
|
rc = assuan_send_data (ctx, numbuf, strlen (numbuf));
|
|
|
|
|
}
|
2007-06-18 12:33:12 +02:00
|
|
|
|
else if (!strcmp (line, "socket_name"))
|
|
|
|
|
{
|
|
|
|
|
const char *s = get_agent_socket_name ();
|
|
|
|
|
|
|
|
|
|
if (s)
|
|
|
|
|
rc = assuan_send_data (ctx, s, strlen (s));
|
|
|
|
|
else
|
|
|
|
|
rc = gpg_error (GPG_ERR_NO_DATA);
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (line, "ssh_socket_name"))
|
|
|
|
|
{
|
|
|
|
|
const char *s = get_agent_ssh_socket_name ();
|
|
|
|
|
|
|
|
|
|
if (s)
|
|
|
|
|
rc = assuan_send_data (ctx, s, strlen (s));
|
|
|
|
|
else
|
|
|
|
|
rc = gpg_error (GPG_ERR_NO_DATA);
|
|
|
|
|
}
|
2009-03-03 10:02:58 +01:00
|
|
|
|
else if (!strcmp (line, "scd_running"))
|
|
|
|
|
{
|
2020-06-24 12:44:02 +02:00
|
|
|
|
rc = agent_daemon_check_running (DAEMON_SCD)? 0:gpg_error (GPG_ERR_FALSE);
|
2009-03-03 10:02:58 +01:00
|
|
|
|
}
|
2015-06-08 18:38:00 +02:00
|
|
|
|
else if (!strcmp (line, "std_env_names"))
|
|
|
|
|
{
|
|
|
|
|
int iterator;
|
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
|
|
iterator = 0;
|
|
|
|
|
while ((name = session_env_list_stdenvnames (&iterator, NULL)))
|
|
|
|
|
{
|
|
|
|
|
rc = assuan_send_data (ctx, name, strlen (name)+1);
|
|
|
|
|
if (!rc)
|
|
|
|
|
rc = assuan_send_data (ctx, NULL, 0);
|
|
|
|
|
if (rc)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-11 20:00:31 +02:00
|
|
|
|
else if (!strcmp (line, "std_session_env")
|
|
|
|
|
|| !strcmp (line, "std_startup_env"))
|
|
|
|
|
{
|
|
|
|
|
int iterator;
|
|
|
|
|
const char *name, *value;
|
|
|
|
|
char *string;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
|
|
|
|
iterator = 0;
|
2010-05-11 20:00:31 +02:00
|
|
|
|
while ((name = session_env_list_stdenvnames (&iterator, NULL)))
|
|
|
|
|
{
|
|
|
|
|
value = session_env_getenv_or_default
|
|
|
|
|
(line[5] == 't'? opt.startup_env:ctrl->session_env, name, NULL);
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
2011-02-04 12:57:53 +01:00
|
|
|
|
string = xtryasprintf ("%s=%s", name, value);
|
2010-05-11 20:00:31 +02:00
|
|
|
|
if (!string)
|
|
|
|
|
rc = gpg_error_from_syserror ();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rc = assuan_send_data (ctx, string, strlen (string)+1);
|
|
|
|
|
if (!rc)
|
|
|
|
|
rc = assuan_send_data (ctx, NULL, 0);
|
|
|
|
|
}
|
|
|
|
|
if (rc)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-12 11:24:54 +02:00
|
|
|
|
else if (!strncmp (line, "getenv", 6)
|
|
|
|
|
&& (line[6] == ' ' || line[6] == '\t' || !line[6]))
|
|
|
|
|
{
|
|
|
|
|
line += 6;
|
|
|
|
|
while (*line == ' ' || *line == '\t')
|
|
|
|
|
line++;
|
|
|
|
|
if (!*line)
|
|
|
|
|
rc = gpg_error (GPG_ERR_MISSING_VALUE);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const char *s = getenv (line);
|
|
|
|
|
if (!s)
|
|
|
|
|
rc = set_error (GPG_ERR_NOT_FOUND, "No such envvar");
|
|
|
|
|
else
|
|
|
|
|
rc = assuan_send_data (ctx, s, strlen (s));
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-06 10:14:17 +02:00
|
|
|
|
else if (!strcmp (line, "connections"))
|
|
|
|
|
{
|
|
|
|
|
char numbuf[20];
|
|
|
|
|
|
|
|
|
|
snprintf (numbuf, sizeof numbuf, "%d",
|
|
|
|
|
get_agent_active_connection_count ());
|
|
|
|
|
rc = assuan_send_data (ctx, numbuf, strlen (numbuf));
|
|
|
|
|
}
|
2017-07-17 14:08:00 +02:00
|
|
|
|
else if (!strcmp (line, "jent_active"))
|
|
|
|
|
{
|
|
|
|
|
char *buf;
|
common,agent,dirmngr,g10,tools: Fix split_fields API.
* common/stringhelp.h (split_fields): Use const * for the strings in
the ARRAY.
(split_fields_colon): Likewise.
* common/stringhelp.c (split_fields, split_fields_colon): Fix
the implementation.
* agent/call-scd.c, agent/command.c: Follow the change.
* common/t-stringhelp.c, dirmngr/loadswdb.c: Likewise.
* g10/call-agent.c, tools/card-call-scd.c: Likewise.
* tools/card-yubikey.c, tools/gpg-card.c: Likewise.
* tools/gpg-card.h, tools/gpg-wks-client.c: Likewise.
* tools/gpgconf-comp.c, tools/gpgconf.c: Likewise.
* tools/wks-util.c: Likewise.
--
The strings in the ARRAY don't need to be released by caller, as those
are references. It's easier to follow the code when it's explicitly
const *.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-09-18 03:20:23 +02:00
|
|
|
|
const char *fields[5];
|
2017-07-17 14:08:00 +02:00
|
|
|
|
|
|
|
|
|
buf = gcry_get_config (0, "rng-type");
|
|
|
|
|
if (buf
|
|
|
|
|
&& split_fields_colon (buf, fields, DIM (fields)) >= 5
|
|
|
|
|
&& atoi (fields[4]) > 0)
|
|
|
|
|
rc = 0;
|
|
|
|
|
else
|
|
|
|
|
rc = gpg_error (GPG_ERR_FALSE);
|
|
|
|
|
gcry_free (buf);
|
|
|
|
|
}
|
2017-11-06 14:20:03 +01:00
|
|
|
|
else if (!strcmp (line, "s2k_count_cal"))
|
|
|
|
|
{
|
|
|
|
|
char numbuf[50];
|
|
|
|
|
|
|
|
|
|
snprintf (numbuf, sizeof numbuf, "%lu", get_calibrated_s2k_count ());
|
|
|
|
|
rc = assuan_send_data (ctx, numbuf, strlen (numbuf));
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (line, "s2k_time"))
|
|
|
|
|
{
|
|
|
|
|
char numbuf[50];
|
|
|
|
|
|
|
|
|
|
snprintf (numbuf, sizeof numbuf, "%lu", get_standard_s2k_time ());
|
|
|
|
|
rc = assuan_send_data (ctx, numbuf, strlen (numbuf));
|
|
|
|
|
}
|
2007-06-18 12:33:12 +02:00
|
|
|
|
else
|
|
|
|
|
rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* This function is called by Libassuan to parse the OPTION command.
|
|
|
|
|
It has been registered similar to the other Assuan 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 02:01:25 +02:00
|
|
|
|
static gpg_error_t
|
2006-09-06 18:35:52 +02:00
|
|
|
|
option_handler (assuan_context_t ctx, const char *key, const char *value)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2004-02-13 18:06:34 +01:00
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2009-07-07 12:02:41 +02:00
|
|
|
|
gpg_error_t err = 0;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2010-10-13 17:57:08 +02:00
|
|
|
|
if (!strcmp (key, "agent-awareness"))
|
|
|
|
|
{
|
|
|
|
|
/* The value is a version string telling us of which agent
|
|
|
|
|
version the caller is aware of. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
ctrl->server_local->allow_fully_canceled =
|
2010-10-13 17:57:08 +02:00
|
|
|
|
gnupg_compare_version (value, "2.1.0");
|
|
|
|
|
}
|
2014-11-27 20:41:37 +01:00
|
|
|
|
else if (ctrl->restricted)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_FORBIDDEN);
|
|
|
|
|
}
|
|
|
|
|
/* All options below are not allowed in restricted mode. */
|
2010-10-13 17:57:08 +02:00
|
|
|
|
else if (!strcmp (key, "putenv"))
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2009-07-07 12:02:41 +02: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 (ctrl->session_env, value);
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "display"))
|
|
|
|
|
{
|
|
|
|
|
err = session_env_setenv (ctrl->session_env, "DISPLAY", value);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "ttyname"))
|
|
|
|
|
{
|
|
|
|
|
if (!opt.keep_tty)
|
2009-07-07 12:02:41 +02:00
|
|
|
|
err = session_env_setenv (ctrl->session_env, "GPG_TTY", value);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "ttytype"))
|
|
|
|
|
{
|
|
|
|
|
if (!opt.keep_tty)
|
2009-07-07 12:02:41 +02:00
|
|
|
|
err = session_env_setenv (ctrl->session_env, "TERM", value);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "lc-ctype"))
|
|
|
|
|
{
|
|
|
|
|
if (ctrl->lc_ctype)
|
2008-05-27 14:03:50 +02:00
|
|
|
|
xfree (ctrl->lc_ctype);
|
|
|
|
|
ctrl->lc_ctype = xtrystrdup (value);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (!ctrl->lc_ctype)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return out_of_core ();
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "lc-messages"))
|
|
|
|
|
{
|
|
|
|
|
if (ctrl->lc_messages)
|
2008-05-27 14:03:50 +02:00
|
|
|
|
xfree (ctrl->lc_messages);
|
|
|
|
|
ctrl->lc_messages = xtrystrdup (value);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (!ctrl->lc_messages)
|
2006-09-06 18:35:52 +02:00
|
|
|
|
return out_of_core ();
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
2007-11-19 17:03:50 +01:00
|
|
|
|
else if (!strcmp (key, "xauthority"))
|
|
|
|
|
{
|
2009-07-07 12:02:41 +02:00
|
|
|
|
err = session_env_setenv (ctrl->session_env, "XAUTHORITY", value);
|
2007-11-19 17:03:50 +01:00
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (key, "pinentry-user-data"))
|
|
|
|
|
{
|
2009-07-07 12:02:41 +02:00
|
|
|
|
err = session_env_setenv (ctrl->session_env, "PINENTRY_USER_DATA", value);
|
2007-11-19 17:03:50 +01:00
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
else if (!strcmp (key, "use-cache-for-signing"))
|
2016-09-05 14:43:42 +02:00
|
|
|
|
ctrl->server_local->use_cache_for_signing = *value? !!atoi (value) : 0;
|
2008-02-14 20:50:10 +01:00
|
|
|
|
else if (!strcmp (key, "allow-pinentry-notify"))
|
|
|
|
|
ctrl->server_local->allow_pinentry_notify = 1;
|
2011-03-03 18:35:08 +01:00
|
|
|
|
else if (!strcmp (key, "pinentry-mode"))
|
|
|
|
|
{
|
2013-02-06 12:49:52 +01:00
|
|
|
|
int tmp = parse_pinentry_mode (value);
|
|
|
|
|
if (tmp == -1)
|
2011-03-03 18:35:08 +01:00
|
|
|
|
err = gpg_error (GPG_ERR_INV_VALUE);
|
2013-02-06 12:49:52 +01:00
|
|
|
|
else if (tmp == PINENTRY_MODE_LOOPBACK && !opt.allow_loopback_pinentry)
|
|
|
|
|
err = gpg_error (GPG_ERR_NOT_SUPPORTED);
|
|
|
|
|
else
|
|
|
|
|
ctrl->pinentry_mode = tmp;
|
2011-03-03 18:35:08 +01:00
|
|
|
|
}
|
2011-04-21 15:40:48 +02:00
|
|
|
|
else if (!strcmp (key, "cache-ttl-opt-preset"))
|
|
|
|
|
{
|
|
|
|
|
ctrl->cache_ttl_opt_preset = *value? atoi (value) : 0;
|
|
|
|
|
}
|
2011-06-29 02:35:13 +02:00
|
|
|
|
else if (!strcmp (key, "s2k-count"))
|
|
|
|
|
{
|
|
|
|
|
ctrl->s2k_count = *value? strtoul(value, NULL, 10) : 0;
|
2011-08-10 00:56:16 +02:00
|
|
|
|
if (ctrl->s2k_count && ctrl->s2k_count < 65536)
|
|
|
|
|
{
|
2011-06-29 02:35:13 +02:00
|
|
|
|
ctrl->s2k_count = 0;
|
2011-08-10 00:56:16 +02:00
|
|
|
|
}
|
2011-06-29 02:35:13 +02:00
|
|
|
|
}
|
2018-03-23 08:14:58 +01:00
|
|
|
|
else if (!strcmp (key, "pretend-request-origin"))
|
|
|
|
|
{
|
|
|
|
|
log_assert (!ctrl->restricted);
|
|
|
|
|
switch (parse_request_origin (value))
|
|
|
|
|
{
|
|
|
|
|
case REQUEST_ORIGIN_LOCAL: ctrl->restricted = 0; break;
|
|
|
|
|
case REQUEST_ORIGIN_REMOTE: ctrl->restricted = 1; break;
|
|
|
|
|
case REQUEST_ORIGIN_BROWSER: ctrl->restricted = 2; break;
|
|
|
|
|
default:
|
|
|
|
|
err = gpg_error (GPG_ERR_INV_VALUE);
|
|
|
|
|
/* Better pretend to be remote in case of a bad value. */
|
|
|
|
|
ctrl->restricted = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
else
|
2009-07-07 12:02:41 +02:00
|
|
|
|
err = gpg_error (GPG_ERR_UNKNOWN_OPTION);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2009-07-07 12:02:41 +02:00
|
|
|
|
return err;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-26 19:32:28 +02:00
|
|
|
|
|
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2006-11-14 17:40:44 +01:00
|
|
|
|
/* Called by libassuan after all commands. ERR is the error from the
|
|
|
|
|
last assuan operation and not the one returned from the command. */
|
|
|
|
|
static void
|
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 02:01:25 +02:00
|
|
|
|
post_cmd_notify (assuan_context_t ctx, gpg_error_t err)
|
2006-11-14 17:40:44 +01:00
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2008-10-20 15:53:23 +02:00
|
|
|
|
(void)err;
|
2006-11-14 17:40:44 +01:00
|
|
|
|
|
|
|
|
|
/* Switch off any I/O monitor controlled logging pausing. */
|
|
|
|
|
ctrl->server_local->pause_io_logging = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This function is called by libassuan for all I/O. We use it here
|
|
|
|
|
to disable logging for the GETEVENTCOUNTER commands. This is so
|
|
|
|
|
that the debug output won't get cluttered by this primitive
|
|
|
|
|
command. */
|
|
|
|
|
static unsigned int
|
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 02:01:25 +02:00
|
|
|
|
io_monitor (assuan_context_t ctx, void *hook, int direction,
|
2006-11-14 17:40:44 +01:00
|
|
|
|
const char *line, size_t linelen)
|
|
|
|
|
{
|
|
|
|
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
2011-02-04 12:57:53 +01: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 02:01:25 +02:00
|
|
|
|
(void) hook;
|
|
|
|
|
|
2016-09-05 16:13:41 +02:00
|
|
|
|
/* We want to suppress all Assuan log messages for connections from
|
|
|
|
|
* self. However, assuan_get_pid works only after
|
|
|
|
|
* assuan_accept. Now, assuan_accept already logs a line ending with
|
|
|
|
|
* the process id. We use this hack here to get the peers pid so
|
|
|
|
|
* that we can compare it to our pid. We should add an assuan
|
|
|
|
|
* function to return the pid for a file descriptor and use that to
|
|
|
|
|
* detect connections to self. */
|
|
|
|
|
if (ctx && !ctrl->server_local->greeting_seen
|
|
|
|
|
&& direction == ASSUAN_IO_TO_PEER)
|
|
|
|
|
{
|
|
|
|
|
ctrl->server_local->greeting_seen = 1;
|
|
|
|
|
if (linelen > 32
|
|
|
|
|
&& !strncmp (line, "OK Pleased to meet you, process ", 32)
|
|
|
|
|
&& strtoul (line+32, NULL, 10) == getpid ())
|
|
|
|
|
return ASSUAN_IO_MONITOR_NOLOG;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Do not log self-connections. This makes the log cleaner because
|
|
|
|
|
* we won't see the check-our-own-socket calls. */
|
|
|
|
|
if (ctx && ctrl->server_local->connect_from_self)
|
|
|
|
|
return ASSUAN_IO_MONITOR_NOLOG;
|
|
|
|
|
|
More cleanup of "allow to".
* README, agent/command.c, agent/keyformat.txt, common/i18n.c,
common/iobuf.c, common/keyserver.h, dirmngr/cdblib.c,
dirmngr/ldap-wrapper.c, doc/DETAILS, doc/TRANSLATE,
doc/announce-2.1.txt, doc/gpg.texi, doc/gpgsm.texi,
doc/scdaemon.texi, doc/tools.texi, doc/whats-new-in-2.1.txt,
g10/export.c, g10/getkey.c, g10/import.c, g10/keyedit.c, m4/ksba.m4,
m4/libgcrypt.m4, m4/ntbtls.m4, po/ca.po, po/cs.po, po/da.po,
po/de.po, po/el.po, po/eo.po, po/es.po, po/et.po, po/fi.po,
po/fr.po, po/gl.po, po/hu.po, po/id.po, po/it.po, po/ja.po,
po/nb.po, po/pl.po, po/pt.po, po/ro.po, po/ru.po, po/sk.po,
po/sv.po, po/tr.po, po/uk.po, po/zh_CN.po, po/zh_TW.po,
scd/app-p15.c, scd/ccid-driver.c, scd/command.c, sm/gpgsm.c,
sm/sign.c, tools/gpgconf-comp.c, tools/gpgtar.h: replace "Allow to"
with clearer text.
In standard English, the normal construction is "${XXX} allows ${YYY}
to" -- that is, the subject (${XXX}) of the sentence is allowing the
object (${YYY}) to do something. When the object is missing, the
phrasing sounds awkward, even if the object is implied by context.
There's almost always a better construction that isn't as awkward.
These changes should make the language a bit clearer.
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-08-02 04:19:17 +02:00
|
|
|
|
/* Note that we only check for the uppercase name. This allows the user to
|
2006-11-14 17:40:44 +01:00
|
|
|
|
see the logging for debugging if using a non-upercase command
|
|
|
|
|
name. */
|
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 02:01:25 +02:00
|
|
|
|
if (ctx && direction == ASSUAN_IO_FROM_PEER
|
2006-11-14 17:40:44 +01:00
|
|
|
|
&& linelen >= 15
|
|
|
|
|
&& !strncmp (line, "GETEVENTCOUNTER", 15)
|
|
|
|
|
&& (linelen == 15 || spacep (line+15)))
|
|
|
|
|
{
|
|
|
|
|
ctrl->server_local->pause_io_logging = 1;
|
|
|
|
|
}
|
|
|
|
|
|
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 02:01:25 +02:00
|
|
|
|
return ctrl->server_local->pause_io_logging? ASSUAN_IO_MONITOR_NOLOG : 0;
|
2006-11-14 17:40:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-07-07 18:52:12 +02:00
|
|
|
|
/* Return true if the command CMD implements the option OPT. */
|
2009-03-17 18:59:36 +01:00
|
|
|
|
static int
|
|
|
|
|
command_has_option (const char *cmd, const char *cmdopt)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp (cmd, "GET_PASSPHRASE"))
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp (cmdopt, "repeat"))
|
2020-07-08 14:20:01 +02:00
|
|
|
|
return 1;
|
|
|
|
|
if (!strcmp (cmdopt, "newsymkey"))
|
|
|
|
|
return 1;
|
2009-03-17 18:59:36 +01:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2009-03-17 18:59:36 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Tell Libassuan about our commands. Also register the other Assuan
|
|
|
|
|
handlers. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
static int
|
2006-09-06 18:35:52 +02:00
|
|
|
|
register_commands (assuan_context_t ctx)
|
2003-08-05 19:11:04 +02: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 18:47:11 +01:00
|
|
|
|
assuan_handler_t handler;
|
2009-11-04 12:58:06 +01:00
|
|
|
|
const char * const help;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
} table[] = {
|
2009-11-04 12:58:06 +01:00
|
|
|
|
{ "GETEVENTCOUNTER",cmd_geteventcounter, hlp_geteventcounter },
|
|
|
|
|
{ "ISTRUSTED", cmd_istrusted, hlp_istrusted },
|
|
|
|
|
{ "HAVEKEY", cmd_havekey, hlp_havekey },
|
|
|
|
|
{ "KEYINFO", cmd_keyinfo, hlp_keyinfo },
|
|
|
|
|
{ "SIGKEY", cmd_sigkey, hlp_sigkey },
|
|
|
|
|
{ "SETKEY", cmd_sigkey, hlp_sigkey },
|
|
|
|
|
{ "SETKEYDESC", cmd_setkeydesc,hlp_setkeydesc },
|
|
|
|
|
{ "SETHASH", cmd_sethash, hlp_sethash },
|
|
|
|
|
{ "PKSIGN", cmd_pksign, hlp_pksign },
|
|
|
|
|
{ "PKDECRYPT", cmd_pkdecrypt, hlp_pkdecrypt },
|
|
|
|
|
{ "GENKEY", cmd_genkey, hlp_genkey },
|
|
|
|
|
{ "READKEY", cmd_readkey, hlp_readkey },
|
|
|
|
|
{ "GET_PASSPHRASE", cmd_get_passphrase, hlp_get_passphrase },
|
|
|
|
|
{ "PRESET_PASSPHRASE", cmd_preset_passphrase, hlp_preset_passphrase },
|
|
|
|
|
{ "CLEAR_PASSPHRASE", cmd_clear_passphrase, hlp_clear_passphrase },
|
|
|
|
|
{ "GET_CONFIRMATION", cmd_get_confirmation, hlp_get_confirmation },
|
|
|
|
|
{ "LISTTRUSTED", cmd_listtrusted, hlp_listtrusted },
|
|
|
|
|
{ "MARKTRUSTED", cmd_marktrusted, hlp_martrusted },
|
|
|
|
|
{ "LEARN", cmd_learn, hlp_learn },
|
|
|
|
|
{ "PASSWD", cmd_passwd, hlp_passwd },
|
2011-02-04 12:57:53 +01:00
|
|
|
|
{ "INPUT", NULL },
|
|
|
|
|
{ "OUTPUT", NULL },
|
2009-11-04 12:58:06 +01:00
|
|
|
|
{ "SCD", cmd_scd, hlp_scd },
|
2010-06-17 17:44:44 +02:00
|
|
|
|
{ "KEYWRAP_KEY", cmd_keywrap_key, hlp_keywrap_key },
|
|
|
|
|
{ "IMPORT_KEY", cmd_import_key, hlp_import_key },
|
|
|
|
|
{ "EXPORT_KEY", cmd_export_key, hlp_export_key },
|
2014-04-15 16:40:48 +02:00
|
|
|
|
{ "DELETE_KEY", cmd_delete_key, hlp_delete_key },
|
2018-07-02 21:24:15 +02:00
|
|
|
|
{ "GET_SECRET", cmd_get_secret, hlp_get_secret },
|
|
|
|
|
{ "PUT_SECRET", cmd_put_secret, hlp_put_secret },
|
2009-11-04 12:58:06 +01:00
|
|
|
|
{ "GETVAL", cmd_getval, hlp_getval },
|
|
|
|
|
{ "PUTVAL", cmd_putval, hlp_putval },
|
|
|
|
|
{ "UPDATESTARTUPTTY", cmd_updatestartuptty, hlp_updatestartuptty },
|
|
|
|
|
{ "KILLAGENT", cmd_killagent, hlp_killagent },
|
|
|
|
|
{ "RELOADAGENT", cmd_reloadagent,hlp_reloadagent },
|
|
|
|
|
{ "GETINFO", cmd_getinfo, hlp_getinfo },
|
2013-02-06 06:00:05 +01:00
|
|
|
|
{ "KEYTOCARD", cmd_keytocard, hlp_keytocard },
|
2021-03-09 22:50:30 +01:00
|
|
|
|
{ "KEYTOTPM", cmd_keytotpm, hlp_keytotpm },
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{ NULL }
|
|
|
|
|
};
|
|
|
|
|
int i, rc;
|
|
|
|
|
|
|
|
|
|
for (i=0; table[i].name; i++)
|
|
|
|
|
{
|
2009-11-04 12:58:06 +01:00
|
|
|
|
rc = assuan_register_command (ctx, table[i].name, table[i].handler,
|
|
|
|
|
table[i].help);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
if (rc)
|
|
|
|
|
return rc;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
}
|
2006-11-14 17:40:44 +01:00
|
|
|
|
assuan_register_post_cmd_notify (ctx, post_cmd_notify);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
assuan_register_reset_notify (ctx, reset_notify);
|
|
|
|
|
assuan_register_option_handler (ctx, option_handler);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-20 17:49:41 +01:00
|
|
|
|
/* Startup the server. If LISTEN_FD and FD is given as -1, this is a
|
|
|
|
|
simple piper server, otherwise it is a regular server. CTRL is the
|
|
|
|
|
control structure for this connection; it has only the basic
|
Fix more spelling
* NEWS, acinclude.m4, agent/command-ssh.c, agent/command.c,
agent/gpg-agent.c, agent/keyformat.txt, agent/protect-tool.c,
common/asshelp.c, common/b64enc.c, common/recsel.c, doc/DETAILS,
doc/HACKING, doc/Notes, doc/TRANSLATE, doc/dirmngr.texi,
doc/faq.org, doc/gpg-agent.texi, doc/gpg.texi, doc/gpgsm.texi,
doc/instguide.texi, g10/armor.c, g10/gpg.c, g10/keyedit.c,
g10/mainproc.c, g10/pkclist.c, g10/tofu.c, g13/sh-cmd.c,
g13/sh-dmcrypt.c, kbx/keybox-init.c, m4/pkg.m4, sm/call-dirmngr.c,
sm/gpgsm.c, tests/Makefile.am, tests/gpgscm/Manual.txt,
tests/gpgscm/scheme.c, tests/openpgp/gpgv-forged-keyring.scm,
tests/openpgp/multisig.test, tests/openpgp/verify.scm,
tests/pkits/README, tools/applygnupgdefaults,
tools/gpg-connect-agent.c, tools/mime-maker.c, tools/mime-parser.c:
minor spelling cleanup.
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-09-15 20:21:15 +02:00
|
|
|
|
initialization. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
void
|
2007-10-01 16:48:39 +02:00
|
|
|
|
start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
|
|
|
|
int rc;
|
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 02:01:25 +02:00
|
|
|
|
assuan_context_t ctx = NULL;
|
|
|
|
|
|
2014-12-19 13:07:09 +01:00
|
|
|
|
if (ctrl->restricted)
|
|
|
|
|
{
|
|
|
|
|
if (agent_copy_startup_env (ctrl))
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
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 02:01:25 +02:00
|
|
|
|
rc = assuan_new (&ctx);
|
|
|
|
|
if (rc)
|
|
|
|
|
{
|
|
|
|
|
log_error ("failed to allocate assuan context: %s\n", gpg_strerror (rc));
|
|
|
|
|
agent_exit (2);
|
|
|
|
|
}
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2007-10-01 16:48:39 +02:00
|
|
|
|
if (listen_fd == GNUPG_INVALID_FD && fd == GNUPG_INVALID_FD)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2009-11-25 18:58:26 +01:00
|
|
|
|
assuan_fd_t filedes[2];
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2009-11-25 18:58:26 +01:00
|
|
|
|
filedes[0] = assuan_fdopen (0);
|
|
|
|
|
filedes[1] = assuan_fdopen (1);
|
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 02:01:25 +02:00
|
|
|
|
rc = assuan_init_pipe_server (ctx, filedes);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
2007-10-01 16:48:39 +02:00
|
|
|
|
else if (listen_fd != GNUPG_INVALID_FD)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2009-11-05 13:06:45 +01:00
|
|
|
|
rc = assuan_init_socket_server (ctx, listen_fd, 0);
|
2009-09-04 19:39:50 +02:00
|
|
|
|
/* FIXME: Need to call assuan_sock_set_nonce for Windows. But
|
|
|
|
|
this branch is currently not used. */
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
else
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
2009-11-05 13:06:45 +01:00
|
|
|
|
rc = assuan_init_socket_server (ctx, fd, ASSUAN_SOCKET_SERVER_ACCEPTED);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
|
|
|
|
if (rc)
|
|
|
|
|
{
|
|
|
|
|
log_error ("failed to initialize the server: %s\n",
|
2006-09-06 18:35:52 +02:00
|
|
|
|
gpg_strerror(rc));
|
2003-08-05 19:11:04 +02:00
|
|
|
|
agent_exit (2);
|
|
|
|
|
}
|
|
|
|
|
rc = register_commands (ctx);
|
|
|
|
|
if (rc)
|
|
|
|
|
{
|
|
|
|
|
log_error ("failed to register commands with Assuan: %s\n",
|
2006-09-06 18:35:52 +02:00
|
|
|
|
gpg_strerror(rc));
|
2003-08-05 19:11:04 +02:00
|
|
|
|
agent_exit (2);
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-20 17:49:41 +01:00
|
|
|
|
assuan_set_pointer (ctx, ctrl);
|
|
|
|
|
ctrl->server_local = xcalloc (1, sizeof *ctrl->server_local);
|
|
|
|
|
ctrl->server_local->assuan_ctx = ctx;
|
|
|
|
|
ctrl->server_local->use_cache_for_signing = 1;
|
2016-09-05 16:13:41 +02:00
|
|
|
|
|
2020-05-18 19:24:41 +02:00
|
|
|
|
ctrl->digest.data = NULL;
|
2006-11-20 17:49:41 +01:00
|
|
|
|
ctrl->digest.raw_value = 0;
|
2020-08-10 10:01:03 +02:00
|
|
|
|
ctrl->digest.is_pss = 0;
|
2003-08-05 19:11:04 +02: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 02:01:25 +02:00
|
|
|
|
assuan_set_io_monitor (ctx, io_monitor, NULL);
|
2016-01-25 11:20:23 +01:00
|
|
|
|
agent_set_progress_cb (progress_cb, ctrl);
|
2006-11-14 17:40:44 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
for (;;)
|
|
|
|
|
{
|
2018-07-02 20:22:42 +02:00
|
|
|
|
assuan_peercred_t client_creds; /* Note: Points into CTX. */
|
|
|
|
|
pid_t pid;
|
2017-02-03 17:13:08 +01:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
rc = assuan_accept (ctx);
|
2008-11-11 09:22:06 +01:00
|
|
|
|
if (gpg_err_code (rc) == GPG_ERR_EOF || rc == -1)
|
2003-08-05 19:11:04 +02:00
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (rc)
|
|
|
|
|
{
|
2006-09-06 18:35:52 +02:00
|
|
|
|
log_info ("Assuan accept problem: %s\n", gpg_strerror (rc));
|
2003-08-05 19:11:04 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2011-02-04 12:57:53 +01:00
|
|
|
|
|
2017-02-05 08:12:25 +01:00
|
|
|
|
rc = assuan_get_peercred (ctx, &client_creds);
|
|
|
|
|
if (rc)
|
|
|
|
|
{
|
2021-04-23 09:52:28 +02:00
|
|
|
|
/* Note that on Windows we don't get the peer credentials
|
|
|
|
|
* and thus we silence the error. */
|
2018-07-02 20:22:42 +02:00
|
|
|
|
if (listen_fd == GNUPG_INVALID_FD && fd == GNUPG_INVALID_FD)
|
|
|
|
|
;
|
2021-04-23 09:52:28 +02:00
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
else if (gpg_err_code (rc) == GPG_ERR_ASS_GENERAL)
|
|
|
|
|
;
|
|
|
|
|
#endif
|
2018-07-02 20:22:42 +02:00
|
|
|
|
else
|
|
|
|
|
log_info ("Assuan get_peercred failed: %s\n", gpg_strerror (rc));
|
|
|
|
|
pid = assuan_get_pid (ctx);
|
2017-02-05 08:12:25 +01:00
|
|
|
|
ctrl->client_uid = -1;
|
|
|
|
|
}
|
2017-02-03 17:13:08 +01:00
|
|
|
|
else
|
2018-07-02 20:22:42 +02:00
|
|
|
|
{
|
2018-10-22 17:24:58 +02:00
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
pid = assuan_get_pid (ctx);
|
|
|
|
|
ctrl->client_uid = -1;
|
|
|
|
|
#else
|
2018-07-02 20:22:42 +02:00
|
|
|
|
pid = client_creds->pid;
|
|
|
|
|
ctrl->client_uid = client_creds->uid;
|
2018-10-22 17:24:58 +02:00
|
|
|
|
#endif
|
2018-07-02 20:22:42 +02:00
|
|
|
|
}
|
|
|
|
|
ctrl->client_pid = (pid == ASSUAN_INVALID_PID)? 0 : (unsigned long)pid;
|
|
|
|
|
ctrl->server_local->connect_from_self = (pid == getpid ());
|
2016-09-05 16:13:41 +02:00
|
|
|
|
|
2003-08-05 19:11:04 +02:00
|
|
|
|
rc = assuan_process (ctx);
|
|
|
|
|
if (rc)
|
|
|
|
|
{
|
2006-09-06 18:35:52 +02:00
|
|
|
|
log_info ("Assuan processing failed: %s\n", gpg_strerror (rc));
|
2003-08-05 19:11:04 +02:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-13 16:27:12 +01:00
|
|
|
|
/* Clear the keyinfo cache. */
|
|
|
|
|
agent_card_free_keyinfo (ctrl->server_local->last_card_keyinfo.ki);
|
|
|
|
|
|
2010-10-26 11:10:29 +02:00
|
|
|
|
/* Reset the nonce caches. */
|
|
|
|
|
clear_nonce_cache (ctrl);
|
|
|
|
|
|
2004-01-29 21:17:27 +01:00
|
|
|
|
/* Reset the SCD if needed. */
|
2020-06-24 12:44:02 +02:00
|
|
|
|
agent_reset_daemon (ctrl);
|
2003-08-05 19:11:04 +02:00
|
|
|
|
|
2005-11-28 12:52:25 +01:00
|
|
|
|
/* Reset the pinentry (in case of popup messages). */
|
2006-11-20 17:49:41 +01:00
|
|
|
|
agent_reset_query (ctrl);
|
2005-11-28 12:52:25 +01:00
|
|
|
|
|
2006-11-20 17:49:41 +01:00
|
|
|
|
/* Cleanup. */
|
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 02:01:25 +02:00
|
|
|
|
assuan_release (ctx);
|
2010-06-17 17:44:44 +02:00
|
|
|
|
xfree (ctrl->server_local->keydesc);
|
|
|
|
|
xfree (ctrl->server_local->import_key);
|
|
|
|
|
xfree (ctrl->server_local->export_key);
|
2007-06-18 12:33:12 +02:00
|
|
|
|
if (ctrl->server_local->stopme)
|
|
|
|
|
agent_exit (0);
|
2006-11-20 17:49:41 +01:00
|
|
|
|
xfree (ctrl->server_local);
|
|
|
|
|
ctrl->server_local = NULL;
|
2003-08-05 19:11:04 +02:00
|
|
|
|
}
|
2011-09-11 22:55:34 +02:00
|
|
|
|
|
|
|
|
|
|
2011-12-05 10:54:59 +01:00
|
|
|
|
/* Helper for the pinentry loopback mode. It merely passes the
|
|
|
|
|
parameters on to the client. */
|
2011-09-11 22:55:34 +02:00
|
|
|
|
gpg_error_t
|
|
|
|
|
pinentry_loopback(ctrl_t ctrl, const char *keyword,
|
|
|
|
|
unsigned char **buffer, size_t *size,
|
|
|
|
|
size_t max_length)
|
|
|
|
|
{
|
|
|
|
|
gpg_error_t rc;
|
|
|
|
|
assuan_context_t ctx = ctrl->server_local->assuan_ctx;
|
2012-01-18 01:49:10 +01:00
|
|
|
|
|
2013-08-22 09:35:21 +02:00
|
|
|
|
rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%zu", max_length);
|
2012-01-18 01:49:10 +01:00
|
|
|
|
if (rc)
|
|
|
|
|
return rc;
|
2011-09-11 22:55:34 +02:00
|
|
|
|
|
|
|
|
|
assuan_begin_confidential (ctx);
|
|
|
|
|
rc = assuan_inquire (ctx, keyword, buffer, size, max_length);
|
|
|
|
|
assuan_end_confidential (ctx);
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
2019-06-04 02:17:21 +02:00
|
|
|
|
|
|
|
|
|
/* Helper for the pinentry loopback mode to ask confirmation
|
|
|
|
|
or just to show message. */
|
|
|
|
|
gpg_error_t
|
|
|
|
|
pinentry_loopback_confirm (ctrl_t ctrl, const char *desc,
|
|
|
|
|
int ask_confirmation,
|
|
|
|
|
const char *ok, const char *notok)
|
|
|
|
|
{
|
|
|
|
|
gpg_error_t err = 0;
|
|
|
|
|
assuan_context_t ctx = ctrl->server_local->assuan_ctx;
|
|
|
|
|
|
|
|
|
|
if (desc)
|
|
|
|
|
err = print_assuan_status (ctx, "SETDESC", "%s", desc);
|
|
|
|
|
if (!err && ok)
|
|
|
|
|
err = print_assuan_status (ctx, "SETOK", "%s", ok);
|
|
|
|
|
if (!err && notok)
|
|
|
|
|
err = print_assuan_status (ctx, "SETNOTOK", "%s", notok);
|
|
|
|
|
|
|
|
|
|
if (!err)
|
|
|
|
|
err = assuan_inquire (ctx, ask_confirmation ? "CONFIRM 1" : "CONFIRM 0",
|
|
|
|
|
NULL, NULL, 0);
|
|
|
|
|
return err;
|
|
|
|
|
}
|