diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2020-01-25 00:03:37 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2020-01-25 00:03:37 +0000 |
commit | 85c9568845c5930d5ce54984e4dbe8ced31c5ddc (patch) | |
tree | 94be5889df86ba7df9dd530a84e50765da6d3df7 /usr.bin/ssh/ssh-agent.c | |
parent | 748aea8a0df76938e66e1db79f28c7d9d52714be (diff) |
expose PKCS#11 key labels/X.509 subjects as comments
Extract the key label or X.509 subject string when PKCS#11 keys
are retrieved from the token and plumb this through to places where
it may be used as a comment.
based on https://github.com/openssh/openssh-portable/pull/138
by Danielle Church
feedback and ok markus@
Diffstat (limited to 'usr.bin/ssh/ssh-agent.c')
-rw-r--r-- | usr.bin/ssh/ssh-agent.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c index 835da83a947..af50b8237f0 100644 --- a/usr.bin/ssh/ssh-agent.c +++ b/usr.bin/ssh/ssh-agent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-agent.c,v 1.252 2020/01/23 07:10:22 dtucker Exp $ */ +/* $OpenBSD: ssh-agent.c,v 1.253 2020/01/25 00:03:36 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -619,6 +619,7 @@ static void process_add_smartcard_key(SocketEntry *e) { char *provider = NULL, *pin = NULL, canonical_provider[PATH_MAX]; + char **comments = NULL; int r, i, count = 0, success = 0, confirm = 0; u_int seconds; time_t death = 0; @@ -668,28 +669,34 @@ process_add_smartcard_key(SocketEntry *e) if (lifetime && !death) death = monotime() + lifetime; - count = pkcs11_add_provider(canonical_provider, pin, &keys); + count = pkcs11_add_provider(canonical_provider, pin, &keys, &comments); for (i = 0; i < count; i++) { k = keys[i]; if (lookup_identity(k) == NULL) { id = xcalloc(1, sizeof(Identity)); id->key = k; + keys[i] = NULL; /* transferred */ id->provider = xstrdup(canonical_provider); - id->comment = xstrdup(canonical_provider); /* XXX */ + if (*comments[i] != '\0') { + id->comment = comments[i]; + comments[i] = NULL; /* transferred */ + } else { + id->comment = xstrdup(canonical_provider); + } id->death = death; id->confirm = confirm; TAILQ_INSERT_TAIL(&idtab->idlist, id, next); idtab->nentries++; success = 1; - } else { - sshkey_free(k); } - keys[i] = NULL; + sshkey_free(keys[i]); + free(comments[i]); } send: free(pin); free(provider); free(keys); + free(comments); send_status(e, success); } |