From 789e95dbe931bad60cb5f91d995470f433f4e02b Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Thu, 12 Sep 2002 09:52:46 +1000 Subject: - stevesk@cvs.openbsd.org 2002/09/11 18:27:26 [authfd.c authfd.h ssh.c] don't connect to agent to test for presence if we've previously connected; ok markus@ --- authfd.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'authfd.c') diff --git a/authfd.c b/authfd.c index 4c4552d52..f04e0858b 100644 --- a/authfd.c +++ b/authfd.c @@ -35,7 +35,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: authfd.c,v 1.56 2002/06/25 16:22:42 markus Exp $"); +RCSID("$OpenBSD: authfd.c,v 1.57 2002/09/11 18:27:26 stevesk Exp $"); #include @@ -53,6 +53,8 @@ RCSID("$OpenBSD: authfd.c,v 1.56 2002/06/25 16:22:42 markus Exp $"); #include "log.h" #include "atomicio.h" +static int agent_present = 0; + /* helper */ int decode_reply(int type); @@ -61,6 +63,21 @@ int decode_reply(int type); ((x == SSH_AGENT_FAILURE) || (x == SSH_COM_AGENT2_FAILURE) || \ (x == SSH2_AGENT_FAILURE)) +int +ssh_agent_present(void) +{ + int authfd; + + if (agent_present) + return 1; + if ((authfd = ssh_get_authentication_socket()) == -1) + return 0; + else { + ssh_close_authentication_socket(authfd); + return 1; + } +} + /* Returns the number of the authentication fd, or -1 if there is none. */ int @@ -90,6 +107,7 @@ ssh_get_authentication_socket(void) close(sock); return -1; } + agent_present = 1; return sock; } -- cgit v1.2.3