1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

smbd: call canonicalize_snapshot_path() on link target paths from client

Prepares for having canonicalize_snapshot_path() strip any @GMT token from link
targets. In the future VFS modules won't be doing @GMT token stripping, so we
have to do it here.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2020-04-30 17:46:31 +02:00 committed by Jeremy Allison
parent 96921b6f5b
commit 7fca428cfb
2 changed files with 33 additions and 2 deletions

View File

@ -6982,7 +6982,9 @@ static NTSTATUS smb_set_file_unix_link(connection_struct *conn,
const struct smb_filename *new_smb_fname)
{
char *link_target = NULL;
struct smb_filename target_fname;
TALLOC_CTX *ctx = talloc_tos();
NTSTATUS status;
int ret;
/* Set a symbolic link. */
@ -7003,11 +7005,21 @@ static NTSTATUS smb_set_file_unix_link(connection_struct *conn,
return NT_STATUS_INVALID_PARAMETER;
}
target_fname = (struct smb_filename) {
.base_name = link_target,
};
/* Removes @GMT tokens if any */
status = canonicalize_snapshot_path(&target_fname, 0);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
DEBUG(10,("smb_set_file_unix_link: SMB_SET_FILE_UNIX_LINK doing symlink %s -> %s\n",
new_smb_fname->base_name, link_target ));
ret = SMB_VFS_SYMLINKAT(conn,
link_target,
target_fname.base_name,
conn->cwd_fsp,
new_smb_fname);
if (ret != 0) {

View File

@ -1145,7 +1145,10 @@ static NTSTATUS cmd_lock(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
static NTSTATUS cmd_symlink(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
int ret;
char *target = NULL;
struct smb_filename target_fname;
struct smb_filename *new_smb_fname = NULL;
NTSTATUS status;
if (argc != 3) {
printf("Usage: symlink <path> <link>\n");
@ -1158,8 +1161,24 @@ static NTSTATUS cmd_symlink(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc
if (new_smb_fname == NULL) {
return NT_STATUS_NO_MEMORY;
}
target = talloc_strdup(mem_ctx, argv[1]);
if (target == NULL) {
return NT_STATUS_NO_MEMORY;
}
target_fname = (struct smb_filename) {
.base_name = target,
};
/* Removes @GMT tokens if any */
status = canonicalize_snapshot_path(&target_fname, 0);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
ret = SMB_VFS_SYMLINKAT(vfs->conn,
argv[1],
target_fname.base_name,
vfs->conn->cwd_fsp,
new_smb_fname);
if (ret == -1) {