summaryrefslogtreecommitdiffstats
path: root/authfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'authfd.c')
-rw-r--r--authfd.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/authfd.c b/authfd.c
index 4c4552d5..f04e0858 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 <openssl/evp.h>
@@ -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;
}