From 89d36ea5d5a28c68cca239024df7b94e3a558349 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Thu, 30 Sep 2021 02:35:03 +0000 Subject: pledge(2) hilex --- bin/hilex.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'bin/hilex.c') diff --git a/bin/hilex.c b/bin/hilex.c index 8a06eb36..2289ef95 100644 --- a/bin/hilex.c +++ b/bin/hilex.c @@ -149,6 +149,11 @@ static void ansiHeader(const char *opts[]) { close(rw[0]); close(rw[1]); setlinebuf(stdout); + +#ifdef __OpenBSD__ + error = pledge("stdio", NULL); + if (error) err(EX_OSERR, "pledge"); +#endif } static void ansiFooter(const char *opts[]) { @@ -369,6 +374,16 @@ int main(int argc, char *argv[]) { pager = isatty(STDOUT_FILENO); } +#ifdef __OpenBSD__ + int error; + if (formatter->header == ansiHeader && pager) { + error = pledge("stdio proc exec", NULL); + } else { + error = pledge("stdio", NULL); + } + if (error) err(EX_OSERR, "pledge"); +#endif + if (!name) { if (NULL != (name = strrchr(path, '/'))) { name++; -- cgit 1.4.1