about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKlemens Nanni <klemens@posteo.de>2021-06-11 12:30:59 +0000
committerJune McEnroe <june@causal.agency>2021-06-11 20:57:40 -0400
commit772c9789b785231e235e08af69da89273027cf70 (patch)
tree57ac8bdda7b686e698d5e6a481368a0add7a3356
parentOpen save file once in uiLoad() and keep it open until uiSave() (diff)
downloadcatgirl-772c9789b785231e235e08af69da89273027cf70.tar.gz
catgirl-772c9789b785231e235e08af69da89273027cf70.zip
OpenBSD: Drop now unneeded file system access for save file
All opening happens before unveil/pledge and the file handle is kept
open read/write so it can be used without any pledge.

Simpler/less code and less chances to write other files (accidentially).
Diffstat (limited to '')
-rw-r--r--chat.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/chat.c b/chat.c
index e6cd270..d92240d 100644
--- a/chat.c
+++ b/chat.c
@@ -283,16 +283,15 @@ int main(int argc, char *argv[]) {
 
 #ifdef __OpenBSD__
 	if (self.restricted) {
-		if (save || logEnable) {
+		if (logEnable) {
 			dataMkdir("");
 			unveilData("");
 		}
-		if (save) unveilData(save);
 	}
 
 	char promises[64] = "stdio tty";
 	char *ptr = &promises[strlen(promises)], *end = &promises[sizeof(promises)];
-	if (save || logEnable) ptr = seprintf(ptr, end, " wpath cpath");
+	if (logEnable) ptr = seprintf(ptr, end, " wpath cpath");
 	if (!self.restricted) ptr = seprintf(ptr, end, " proc exec");
 
 	char *promisesFinal = strdup(promises);