View | Details | Raw Unified | Return to bug 1871 | Differences between
and this patch

Collapse All | Expand All

(-)misc.h (+1 lines)
Lines 97-102 Link Here
97
#define RP_ALLOW_STDIN		0x0002
97
#define RP_ALLOW_STDIN		0x0002
98
#define RP_ALLOW_EOF		0x0004
98
#define RP_ALLOW_EOF		0x0004
99
#define RP_USE_ASKPASS		0x0008
99
#define RP_USE_ASKPASS		0x0008
100
#define RP_CONFIRMATION_ONLY	0x0010
100
101
101
char	*read_passphrase(const char *, int);
102
char	*read_passphrase(const char *, int);
102
int	 ask_permission(const char *, ...) __attribute__((format(printf, 1, 2)));
103
int	 ask_permission(const char *, ...) __attribute__((format(printf, 1, 2)));
(-)readpass.c (-4 / +6 lines)
Lines 48-54 Link Here
48
#include "uidswap.h"
48
#include "uidswap.h"
49
49
50
static char *
50
static char *
51
ssh_askpass(char *askpass, const char *msg)
51
ssh_askpass(char *askpass, const char *msg, int confirmation_only)
52
{
52
{
53
	pid_t pid, ret;
53
	pid_t pid, ret;
54
	size_t len;
54
	size_t len;
Lines 76-81 Link Here
76
		close(p[0]);
76
		close(p[0]);
77
		if (dup2(p[1], STDOUT_FILENO) < 0)
77
		if (dup2(p[1], STDOUT_FILENO) < 0)
78
			fatal("ssh_askpass: dup2: %s", strerror(errno));
78
			fatal("ssh_askpass: dup2: %s", strerror(errno));
79
		putenv(confirmation_only ? "SSH_ASKPASS_CONFIRMATION_ONLY=" : "SSH_ASKPASS_CONFIRMATION_ONLY");
79
		execlp(askpass, askpass, msg, (char *) 0);
80
		execlp(askpass, askpass, msg, (char *) 0);
80
		fatal("ssh_askpass: exec(%s): %s", askpass, strerror(errno));
81
		fatal("ssh_askpass: exec(%s): %s", askpass, strerror(errno));
81
	}
82
	}
Lines 119-127 Link Here
119
read_passphrase(const char *prompt, int flags)
120
read_passphrase(const char *prompt, int flags)
120
{
121
{
121
	char *askpass = NULL, *ret, buf[1024];
122
	char *askpass = NULL, *ret, buf[1024];
122
	int rppflags, use_askpass = 0, ttyfd;
123
	int rppflags, use_askpass = 0, ttyfd, confirmation_only;
123
124
124
	rppflags = (flags & RP_ECHO) ? RPP_ECHO_ON : RPP_ECHO_OFF;
125
	rppflags = (flags & RP_ECHO) ? RPP_ECHO_ON : RPP_ECHO_OFF;
126
        confirmation_only = (flags & RP_CONFIRMATION_ONLY);
125
	if (flags & RP_USE_ASKPASS)
127
	if (flags & RP_USE_ASKPASS)
126
		use_askpass = 1;
128
		use_askpass = 1;
127
	else if (flags & RP_ALLOW_STDIN) {
129
	else if (flags & RP_ALLOW_STDIN) {
Lines 149-155 Link Here
149
			askpass = getenv(SSH_ASKPASS_ENV);
151
			askpass = getenv(SSH_ASKPASS_ENV);
150
		else
152
		else
151
			askpass = _PATH_SSH_ASKPASS_DEFAULT;
153
			askpass = _PATH_SSH_ASKPASS_DEFAULT;
152
		if ((ret = ssh_askpass(askpass, prompt)) == NULL)
154
		if ((ret = ssh_askpass(askpass, prompt, confirmation_only)) == NULL)
153
			if (!(flags & RP_ALLOW_EOF))
155
			if (!(flags & RP_ALLOW_EOF))
154
				return xstrdup("");
156
				return xstrdup("");
155
		return ret;
157
		return ret;
Lines 177-183 Link Here
177
	vsnprintf(prompt, sizeof(prompt), fmt, args);
179
	vsnprintf(prompt, sizeof(prompt), fmt, args);
178
	va_end(args);
180
	va_end(args);
179
181
180
	p = read_passphrase(prompt, RP_USE_ASKPASS|RP_ALLOW_EOF);
182
	p = read_passphrase(prompt, RP_USE_ASKPASS|RP_ALLOW_EOF|RP_CONFIRMATION_ONLY);
181
	if (p != NULL) {
183
	if (p != NULL) {
182
		/*
184
		/*
183
		 * Accept empty responses and responses consisting
185
		 * Accept empty responses and responses consisting

Return to bug 1871