Pledge on OpenBSD

master
Hiltjo Posthuma 7 years ago
parent 041912a791
commit 30ce2cc002

@ -23,6 +23,12 @@ CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
STCFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS) STCFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS)
STLDFLAGS = $(LIBS) $(LDFLAGS) 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 # compiler and linker
# CC = c99 # CC = c99

@ -28,6 +28,10 @@
#include <libutil.h> #include <libutil.h>
#endif #endif
#ifndef __OpenBSD__
#define pledge(a,b) 0
#endif
/* Arbitrary sizes */ /* Arbitrary sizes */
#define UTF_INVALID 0xFFFD #define UTF_INVALID 0xFFFD
#define UTF_SIZ 4 #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)); die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
close(s); close(s);
close(m); close(m);
if (pledge("stdio getpw proc exec", NULL) == -1)
die("pledge\n");
execsh(cmd, args); execsh(cmd, args);
break; break;
default: default:
if (pledge("stdio rpath tty proc", NULL) == -1)
die("pledge\n");
close(s); close(s);
cmdfd = m; cmdfd = m;
signal(SIGCHLD, sigchld); signal(SIGCHLD, sigchld);

Loading…
Cancel
Save