mirror of
https://github.com/9001/copyparty.git
synced 2026-01-12 07:44:08 -07:00
sftp: allow ENOENT from rm (closes #1170);
some sftp clients will try to rm a file before creating it, expecting ENOENT even in write-only folders
This commit is contained in:
parent
9030828494
commit
8c9e1016de
|
|
@ -585,6 +585,23 @@ class SFTP_Srv(paramiko.SFTPServerInterface):
|
|||
except Pebkac as ex:
|
||||
t = "denied delete [%s]: %s"
|
||||
self.log(t % (vp, ex))
|
||||
if str(ex).startswith("file not found"):
|
||||
return SFTP_NO_SUCH_FILE
|
||||
try:
|
||||
# write-only client trying to rm before upload?
|
||||
ap, vn, _ = self.v2a(vp)
|
||||
if (
|
||||
self.uname not in vn.axs.uread
|
||||
and self.uname not in vn.axs.uwrite
|
||||
and self.uname not in vn.axs.uget
|
||||
):
|
||||
self.log("rm(%s): EPERM" % (vp,))
|
||||
return SFTP_PERMISSION_DENIED
|
||||
if not bos.path.exists(ap):
|
||||
self.log(" `- file didn't exist; returning ENOENT")
|
||||
return SFTP_NO_SUCH_FILE
|
||||
except:
|
||||
pass
|
||||
return SFTP_PERMISSION_DENIED
|
||||
except OSError as ex:
|
||||
self.log("failed: rm(%s): %r" % (vp, ex))
|
||||
|
|
|
|||
Loading…
Reference in a new issue