-/* $OpenBSD: mesg.c,v 1.12 2016/07/07 09:26:26 semarie Exp $ */
+/* $OpenBSD: mesg.c,v 1.13 2018/08/03 06:57:34 deraadt Exp $ */
/* $NetBSD: mesg.c,v 1.4 1994/12/23 07:16:32 jtc Exp $ */
/*
char *tty;
int ch;
- if (pledge("stdio rpath fattr", NULL) == -1)
- err(2, "pledge");
-
while ((ch = getopt(argc, argv, "")) != -1)
switch (ch) {
case '?':
if ((tty = ttyname(STDERR_FILENO)) == NULL)
err(2, "ttyname");
+
+ if (unveil(tty, "rw") == -1)
+ err(1, "unveil");
+ if (pledge("stdio rpath fattr", NULL) == -1)
+ err(1, "unveil");
+
if (stat(tty, &sb) < 0)
err(2, "%s", tty);