git: 9front

Download patch

ref: fd46aa6665112a84b4497f449a6cc0aa494cc9a6
parent: 9e94af8a63f547479c8b019942adc141fb42bbb1
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Aug 25 10:47:17 EDT 2024

gefs: only allow 'none' attach when previously authenticated

For each connection, remember if authentication
protocol ran successfully and only then, allow
attach as 'none' user.

This prevents anonymous remote mounts of none.

The 'none' user also shouldnt attach to the dump
file system.

--- a/sys/src/cmd/gefs/dat.h
+++ b/sys/src/cmd/gefs/dat.h
@@ -659,6 +659,7 @@
 	int	wfd;
 	int	iounit;
 	int	versioned;
+	int	authok;
 
 	/* fid hash table */
 	Lock	fidtablk[Nfidtab];
--- a/sys/src/cmd/gefs/fs.c
+++ b/sys/src/cmd/gefs/fs.c
@@ -1158,10 +1158,15 @@
 		putfid(af);
 		if(af->uid != uid)
 			error(Ebadu);
-	}else if(!fs->noauth && strcmp(m->uname, "none") != 0)
-		error(Ebadu);
+		m->conn->authok = 1;	/* none attach allowed now */
+	}else if(!fs->noauth){
+		if(uid != noneid || !m->conn->authok)
+			error(Ebadu);
+	}
 
 	if(strcmp(m->aname, "dump") == 0){
+		if(uid == noneid)
+			error(Eperm);
 		memset(&d, 0, sizeof(d));
 		filldumpdir(&d);
 	}else{
--