mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
* command-ssh.c (get_passphrase): Removed.
(ssh_identity_register): Partly rewritten. (open_control_file, search_control_file, add_control_entry): New. (ssh_handler_request_identities): Return only files listed in our control file. * findkey.c (unprotect): Check for allocation error. * agent.h (opt): Add fields to record the startup terminal settings. * gpg-agent.c (main): Record them and do not force keep display with --enable-ssh-support. * command-ssh.c (start_command_handler_ssh): Use them here. * gpg-agent.c: Renamed option --ssh-support to --enable-ssh-support. * command.c (cmd_readkey): New. (register_commands): Register new command "READKEY". * command-ssh.c (ssh_request_process): Improved logging. * findkey.c (agent_write_private_key): Always use plain open. Don't depend on an umask for permissions. (agent_key_from_file): Factored file reading code out to .. (read_key_file): .. new function. (agent_public_key_from_file): New.
This commit is contained in:
parent
cf8f6d3cef
commit
4e5bf2fd93
9 changed files with 691 additions and 150 deletions
|
@ -1,5 +1,5 @@
|
|||
/* command.c - gpg-agent command handler
|
||||
* Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
|
@ -22,12 +22,14 @@
|
|||
some buffering in secure mempory to protect session keys etc. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <assuan.h>
|
||||
|
||||
|
@ -504,6 +506,55 @@ cmd_genkey (ASSUAN_CONTEXT ctx, char *line)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* READKEY <hexstring_with_keygrip>
|
||||
|
||||
Return the public key for the given keygrip. */
|
||||
static int
|
||||
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;
|
||||
|
||||
rc = parse_keygrip (ctx, line, grip);
|
||||
if (rc)
|
||||
return rc; /* Return immediately as this is already an Assuan error code.*/
|
||||
|
||||
rc = agent_public_key_from_file (ctrl, grip, &s_pkey);
|
||||
if (!rc)
|
||||
{
|
||||
size_t len;
|
||||
unsigned char *buf;
|
||||
|
||||
len = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, NULL, 0);
|
||||
assert (len);
|
||||
buf = xtrymalloc (len);
|
||||
if (!buf)
|
||||
rc = gpg_error_from_errno (errno);
|
||||
else
|
||||
{
|
||||
len = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, buf, len);
|
||||
assert (len);
|
||||
rc = assuan_send_data (ctx, buf, len);
|
||||
rc = map_assuan_err (rc);
|
||||
xfree (buf);
|
||||
}
|
||||
gcry_sexp_release (s_pkey);
|
||||
}
|
||||
|
||||
if (rc)
|
||||
log_error ("command readkey failed: %s\n", gpg_strerror (rc));
|
||||
return map_to_assuan_status (rc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* GET_PASSPHRASE <cache_id> [<error_message> <prompt> <description>]
|
||||
|
||||
This function is usually used to ask for a passphrase to be used
|
||||
|
@ -894,6 +945,7 @@ register_commands (ASSUAN_CONTEXT ctx)
|
|||
{ "PKSIGN", cmd_pksign },
|
||||
{ "PKDECRYPT", cmd_pkdecrypt },
|
||||
{ "GENKEY", cmd_genkey },
|
||||
{ "READKEY", cmd_readkey },
|
||||
{ "GET_PASSPHRASE", cmd_get_passphrase },
|
||||
{ "PRESET_PASSPHRASE", cmd_preset_passphrase },
|
||||
{ "CLEAR_PASSPHRASE", cmd_clear_passphrase },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue