From 296e40887bea88959cf496221ec8a9e0a665b726 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Mon, 17 Aug 2020 16:38:22 -0400 Subject: Use pledge(2) and unveil(2) on OpenBSD --- daemon.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/daemon.c b/daemon.c index 785504f..03955bd 100644 --- a/daemon.c +++ b/daemon.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -189,7 +190,9 @@ static void setTitle(void) { } int main(int argc, char *argv[]) { + int error; setprogname(argv[0]); + openlog(getprogname(), LOG_NDELAY | LOG_PID | LOG_PERROR, LOG_DAEMON); bool daemonize = true; setAdd(&stopExits, EX_USAGE); @@ -220,8 +223,28 @@ int main(int argc, char *argv[]) { break; default: return EX_USAGE; } } + +#ifdef __OpenBSD__ + if (pidPath) { + error = unveil(pidPath, "cw"); + if (error) err(EX_OSERR, "unveil"); + } + error = unveil(fifoPath, "crw") + || unveil(configPath, "r") + || unveil("/", "r") + || unveil("/dev/null", "rw") + || unveil(serviceDir, "r") + || unveil(_PATH_BSHELL, "x") + || unveil(NULL, NULL); + if (error) err(EX_OSERR, "unveil"); + + error = pledge( + "stdio cpath dpath rpath wpath flock getpw proc exec id", NULL + ); + if (error) err(EX_OSERR, "pledge"); +#endif - int error = access(serviceDir, X_OK); + error = access(serviceDir, X_OK); if (error) err(EX_NOINPUT, "%s", serviceDir); errno = 0; -- cgit 1.4.1 ='right' method='get' action='/scooper/log/configure'>
Commit message (Expand)Author
2021-09-13Link with -ldl on Linux 1.3June McEnroe
2021-09-13Document lack of dependency on SQLiteJune McEnroe
2021-09-13Build with vendored sqlite3June McEnroe
2021-09-12Call sqlite3_initialize explicitlyJune McEnroe
2021-09-12Vendor SQLite 3.36.0June McEnroe
2021-05-19Add -h flag to hide user hostnames 1.2June McEnroe
2021-05-19Replace freenode with tilde.chatJune McEnroe
2021-05-08Document the export query parameterJune McEnroe
2021-05-07Create a database with litterbox for testJune McEnroe
2021-05-07Add missing static declarations in html.cJune McEnroe
2021-05-07Reverse order of search resultsJune McEnroe
2021-05-07Try to keep query at end of parametersJune McEnroe
2021-05-07Use LDADD variables, support BINDIRJune McEnroe
2020-12-13Use nick for color if user is "*" 1.1June McEnroe
2020-08-23Use DESTDIR in install 1.0June McEnroe
2020-08-23Add catsit example to READMEJune McEnroe
2020-08-23Update litterbox version rangeJune McEnroe
2020-08-19Set a database busy timeoutJune McEnroe
2020-07-29Add Linux supportJune McEnroe
2020-07-29Remove unused prevEventJune McEnroe
2020-07-23Rewrite configure scriptJune McEnroe
2020-07-21Add OpenBSD instructionsJune McEnroe
2020-07-21Use a .pc file to configureJune McEnroe
2020-07-19Filter networks with only private contexts from recents as wellJune McEnroe
2020-07-18Specify litterbox version in readmeJune McEnroe
2020-07-18Reverse order of X macro parameters for pages and keysJune McEnroe
2020-07-18Remove kcgi 0.11 compatibilityJune McEnroe
2020-07-17Filter networks with only private contextsJune McEnroe
2020-07-17Add export optionJune McEnroe
2020-07-17Add margin to inputsJune McEnroe
2020-07-16Don't write null terminator in stylesheet responseJune McEnroe
2020-07-16Remove sudo from make installJune McEnroe