1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s3: smbd: Change smb_set_file_unix_link() to use a real directory fsp for SMB_VFS_SYMLINKAT().

New VFS change.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Jeremy Allison 2021-01-15 14:29:08 -08:00
parent 35f2c7641e
commit f09ea26e65

View File

@ -7009,6 +7009,9 @@ static NTSTATUS smb_set_file_unix_link(connection_struct *conn,
TALLOC_CTX *ctx = talloc_tos();
NTSTATUS status;
int ret;
struct smb_filename *parent_fname = NULL;
struct smb_filename *base_name = NULL;
bool ok;
/* Set a symbolic link. */
/* Don't allow this if follow links is false. */
@ -7041,14 +7044,38 @@ static NTSTATUS smb_set_file_unix_link(connection_struct *conn,
DEBUG(10,("smb_set_file_unix_link: SMB_SET_FILE_UNIX_LINK doing symlink %s -> %s\n",
new_smb_fname->base_name, link_target ));
ok = parent_smb_fname(ctx,
new_smb_fname,
&parent_fname,
&base_name);
if (!ok) {
return NT_STATUS_NO_MEMORY;
}
ret = vfs_stat(conn, parent_fname);
if (ret == -1) {
TALLOC_FREE(parent_fname);
return map_nt_error_from_unix(errno);
}
status = openat_pathref_fsp(conn->cwd_fsp, parent_fname);
if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) {
status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(parent_fname);
return status;
}
ret = SMB_VFS_SYMLINKAT(conn,
&target_fname,
conn->cwd_fsp,
new_smb_fname);
parent_fname->fsp,
base_name);
if (ret != 0) {
TALLOC_FREE(parent_fname);
return map_nt_error_from_unix(errno);
}
TALLOC_FREE(parent_fname);
return NT_STATUS_OK;
}