upstream commit

clean up agent_fd handling; properly initialise it to -1
 and make tests consistent

ok markus@

Upstream-ID: ac9554323d5065745caf17b5e37cb0f0d4825707
This commit is contained in:
djm@openbsd.org 2015-12-04 00:24:55 +00:00 committed by Damien Miller
parent b91926a976
commit 6064a8b829
1 changed files with 9 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sshconnect2.c,v 1.229 2015/11/15 22:26:49 jcs Exp $ */
/* $OpenBSD: sshconnect2.c,v 1.230 2015/12/04 00:24:55 djm Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
* Copyright (c) 2008 Damien Miller. All rights reserved.
@ -978,7 +978,7 @@ identity_sign(struct identity *id, u_char **sigp, size_t *lenp,
int ret;
/* the agent supports this key */
if (id->agent_fd)
if (id->agent_fd != -1)
return ssh_agent_sign(id->agent_fd, id->key, sigp, lenp,
data, datalen, compat);
@ -1197,7 +1197,7 @@ load_identity_file(Identity *id)
quit = 1;
break;
}
if (!quit && private != NULL && !id->agent_fd &&
if (!quit && private != NULL && id->agent_fd == -1 &&
!(id->key && id->isprivate))
maybe_add_key_to_agent(id->filename, private, comment,
passphrase);
@ -1227,7 +1227,7 @@ pubkey_prepare(Authctxt *authctxt)
struct identity *id, *id2, *tmp;
struct idlist agent, files, *preferred;
struct sshkey *key;
int agent_fd, i, r, found;
int agent_fd = -1, i, r, found;
size_t j;
struct ssh_identitylist *idlist;
@ -1245,6 +1245,7 @@ pubkey_prepare(Authctxt *authctxt)
continue;
options.identity_keys[i] = NULL;
id = xcalloc(1, sizeof(*id));
id->agent_fd = -1;
id->key = key;
id->filename = xstrdup(options.identity_files[i]);
id->userprovided = options.identity_file_userprovided[i];
@ -1280,6 +1281,7 @@ pubkey_prepare(Authctxt *authctxt)
key->cert->type != SSH2_CERT_TYPE_USER)
continue;
id = xcalloc(1, sizeof(*id));
id->agent_fd = -1;
id->key = key;
id->filename = xstrdup(options.certificate_files[i]);
id->userprovided = options.certificate_file_userprovided[i];
@ -1348,8 +1350,9 @@ pubkey_prepare(Authctxt *authctxt)
memset(id, 0, sizeof(*id));
continue;
}
debug2("key: %s (%p),%s", id->filename, id->key,
id->userprovided ? " explicit" : "");
debug2("key: %s (%p)%s%s", id->filename, id->key,
id->userprovided ? ", explicit" : "",
id->agent_fd != -1 ? ", agent" : "");
}
}