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).
weechat-hashes
Klemens Nanni 2021-06-11 12:30:59 +00:00 committed by C. McEnroe
parent cdd4ccf16f
commit 772c9789b7
1 changed files with 2 additions and 3 deletions

5
chat.c
View File

@ -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);