|
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)) { |