diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | authfd.c | 20 | ||||
-rw-r--r-- | authfd.h | 3 | ||||
-rw-r--r-- | ssh.c | 7 |
4 files changed, 28 insertions, 8 deletions
@@ -18,6 +18,10 @@ | |||
18 | - stevesk@cvs.openbsd.org 2002/09/11 17:55:03 | 18 | - stevesk@cvs.openbsd.org 2002/09/11 17:55:03 |
19 | [ssh.1] | 19 | [ssh.1] |
20 | add agent and X11 forwarding warning text from ssh_config.5; ok markus@ | 20 | add agent and X11 forwarding warning text from ssh_config.5; ok markus@ |
21 | - stevesk@cvs.openbsd.org 2002/09/11 18:27:26 | ||
22 | [authfd.c authfd.h ssh.c] | ||
23 | don't connect to agent to test for presence if we've previously | ||
24 | connected; ok markus@ | ||
21 | 25 | ||
22 | 20020911 | 26 | 20020911 |
23 | - (djm) Sync openbsd-compat with OpenBSD -current | 27 | - (djm) Sync openbsd-compat with OpenBSD -current |
@@ -1638,4 +1642,4 @@ | |||
1638 | - (stevesk) entropy.c: typo in debug message | 1642 | - (stevesk) entropy.c: typo in debug message |
1639 | - (djm) ssh-keygen -i needs seeded RNG; report from markus@ | 1643 | - (djm) ssh-keygen -i needs seeded RNG; report from markus@ |
1640 | 1644 | ||
1641 | $Id: ChangeLog,v 1.2456 2002/09/11 23:52:03 djm Exp $ | 1645 | $Id: ChangeLog,v 1.2457 2002/09/11 23:52:46 djm Exp $ |
@@ -35,7 +35,7 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include "includes.h" | 37 | #include "includes.h" |
38 | RCSID("$OpenBSD: authfd.c,v 1.56 2002/06/25 16:22:42 markus Exp $"); | 38 | RCSID("$OpenBSD: authfd.c,v 1.57 2002/09/11 18:27:26 stevesk Exp $"); |
39 | 39 | ||
40 | #include <openssl/evp.h> | 40 | #include <openssl/evp.h> |
41 | 41 | ||
@@ -53,6 +53,8 @@ RCSID("$OpenBSD: authfd.c,v 1.56 2002/06/25 16:22:42 markus Exp $"); | |||
53 | #include "log.h" | 53 | #include "log.h" |
54 | #include "atomicio.h" | 54 | #include "atomicio.h" |
55 | 55 | ||
56 | static int agent_present = 0; | ||
57 | |||
56 | /* helper */ | 58 | /* helper */ |
57 | int decode_reply(int type); | 59 | int decode_reply(int type); |
58 | 60 | ||
@@ -61,6 +63,21 @@ int decode_reply(int type); | |||
61 | ((x == SSH_AGENT_FAILURE) || (x == SSH_COM_AGENT2_FAILURE) || \ | 63 | ((x == SSH_AGENT_FAILURE) || (x == SSH_COM_AGENT2_FAILURE) || \ |
62 | (x == SSH2_AGENT_FAILURE)) | 64 | (x == SSH2_AGENT_FAILURE)) |
63 | 65 | ||
66 | int | ||
67 | ssh_agent_present(void) | ||
68 | { | ||
69 | int authfd; | ||
70 | |||
71 | if (agent_present) | ||
72 | return 1; | ||
73 | if ((authfd = ssh_get_authentication_socket()) == -1) | ||
74 | return 0; | ||
75 | else { | ||
76 | ssh_close_authentication_socket(authfd); | ||
77 | return 1; | ||
78 | } | ||
79 | } | ||
80 | |||
64 | /* Returns the number of the authentication fd, or -1 if there is none. */ | 81 | /* Returns the number of the authentication fd, or -1 if there is none. */ |
65 | 82 | ||
66 | int | 83 | int |
@@ -90,6 +107,7 @@ ssh_get_authentication_socket(void) | |||
90 | close(sock); | 107 | close(sock); |
91 | return -1; | 108 | return -1; |
92 | } | 109 | } |
110 | agent_present = 1; | ||
93 | return sock; | 111 | return sock; |
94 | } | 112 | } |
95 | 113 | ||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: authfd.h,v 1.30 2002/06/19 00:27:55 deraadt Exp $ */ | 1 | /* $OpenBSD: authfd.h,v 1.31 2002/09/11 18:27:25 stevesk Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -66,6 +66,7 @@ typedef struct { | |||
66 | int howmany; | 66 | int howmany; |
67 | } AuthenticationConnection; | 67 | } AuthenticationConnection; |
68 | 68 | ||
69 | int ssh_agent_present(void); | ||
69 | int ssh_get_authentication_socket(void); | 70 | int ssh_get_authentication_socket(void); |
70 | void ssh_close_authentication_socket(int); | 71 | void ssh_close_authentication_socket(int); |
71 | 72 | ||
@@ -40,7 +40,7 @@ | |||
40 | */ | 40 | */ |
41 | 41 | ||
42 | #include "includes.h" | 42 | #include "includes.h" |
43 | RCSID("$OpenBSD: ssh.c,v 1.184 2002/08/29 19:49:42 stevesk Exp $"); | 43 | RCSID("$OpenBSD: ssh.c,v 1.185 2002/09/11 18:27:26 stevesk Exp $"); |
44 | 44 | ||
45 | #include <openssl/evp.h> | 45 | #include <openssl/evp.h> |
46 | #include <openssl/err.h> | 46 | #include <openssl/err.h> |
@@ -829,11 +829,8 @@ check_agent_present(void) | |||
829 | { | 829 | { |
830 | if (options.forward_agent) { | 830 | if (options.forward_agent) { |
831 | /* Clear agent forwarding if we don\'t have an agent. */ | 831 | /* Clear agent forwarding if we don\'t have an agent. */ |
832 | int authfd = ssh_get_authentication_socket(); | 832 | if (!ssh_agent_present()) |
833 | if (authfd < 0) | ||
834 | options.forward_agent = 0; | 833 | options.forward_agent = 0; |
835 | else | ||
836 | ssh_close_authentication_socket(authfd); | ||
837 | } | 834 | } |
838 | } | 835 | } |
839 | 836 | ||