summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-02-03 18:01:26 -0200
committerRenato Botelho <renato@netgate.com>2016-02-03 18:01:26 -0200
commitaf0758169e63a4e7f6024c241d9254a8bc09908d (patch)
treea31903fc62c875e8d23a391beb8ae57ed0092c45 /lib/libc
parent79f27b5150f7b79a6f1bcd30e9233f1abb9c3e36 (diff)
parent6114d518f71115abacc5d610c4d668ef6e0b2f37 (diff)
downloadFreeBSD-src-af0758169e63a4e7f6024c241d9254a8bc09908d.zip
FreeBSD-src-af0758169e63a4e7f6024c241d9254a8bc09908d.tar.gz
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/readpassphrase.c24
-rw-r--r--lib/libc/mips/SYS.h28
2 files changed, 37 insertions, 15 deletions
diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c
index 60051a1..0961fbb 100644
--- a/lib/libc/gen/readpassphrase.c
+++ b/lib/libc/gen/readpassphrase.c
@@ -46,7 +46,7 @@ char *
readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
{
ssize_t nr;
- int input, output, save_errno, i, need_restart;
+ int input, output, save_errno, i, need_restart, input_is_tty;
char ch, *p, *end;
struct termios term, oterm;
struct sigaction sa, savealrm, saveint, savehup, savequit, saveterm;
@@ -68,12 +68,20 @@ restart:
* Read and write to /dev/tty if available. If not, read from
* stdin and write to stderr unless a tty is required.
*/
- if ((flags & RPP_STDIN) ||
- (input = output = _open(_PATH_TTY, O_RDWR | O_CLOEXEC)) == -1) {
- if (flags & RPP_REQUIRE_TTY) {
- errno = ENOTTY;
- return(NULL);
+ input_is_tty = 0;
+ if (!(flags & RPP_STDIN)) {
+ input = output = _open(_PATH_TTY, O_RDWR | O_CLOEXEC);
+ if (input == -1) {
+ if (flags & RPP_REQUIRE_TTY) {
+ errno = ENOTTY;
+ return(NULL);
+ }
+ input = STDIN_FILENO;
+ output = STDERR_FILENO;
+ } else {
+ input_is_tty = 1;
}
+ } else {
input = STDIN_FILENO;
output = STDERR_FILENO;
}
@@ -83,7 +91,7 @@ restart:
* If we are using a tty but are not the foreground pgrp this will
* generate SIGTTOU, so do it *before* installing the signal handlers.
*/
- if (input != STDIN_FILENO && tcgetattr(input, &oterm) == 0) {
+ if (input_is_tty && tcgetattr(input, &oterm) == 0) {
memcpy(&term, &oterm, sizeof(term));
if (!(flags & RPP_ECHO_ON))
term.c_lflag &= ~(ECHO | ECHONL);
@@ -152,7 +160,7 @@ restart:
(void)__libc_sigaction(SIGTSTP, &savetstp, NULL);
(void)__libc_sigaction(SIGTTIN, &savettin, NULL);
(void)__libc_sigaction(SIGTTOU, &savettou, NULL);
- if (input != STDIN_FILENO)
+ if (input_is_tty)
(void)_close(input);
/*
diff --git a/lib/libc/mips/SYS.h b/lib/libc/mips/SYS.h
index 10205b8..ceb6812 100644
--- a/lib/libc/mips/SYS.h
+++ b/lib/libc/mips/SYS.h
@@ -100,13 +100,31 @@
* Do a syscall that cannot fail (sync, get{p,u,g,eu,eg)id)
*/
#define RSYSCALL_NOERROR(x) \
- PSEUDO_NOERROR(x)
+LEAF(__sys_ ## x); \
+ .weak _C_LABEL(x); \
+ _C_LABEL(x) = _C_LABEL(__CONCAT(__sys_,x)); \
+ .weak _C_LABEL(__CONCAT(_,x)); \
+ _C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \
+ SYSTRAP(x); \
+ j ra; \
+END(__sys_ ## x)
/*
* Do a normal syscall.
*/
#define RSYSCALL(x) \
- PSEUDO(x)
+LEAF(__sys_ ## x); \
+ .weak _C_LABEL(x); \
+ _C_LABEL(x) = _C_LABEL(__CONCAT(__sys_,x)); \
+ .weak _C_LABEL(__CONCAT(_,x)); \
+ _C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \
+ PIC_PROLOGUE(__sys_ ## x); \
+ SYSTRAP(x); \
+ bne a3,zero,err; \
+ PIC_RETURN(); \
+err: \
+ PIC_TAILCALL(__cerror); \
+END(__sys_ ## x)
/*
* Do a renamed or pseudo syscall (e.g., _exit()), where the entrypoint
@@ -114,18 +132,14 @@
*/
#define PSEUDO_NOERROR(x) \
LEAF(__sys_ ## x); \
- .weak _C_LABEL(x); \
- _C_LABEL(x) = _C_LABEL(__CONCAT(__sys_,x)); \
.weak _C_LABEL(__CONCAT(_,x)); \
_C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \
SYSTRAP(x); \
j ra; \
- END(__sys_ ## x)
+END(__sys_ ## x)
#define PSEUDO(x) \
LEAF(__sys_ ## x); \
- .weak _C_LABEL(x); \
- _C_LABEL(x) = _C_LABEL(__CONCAT(__sys_,x)); \
.weak _C_LABEL(__CONCAT(_,x)); \
_C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \
PIC_PROLOGUE(__sys_ ## x); \
OpenPOWER on IntegriCloud