The branch, v4-16-test has been updated
       via  64aea70f9f8 lib: libsmbclient: Ensure cli_rename() always sets 
cli->raw_status.
       via  5c55418c25e s4: test: Add samba4.libsmbclient.rename test. 
Currently fails for SMB3.
      from  29355d0a2d4 VERSION: Bump version up to Samba 4.16.0rc3...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-16-test


- Log -----------------------------------------------------------------
commit 64aea70f9f80acec2ba4f5da44e413f2f91c75c0
Author: Jeremy Allison <j...@samba.org>
Date:   Wed Feb 2 10:52:09 2022 -0800

    lib: libsmbclient: Ensure cli_rename() always sets cli->raw_status.
    
    Identical change as used in cli_unlink(), cli_mkdir(), cli_rmdir()
    cli_chkpath() to ensure SMB2 calls correctly set raw_status for
    libsmbclient uses.
    
    Remove knownfail.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14938
    
    Signed-off-by: Jeremy Allison <j...@samba.org>
    Reviewed-by: Ralph Boehme <s...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Wed Feb  2 21:50:31 UTC 2022 on sn-devel-184
    
    (cherry picked from commit ca60f6350d566b7ecc822bcbb44fb65a1d150bbe)
    
    Autobuild-User(v4-16-test): Jule Anger <jan...@samba.org>
    Autobuild-Date(v4-16-test): Fri Feb  4 08:41:09 UTC 2022 on sn-devel-184

commit 5c55418c25eb18d44416f486d1468ca6ccce0ab7
Author: Jeremy Allison <j...@samba.org>
Date:   Wed Feb 2 10:49:17 2022 -0800

    s4: test: Add samba4.libsmbclient.rename test. Currently fails for SMB3.
    
    Add knownfail.d/libsmbclient_rename
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14938
    
    Signed-off-by: Jeremy Allison <j...@samba.org>
    Reviewed-by: Ralph Boehme <s...@samba.org>
    (cherry picked from commit 0ecc58858360bcc0181a02e52ada3e8327f97c5b)

-----------------------------------------------------------------------

Summary of changes:
 source3/libsmb/clifile.c                    |   1 +
 source4/torture/libsmbclient/libsmbclient.c | 112 ++++++++++++++++++++++++++++
 2 files changed, 113 insertions(+)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index f1d0a9483f6..3c3f44923fc 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -1489,6 +1489,7 @@ NTSTATUS cli_rename(struct cli_state *cli,
        }
 
        status = cli_rename_recv(req);
+       cli->raw_status = status; /* cli_smb2_rename_recv doesn't set this */
 
  fail:
        TALLOC_FREE(frame);
diff --git a/source4/torture/libsmbclient/libsmbclient.c 
b/source4/torture/libsmbclient/libsmbclient.c
index fd770e5002f..b04dbde04ac 100644
--- a/source4/torture/libsmbclient/libsmbclient.c
+++ b/source4/torture/libsmbclient/libsmbclient.c
@@ -1303,6 +1303,115 @@ out:
        return ok;
 }
 
+static bool torture_libsmbclient_rename(struct torture_context *tctx)
+{
+       SMBCCTX *ctx = NULL;
+       int fhandle = -1;
+       bool success = false;
+       const char *filename_src = NULL;
+       const char *filename_dst = NULL;
+       int ret;
+       const char *smburl = torture_setting_string(tctx, "smburl", NULL);
+
+       if (smburl == NULL) {
+               torture_fail(tctx,
+                       "option --option=torture:smburl="
+                       "smb://user:password@server/share missing\n");
+       }
+
+       torture_assert_goto(tctx,
+                               torture_libsmbclient_init_context(tctx, &ctx),
+                               success,
+                               done,
+                               "");
+
+       smbc_set_context(ctx);
+
+       filename_src = talloc_asprintf(tctx,
+                       "%s/src",
+                       smburl);
+       if (filename_src == NULL) {
+               torture_fail_goto(tctx, done, "talloc fail\n");
+       }
+
+       filename_dst = talloc_asprintf(tctx,
+                       "%s/dst",
+                       smburl);
+       if (filename_dst == NULL) {
+               torture_fail_goto(tctx, done, "talloc fail\n");
+       }
+
+       /* Ensure the files don't exist. */
+       smbc_unlink(filename_src);
+       smbc_unlink(filename_dst);
+
+       /* Create them. */
+       fhandle = smbc_creat(filename_src, 0666);
+       if (fhandle < 0) {
+               torture_fail_goto(tctx,
+                       done,
+                       talloc_asprintf(tctx,
+                               "failed to create file '%s': %s",
+                               filename_src,
+                               strerror(errno)));
+       }
+       ret = smbc_close(fhandle);
+       torture_assert_int_equal_goto(tctx,
+               ret,
+               0,
+               success,
+               done,
+               talloc_asprintf(tctx,
+                       "failed to close handle for '%s'",
+                       filename_src));
+
+       fhandle = smbc_creat(filename_dst, 0666);
+       if (fhandle < 0) {
+               torture_fail_goto(tctx,
+                       done,
+                       talloc_asprintf(tctx,
+                               "failed to create file '%s': %s",
+                               filename_dst,
+                               strerror(errno)));
+       }
+       ret = smbc_close(fhandle);
+       torture_assert_int_equal_goto(tctx,
+               ret,
+               0,
+               success,
+               done,
+               talloc_asprintf(tctx,
+                       "failed to close handle for '%s'",
+                       filename_dst));
+
+       ret = smbc_rename(filename_src, filename_dst);
+
+       /*
+        * BUG: https://bugzilla.samba.org/show_bug.cgi?id=14938
+        * gives ret == -1, but errno = 0 for overwrite renames
+        * over SMB2.
+        */
+       torture_assert_int_equal_goto(tctx,
+               ret,
+               0,
+               success,
+               done,
+               talloc_asprintf(tctx,
+                       "smbc_rename '%s' -> '%s' failed with %s\n",
+                       filename_src,
+                       filename_dst,
+                       strerror(errno)));
+
+       /* Remove them again. */
+       smbc_unlink(filename_src);
+       smbc_unlink(filename_dst);
+       success = true;
+
+  done:
+       smbc_free_context(ctx, 1);
+       return success;
+}
+
 NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx)
 {
        struct torture_suite *suite;
@@ -1326,6 +1435,9 @@ NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx)
                suite, "utimes", torture_libsmbclient_utimes);
        torture_suite_add_simple_test(
                suite, "noanon_list", torture_libsmbclient_noanon_list);
+       torture_suite_add_simple_test(suite,
+                                       "rename",
+                                       torture_libsmbclient_rename);
 
        suite->description = talloc_strdup(suite, "libsmbclient interface 
tests");
 


-- 
Samba Shared Repository

Reply via email to