commit 554a4490777e44371547a2337f2fc23cec5f376a
parent 0c78bacd8da3df3671010da5a81cda27102e1339
Author: Santtu Lakkala <inz@inz.fi>
Date:   Sat, 15 May 2021 23:21:08 +0300
Resolve absolute gopherroot
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/main.c b/main.c
@@ -20,6 +20,7 @@
 #include <pwd.h>
 #include <grp.h>
 #include <fcntl.h>
+#include <limits.h>
 #ifdef USE_TLS
 #include <tls.h>
 #endif
@@ -1233,6 +1234,7 @@ int main (int argc, char *argv[])
 	const char *keyfile = NULL;
 	const char *certfile = NULL;
 #endif
+	char gopherrootbuf[PATH_MAX];
 	struct addrinfo hints = { .ai_family = AF_UNSPEC, .ai_flags = AI_PASSIVE, .ai_socktype = SOCK_STREAM };
 	struct addrinfo *addrs;
 	struct addrinfo *ai;
@@ -1347,6 +1349,9 @@ int main (int argc, char *argv[])
 			croak("setuid failed");
 	}
 
+	if (*gopherroot != '/')
+		gopherroot = realpath(gopherroot, gopherrootbuf);
+
 	if (dofork) {
 		if (fork()) {
 			close(lfd);