summaryrefslogtreecommitdiff
path: root/sshconnect2.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-12-04 00:24:55 +0000
committerDamien Miller <djm@mindrot.org>2015-12-04 15:15:00 +1100
commit6064a8b8295cb5a17b5ebcfade53053377714f40 (patch)
tree3db2e936b90ed2b489fa0273d2e211e385ad082e /sshconnect2.c
parentb91926a97620f3e51761c271ba57aa5db790f48d (diff)
upstream commit
clean up agent_fd handling; properly initialise it to -1 and make tests consistent ok markus@ Upstream-ID: ac9554323d5065745caf17b5e37cb0f0d4825707
Diffstat (limited to 'sshconnect2.c')
-rw-r--r--sshconnect2.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sshconnect2.c b/sshconnect2.c
index 69d0bee4e..d29f630f2 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect2.c,v 1.229 2015/11/15 22:26:49 jcs Exp $ */ 1/* $OpenBSD: sshconnect2.c,v 1.230 2015/12/04 00:24:55 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2008 Damien Miller. All rights reserved. 4 * Copyright (c) 2008 Damien Miller. All rights reserved.
@@ -978,7 +978,7 @@ identity_sign(struct identity *id, u_char **sigp, size_t *lenp,
978 int ret; 978 int ret;
979 979
980 /* the agent supports this key */ 980 /* the agent supports this key */
981 if (id->agent_fd) 981 if (id->agent_fd != -1)
982 return ssh_agent_sign(id->agent_fd, id->key, sigp, lenp, 982 return ssh_agent_sign(id->agent_fd, id->key, sigp, lenp,
983 data, datalen, compat); 983 data, datalen, compat);
984 984
@@ -1197,7 +1197,7 @@ load_identity_file(Identity *id)
1197 quit = 1; 1197 quit = 1;
1198 break; 1198 break;
1199 } 1199 }
1200 if (!quit && private != NULL && !id->agent_fd && 1200 if (!quit && private != NULL && id->agent_fd == -1 &&
1201 !(id->key && id->isprivate)) 1201 !(id->key && id->isprivate))
1202 maybe_add_key_to_agent(id->filename, private, comment, 1202 maybe_add_key_to_agent(id->filename, private, comment,
1203 passphrase); 1203 passphrase);
@@ -1227,7 +1227,7 @@ pubkey_prepare(Authctxt *authctxt)
1227 struct identity *id, *id2, *tmp; 1227 struct identity *id, *id2, *tmp;
1228 struct idlist agent, files, *preferred; 1228 struct idlist agent, files, *preferred;
1229 struct sshkey *key; 1229 struct sshkey *key;
1230 int agent_fd, i, r, found; 1230 int agent_fd = -1, i, r, found;
1231 size_t j; 1231 size_t j;
1232 struct ssh_identitylist *idlist; 1232 struct ssh_identitylist *idlist;
1233 1233
@@ -1245,6 +1245,7 @@ pubkey_prepare(Authctxt *authctxt)
1245 continue; 1245 continue;
1246 options.identity_keys[i] = NULL; 1246 options.identity_keys[i] = NULL;
1247 id = xcalloc(1, sizeof(*id)); 1247 id = xcalloc(1, sizeof(*id));
1248 id->agent_fd = -1;
1248 id->key = key; 1249 id->key = key;
1249 id->filename = xstrdup(options.identity_files[i]); 1250 id->filename = xstrdup(options.identity_files[i]);
1250 id->userprovided = options.identity_file_userprovided[i]; 1251 id->userprovided = options.identity_file_userprovided[i];
@@ -1280,6 +1281,7 @@ pubkey_prepare(Authctxt *authctxt)
1280 key->cert->type != SSH2_CERT_TYPE_USER) 1281 key->cert->type != SSH2_CERT_TYPE_USER)
1281 continue; 1282 continue;
1282 id = xcalloc(1, sizeof(*id)); 1283 id = xcalloc(1, sizeof(*id));
1284 id->agent_fd = -1;
1283 id->key = key; 1285 id->key = key;
1284 id->filename = xstrdup(options.certificate_files[i]); 1286 id->filename = xstrdup(options.certificate_files[i]);
1285 id->userprovided = options.certificate_file_userprovided[i]; 1287 id->userprovided = options.certificate_file_userprovided[i];
@@ -1348,8 +1350,9 @@ pubkey_prepare(Authctxt *authctxt)
1348 memset(id, 0, sizeof(*id)); 1350 memset(id, 0, sizeof(*id));
1349 continue; 1351 continue;
1350 } 1352 }
1351 debug2("key: %s (%p),%s", id->filename, id->key, 1353 debug2("key: %s (%p)%s%s", id->filename, id->key,
1352 id->userprovided ? " explicit" : ""); 1354 id->userprovided ? ", explicit" : "",
1355 id->agent_fd != -1 ? ", agent" : "");
1353 } 1356 }
1354} 1357}
1355 1358