Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenBSD: use pledge(2) #112

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pigz.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdio.h> // fflush(), fprintf(), fputs(), getchar(), putc(),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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++)
Expand Down