]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: call canonicalize_snapshot_path() on link target paths from client
authorRalph Boehme <slow@samba.org>
Thu, 30 Apr 2020 15:46:31 +0000 (17:46 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 5 May 2020 19:18:41 +0000 (19:18 +0000)
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>
source3/smbd/trans2.c
source3/torture/cmd_vfs.c

index 96087e6b456d533386d92d91f2a45e7069e0d782..fa77cb4c6e0c646c3298276be4e55dd567819ddd 100644 (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) {
index 52e0e647469569ac9fc8f169baef0bf679636155..e33c886388315398090d5c16f92cbc63a5253874 100644 (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) {