ftpd: only mention vols that user can access

if an ftp client tried to list the toplevel folder on a server
where nothing is mounted toplevel, it would syntheisze a
directory listing which included all volumes, even those
which the user would not be able to access

so basically not a problem, just very confusing
This commit is contained in:
ed 2024-07-15 21:24:26 +00:00
parent 6e58514b84
commit 84e8e1ddfb

View file

@ -307,9 +307,20 @@ class FtpFs(AbstractedFS):
# display write-only folders as empty # display write-only folders as empty
return [] return []
# return list of volumes # return list of accessible volumes
r = {x.split("/")[0]: 1 for x in self.hub.asrv.vfs.all_vols.keys()} ret = []
return list(sorted(list(r.keys()))) for vn in self.hub.asrv.vfs.all_vols.values():
if "/" in vn.vpath or not vn.vpath:
continue # only include toplevel-mounted vols
try:
self.hub.asrv.vfs.get(vn.vpath, self.uname, True, False)
ret.append(vn.vpath)
except:
pass
ret.sort()
return ret
def rmdir(self, path: str) -> None: def rmdir(self, path: str) -> None:
ap = self.rv2a(path, d=True)[0] ap = self.rv2a(path, d=True)[0]