diff options
author | Can Erkin Acar <canacar@cvs.openbsd.org> | 2007-09-25 23:48:58 +0000 |
---|---|---|
committer | Can Erkin Acar <canacar@cvs.openbsd.org> | 2007-09-25 23:48:58 +0000 |
commit | 3ef1cb57db54c743a4b650b47989c54d9846a4d2 (patch) | |
tree | 11f11710b08b5447f8c1c6ce0171b8b2e3c625e9 | |
parent | e060170444722753b5bc1b5e826e517ac4a11085 (diff) |
When adding a key that already exists, update the properties
(time, confirm, comment) instead of discarding them. ok djm@ markus@
-rw-r--r-- | usr.bin/ssh/ssh-agent.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c index b5da1ec3c9b..0f6ca08d5f1 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.156 2007/09/09 11:38:01 sobrado Exp $ */ +/* $OpenBSD: ssh-agent.c,v 1.157 2007/09/25 23:48:57 canacar Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -444,6 +444,7 @@ static void process_add_identity(SocketEntry *e, int version) { Idtab *tab = idtab_lookup(version); + Identity *id; int type, success = 0, death = 0, confirm = 0; char *type_name, *comment; Key *k = NULL; @@ -526,19 +527,19 @@ process_add_identity(SocketEntry *e, int version) } if (lifetime && !death) death = time(NULL) + lifetime; - if (lookup_identity(k, version) == NULL) { - Identity *id = xmalloc(sizeof(Identity)); + if ((id = lookup_identity(k, version)) == NULL) { + id = xmalloc(sizeof(Identity)); id->key = k; - id->comment = comment; - id->death = death; - id->confirm = confirm; TAILQ_INSERT_TAIL(&tab->idlist, id, next); /* Increment the number of identities. */ tab->nentries++; } else { key_free(k); - xfree(comment); + xfree(id->comment); } + id->comment = comment; + id->death = death; + id->confirm = confirm; send: buffer_put_int(&e->output, 1); buffer_put_char(&e->output, |