From 7d174c1f7ccc65eec267a13b704937e869c50c7a Mon Sep 17 00:00:00 2001 From: DTB Date: Wed, 28 Aug 2024 18:17:58 -0600 Subject: [PATCH] peek(1): warn on pledge(2) or unveil(2) errors --- src/peek.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/peek.c b/src/peek.c index 95fcf80..bde3811 100644 --- a/src/peek.c +++ b/src/peek.c @@ -62,8 +62,11 @@ usage(char *argv0) { int main(int argc, char *argv[]){ #ifdef __OpenBSD__ - pledge("stdio tty unveil", NULL); - unveil(NULL, NULL); + if (pledge("stdio tty unveil", "") != 0 || unveil(NULL, NULL) != 0) { + /* This isn't fatal; these return values could be cast to void just as + * easily. */ + (void)perror(argv[0] == NULL ? argv[0] : program_name); + } #endif if (argc > 0) { /* option parsing */