1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

agent: Support ssh-agent extensions for environment variables.

* common/session-env.c (session_env_list_stdenvnames): Extend to allow
return all names as one string.
* agent/command-ssh.c (SSH_REQUEST_EXTENSION): New.
(SSH_RESPONSE_EXTENSION_FAILURE): New.
(request_specs): Add handler for the extension command.
(ssh_handler_extension): New.
--

The extension mechanism is specified in
https://tools.ietf.org/html/draft-miller-ssh-agent-04

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2021-01-25 10:35:06 +01:00
parent 60499d9894
commit 224e26cf7b
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
2 changed files with 120 additions and 4 deletions

View file

@ -98,13 +98,45 @@ static size_t lastallocatedarraysize;
/* Return the names of standard environment variables one after the
other. The caller needs to set the value at the address of
ITERATOR initially to 0 and then call this function until it returns
NULL. */
ITERATOR initially to 0 and then call this function until it
returns NULL. If ITERATOR is NULL, a single comma delimited string
with the names is returned; NULL is never returned in this case and
R_ASSNAME is ignored. */
const char *
session_env_list_stdenvnames (int *iterator, const char **r_assname)
{
int idx = *iterator;
int idx;
static char *commastring;
if (!iterator)
{
if (!commastring)
{
size_t len = 0;
char *p;
for (idx = 0; idx < DIM (stdenvnames); idx++)
len += strlen (stdenvnames[idx].name) + 1;
commastring = xtrymalloc (len);
if (!commastring)
{
log_error ("%s: error allocating string: %s\n", __func__,
gpg_strerror (gpg_error_from_syserror ()));
return "GPG_TTY,TERM,DISPLAY";
}
p = commastring;
for (idx = 0; idx < DIM (stdenvnames); idx++)
{
if (idx)
*p++ = ',';
p = stpcpy (p, stdenvnames[idx].name);
}
gpgrt_annotate_leaked_object (commastring);
}
return commastring;
}
idx = *iterator;
if (idx < 0 || idx >= DIM (stdenvnames))
return NULL;
*iterator = idx + 1;