From: Ralph Boehme Date: Thu, 12 Nov 2020 14:44:08 +0000 (+0100) Subject: smbd: use openat_pathref_fsp() rename_internals() X-Git-Tag: samba-4.14.0rc1~345 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=492ca5819a40f06d59d670d39c98271b223a5a55;p=thirdparty%2Fsamba.git smbd: use openat_pathref_fsp() rename_internals() Ensures we have a pathref handle in the smb_fname we pass to SMB_VFS_CREATE_FILE(). Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index e945c4ecbe5..2dbe3c60b8a 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -8017,6 +8017,14 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, goto out; } + status = openat_pathref_fsp(conn->cwd_fsp, smb_fname_src); + if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) { + status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + if (!NT_STATUS_IS_OK(status)) { + goto out; + } + if (S_ISDIR(smb_fname_src->st.st_ex_mode)) { create_options |= FILE_DIRECTORY_FILE; } @@ -8181,6 +8189,17 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, SMB_VFS_STAT(conn, smb_fname_src); } + status = openat_pathref_fsp(conn->cwd_fsp, smb_fname_src); + if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) { + status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + if (!NT_STATUS_IS_OK(status)) { + DBG_INFO("openat_pathref_fsp [%s] failed: %s\n", + smb_fname_str_dbg(smb_fname_src), + nt_errstr(status)); + break; + } + create_options = 0; if (S_ISDIR(smb_fname_src->st.st_ex_mode)) {