about summary refs log tree commit diff
path: root/chat.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-06-24 18:06:09 -0400
committerJune McEnroe <june@causal.agency>2021-06-25 11:50:14 -0400
commit1239ffa689964778425a75786116eb363c4961f1 (patch)
treef1a333a655bc5d1c989c7b2d09d948d60e46bc60 /chat.c
parentRemove explicit tls_handshake(3) from ircConnect (diff)
downloadcatgirl-1239ffa689964778425a75786116eb363c4961f1.tar.gz
catgirl-1239ffa689964778425a75786116eb363c4961f1.zip
FreeBSD: Limit rights on stdio and socket
Diffstat (limited to 'chat.c')
-rw-r--r--chat.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/chat.c b/chat.c
index 873eed9..821d510 100644
--- a/chat.c
+++ b/chat.c
@@ -319,6 +319,18 @@ int main(int argc, char *argv[]) {
 #endif
 
 #ifdef __FreeBSD__
+	struct { cap_rights_t stdin, stdout, stderr, irc; } rights;
+	cap_rights_init(&rights.stdin, CAP_READ, CAP_EVENT);
+	cap_rights_init(&rights.stdout, CAP_WRITE, CAP_IOCTL);
+	cap_rights_init(&rights.stderr, CAP_WRITE);
+	cap_rights_init(&rights.irc, CAP_SEND, CAP_RECV, CAP_EVENT);
+	int error = 0
+		|| cap_rights_limit(STDIN_FILENO, &rights.stdin)
+		|| cap_rights_limit(STDOUT_FILENO, &rights.stdout)
+		|| cap_rights_limit(STDERR_FILENO, &rights.stderr)
+		|| cap_rights_limit(irc, &rights.irc);
+	if (error) err(EX_OSERR, "cap_rights_limit");
+
 	if (self.restricted) {
 		int error = cap_enter();
 		if (error) err(EX_OSERR, "cap_enter");
07-08Remove TOURJune McEnroe There is not that much distinct stuff here anymore. 2022-07-03Add The Bone Shard EmperorJune McEnroe Suffers a little bit from middle book but I really enjoyed it. Read it faster than the first one too, despite its length. 2022-06-25Bump xterm font size to 12June McEnroe 2022-06-10Handle subshells (and functions) inside substitutionsJune McEnroe 2022-06-10Switch to jorts Install scriptJune McEnroe 2022-06-08Indicate if still reading or no resultsJune McEnroe 2022-06-08Add Maiden, Mother, CroneJune McEnroe Mixed bag like most collections of short stories. Some of them are pretty good. The author of the worst written story also has the worst written bio. 2022-06-05FIRST SHOW IN 2.5 YEARS BABEY!!!June McEnroe 2022-06-03Set line number on File linesJune McEnroe 2022-06-03Stop polling stdin after EOFJune McEnroe 2022-06-02Set TABSIZE=4June McEnroe Absolutely indiscriminately. 2022-06-02Do basic match highlightingJune McEnroe 2022-06-02Clean up parsing a littleJune McEnroe 2022-06-02Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe For some reason I haven't been able to figure out, trying to poll /dev/tty returns POLLNVAL (and this was using 100% CPU looping), but using stderr instead works fine. 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe