From 9b476d3ab54ac0aae949c512da5bb6bc40427a3c Mon Sep 17 00:00:00 2001 From: nekobit Date: Thu, 1 Jun 2023 01:10:47 +0000 Subject: [PATCH] OpenBSD Pledge support FossilOrigin-Name: 8cedfc5118348282ee78d14830a8d64326a62f91d34492e2f6b31e924cda0d5d --- .fossil-settings/ignore-glob | 2 ++ src/main.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob index 98f7ff8..9a70459 100644 --- a/.fossil-settings/ignore-glob +++ b/.fossil-settings/ignore-glob @@ -13,6 +13,8 @@ test/tests scripts/*.o templates/*.ctt test/unit/*.bin +treebird.core +filec.core compile_commands.json build/ obj/ diff --git a/src/main.c b/src/main.c index ee8ccaa..a184dec 100644 --- a/src/main.c +++ b/src/main.c @@ -5,6 +5,9 @@ */ #include "global_perl.h" +#ifdef __OpenBSD__ +# include +#endif #include #include #include "memory.h" @@ -272,6 +275,14 @@ int main(int argc, char **argv, char **env) #endif +#ifdef __OpenBSD__ + if (pledge("stdio rpath inet dns unveil prot_exec", "") == -1) + { + perror("pledge"); + exit(2); + } +#endif + // Global init mstdnt_global_curl_init(); #ifndef CGI_MODE @@ -281,7 +292,6 @@ int main(int argc, char **argv, char **env) } #endif - // Initialize Perl PERL_SYS_INIT3(&argc, &argv, &env); my_perl = perl_alloc();