From 3f411106176e4c3f63f6ab0da202786d11d19519 Mon Sep 17 00:00:00 2001 From: DTB Date: Tue, 27 Aug 2024 21:16:12 -0600 Subject: [PATCH] peek(1): pledge(2) and unveil(2) on OpenBSD --- src/peek.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/peek.c b/src/peek.c index f9fb6f8..95fcf80 100644 --- a/src/peek.c +++ b/src/peek.c @@ -22,7 +22,8 @@ #include /* exit(3), EXIT_FAILURE */ #include /* EX_IOERR, EX_OK, EX_USAGE */ #include /* tcgetattr(3), tcsetattr(3), struct termios, ECHO */ -#include /* getopt(3), isatty(3), STDIN_FILENO */ +#include /* getopt(3), isatty(3), pledge(2), unveil(2), + * STDIN_FILENO */ char *program_name = "peek"; @@ -60,6 +61,11 @@ usage(char *argv0) { } int main(int argc, char *argv[]){ +#ifdef __OpenBSD__ + pledge("stdio tty unveil", NULL); + unveil(NULL, NULL); +#endif + if (argc > 0) { /* option parsing */ char allow_nonterminals; int c;