shithub: front

Download patch

ref: f384231c607989e0dfa51da2fcce925ccd7f89ae
parent: 9645ae07eb66a59015e3e118d0024790c37400da
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{
--