diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2018-05-25 11:59:28 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2018-05-25 11:59:28 +0200 |
commit | 30ce2cc002585409b36c630512c6ca4db8f88f15 (patch) | |
tree | a723de654153adcdd84bf51844ff7800e2f555f3 | |
parent | 041912a791e8c2f4d5d2415b16210d29d7e701c5 (diff) | |
download | st-30ce2cc002585409b36c630512c6ca4db8f88f15.tar.gz st-30ce2cc002585409b36c630512c6ca4db8f88f15.zip |
Pledge on OpenBSD
-rw-r--r-- | config.mk | 6 | ||||
-rw-r--r-- | st.c | 8 |
2 files changed, 14 insertions, 0 deletions
@@ -23,6 +23,12 @@ CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 | |||
23 | STCFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS) | 23 | STCFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS) |
24 | STLDFLAGS = $(LIBS) $(LDFLAGS) | 24 | STLDFLAGS = $(LIBS) $(LDFLAGS) |
25 | 25 | ||
26 | # OpenBSD: | ||
27 | #CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE | ||
28 | #LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \ | ||
29 | # `pkg-config --libs fontconfig` \ | ||
30 | # `pkg-config --libs freetype2` | ||
31 | |||
26 | # compiler and linker | 32 | # compiler and linker |
27 | # CC = c99 | 33 | # CC = c99 |
28 | 34 | ||
@@ -28,6 +28,10 @@ | |||
28 | #include <libutil.h> | 28 | #include <libutil.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #ifndef __OpenBSD__ | ||
32 | #define pledge(a,b) 0 | ||
33 | #endif | ||
34 | |||
31 | /* Arbitrary sizes */ | 35 | /* Arbitrary sizes */ |
32 | #define UTF_INVALID 0xFFFD | 36 | #define UTF_INVALID 0xFFFD |
33 | #define UTF_SIZ 4 | 37 | #define UTF_SIZ 4 |
@@ -806,9 +810,13 @@ ttynew(char *line, char *cmd, char *out, char **args) | |||
806 | die("ioctl TIOCSCTTY failed: %s\n", strerror(errno)); | 810 | die("ioctl TIOCSCTTY failed: %s\n", strerror(errno)); |
807 | close(s); | 811 | close(s); |
808 | close(m); | 812 | close(m); |
813 | if (pledge("stdio getpw proc exec", NULL) == -1) | ||
814 | die("pledge\n"); | ||
809 | execsh(cmd, args); | 815 | execsh(cmd, args); |
810 | break; | 816 | break; |
811 | default: | 817 | default: |
818 | if (pledge("stdio rpath tty proc", NULL) == -1) | ||
819 | die("pledge\n"); | ||
812 | close(s); | 820 | close(s); |
813 | cmdfd = m; | 821 | cmdfd = m; |
814 | signal(SIGCHLD, sigchld); | 822 | signal(SIGCHLD, sigchld); |