aboutsummaryrefslogtreecommitdiffstats
path: root/common/session-env.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2021-01-25 09:35:06 +0000
committerWerner Koch <[email protected]>2021-01-25 09:35:06 +0000
commit224e26cf7b67f22bb0140133eac6b4ad24f3b1b7 (patch)
tree8ffb4f94ef64331109af30f6984237be37da61e4 /common/session-env.c
parentscd:p15: Show the ATR as part of the TokenInfo diagnostics. (diff)
downloadgnupg-224e26cf7b67f22bb0140133eac6b4ad24f3b1b7.tar.gz
gnupg-224e26cf7b67f22bb0140133eac6b4ad24f3b1b7.zip
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 <[email protected]>
Diffstat (limited to 'common/session-env.c')
-rw-r--r--common/session-env.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/common/session-env.c b/common/session-env.c
index 1df2c4431..5d6b66dd6 100644
--- a/common/session-env.c
+++ b/common/session-env.c
@@ -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;