Skip to content

Commit

Permalink
__OpenBSD__ around pledge().
Browse files Browse the repository at this point in the history
  • Loading branch information
nicm committed Oct 17, 2015
1 parent 487285b commit 6c3ade7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client.c
Expand Up @@ -276,6 +276,7 @@ client_main(struct event_base *base, int argc, char **argv, int flags)
if ((ttynam = ttyname(STDIN_FILENO)) == NULL)
ttynam = "";

#ifdef __OpenBSD__
/*
* Drop privileges for client. "proc exec" is needed for -c and for
* locking (which uses system(3)).
Expand All @@ -287,6 +288,7 @@ client_main(struct event_base *base, int argc, char **argv, int flags)
*/
if (pledge("stdio unix sendfd proc exec tty", NULL) != 0)
fatal("pledge failed");
#endif

/* Free stuff that is not used in the client. */
options_free(&global_options);
Expand Down Expand Up @@ -605,6 +607,7 @@ client_dispatch_wait(void)
struct msg_stdout_data stdoutdata;
struct msg_stderr_data stderrdata;
int retval;
#ifdef __OpenBSD__
static int pledge_applied;

/*
Expand All @@ -618,6 +621,7 @@ client_dispatch_wait(void)
fatal("pledge failed");
pledge_applied = 1;
};
#endif

for (;;) {
if ((n = imsg_get(&client_ibuf, &imsg)) == -1)
Expand Down

0 comments on commit 6c3ade7

Please sign in to comment.