From: Ralph Boehme Date: Thu, 22 May 2025 15:52:28 +0000 (+0200) Subject: smbd: remove parent_dirname_compatible_open() X-Git-Tag: tevent-0.17.0~89 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=17ed8c0f9a0ab8b4b7feb213b4e3a0765f8cc0cd;p=thirdparty%2Fsamba.git smbd: remove parent_dirname_compatible_open() This is now handled correctly smbd_smb2_setinfo_rename_dst_parent_check(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=15861 Signed-off-by: Ralph Boehme Reviewed-by: Bjoern Jacke --- diff --git a/selftest/knownfail b/selftest/knownfail index 3b02dcef2de..103a0bb1d76 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -205,9 +205,7 @@ ^samba3.smb2.dir.one ^samba3.smb2.dir.modify ^samba3.smb2.oplock.stream1 -^samba3.smb2.streams.rename ^samba3.smb2.streams.rename2 -^samba3.smb2.streams streams_xattr.rename\(nt4_dc\) ^samba3.smb2.streams streams_xattr.rename2\(nt4_dc\) ^samba3.smb2.getinfo.complex ^samba3.smb2.getinfo.fsinfo # quotas don't work yet diff --git a/source3/smbd/smb2_reply.c b/source3/smbd/smb2_reply.c index 00c9f2aa6e6..cc8f02ea124 100644 --- a/source3/smbd/smb2_reply.c +++ b/source3/smbd/smb2_reply.c @@ -1343,49 +1343,6 @@ static void notify_rename(struct connection_struct *conn, TALLOC_FREE(parent_dir_dst); } -/**************************************************************************** - Returns an error if the parent directory for a filename is open in an - incompatible way. -****************************************************************************/ - -static NTSTATUS parent_dirname_compatible_open(connection_struct *conn, - const struct smb_filename *smb_fname_dst_in) -{ - struct smb_filename *smb_fname_parent = NULL; - struct file_id id; - files_struct *fsp = NULL; - int ret; - NTSTATUS status; - - status = SMB_VFS_PARENT_PATHNAME(conn, - talloc_tos(), - smb_fname_dst_in, - &smb_fname_parent, - NULL); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - ret = vfs_stat(conn, smb_fname_parent); - if (ret == -1) { - return map_nt_error_from_unix(errno); - } - - /* - * We're only checking on this smbd here, mostly good - * enough.. and will pass tests. - */ - - id = vfs_file_id_from_sbuf(conn, &smb_fname_parent->st); - for (fsp = file_find_di_first(conn->sconn, id, true); fsp; - fsp = file_find_di_next(fsp, true)) { - if (fsp->access_mask & DELETE_ACCESS) { - return NT_STATUS_SHARING_VIOLATION; - } - } - return NT_STATUS_OK; -} - /**************************************************************************** Rename an open file - given an fsp. ****************************************************************************/ @@ -1414,11 +1371,6 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, true : conn->case_preserve; struct vfs_rename_how rhow = { .flags = 0, }; - status = parent_dirname_compatible_open(conn, smb_fname_dst_in); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - if (file_has_open_streams(fsp)) { return NT_STATUS_ACCESS_DENIED; }