s3/torture: Make cmd_chmod now use SMB_VFS_FCHMOD
authorNoel Power <noel.power@suse.com>
Thu, 8 Apr 2021 12:02:09 +0000 (13:02 +0100)
committerNoel Power <npower@samba.org>
Sun, 11 Apr 2021 22:27:34 +0000 (22:27 +0000)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/torture/cmd_vfs.c

index fec7af8a6fb25f635de122a05cc8224c2f6eb683..75d20f07d50568f5333310fa35bea624443ec095 100644 (file)
@@ -911,6 +911,8 @@ static NTSTATUS cmd_chmod(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
 {
        struct smb_filename *smb_fname = NULL;
        mode_t mode;
+       struct smb_filename *pathref_fname = NULL;
+       NTSTATUS status;
        if (argc != 3) {
                printf("Usage: chmod <path> <mode>\n");
                return NT_STATUS_OK;
@@ -918,17 +920,25 @@ static NTSTATUS cmd_chmod(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
 
        mode = atoi(argv[2]);
 
-       smb_fname = synthetic_smb_fname(talloc_tos(),
+       smb_fname = synthetic_smb_fname_split(mem_ctx,
                                        argv[1],
-                                       NULL,
-                                       NULL,
-                                       0,
-                                       ssf_flags());
+                                       lp_posix_pathnames());
        if (smb_fname == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
 
-       if (SMB_VFS_CHMOD(vfs->conn, smb_fname, mode) == -1) {
+       status = synthetic_pathref(mem_ctx,
+                               vfs->conn->cwd_fsp,
+                               smb_fname->base_name,
+                               NULL,
+                               NULL,
+                               smb_fname->twrp,
+                               smb_fname->flags,
+                               &pathref_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+       if (SMB_VFS_FCHMOD(pathref_fname->fsp, mode) == -1) {
                printf("chmod: error=%d (%s)\n", errno, strerror(errno));
                return NT_STATUS_UNSUCCESSFUL;
        }