- (dtucker) [openbsd-compat/readpassphrase.c] Update to OpenBSD's r1.21.
This commit is contained in:
parent
ab3c2cab18
commit
1035cb4729
|
@ -2,6 +2,7 @@
|
||||||
- (dtucker) [monitor_fdpass.c] Wrap poll.h include in ifdefs.
|
- (dtucker) [monitor_fdpass.c] Wrap poll.h include in ifdefs.
|
||||||
- (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.
|
||||||
|
|
||||||
20100112
|
20100112
|
||||||
- (dtucker) OpenBSD CVS Sync
|
- (dtucker) OpenBSD CVS Sync
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* $OpenBSD: readpassphrase.c,v 1.18 2005/08/08 08:05:34 espie Exp $ */
|
/* $OpenBSD: readpassphrase.c,v 1.21 2008/01/17 16:27:07 millert Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000-2002 Todd C. Miller <Todd.Miller@courtesan.com>
|
* Copyright (c) 2000-2002, 2007 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -68,6 +68,8 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
signo = 0;
|
signo = 0;
|
||||||
|
nr = -1;
|
||||||
|
save_errno = 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.
|
||||||
|
@ -117,26 +119,30 @@ restart:
|
||||||
oterm.c_lflag |= ECHO;
|
oterm.c_lflag |= ECHO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & RPP_STDIN))
|
/* No I/O if we are already backgrounded. */
|
||||||
(void)write(output, prompt, strlen(prompt));
|
if (signo != SIGTTOU && signo != SIGTTIN) {
|
||||||
end = buf + bufsiz - 1;
|
if (!(flags & RPP_STDIN))
|
||||||
for (p = buf; (nr = read(input, &ch, 1)) == 1 && ch != '\n' && ch != '\r';) {
|
(void)write(output, prompt, strlen(prompt));
|
||||||
if (p < end) {
|
end = buf + bufsiz - 1;
|
||||||
if ((flags & RPP_SEVENBIT))
|
p = buf;
|
||||||
ch &= 0x7f;
|
while ((nr = read(input, &ch, 1)) == 1 && ch != '\n' && ch != '\r') {
|
||||||
if (isalpha(ch)) {
|
if (p < end) {
|
||||||
if ((flags & RPP_FORCELOWER))
|
if ((flags & RPP_SEVENBIT))
|
||||||
ch = tolower(ch);
|
ch &= 0x7f;
|
||||||
if ((flags & RPP_FORCEUPPER))
|
if (isalpha(ch)) {
|
||||||
ch = toupper(ch);
|
if ((flags & RPP_FORCELOWER))
|
||||||
|
ch = (char)tolower(ch);
|
||||||
|
if ((flags & RPP_FORCEUPPER))
|
||||||
|
ch = (char)toupper(ch);
|
||||||
|
}
|
||||||
|
*p++ = ch;
|
||||||
}
|
}
|
||||||
*p++ = ch;
|
|
||||||
}
|
}
|
||||||
|
*p = '\0';
|
||||||
|
save_errno = errno;
|
||||||
|
if (!(term.c_lflag & ECHO))
|
||||||
|
(void)write(output, "\n", 1);
|
||||||
}
|
}
|
||||||
*p = '\0';
|
|
||||||
save_errno = errno;
|
|
||||||
if (!(term.c_lflag & ECHO))
|
|
||||||
(void)write(output, "\n", 1);
|
|
||||||
|
|
||||||
/* Restore old terminal settings and signals. */
|
/* Restore old terminal settings and signals. */
|
||||||
if (memcmp(&term, &oterm, sizeof(term)) != 0) {
|
if (memcmp(&term, &oterm, sizeof(term)) != 0) {
|
||||||
|
@ -170,7 +176,8 @@ restart:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = save_errno;
|
if (save_errno)
|
||||||
|
errno = save_errno;
|
||||||
return(nr == -1 ? NULL : buf);
|
return(nr == -1 ? NULL : buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue