]> git.armaanb.net Git - st.git/commitdiff
Pledge on OpenBSD
authorHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 25 May 2018 09:59:28 +0000 (11:59 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 25 May 2018 09:59:28 +0000 (11:59 +0200)
config.mk
st.c

index 039c42cef08937b45ce5a4b53ddc84e8716f41c6..c7355f1507c8b30d0ee08066322f3b51d7928c11 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -23,6 +23,12 @@ CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
 STCFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS)
 STLDFLAGS = $(LIBS) $(LDFLAGS)
 
+# OpenBSD:
+#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
+#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
+#       `pkg-config --libs fontconfig` \
+#       `pkg-config --libs freetype2`
+
 # compiler and linker
 # CC = c99
 
diff --git a/st.c b/st.c
index 0628707eae4bc351c483caf7477782d8273203b4..b9750f28a4eded5b908675bdbb8bb89aac358a5b 100644 (file)
--- a/st.c
+++ b/st.c
  #include <libutil.h>
 #endif
 
+#ifndef __OpenBSD__
+#define pledge(a,b) 0
+#endif
+
 /* Arbitrary sizes */
 #define UTF_INVALID   0xFFFD
 #define UTF_SIZ       4
@@ -806,9 +810,13 @@ ttynew(char *line, char *cmd, char *out, char **args)
                        die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
                close(s);
                close(m);
+               if (pledge("stdio getpw proc exec", NULL) == -1)
+                       die("pledge\n");
                execsh(cmd, args);
                break;
        default:
+               if (pledge("stdio rpath tty proc", NULL) == -1)
+                       die("pledge\n");
                close(s);
                cmdfd = m;
                signal(SIGCHLD, sigchld);