ftp: CWD is optional (#539)

This commit is contained in:
ed 2025-09-05 22:36:16 +00:00
parent aaeec11f81
commit b049631169

View file

@ -152,10 +152,6 @@ class FtpFs(AbstractedFS):
self.cwd = "/" # pyftpdlib convention of leading slash self.cwd = "/" # pyftpdlib convention of leading slash
self.root = "/var/lib/empty" self.root = "/var/lib/empty"
self.can_read = self.can_write = self.can_move = False
self.can_delete = self.can_get = self.can_upget = False
self.can_admin = self.can_dot = False
self.listdirinfo = self.listdir self.listdirinfo = self.listdir
self.chdir(".") self.chdir(".")
@ -218,7 +214,7 @@ class FtpFs(AbstractedFS):
m: bool = False, m: bool = False,
d: bool = False, d: bool = False,
) -> tuple[str, VFS, str]: ) -> tuple[str, VFS, str]:
return self.v2a(os.path.join(self.cwd, vpath), r, w, m, d) return self.v2a(join(self.cwd, vpath), r, w, m, d)
def ftp2fs(self, ftppath: str) -> str: def ftp2fs(self, ftppath: str) -> str:
# return self.v2a(ftppath) # return self.v2a(ftppath)
@ -297,16 +293,6 @@ class FtpFs(AbstractedFS):
avfs = vfs avfs = vfs
self.cwd = nwd self.cwd = nwd
(
self.can_read,
self.can_write,
self.can_move,
self.can_delete,
self.can_get,
self.can_upget,
self.can_admin,
self.can_dot,
) = avfs.can_access("", self.h.uname)
def mkdir(self, path: str) -> None: def mkdir(self, path: str) -> None:
ap, vfs, _ = self.rv2a(path, w=True) ap, vfs, _ = self.rv2a(path, w=True)
@ -329,7 +315,7 @@ class FtpFs(AbstractedFS):
vfs_ls = [x[0] for x in vfs_ls1] vfs_ls = [x[0] for x in vfs_ls1]
vfs_ls.extend(vfs_virt.keys()) vfs_ls.extend(vfs_virt.keys())
if not self.can_dot: if self.uname not in vfs.axs.udot:
vfs_ls = exclude_dotfiles(vfs_ls) vfs_ls = exclude_dotfiles(vfs_ls)
vfs_ls.sort() vfs_ls.sort()
@ -377,9 +363,6 @@ class FtpFs(AbstractedFS):
raise FSE(str(ex)) raise FSE(str(ex))
def rename(self, src: str, dst: str) -> None: def rename(self, src: str, dst: str) -> None:
if not self.can_move:
raise FSE("Not allowed for user " + self.h.uname)
if self.args.no_mv: if self.args.no_mv:
raise FSE("The rename/move feature is disabled in server config") raise FSE("The rename/move feature is disabled in server config")