mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-28 22:49:59 +01:00
2005-01-28 Moritz Schulte <moritz@g10code.com>
* command-ssh.c (ssh_handler_add_identity): Pass ctrl to ssh_identity_register(). (ssh_identity_register): New argument: ctrl; pass ctrl to get_passphrase(). (get_passphrase): Pass ctrl instead of NULL to agent_askpin(). (start_command_handler_ssh): Use agent_init_default_ctrl(); deallocate structure members, which might be dynamically allocated. (lifetime_default): Removed variable. (ssh_handler_add_identity): Fix ttl handling; renamed variable `death' to `ttl'. (ssh_identity_register): Fix key grip handling.
This commit is contained in:
parent
8bcf546b14
commit
2b8e9bc5c5
@ -1,3 +1,18 @@
|
|||||||
|
2005-01-28 Moritz Schulte <moritz@g10code.com>
|
||||||
|
|
||||||
|
* command-ssh.c (ssh_handler_add_identity): Pass ctrl to
|
||||||
|
ssh_identity_register().
|
||||||
|
(ssh_identity_register): New argument: ctrl; pass ctrl to
|
||||||
|
get_passphrase().
|
||||||
|
(get_passphrase): Pass ctrl instead of NULL to agent_askpin().
|
||||||
|
(start_command_handler_ssh): Use agent_init_default_ctrl();
|
||||||
|
deallocate structure members, which might be dynamically
|
||||||
|
allocated.
|
||||||
|
(lifetime_default): Removed variable.
|
||||||
|
(ssh_handler_add_identity): Fix ttl handling; renamed variable
|
||||||
|
`death' to `ttl'.
|
||||||
|
(ssh_identity_register): Fix key grip handling.
|
||||||
|
|
||||||
2005-01-26 Moritz Schulte <moritz@g10code.com>
|
2005-01-26 Moritz Schulte <moritz@g10code.com>
|
||||||
|
|
||||||
* command-ssh.c (ssh_handler_sign_request): Confirm to agent
|
* command-ssh.c (ssh_handler_sign_request): Confirm to agent
|
||||||
|
@ -94,8 +94,6 @@ typedef struct ssh_key_type_spec
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static uint32_t lifetime_default;
|
|
||||||
|
|
||||||
/* General utility functions. */
|
/* General utility functions. */
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
@ -1725,7 +1723,8 @@ ssh_handler_sign_request (ctrl_t ctrl, estream_t request, estream_t response)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
get_passphrase (const char *description, size_t passphrase_n, char *passphrase)
|
get_passphrase (ctrl_t ctrl,
|
||||||
|
const char *description, size_t passphrase_n, char *passphrase)
|
||||||
{
|
{
|
||||||
struct pin_entry_info_s *pi;
|
struct pin_entry_info_s *pi;
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
@ -1747,7 +1746,7 @@ get_passphrase (const char *description, size_t passphrase_n, char *passphrase)
|
|||||||
pi->cb_errtext = NULL;
|
pi->cb_errtext = NULL;
|
||||||
pi->max_length = 100;
|
pi->max_length = 100;
|
||||||
|
|
||||||
err = agent_askpin (NULL, description, NULL, pi);
|
err = agent_askpin (ctrl, description, NULL, pi);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -1851,7 +1850,7 @@ ssh_key_to_buffer (gcry_sexp_t key, const char *passphrase,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
ssh_identity_register (gcry_sexp_t key, int ttl)
|
ssh_identity_register (ctrl_t ctrl, gcry_sexp_t key, int ttl)
|
||||||
{
|
{
|
||||||
unsigned char key_grip_raw[21];
|
unsigned char key_grip_raw[21];
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
@ -1862,11 +1861,11 @@ ssh_identity_register (gcry_sexp_t key, int ttl)
|
|||||||
char key_grip[41];
|
char key_grip[41];
|
||||||
char *comment;
|
char *comment;
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
|
unsigned int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (DBG_COMMAND)
|
if (DBG_COMMAND)
|
||||||
log_debug ("[ssh-agent] registering identity `%s'\n", key_grip);
|
log_debug ("[ssh-agent] registering identity\n");
|
||||||
|
|
||||||
description = NULL;
|
description = NULL;
|
||||||
comment = NULL;
|
comment = NULL;
|
||||||
@ -1898,7 +1897,7 @@ ssh_identity_register (gcry_sexp_t key, int ttl)
|
|||||||
"for protecting the received secret key `%s':",
|
"for protecting the received secret key `%s':",
|
||||||
comment ? comment : "");
|
comment ? comment : "");
|
||||||
|
|
||||||
err = get_passphrase (description, sizeof (passphrase), passphrase);
|
err = get_passphrase (ctrl, description, sizeof (passphrase), passphrase);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -1910,7 +1909,10 @@ ssh_identity_register (gcry_sexp_t key, int ttl)
|
|||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
err = agent_put_cache (key_grip_raw, passphrase, ttl);
|
for (i = 0; i < 20; i++)
|
||||||
|
sprintf (key_grip + 2 * i, "%02X", key_grip_raw[i]);
|
||||||
|
|
||||||
|
err = agent_put_cache (key_grip, passphrase, ttl);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -1954,15 +1956,15 @@ ssh_handler_add_identity (ctrl_t ctrl, estream_t request, estream_t response)
|
|||||||
gcry_sexp_t key;
|
gcry_sexp_t key;
|
||||||
byte_t b;
|
byte_t b;
|
||||||
int confirm;
|
int confirm;
|
||||||
int death;
|
int ttl;
|
||||||
int bad;
|
int bad;
|
||||||
|
|
||||||
if (DBG_COMMAND)
|
if (DBG_COMMAND)
|
||||||
log_debug ("[ssh-agent] add identity\n");
|
log_debug ("[ssh-agent] add identity\n");
|
||||||
|
|
||||||
confirm = 0;
|
confirm = 0;
|
||||||
death = 0;
|
|
||||||
key = NULL;
|
key = NULL;
|
||||||
|
ttl = 0;
|
||||||
bad = 0;
|
bad = 0;
|
||||||
|
|
||||||
/* FIXME? */
|
/* FIXME? */
|
||||||
@ -1990,7 +1992,7 @@ ssh_handler_add_identity (ctrl_t ctrl, estream_t request, estream_t response)
|
|||||||
|
|
||||||
err = es_read_uint32 (request, &n);
|
err = es_read_uint32 (request, &n);
|
||||||
if (! err)
|
if (! err)
|
||||||
death = time (NULL) + n;
|
ttl = n;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2008,12 +2010,9 @@ ssh_handler_add_identity (ctrl_t ctrl, estream_t request, estream_t response)
|
|||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (lifetime_default && (! death))
|
|
||||||
death = time (NULL) + lifetime_default;
|
|
||||||
|
|
||||||
/* FIXME: are constraints used correctly? */
|
/* FIXME: are constraints used correctly? */
|
||||||
|
|
||||||
err = ssh_identity_register (key, death);
|
err = ssh_identity_register (ctrl, key, ttl);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
@ -2217,6 +2216,7 @@ start_command_handler_ssh (int sock_client)
|
|||||||
log_debug ("[ssh-agent] Starting command handler\n");
|
log_debug ("[ssh-agent] Starting command handler\n");
|
||||||
|
|
||||||
memset (&ctrl, 0, sizeof (ctrl));
|
memset (&ctrl, 0, sizeof (ctrl));
|
||||||
|
agent_init_default_ctrl (&ctrl);
|
||||||
ctrl.connection_fd = sock_client;
|
ctrl.connection_fd = sock_client;
|
||||||
|
|
||||||
stream_response = NULL;
|
stream_response = NULL;
|
||||||
@ -2324,4 +2324,10 @@ start_command_handler_ssh (int sock_client)
|
|||||||
|
|
||||||
if (DBG_COMMAND)
|
if (DBG_COMMAND)
|
||||||
log_debug ("[ssh-agent] Leaving ssh command handler: %s\n", gpg_strerror (err));
|
log_debug ("[ssh-agent] Leaving ssh command handler: %s\n", gpg_strerror (err));
|
||||||
|
|
||||||
|
free (ctrl.display);
|
||||||
|
free (ctrl.ttyname);
|
||||||
|
free (ctrl.ttytype);
|
||||||
|
free (ctrl.lc_ctype);
|
||||||
|
free (ctrl.lc_messages);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user