]> andersk Git - openssh.git/blobdiff - authfd.c
- stevesk@cvs.openbsd.org 2002/09/11 18:27:26
[openssh.git] / authfd.c
index 4c4552d527f0deab67941c2b2a814ae2249a58e9..f04e0858b04806e2da4c53e59dbcb702bbf8ddf3 100644 (file)
--- 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;
 }
 
This page took 0.034861 seconds and 4 git commands to generate.