From a70617001b96579340f5f48e4c48069cc5aecd59 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sun, 26 Sep 2021 12:00:20 -0400 Subject: OpenBSD: pledge(2) and unveil(2) --- play.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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"); -- cgit 1.4.1