From 84e8e1ddfbe2629151ff0ae498b6e335501bc0bb Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 15 Jul 2024 21:24:26 +0000 Subject: [PATCH] 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 --- copyparty/ftpd.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/copyparty/ftpd.py b/copyparty/ftpd.py index ea6a9798..1e1fa577 100644 --- a/copyparty/ftpd.py +++ b/copyparty/ftpd.py @@ -307,9 +307,20 @@ class FtpFs(AbstractedFS): # display write-only folders as empty return [] - # return list of volumes - r = {x.split("/")[0]: 1 for x in self.hub.asrv.vfs.all_vols.keys()} - return list(sorted(list(r.keys()))) + # return list of accessible volumes + ret = [] + 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: ap = self.rv2a(path, d=True)[0]