mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-31 01:35:11 +02:00
- (dtucker) [openbsd-compat/readpassphrase.c] Update to OpenBSD's r1.22.
Fixes bz #1590, where sometimes you could not interrupt a connection while ssh was prompting for a passphrase or password.
This commit is contained in:
parent
1035cb4729
commit
d59487a33b
@ -3,6 +3,9 @@
|
|||||||
- (dtucker) [openbsd-compat/readpassphrase.c] Resync against OpenBSD's r1.18:
|
- (dtucker) [openbsd-compat/readpassphrase.c] Resync against OpenBSD's r1.18:
|
||||||
missing restore of SIGTTOU and some whitespace.
|
missing restore of SIGTTOU and some whitespace.
|
||||||
- (dtucker) [openbsd-compat/readpassphrase.c] Update to OpenBSD's r1.21.
|
- (dtucker) [openbsd-compat/readpassphrase.c] Update to OpenBSD's r1.21.
|
||||||
|
- (dtucker) [openbsd-compat/readpassphrase.c] Update to OpenBSD's r1.22.
|
||||||
|
Fixes bz #1590, where sometimes you could not interrupt a connection while
|
||||||
|
ssh was prompting for a passphrase or password.
|
||||||
|
|
||||||
20100112
|
20100112
|
||||||
- (dtucker) OpenBSD CVS Sync
|
- (dtucker) OpenBSD CVS Sync
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: readpassphrase.c,v 1.21 2008/01/17 16:27:07 millert Exp $ */
|
/* $OpenBSD: readpassphrase.c,v 1.22 2010/01/13 10:20:54 dtucker Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000-2002, 2007 Todd C. Miller <Todd.Miller@courtesan.com>
|
* Copyright (c) 2000-2002, 2007 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
@ -46,7 +46,7 @@
|
|||||||
# define _POSIX_VDISABLE VDISABLE
|
# define _POSIX_VDISABLE VDISABLE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static volatile sig_atomic_t signo;
|
static volatile sig_atomic_t signo[_NSIG];
|
||||||
|
|
||||||
static void handler(int);
|
static void handler(int);
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ char *
|
|||||||
readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
|
readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
|
||||||
{
|
{
|
||||||
ssize_t nr;
|
ssize_t nr;
|
||||||
int input, output, save_errno;
|
int input, output, save_errno, i, need_restart;
|
||||||
char ch, *p, *end;
|
char ch, *p, *end;
|
||||||
struct termios term, oterm;
|
struct termios term, oterm;
|
||||||
struct sigaction sa, savealrm, saveint, savehup, savequit, saveterm;
|
struct sigaction sa, savealrm, saveint, savehup, savequit, saveterm;
|
||||||
@ -67,9 +67,11 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
signo = 0;
|
for (i = 0; i < _NSIG; i++)
|
||||||
|
signo[i] = 0;
|
||||||
nr = -1;
|
nr = -1;
|
||||||
save_errno = 0;
|
save_errno = 0;
|
||||||
|
need_restart = 0;
|
||||||
/*
|
/*
|
||||||
* Read and write to /dev/tty if available. If not, read from
|
* Read and write to /dev/tty if available. If not, read from
|
||||||
* stdin and write to stderr unless a tty is required.
|
* stdin and write to stderr unless a tty is required.
|
||||||
@ -120,7 +122,7 @@ restart:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* No I/O if we are already backgrounded. */
|
/* No I/O if we are already backgrounded. */
|
||||||
if (signo != SIGTTOU && signo != SIGTTIN) {
|
if (signo[SIGTTOU] != 1 && signo[SIGTTIN] != 1) {
|
||||||
if (!(flags & RPP_STDIN))
|
if (!(flags & RPP_STDIN))
|
||||||
(void)write(output, prompt, strlen(prompt));
|
(void)write(output, prompt, strlen(prompt));
|
||||||
end = buf + bufsiz - 1;
|
end = buf + bufsiz - 1;
|
||||||
@ -166,15 +168,19 @@ restart:
|
|||||||
* If we were interrupted by a signal, resend it to ourselves
|
* If we were interrupted by a signal, resend it to ourselves
|
||||||
* now that we have restored the signal handlers.
|
* now that we have restored the signal handlers.
|
||||||
*/
|
*/
|
||||||
if (signo) {
|
for (i = 0; i < _NSIG; i++) {
|
||||||
kill(getpid(), signo);
|
if (signo[i]) {
|
||||||
switch (signo) {
|
kill(getpid(), i);
|
||||||
|
switch (i) {
|
||||||
case SIGTSTP:
|
case SIGTSTP:
|
||||||
case SIGTTIN:
|
case SIGTTIN:
|
||||||
case SIGTTOU:
|
case SIGTTOU:
|
||||||
|
need_restart = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (need_restart)
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (save_errno)
|
if (save_errno)
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
@ -194,6 +200,6 @@ getpass(const char *prompt)
|
|||||||
static void handler(int s)
|
static void handler(int s)
|
||||||
{
|
{
|
||||||
|
|
||||||
signo = s;
|
signo[s] = 1;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_READPASSPHRASE */
|
#endif /* HAVE_READPASSPHRASE */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user