diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-10-11 15:27:20 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-10-11 15:27:20 +0000 |
commit | 0c4eb929418a5f2283c5f741ef5da90b4023961c (patch) | |
tree | 46be7bf14ba5b2fb23b4c8bcc731793b376c849d /bin | |
parent | fb83d8a188634fafc7e57cde21b99b2472daf16d (diff) |
pledge "stdio tty" works once the kernel allows TIOCGWINSZ. Do the pledge
after TIOCGETD, which the kernel is unlikely to support (does not feel like
a good idea for a program to switch line disc, and therefor not worth allowing
the program to ask either)
Diffstat (limited to 'bin')
-rw-r--r-- | bin/stty/stty.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/bin/stty/stty.c b/bin/stty/stty.c index c8b6f72d43f..beb80f08d9d 100644 --- a/bin/stty/stty.c +++ b/bin/stty/stty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stty.c,v 1.16 2015/02/15 11:42:30 tedu Exp $ */ +/* $OpenBSD: stty.c,v 1.17 2015/10/11 15:27:19 deraadt Exp $ */ /* $NetBSD: stty.c,v 1.11 1995/03/21 09:11:30 cgd Exp $ */ /*- @@ -80,10 +80,14 @@ main(int argc, char *argv[]) args: argc -= optind; argv += optind; - if (tcgetattr(i.fd, &i.t) < 0) - errx(1, "not a terminal"); if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0 ) err(1, "TIOCGETD"); + + if (pledge("stdio tty", NULL) == -1) + err(1, "pledge"); + + if (tcgetattr(i.fd, &i.t) < 0) + errx(1, "not a terminal"); if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0) warn("TIOCGWINSZ"); @@ -94,9 +98,13 @@ args: argc -= optind; /* FALLTHROUGH */ case BSD: case POSIX: + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); print(&i.t, &i.win, i.ldisc, fmt); break; case GFLAG: + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); gprint(&i.t, &i.win, i.ldisc); break; } |