=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/authfd.c,v retrieving revision 1.49.2.1 retrieving revision 1.49.2.2 diff -u -r1.49.2.1 -r1.49.2.2 --- src/usr.bin/ssh/authfd.c 2002/06/26 15:30:37 1.49.2.1 +++ src/usr.bin/ssh/authfd.c 2002/10/11 14:51:52 1.49.2.2 @@ -35,7 +35,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: authfd.c,v 1.49.2.1 2002/06/26 15:30:37 jason Exp $"); +RCSID("$OpenBSD: authfd.c,v 1.49.2.2 2002/10/11 14:51:52 miod Exp $"); #include @@ -53,6 +53,8 @@ #include "log.h" #include "atomicio.h" +static int agent_present = 0; + /* helper */ int decode_reply(int type); @@ -61,6 +63,21 @@ ((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 @@ close(sock); return -1; } + agent_present = 1; return sock; }