summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--clientloop.c23
-rw-r--r--misc.h3
-rw-r--r--readpass.c28
-rw-r--r--ssh-agent.c20
5 files changed, 43 insertions, 36 deletions
diff --git a/ChangeLog b/ChangeLog
index 02892cc61..3847553dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -51,6 +51,9 @@
51 were not being updated if they had changed after ~^Z suspends and SIGWINCH 51 were not being updated if they had changed after ~^Z suspends and SIGWINCH
52 was not being processed unless the first connection had requested a tty; 52 was not being processed unless the first connection had requested a tty;
53 ok markus 53 ok markus
54 - djm@cvs.openbsd.org 2004/10/29 22:53:56
55 [clientloop.c misc.h readpass.c ssh-agent.c]
56 factor out common permission-asking code to separate function; ok markus@
54 57
5520041102 5820041102
56 - (dtucker) [configure.ac includes.h] Bug #947: Fix compile error on HP-UX 59 - (dtucker) [configure.ac includes.h] Bug #947: Fix compile error on HP-UX
@@ -1830,4 +1833,4 @@
1830 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 1833 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
1831 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 1834 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
1832 1835
1833$Id: ChangeLog,v 1.3575 2004/11/05 09:35:44 dtucker Exp $ 1836$Id: ChangeLog,v 1.3576 2004/11/05 09:38:03 dtucker Exp $
diff --git a/clientloop.c b/clientloop.c
index 009480ea1..d77337b82 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.132 2004/10/29 21:47:15 djm Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.133 2004/10/29 22:53:56 djm Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -592,24 +592,9 @@ client_process_control(fd_set * readset)
592 } 592 }
593 593
594 allowed = 1; 594 allowed = 1;
595 if (options.control_master == 2) { 595 if (options.control_master == 2)
596 char *p, prompt[1024]; 596 allowed = ask_permission("Allow shared connection to %s? ",
597 597 host);
598 allowed = 0;
599 snprintf(prompt, sizeof(prompt),
600 "Allow shared connection to %s? ", host);
601 p = read_passphrase(prompt, RP_USE_ASKPASS|RP_ALLOW_EOF);
602 if (p != NULL) {
603 /*
604 * Accept empty responses and responses consisting
605 * of the word "yes" as affirmative.
606 */
607 if (*p == '\0' || *p == '\n' ||
608 strcasecmp(p, "yes") == 0)
609 allowed = 1;
610 xfree(p);
611 }
612 }
613 598
614 unset_nonblock(client_fd); 599 unset_nonblock(client_fd);
615 600
diff --git a/misc.h b/misc.h
index ec47a611d..0290a2d64 100644
--- a/misc.h
+++ b/misc.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.h,v 1.17 2004/08/11 21:43:05 avsm Exp $ */ 1/* $OpenBSD: misc.h,v 1.18 2004/10/29 22:53:56 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -46,3 +46,4 @@ char *tilde_expand_filename(const char *, uid_t);
46#define RP_USE_ASKPASS 0x0008 46#define RP_USE_ASKPASS 0x0008
47 47
48char *read_passphrase(const char *, int); 48char *read_passphrase(const char *, int);
49int ask_permission(const char *, ...) __attribute__((format(printf, 1, 2)));
diff --git a/readpass.c b/readpass.c
index eb4f6fdb6..c2bacdcd4 100644
--- a/readpass.c
+++ b/readpass.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: readpass.c,v 1.30 2004/06/17 15:10:14 djm Exp $"); 26RCSID("$OpenBSD: readpass.c,v 1.31 2004/10/29 22:53:56 djm Exp $");
27 27
28#include "xmalloc.h" 28#include "xmalloc.h"
29#include "misc.h" 29#include "misc.h"
@@ -141,3 +141,29 @@ read_passphrase(const char *prompt, int flags)
141 memset(buf, 'x', sizeof buf); 141 memset(buf, 'x', sizeof buf);
142 return ret; 142 return ret;
143} 143}
144
145int
146ask_permission(const char *fmt, ...)
147{
148 va_list args;
149 char *p, prompt[1024];
150 int allowed = 0;
151
152 va_start(args, fmt);
153 vsnprintf(prompt, sizeof(prompt), fmt, args);
154 va_end(args);
155
156 p = read_passphrase(prompt, RP_USE_ASKPASS|RP_ALLOW_EOF);
157 if (p != NULL) {
158 /*
159 * Accept empty responses and responses consisting
160 * of the word "yes" as affirmative.
161 */
162 if (*p == '\0' || *p == '\n' ||
163 strcasecmp(p, "yes") == 0)
164 allowed = 1;
165 xfree(p);
166 }
167
168 return (allowed);
169}
diff --git a/ssh-agent.c b/ssh-agent.c
index fffed1342..dd7e22ad5 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -35,7 +35,7 @@
35 35
36#include "includes.h" 36#include "includes.h"
37#include "openbsd-compat/sys-queue.h" 37#include "openbsd-compat/sys-queue.h"
38RCSID("$OpenBSD: ssh-agent.c,v 1.121 2004/10/07 10:12:36 djm Exp $"); 38RCSID("$OpenBSD: ssh-agent.c,v 1.122 2004/10/29 22:53:56 djm Exp $");
39 39
40#include <openssl/evp.h> 40#include <openssl/evp.h>
41#include <openssl/md5.h> 41#include <openssl/md5.h>
@@ -168,23 +168,15 @@ lookup_identity(Key *key, int version)
168static int 168static int
169confirm_key(Identity *id) 169confirm_key(Identity *id)
170{ 170{
171 char *p, prompt[1024]; 171 char *p;
172 int ret = -1; 172 int ret = -1;
173 173
174 p = key_fingerprint(id->key, SSH_FP_MD5, SSH_FP_HEX); 174 p = key_fingerprint(id->key, SSH_FP_MD5, SSH_FP_HEX);
175 snprintf(prompt, sizeof(prompt), "Allow use of key %s?\n" 175 if (ask_permission("Allow use of key %s?\nKey fingerprint %s.",
176 "Key fingerprint %s.", id->comment, p); 176 id->comment, p))
177 ret = 0;
177 xfree(p); 178 xfree(p);
178 p = read_passphrase(prompt, RP_ALLOW_EOF); 179
179 if (p != NULL) {
180 /*
181 * Accept empty responses and responses consisting
182 * of the word "yes" as affirmative.
183 */
184 if (*p == '\0' || *p == '\n' || strcasecmp(p, "yes") == 0)
185 ret = 0;
186 xfree(p);
187 }
188 return (ret); 180 return (ret);
189} 181}
190 182