shithub: fingerd

Download patch

ref: 5c1eb502a15d76a93a0600b57fb50a53e320790b
parent: cd993f01c6418a32db4632e88dbda5626e71a7ad
author: sirjofri <sirjofri@sirjofri.de>
date: Thu Apr 29 11:14:13 EDT 2021

adds server files

request line:
+file
(without user)

--- a/fingerd.c
+++ b/fingerd.c
@@ -100,14 +100,14 @@
 printnouser(char *user)
 {
 	if (!cat(usernotfound, 0))
-		print("User %s not found or private.\r\n", user);
+		print("User '%s' not found or private.\r\n", user);
 }
 
 void
 printnofile(char *file)
 {
-	if (!cat(usernotfound, 0))
-		print("File %s not found.\r\n", file);
+	if (!cat(filenotfound, 0))
+		print("File '%s' not found.\r\n", file);
 }
 
 void
@@ -136,17 +136,24 @@
 	}
 
 	switch(n){
-	case 0:  /* server request */
+	case 0:  /* null server request */
 		if (!cat(motd, 0))
 			print("motd not found.\r\n");
 		if (puserlist)
 			printuserlist();
 		break;
-	default: /* user request   */
+	default: /* non-null request */
 		file = splitpath(req);
 		user = req;
 		if (strlen(user) <= 0) {
-			print("bad request.\n");
+			path = smprint("/lib/finger/tree/%s", file);
+			if (!vaccess(path)){
+				printnofile(file);
+				break;
+			}
+			if (!cat(path, OREAD))
+				printnofile(file);
+			free(path);
 			break;
 		}
 		path = smprint("/usr/%s/finger/finger", user);
@@ -160,4 +167,5 @@
 			printnofile(file);
 		free(path);
 	}
+	exits(nil);
 }