diff --git a/st.c b/st.c index 27536d2..5b18b58 100644 --- a/st.c +++ b/st.c @@ -45,6 +45,9 @@ char *argv0; #elif defined(__FreeBSD__) || defined(__DragonFly__) #include #endif +#ifndef __OpenBSD__ +int pledge(const char *promises, const char *paths[]) { return 0; } +#endif /* XEMBED messages */ @@ -368,6 +371,7 @@ static void execsh(void); static void stty(void); static void sigchld(int); static void run(void); +static void xpledge(const char *promises, const char *paths[]); static void csidump(void); static void csihandle(void); @@ -4224,6 +4228,8 @@ run(void) struct timespec drawtimeout, *tv = NULL, now, last, lastblink; long deltatime; + xpledge("stdio rpath wpath tty proc getpw exec", NULL); + /* Waiting for window mapping */ do { XNextEvent(xw.dpy, &ev); @@ -4247,6 +4253,8 @@ run(void) clock_gettime(CLOCK_MONOTONIC, &last); lastblink = last; + xpledge("stdio rpath tty proc", NULL); + for (xev = actionfps;;) { FD_ZERO(&rfd); FD_SET(cmdfd, &rfd); @@ -4336,6 +4344,14 @@ usage(void) " [stty_args ...]\n", argv0, argv0); } +void +xpledge(const char *promises, const char *paths[]) +{ + if (pledge(promises, paths) < 0) { + die("st: pledge: %s (%s)\n", strerror(errno), promises); + } +} + int main(int argc, char *argv[]) {