Skip to content

Commit

Permalink
Update to latest pledge(2).
Browse files Browse the repository at this point in the history
From bket@openbsd
  • Loading branch information
dajohi authored and marcopeereboom committed Jan 8, 2019
1 parent 6326e0c commit fa70043
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions netbsd/Makefile
Expand Up @@ -25,6 +25,7 @@ all: spectrwm libswmhack.so.$(LVERS)
spectrwm.c:
ln -sf ../spectrwm.c
ln -sf ../version.h
ln -sf ../linux/pledge.h

swm_hack.c:
ln -sf ../lib/swm_hack.c
Expand Down
22 changes: 15 additions & 7 deletions spectrwm.c
Expand Up @@ -3868,9 +3868,6 @@ spawn(int ws_idx, union arg *args, bool close_fd)
if (args == NULL || args->argv[0] == NULL)
return;

if (pledge("stdio proc exec", NULL) == -1)
err(1, "pledge");

DNPRINTF(SWM_D_MISC, "%s\n", args->argv[0]);

close(xcb_get_file_descriptor(conn));
Expand Down Expand Up @@ -12460,7 +12457,8 @@ main(int argc, char *argv[])
if (setlocale(LC_CTYPE, "") == NULL || setlocale(LC_TIME, "") == NULL)
warnx("no locale support");

if (pledge("stdio rpath proc exec getpw dns unix", NULL) == -1)
if (pledge("stdio proc exec cpath rpath wpath fattr getpw dns inet "
"unix", NULL) == -1)
err(1, "pledge");

/* handle some signals */
Expand All @@ -12480,6 +12478,10 @@ main(int argc, char *argv[])
if ((display = XOpenDisplay(0)) == NULL)
errx(1, "can not open display");

if (pledge("stdio proc exec cpath rpath wpath fattr getpw",
NULL) == -1)
err(1, "pledge");

conn = XGetXCBConnection(display);
if (xcb_connection_has_error(conn))
errx(1, "can not get XCB connection");
Expand All @@ -12489,9 +12491,6 @@ main(int argc, char *argv[])
xcb_prefetch_extension_data(conn, &xcb_randr_id);
xfd = xcb_get_file_descriptor(conn);

if (pledge("stdio rpath proc exec getpw", NULL) == -1)
err(1, "pledge");

/* look for local and global conf file */
pwd = getpwuid(getuid());
if (pwd == NULL)
Expand Down Expand Up @@ -12576,6 +12575,9 @@ main(int argc, char *argv[])
if (cfile)
conf_load(cfile, SWM_CONF_DEFAULT);

if (pledge("stdio proc exec cpath rpath wpath fattr", NULL) == -1)
err(1, "pledge");

validate_spawns();

if (getenv("SWM_STARTED") == NULL)
Expand All @@ -12587,6 +12589,9 @@ main(int argc, char *argv[])
TAILQ_FOREACH(r, &screens[i].rl, entry)
bar_setup(r);

if (pledge("stdio proc exec", NULL) == -1)
err(1, "pledge");

/* Manage existing windows. */
grab_windows();

Expand Down Expand Up @@ -12670,6 +12675,9 @@ main(int argc, char *argv[])
xcb_flush(conn);
}
done:
if (pledge("stdio proc", NULL) == -1)
err(1, "pledge");

shutdown_cleanup();

return (0);
Expand Down

0 comments on commit fa70043

Please sign in to comment.