summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-09-26 12:31:03 -0400
committerJune McEnroe <june@causal.agency>2021-09-26 12:31:21 -0400
commit3e35eeb55dae066d6b616c0d7a84ade9d9df9c44 (patch)
treed85eaf4618ef25b3e0eb74aeb1db25ad6283759a
parentOpenBSD: pledge(2) client (diff)
downloadtorus-3e35eeb55dae066d6b616c0d7a84ade9d9df9c44.tar.gz
torus-3e35eeb55dae066d6b616c0d7a84ade9d9df9c44.zip
OpenBSD: pledge(2) image
-rw-r--r--image.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/image.c b/image.c
index d8fcbc7..5e7fee7 100644
--- a/image.c
+++ b/image.c
@@ -204,11 +204,16 @@ static int streamWrite(void *cookie, const char *buf, int len) {
 
 static void worker(void) {
 	struct kfcgi *fcgi;
-	enum kcgi_err error = khttp_fcgi_init(
+	int error = khttp_fcgi_init(
 		&fcgi, Keys, KeysLen, Pages, PagesLen, PageTile
 	);
 	if (error) errkcgi(EX_CONFIG, error, "khttp_fcgi_init");
 
+#ifdef __OpenBSD__
+	error = pledge("stdio recvfd", NULL);
+	if (error) err(EX_OSERR, "pledge");
+#endif
+
 	for (;;) {
 		struct kreq req;
 		error = khttp_fcgi_parse(fcgi, &req);
@@ -276,6 +281,16 @@ int main(int argc, char *argv[]) {
 	fontLoad(fontPath);
 	tilesMap(dataPath);
 
+#ifdef __OpenBSD__
+	if (kcgi) {
+		int error = pledge("stdio unix sendfd recvfd proc", NULL);
+		if (error) err(EX_OSERR, "pledge");
+	} else {
+		int error = pledge("stdio", NULL);
+		if (error) err(EX_OSERR, "pledge");
+	}
+#endif
+
 #ifdef __FreeBSD__
 	int error = cap_enter();
 	if (error) err(EX_OSERR, "cap_enter");
e(2) serverJune McEnroe 2021-09-24Link with -lncurseswJune McEnroe 2021-09-20Replace strlcpy with snprintfJune McEnroe This removes the last BSD-specific call. 2021-09-20Replace kqueue with poll, remove libutil dependencyJune McEnroe This makes the server much more portable. 2021-02-04Update play@ascii.town descriptionJune McEnroe 2021-02-04Replace donation button with LiberapayJune McEnroe 2020-06-25Use DisableForwarding in sshd_configJune McEnroe 2019-12-19Remove READMEJune McEnroe 2019-12-15Update git URLsJune McEnroe 2019-08-05Add buymeacoffee linkJune McEnroe Can't hurt, I guess? I don't expect to get anything... 2019-07-27Use braces in MakefileJune McEnroe 2019-07-08Remove NetHack from indexJune McEnroe 2019-04-08Don't install rc.kfcgi eitherJune McEnroe 2019-03-28Remove rc.kfcgiJune McEnroe I sent a better version of it to the port maintainer and it is now in the ports tree. 2019-01-16Reformat index.html with explore linkJune McEnroe 2019-01-16Return false from keydown handler in exploreJune McEnroe 2019-01-08Draw lines to tile edgeJune McEnroe 2019-01-08Factor out default pathsJune McEnroe 2019-01-08Remove incorrect default coordinatesJune McEnroe 2019-01-07Set img src when explore fragment changesJune McEnroe 2019-01-07Compress PNG data in imageJune McEnroe kcgi never enables compression for FastCGI. 2019-01-07madvise MADV_NOCORE in imageJune McEnroe 2019-01-07Add license notice to explore JavaScriptJune McEnroe 2019-01-07Add Q/Home binding in exploreJune McEnroe 2019-01-07Fix explore image URLJune McEnroe 2019-01-07Add HOME button, ssh link, AGPL notice to exploreJune McEnroe 2019-01-06Add meta viewport to exploreJune McEnroe 2019-01-06Set background and max-width in exploreJune McEnroe 2019-01-06Swallow writes after the connection is closedJune McEnroe It was not okay. 2019-01-06Handle KCGI_HUPJune McEnroe I hope it's okay that I keep writing to the fwopen stream after streamWrite returns -1. 2019-01-06Install html filesJune McEnroe