diff options
author | 2017-08-22 16:32:37 +0000 | |
---|---|---|
committer | 2017-08-22 16:32:37 +0000 | |
commit | 2db3b77d97066bf441669dcac0dd5243ee3c0bad (patch) | |
tree | e45ebdda71463b0cb9e166c7309ccaada2715fae | |
parent | Use waitpid()/EINTR idiom for the specific pid, rather than generic wait(), (diff) | |
download | wireguard-openbsd-2db3b77d97066bf441669dcac0dd5243ee3c0bad.tar.xz wireguard-openbsd-2db3b77d97066bf441669dcac0dd5243ee3c0bad.zip |
Call isatty(3) prior to ioctl(TIOCEXCL) to check if cu(1) was invoked on a
non-TTY and if that's the case then close the application. Otherwise without
this verification if it's really a non-TTY then cu(1) will be aborted by
pledge(2).
feedback and OK by deraadt@
-rw-r--r-- | usr.bin/cu/cu.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/cu/cu.c b/usr.bin/cu/cu.c index efa2f4f05d7..8d1935a11c2 100644 --- a/usr.bin/cu/cu.c +++ b/usr.bin/cu/cu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cu.c,v 1.24 2015/10/16 07:01:53 deraadt Exp $ */ +/* $OpenBSD: cu.c,v 1.25 2017/08/22 16:32:37 mestre Exp $ */ /* * Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org> @@ -162,6 +162,8 @@ main(int argc, char **argv) line_fd = open(line_path, flags); if (line_fd < 0) err(1, "open(\"%s\")", line_path); + if (!isatty(line_fd)) + err(1, "%s", line_path); if (ioctl(line_fd, TIOCEXCL) != 0) err(1, "ioctl(TIOCEXCL)"); if (tcgetattr(line_fd, &line_tio) != 0) |