diff --git a/pigz.c b/pigz.c index 0e9d635..238783b 100644 --- a/pigz.c +++ b/pigz.c @@ -347,6 +347,9 @@ #define _FILE_OFFSET_BITS 64 // Use large file functions #define _LARGE_FILES // Same thing for AIX #define _XOPEN_SOURCE 700 // For POSIX 2008 +#ifdef __OpenBSD__ +#define _BSD_SOURCE // for pledge(2) +#endif // Included headers and what is expected from each. #include // fflush(), fprintf(), fputs(), getchar(), putc(), @@ -4604,6 +4607,13 @@ int main(int argc, char **argv) { char *opts, *p; // environment default options, marker ball_t err; // error information from throw() +#ifdef __OpenBSD__ + if (pledge("stdio rpath wpath cpath fattr chown", NULL) == -1) { + complain("pledge"); + exit(1); + } +#endif + g.ret = 0; try { // initialize globals @@ -4711,6 +4721,14 @@ int main(int argc, char **argv) { argv[n] = NULL; // remove if option option(NULL); // check for missing parameter +#ifdef __OpenBSD__ + if (g.pipeout || g.decode == 2 || g.list) + if (pledge("stdio rpath", NULL) == -1) { + complain("pledge"); + exit(1); + } +#endif + // process command-line filenames done = 0; for (n = 1; n < argc; n++)