aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-10-31 12:05:35 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-10-31 12:05:35 +0100
commit48801bec1ef80a97c14ec2c9974300a3e2a7eb21 (patch)
treea184a68119a75ee98ddc9ae161fb69538ec07d25
parent92b848f05c63ce52cab1416e8b063cccbe341bb1 (diff)
Work on using pledge() in OpenBSD
-rw-r--r--src/main.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index e0dd03a..cc001af 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,8 +54,20 @@ int
main(int argc, char **argv)
{
mlib_setprogname(argv[0]);
- setlocale(LC_ALL, "");
+ /* TODO: Can we test this in an OpenBSD VM? */
+#if 0 && defined(__OpenBSD__)
+ const char *promises =
+#if GIT_GRAB
+ "stdio rpath prot exec";
+#else
+ "stdio rpath";
+#endif
+ if (pledge("stdio rpath", NULL) == -1)
+ cerr(EXIT_FATAL, "pledge:");
+#endif
+
+ setlocale(LC_ALL, "");
if (streq(nl_langinfo(CODESET), "UTF-8")) {
lquot = u8"‘";
rquot = u8"’";
@@ -367,6 +379,11 @@ getfstream(int globc, char **globv)
cerr(EXIT_FATAL, "execvp: git grep -Ilz '':");
}
+ /* TODO: Can we test this in an OpenBSD VM? */
+#if 0 && defined(__OpenBSD__)
+ if (pledge("stdio rpath") == -1)
+ cerr(EXIT_FATAL, "pledge:");
+#endif
close(fds[W]);
return fdopen(fds[R], "r");
}