summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-09-26 12:00:20 -0400
committerJune McEnroe <june@causal.agency>2021-09-26 12:00:20 -0400
commita70617001b96579340f5f48e4c48069cc5aecd59 (patch)
treed022cdc4fdf177a3bd139b2247a0f1c4c8d6257e
parentDraw foundations in reverse order (diff)
downloadplay-a70617001b96579340f5f48e4c48069cc5aecd59.tar.gz
play-a70617001b96579340f5f48e4c48069cc5aecd59.zip
OpenBSD: pledge(2) and unveil(2)
-rw-r--r--play.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/play.c b/play.c
index 0400b85..37e1445 100644
--- a/play.c
+++ b/play.c
@@ -295,10 +295,18 @@ int main(int argc, char *argv[]) {
 	curse();
 	atexit(info);
 
+#ifdef __OpenBSD__
+	int error = unveil(".", "rwc");
+	if (error) err(EX_OSERR, "unveil");
+
+	error = pledge("stdio tty rpath wpath cpath flock", NULL);
+	if (error) err(EX_OSERR, "pledge");
+#endif
+
 	const struct Game *game = menu();
 	if (!game) return 0;
 	erase();
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
 	setproctitle("%s", game->name);
 #endif
 
@@ -308,6 +316,11 @@ int main(int argc, char *argv[]) {
 	snprintf(buf, sizeof(buf), "%s.weekly", game->name);
 	FILE *weekly = scoresOpen(buf);
 
+#ifdef __OpenBSD__
+	error = pledge("stdio tty flock", NULL);
+	if (error) err(EX_OSERR, "pledge");
+#endif
+
 #ifdef __FreeBSD__
 	int error = cap_enter();
 	if (error) err(EX_OSERR, "cap_enter");