summaryrefslogtreecommitdiff
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authorKevin Steves <stevesk@cvs.openbsd.org>2002-09-11 18:27:27 +0000
committerKevin Steves <stevesk@cvs.openbsd.org>2002-09-11 18:27:27 +0000
commit4a41884da21d639631886d15772d9b8d60852693 (patch)
tree2f1fa674e157b9cc624f8a456f559cff0faa1cc6 /usr.bin/ssh
parent4cbe6f37a1ffd5b467f839d2c40aa0730b2e2883 (diff)
don't connect to agent to test for presence if we've previously
connected; ok markus@
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/authfd.c20
-rw-r--r--usr.bin/ssh/authfd.h3
-rw-r--r--usr.bin/ssh/ssh.c7
3 files changed, 23 insertions, 7 deletions
diff --git a/usr.bin/ssh/authfd.c b/usr.bin/ssh/authfd.c
index 4c4552d527f..f04e0858b04 100644
--- a/usr.bin/ssh/authfd.c
+++ b/usr.bin/ssh/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;
}
diff --git a/usr.bin/ssh/authfd.h b/usr.bin/ssh/authfd.h
index b2767e5c1e4..38ee49e8852 100644
--- a/usr.bin/ssh/authfd.h
+++ b/usr.bin/ssh/authfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: authfd.h,v 1.30 2002/06/19 00:27:55 deraadt Exp $ */
+/* $OpenBSD: authfd.h,v 1.31 2002/09/11 18:27:25 stevesk Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -66,6 +66,7 @@ typedef struct {
int howmany;
} AuthenticationConnection;
+int ssh_agent_present(void);
int ssh_get_authentication_socket(void);
void ssh_close_authentication_socket(int);
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c
index 1994f05f07f..8aef4a9fc03 100644
--- a/usr.bin/ssh/ssh.c
+++ b/usr.bin/ssh/ssh.c
@@ -40,7 +40,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.184 2002/08/29 19:49:42 stevesk Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.185 2002/09/11 18:27:26 stevesk Exp $");
#include <openssl/evp.h>
#include <openssl/err.h>
@@ -805,11 +805,8 @@ check_agent_present(void)
{
if (options.forward_agent) {
/* Clear agent forwarding if we don\'t have an agent. */
- int authfd = ssh_get_authentication_socket();
- if (authfd < 0)
+ if (!ssh_agent_present())
options.forward_agent = 0;
- else
- ssh_close_authentication_socket(authfd);
}
}