[hackers] [st] Pledge on OpenBSD || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Fri, 25 May 2018 12:00:07 +0200 (CEST)

commit 30ce2cc002585409b36c630512c6ca4db8f88f15
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Fri May 25 11:59:28 2018 +0200
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Fri May 25 11:59:28 2018 +0200

    Pledge on OpenBSD

diff --git a/config.mk b/config.mk
index 039c42c..c7355f1 100644
--- a/config.mk
+++ b/config.mk
_AT_@ -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 0628707..b9750f2 100644
--- a/st.c
+++ b/st.c
_AT_@ -28,6 +28,10 @@
  #include <libutil.h>
 #endif
 
+#ifndef __OpenBSD__
+#define pledge(a,b) 0
+#endif
+
 /* Arbitrary sizes */
 #define UTF_INVALID 0xFFFD
 #define UTF_SIZ 4
_AT_@ -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);
Received on Fri May 25 2018 - 12:00:07 CEST

This archive was generated by hypermail 2.3.0 : Fri May 25 2018 - 12:00:34 CEST