mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-31 01:35:11 +02:00
- 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@
This commit is contained in:
parent
5d78de6283
commit
ce327b62ac
@ -51,6 +51,9 @@
|
|||||||
were not being updated if they had changed after ~^Z suspends and SIGWINCH
|
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;
|
was not being processed unless the first connection had requested a tty;
|
||||||
ok markus
|
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
|
20041102
|
||||||
- (dtucker) [configure.ac includes.h] Bug #947: Fix compile error on HP-UX
|
- (dtucker) [configure.ac includes.h] Bug #947: Fix compile error on HP-UX
|
||||||
@ -1830,4 +1833,4 @@
|
|||||||
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
|
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
|
||||||
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
|
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.3575 2004/11/05 09:35:44 dtucker Exp $
|
$Id: ChangeLog,v 1.3576 2004/11/05 09:38:03 dtucker Exp $
|
||||||
|
23
clientloop.c
23
clientloop.c
@ -59,7 +59,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "ssh.h"
|
||||||
#include "ssh1.h"
|
#include "ssh1.h"
|
||||||
@ -592,24 +592,9 @@ client_process_control(fd_set * readset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
allowed = 1;
|
allowed = 1;
|
||||||
if (options.control_master == 2) {
|
if (options.control_master == 2)
|
||||||
char *p, prompt[1024];
|
allowed = ask_permission("Allow shared connection to %s? ",
|
||||||
|
host);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unset_nonblock(client_fd);
|
unset_nonblock(client_fd);
|
||||||
|
|
||||||
|
3
misc.h
3
misc.h
@ -1,4 +1,4 @@
|
|||||||
/* $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>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
@ -46,3 +46,4 @@ char *tilde_expand_filename(const char *, uid_t);
|
|||||||
#define RP_USE_ASKPASS 0x0008
|
#define RP_USE_ASKPASS 0x0008
|
||||||
|
|
||||||
char *read_passphrase(const char *, int);
|
char *read_passphrase(const char *, int);
|
||||||
|
int ask_permission(const char *, ...) __attribute__((format(printf, 1, 2)));
|
||||||
|
28
readpass.c
28
readpass.c
@ -23,7 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 "xmalloc.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
@ -141,3 +141,29 @@ read_passphrase(const char *prompt, int flags)
|
|||||||
memset(buf, 'x', sizeof buf);
|
memset(buf, 'x', sizeof buf);
|
||||||
return ret;
|
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);
|
||||||
|
}
|
||||||
|
20
ssh-agent.c
20
ssh-agent.c
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#include "openbsd-compat/sys-queue.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/evp.h>
|
||||||
#include <openssl/md5.h>
|
#include <openssl/md5.h>
|
||||||
@ -168,23 +168,15 @@ lookup_identity(Key *key, int version)
|
|||||||
static int
|
static int
|
||||||
confirm_key(Identity *id)
|
confirm_key(Identity *id)
|
||||||
{
|
{
|
||||||
char *p, prompt[1024];
|
char *p;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
p = key_fingerprint(id->key, SSH_FP_MD5, SSH_FP_HEX);
|
p = key_fingerprint(id->key, SSH_FP_MD5, SSH_FP_HEX);
|
||||||
snprintf(prompt, sizeof(prompt), "Allow use of key %s?\n"
|
if (ask_permission("Allow use of key %s?\nKey fingerprint %s.",
|
||||||
"Key fingerprint %s.", id->comment, p);
|
id->comment, p))
|
||||||
|
ret = 0;
|
||||||
xfree(p);
|
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);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user