View | Details | Raw Unified | Return to bug 3371
Collapse All | Expand All

(-)a/openbsd-compat/readpassphrase.c (-2 / +30 lines)
Lines 50-55 static volatile sig_atomic_t signo[_NSIG]; Link Here
50
50
51
static void handler(int);
51
static void handler(int);
52
52
53
/* Copied from bash's shtty.c
54
 * Copyright (C) 1999 Free Software Foundation, Inc.
55
 * Licensed under GPL v2 or later version */
56
static void tt_setonechar(struct termios *ttp)
57
{
58
	ttp->c_lflag &= ~ICANON;
59
	ttp->c_lflag |= ISIG;
60
	ttp->c_lflag |= IEXTEN;
61
	ttp->c_iflag |= ICRNL;
62
	ttp->c_iflag &= ~INLCR;
63
	ttp->c_oflag |= OPOST;
64
	ttp->c_oflag |= ONLCR;
65
	ttp->c_oflag &= ~OCRNL;
66
	ttp->c_oflag &= ~ONOCR;
67
	ttp->c_oflag &= ~ONLRET;
68
	ttp->c_cc[VMIN] = 1;
69
	ttp->c_cc[VTIME] = 0;
70
}
71
53
char *
72
char *
54
readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
73
readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
55
{
74
{
Lines 93-100 restart: Link Here
93
	 */
112
	 */
94
	if (input != STDIN_FILENO && tcgetattr(input, &oterm) == 0) {
113
	if (input != STDIN_FILENO && tcgetattr(input, &oterm) == 0) {
95
		memcpy(&term, &oterm, sizeof(term));
114
		memcpy(&term, &oterm, sizeof(term));
96
		if (!(flags & RPP_ECHO_ON))
115
		if (!(flags & RPP_ECHO_ON) || (flags & RPP_ASTERISK))
97
			term.c_lflag &= ~(ECHO | ECHONL);
116
			term.c_lflag &= ~(ECHO | ECHONL);
117
		if ((flags & RPP_ASTERISK))
118
			tt_setonechar(&term);
98
#ifdef VSTATUS
119
#ifdef VSTATUS
99
		if (term.c_cc[VSTATUS] != _POSIX_VDISABLE)
120
		if (term.c_cc[VSTATUS] != _POSIX_VDISABLE)
100
			term.c_cc[VSTATUS] = _POSIX_VDISABLE;
121
			term.c_cc[VSTATUS] = _POSIX_VDISABLE;
Lines 130-136 restart: Link Here
130
	end = buf + bufsiz - 1;
151
	end = buf + bufsiz - 1;
131
	p = buf;
152
	p = buf;
132
	while ((nr = read(input, &ch, 1)) == 1 && ch != '\n' && ch != '\r') {
153
	while ((nr = read(input, &ch, 1)) == 1 && ch != '\n' && ch != '\r') {
133
		if (p < end) {
154
		if ((ch == '\b' || ch == CERASE) && !(term.c_lflag & ECHO)) {
155
			if (p > buf) {
156
				(void)write(output, "\b \b", 3);
157
				--p;
158
			}
159
		} else if (p < end) {
160
			if ((flags & RPP_ASTERISK) && !(term.c_lflag & ECHO))
161
				(void)write(output, "*", 1);
134
			if ((flags & RPP_SEVENBIT))
162
			if ((flags & RPP_SEVENBIT))
135
				ch &= 0x7f;
163
				ch &= 0x7f;
136
			if (isalpha((unsigned char)ch)) {
164
			if (isalpha((unsigned char)ch)) {
(-)a/openbsd-compat/readpassphrase.h (+1 lines)
Lines 36-41 Link Here
36
#define RPP_FORCEUPPER  0x08		/* Force input to upper case. */
36
#define RPP_FORCEUPPER  0x08		/* Force input to upper case. */
37
#define RPP_SEVENBIT    0x10		/* Strip the high bit from input. */
37
#define RPP_SEVENBIT    0x10		/* Strip the high bit from input. */
38
#define RPP_STDIN       0x20		/* Read from stdin, not /dev/tty */
38
#define RPP_STDIN       0x20		/* Read from stdin, not /dev/tty */
39
#define RPP_ASTERISK    0x40		/* Display asterisks */
39
40
40
char * readpassphrase(const char *, char *, size_t, int);
41
char * readpassphrase(const char *, char *, size_t, int);
41
42
(-)a/readpass.c (-1 / +1 lines)
Lines 139-145 read_passphrase(const char *prompt, int flags) Link Here
139
			allow_askpass = 0;
139
			allow_askpass = 0;
140
	}
140
	}
141
141
142
	rppflags = (flags & RP_ECHO) ? RPP_ECHO_ON : RPP_ECHO_OFF;
142
	rppflags = (flags & RP_ECHO) ? RPP_ECHO_ON : RPP_ASTERISK; // RPP_ECHO_OFF;
143
	if (use_askpass)
143
	if (use_askpass)
144
		debug_f("requested to askpass");
144
		debug_f("requested to askpass");
145
	else if (flags & RP_USE_ASKPASS)
145
	else if (flags & RP_USE_ASKPASS)

Return to bug 3371