shithub: fingerd

Download patch

ref: 2d06a930cc56ebbb4b6bdff969b3306a9a61c3c3
parent: 23aaf92ee4cc8844a5390e3048a23b39c917730c
author: sirjofri <[email protected]>
date: Tue Apr 20 04:04:20 EDT 2021

replaces / with + as a path delimiter. Some clients are picky!

--- a/README
+++ b/README
@@ -8,9 +8,10 @@
 - `/lib/finger/usernotfound`
 - `/lib/finger/filenotfound`
 - `/usr/$user/finger/finger`: `finger [email protected]`
-- `/usr/$user/finger/file`: `finger $user/[email protected]`
+- `/usr/$user/finger/file`: `finger [email protected]`
 
 Notes:
 
 - `finger @example.com` can also print a list of users.
 - If `/lib/finger` files are not here, generic messages will be printed.
+- paths can be arbitrarily long, stepping into subdirectories. All `+` will be replaced with `/` for building paths.
--- a/fingerd.c
+++ b/fingerd.c
@@ -24,6 +24,16 @@
 	return -1;
 }
 
+void
+strrepl(char *str, char f, char t)
+{
+	while (*str != 0){
+		if (*str == f)
+			*str = t;
+		str++;
+	}
+}
+
 int
 cat(char *file, int perr)
 {
@@ -46,10 +56,11 @@
 splitpath(char *req)
 {
 	char *file;
-	file = strchr(req, '/');
+	file = strchr(req, '+');
 	if (file == nil || strlen(file) <= 1)
 		return "finger";
 	file[0] = 0;
+	strrepl(file+1, '+', '/');
 	return file+1;
 }