summary refs log tree commit diff
path: root/chat.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-06-24 16:58:28 -0400
committerJune McEnroe <june@causal.agency>2021-06-25 11:50:14 -0400
commitfece6e6eb620068d352ceb0433c3d74d8c22f35b (patch)
tree1a325d74331aa6a55611cdf900a5b3376c2f556c /chat.c
parentEncourage packagers to patch in text macros (diff)
downloadcatgirl-fece6e6eb620068d352ceb0433c3d74d8c22f35b.tar.gz
catgirl-fece6e6eb620068d352ceb0433c3d74d8c22f35b.zip
Keep log directory open, use mkdirat(2) and openat(2)
Diffstat (limited to '')
-rw-r--r--chat.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/chat.c b/chat.c
index a8940c3..71bfb7b 100644
--- a/chat.c
+++ b/chat.c
@@ -144,6 +144,7 @@ int main(int argc, char *argv[]) {
 	const char *cert = NULL;
 	const char *priv = NULL;
 
+	bool log = false;
 	bool sasl = false;
 	const char *pass = NULL;
 	const char *nick = NULL;
@@ -212,7 +213,7 @@ int main(int argc, char *argv[]) {
 			break; case 'i': filterAdd(Ice, optarg);
 			break; case 'j': self.join = optarg;
 			break; case 'k': priv = optarg;
-			break; case 'l': logEnable = true;
+			break; case 'l': log = true; logOpen();
 			break; case 'm': self.mode = optarg;
 			break; case 'n': nick = optarg;
 			break; case 'o': insecure = true; printCert = true;
@@ -277,7 +278,7 @@ int main(int argc, char *argv[]) {
 	}
 
 #ifdef __OpenBSD__
-	if (self.restricted && logEnable) {
+	if (self.restricted && log) {
 		const char *logdir = dataMkdir("");
 		int error = unveil(logdir, "wc");
 		if (error) err(EX_OSERR, "unveil");
@@ -285,7 +286,7 @@ int main(int argc, char *argv[]) {
 
 	char promises[64] = "stdio tty";
 	char *ptr = &promises[strlen(promises)], *end = &promises[sizeof(promises)];
-	if (logEnable) ptr = seprintf(ptr, end, " wpath cpath");
+	if (log) ptr = seprintf(ptr, end, " wpath cpath");
 	if (!self.restricted) ptr = seprintf(ptr, end, " proc exec");
 
 	char *promisesInitial = ptr;