=================================================================== RCS file: /cvs2/brogue-ce/src/platform/main.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -r1.1 -r1.2 --- brogue-ce/src/platform/main.c 2021/05/27 20:31:43 1.1 +++ brogue-ce/src/platform/main.c 2021/05/27 20:44:14 1.2 @@ -1,7 +1,11 @@ #include #include #include "platform.h" +#if defined(__OpenBSD__) +#include // For pledge() and unveil() +#endif + // Expanding a macro as a string constant requires two levels of macros #define _str(x) #x #define STRINGIFY(x) _str(x) @@ -84,6 +88,31 @@ int main(int argc, char *argv[]) int i; for (i = 1; i < argc; i++) { +#if defined(__OpenBSD__) + if (strcmp(argv[i], "--box") == 0) { + if (i + 1 < argc) { + if ( unveil("/usr","r")==-1 ) { + perror("Unveil failure. Aborting."); + exit (1); + } + if ( unveil(argv[i + 1],"rwc")==-1 ) { + perror("Unveil failure. Aborting."); + exit(1); + } + if ( chdir(argv[i+1])==-1 ) { + perror("Could not change directory."); + exit(1); + } + if ( pledge("stdio rpath wpath cpath fattr flock " + "getpw id tty proc", NULL )==-1 ) { + perror("Pledge failure. Aborting."); + exit (1); + } + i++; + continue; + } + } +#endif // OpenBSD if (strcmp(argv[i], "--scores") == 0) { // just dump the scores and quit! dumpScores();