When guenther@ switched isatty(3) to F_ISATTY, he forgot ttyname(3).
With this, simple callers of ttyname(3) like tty(1) and who(1) no
longer need pledge("tty").
Index: lib/libc/gen/ttyname.c
===================================================================
RCS file: /cvs/src/lib/libc/gen/ttyname.c,v
retrieving revision 1.15
diff -u -p -r1.15 ttyname.c
--- lib/libc/gen/ttyname.c 12 Sep 2015 14:56:50 -0000 1.15
+++ lib/libc/gen/ttyname.c 12 Oct 2015 10:58:35 -0000
@@ -32,7 +32,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
-#include <termios.h>
#include <db.h>
#include <string.h>
#include <unistd.h>
@@ -68,7 +67,6 @@ int
ttyname_r(int fd, char *buf, size_t len)
{
struct stat sb;
- struct termios ttyb;
DB *db;
DBT data, key;
struct {
@@ -77,7 +75,7 @@ ttyname_r(int fd, char *buf, size_t len)
} bkey;
/* Must be a terminal. */
- if (tcgetattr(fd, &ttyb) < 0)
+ if (fcntl(fd, F_ISATTY) == -1)
return (errno);
/* Must be a character device. */
if (fstat(fd, &sb))
Index: usr.bin/tty/tty.c
===================================================================
RCS file: /cvs/src/usr.bin/tty/tty.c,v
retrieving revision 1.9
diff -u -p -r1.9 tty.c
--- usr.bin/tty/tty.c 9 Oct 2015 01:37:09 -0000 1.9
+++ usr.bin/tty/tty.c 12 Oct 2015 11:02:51 -0000
@@ -43,7 +43,7 @@ main(int argc, char *argv[])
int ch, sflag;
char *t;
- if (pledge("stdio rpath tty", NULL) == -1)
+ if (pledge("stdio rpath", NULL) == -1)
err(1, "pledge");
sflag = 0;
Index: usr.bin/who/who.c
===================================================================
RCS file: /cvs/src/usr.bin/who/who.c,v
retrieving revision 1.25
diff -u -p -r1.25 who.c
--- usr.bin/who/who.c 11 Oct 2015 23:29:56 -0000 1.25
+++ usr.bin/who/who.c 12 Oct 2015 11:03:11 -0000
@@ -74,7 +74,7 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
- if (pledge("stdio rpath getpw tty", NULL) == -1)
+ if (pledge("stdio rpath getpw", NULL) == -1)
err(1, "pledge");
if (mytty = ttyname(0)) {
--
Christian "naddy" Weisgerber [email protected]