mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
unveil of _PATH_DEVDB "/var/run/dev.db" can be done before pledge for
use by ttyname, no other files are accessed after that.
This commit is contained in:
parent
4d5b013993
commit
ed3a953df5
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: tty.c,v 1.10 2015/10/12 19:56:47 naddy Exp $ */
|
||||
/* $OpenBSD: tty.c,v 1.11 2018/08/03 06:55:41 deraadt Exp $ */
|
||||
/* $NetBSD: tty.c,v 1.4 1994/12/07 00:46:57 jtc Exp $ */
|
||||
|
||||
/*
|
||||
@ -33,6 +33,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <paths.h>
|
||||
#include <err.h>
|
||||
|
||||
static void usage(void);
|
||||
@ -43,9 +44,6 @@ main(int argc, char *argv[])
|
||||
int ch, sflag;
|
||||
char *t;
|
||||
|
||||
if (pledge("stdio rpath", NULL) == -1)
|
||||
err(1, "pledge");
|
||||
|
||||
sflag = 0;
|
||||
while ((ch = getopt(argc, argv, "s")) != -1) {
|
||||
switch(ch) {
|
||||
@ -59,6 +57,11 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (unveil(_PATH_DEVDB, "r") == -1)
|
||||
err(1, "unveil");
|
||||
if (pledge("stdio rpath", NULL) == -1)
|
||||
err(1, "pledge");
|
||||
|
||||
t = ttyname(STDIN_FILENO);
|
||||
if (!sflag)
|
||||
puts(t ? t : "not a tty");
|
||||
|
Loading…
Reference in New Issue
Block a user