summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--daemon.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/daemon.c b/daemon.c
index 785504f..03955bd 100644
--- a/daemon.c
+++ b/daemon.c
@@ -19,6 +19,7 @@
 #include <fcntl.h>
 #include <fnmatch.h>
 #include <grp.h>
+#include <paths.h>
 #include <poll.h>
 #include <pwd.h>
 #include <signal.h>
@@ -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;
gheader'>2013-04-23Remove unused pluginsJune McEnroe 2013-04-23Switch to base16-default colorschemeJune McEnroe 2013-03-26Replace nerdcommenter with vim-commentaryJune McEnroe 2013-03-24Add paredit.vimJune McEnroe 2013-03-14Update base16-vimJune McEnroe It's still crap 2013-03-12Hide mode from below statuslineJune McEnroe 2013-03-12Switch to powerlineJune McEnroe Which I'm not going to bother configuring because it thinks it's all fancy and for other things that aren't Vim so it stores its config file in ~/.config which I keep in a different repo and I only want to use it for Vim so fuck you, Powerline. </rant> 2013-03-12Remove vim-powerlineJune McEnroe 2013-02-03Update base16 and refheapJune McEnroe 2013-02-03Ignore plugin/private.vimJune McEnroe 2012-09-29Disable GUI dialogsJune McEnroe