summary refs log tree commit diff
diff options
context:
space:
mode:
authorKlemens Nanni <kn@openbsd.org>2021-01-22 22:02:02 +0100
committerJune McEnroe <june@causal.agency>2021-01-23 00:48:19 -0500
commitbc3bd956481131a15dcae95eb818b3b3ccc7ed79 (patch)
tree87b247c8590e9de7ad6eee62717999fb2da701bb
parentDrop exec capability iff restricted (diff)
downloadcatgirl-bc3bd956481131a15dcae95eb818b3b3ccc7ed79.tar.gz
catgirl-bc3bd956481131a15dcae95eb818b3b3ccc7ed79.zip
Drop filesystem access iff possible
Log files and state save/restore both require read/write access to
the filesystem, both during start and exit.

If neither features are used, catgirl may run with "stdio tty".
Diffstat (limited to '')
-rw-r--r--chat.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/chat.c b/chat.c
index b36223c..6458925 100644
--- a/chat.c
+++ b/chat.c
@@ -341,10 +341,12 @@ int main(int argc, char *argv[]) {
 	}
 
 #ifdef __OpenBSD__
-	if (self.restricted) {
-		error = pledge("stdio rpath wpath cpath tty", NULL);
-		if (error) err(EX_OSERR, "pledge");
-	}
+	char promises[64] = "stdio tty";
+	struct Cat cat = { promises, sizeof(promises), strlen(promises) };
+	if (save || logEnable) catf(&cat, " rpath wpath cpath");
+	if (!self.restricted) catf(&cat, " proc exec");
+	error = pledge(promises, NULL);
+	if (error) err(EX_OSERR, "pledge");
 #endif
 
 	struct pollfd fds[] = {
='logmsg'> 2017-07-31Track tile access countsJune McEnroe 2017-07-31Adjust move speed in clientJune McEnroe 2017-07-31Handle large movesJune McEnroe 2017-07-30Optimize builds for chrootJune McEnroe 2017-07-30Persist bright across color changesJune McEnroe 2017-07-30Add index.htmlJune McEnroe 2017-07-30Add snapshot.shJune McEnroe 2017-07-30Fix termcap patch for background colorsJune McEnroe 2017-07-30Update helpJune McEnroe 2017-07-30Fix help to track colorJune McEnroe 2017-07-30Support background colorsJune McEnroe 2017-07-30Track color only client-sideJune McEnroe 2017-07-30Add ostensible support for background colorsJune McEnroe 2017-07-30Add tile create and access timestampsJune McEnroe 2017-07-30Assert stable struct Tile field offsetsJune McEnroe 2017-07-30Add chroot.shJune McEnroe 2017-07-30Add ` commandJune McEnroe 2017-07-30Add sshd_configJune McEnroe 2017-07-30Add termcap patchJune McEnroe