were not being updated if they had changed after ~^Z suspends and SIGWINCH
was not being processed unless the first connection had requested a tty;
ok markus
+ - djm@cvs.openbsd.org 2004/10/29 22:53:56
+ [clientloop.c misc.h readpass.c ssh-agent.c]
+ factor out common permission-asking code to separate function; ok markus@
20041102
- (dtucker) [configure.ac includes.h] Bug #947: Fix compile error on HP-UX
*/
#include "includes.h"
-RCSID("$OpenBSD: clientloop.c,v 1.132 2004/10/29 21:47:15 djm Exp $");
+RCSID("$OpenBSD: clientloop.c,v 1.133 2004/10/29 22:53:56 djm Exp $");
#include "ssh.h"
#include "ssh1.h"
}
allowed = 1;
- if (options.control_master == 2) {
- char *p, prompt[1024];
-
- allowed = 0;
- snprintf(prompt, sizeof(prompt),
- "Allow shared connection to %s? ", host);
- p = read_passphrase(prompt, RP_USE_ASKPASS|RP_ALLOW_EOF);
- if (p != NULL) {
- /*
- * Accept empty responses and responses consisting
- * of the word "yes" as affirmative.
- */
- if (*p == '\0' || *p == '\n' ||
- strcasecmp(p, "yes") == 0)
- allowed = 1;
- xfree(p);
- }
- }
+ if (options.control_master == 2)
+ allowed = ask_permission("Allow shared connection to %s? ",
+ host);
unset_nonblock(client_fd);
-/* $OpenBSD: misc.h,v 1.17 2004/08/11 21:43:05 avsm Exp $ */
+/* $OpenBSD: misc.h,v 1.18 2004/10/29 22:53:56 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
#define RP_USE_ASKPASS 0x0008
char *read_passphrase(const char *, int);
+int ask_permission(const char *, ...) __attribute__((format(printf, 1, 2)));
*/
#include "includes.h"
-RCSID("$OpenBSD: readpass.c,v 1.30 2004/06/17 15:10:14 djm Exp $");
+RCSID("$OpenBSD: readpass.c,v 1.31 2004/10/29 22:53:56 djm Exp $");
#include "xmalloc.h"
#include "misc.h"
memset(buf, 'x', sizeof buf);
return ret;
}
+
+int
+ask_permission(const char *fmt, ...)
+{
+ va_list args;
+ char *p, prompt[1024];
+ int allowed = 0;
+
+ va_start(args, fmt);
+ vsnprintf(prompt, sizeof(prompt), fmt, args);
+ va_end(args);
+
+ p = read_passphrase(prompt, RP_USE_ASKPASS|RP_ALLOW_EOF);
+ if (p != NULL) {
+ /*
+ * Accept empty responses and responses consisting
+ * of the word "yes" as affirmative.
+ */
+ if (*p == '\0' || *p == '\n' ||
+ strcasecmp(p, "yes") == 0)
+ allowed = 1;
+ xfree(p);
+ }
+
+ return (allowed);
+}
#include "includes.h"
#include "openbsd-compat/sys-queue.h"
-RCSID("$OpenBSD: ssh-agent.c,v 1.121 2004/10/07 10:12:36 djm Exp $");
+RCSID("$OpenBSD: ssh-agent.c,v 1.122 2004/10/29 22:53:56 djm Exp $");
#include <openssl/evp.h>
#include <openssl/md5.h>
static int
confirm_key(Identity *id)
{
- char *p, prompt[1024];
+ char *p;
int ret = -1;
p = key_fingerprint(id->key, SSH_FP_MD5, SSH_FP_HEX);
- snprintf(prompt, sizeof(prompt), "Allow use of key %s?\n"
- "Key fingerprint %s.", id->comment, p);
+ if (ask_permission("Allow use of key %s?\nKey fingerprint %s.",
+ id->comment, p))
+ ret = 0;
xfree(p);
- p = read_passphrase(prompt, RP_ALLOW_EOF);
- if (p != NULL) {
- /*
- * Accept empty responses and responses consisting
- * of the word "yes" as affirmative.
- */
- if (*p == '\0' || *p == '\n' || strcasecmp(p, "yes") == 0)
- ret = 0;
- xfree(p);
- }
+
return (ret);
}