]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4/torture: add a *real* root_dir_fid test
authorRalph Boehme <slow@samba.org>
Thu, 14 May 2020 12:22:16 +0000 (14:22 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 14 May 2020 18:07:39 +0000 (18:07 +0000)
raw.samba3rootdirfid tests with the share root directory as root_dir_fid handle,
that doesn't cover the case where the relative name has more then one path
component. It only works because in unix_convert() we run into the creating file
optimasation.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14380

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/samba3.raw.samba3rootdirfid2 [new file with mode: 0644]
source3/selftest/tests.py
source4/torture/raw/raw.c
source4/torture/raw/samba3misc.c

diff --git a/selftest/knownfail.d/samba3.raw.samba3rootdirfid2 b/selftest/knownfail.d/samba3.raw.samba3rootdirfid2
new file mode 100644 (file)
index 0000000..745c841
--- /dev/null
@@ -0,0 +1 @@
+^samba3.raw.samba3rootdirfid2
index b5d7c3678834d4272284540fcb2e9c69494e56d0..7309c05a7a521f0b3d4646b5b93471f2ccf5db88 100755 (executable)
@@ -553,7 +553,7 @@ raw = ["raw.acls", "raw.chkpath", "raw.close", "raw.composite", "raw.context", "
        "raw.sfileinfo.base", "raw.sfileinfo.bug", "raw.streams", "raw.unlink", "raw.write",
        "raw.samba3hide", "raw.samba3badpath", "raw.sfileinfo.rename", "raw.session",
        "raw.samba3caseinsensitive", "raw.samba3posixtimedlock",
-       "raw.samba3rootdirfid", "raw.sfileinfo.end-of-file",
+       "raw.samba3rootdirfid", "raw.samba3rootdirfid2", "raw.sfileinfo.end-of-file",
        "raw.bench-oplock", "raw.bench-lock", "raw.bench-open", "raw.bench-tcon",
        "raw.samba3checkfsp", "raw.samba3closeerr", "raw.samba3oplocklogoff", "raw.samba3badnameblob"]
 
@@ -832,6 +832,7 @@ for t in tests:
                   "raw.samba3oplocklogoff",
                   "raw.samba3posixtimedlock",
                   "raw.samba3rootdirfid",
+                  "raw.samba3rootdirfid2",
                   "raw.seek",
                   "raw.sfileinfo.bug",
                   "raw.sfileinfo.end-of-file",
index a225efe0b5d25a767c38ff92f737ac6dc838a23a..b3716b6d0afd1e0b77bfd9fcb10122b9fb122891 100644 (file)
@@ -67,6 +67,8 @@ NTSTATUS torture_raw_init(TALLOC_CTX *ctx)
        torture_suite_add_1smb_test(suite, "samba3closeerr", torture_samba3_closeerr);
        torture_suite_add_1smb_test(suite, "samba3rootdirfid",
                                      torture_samba3_rootdirfid);
+       torture_suite_add_1smb_test(suite, "samba3rootdirfid2",
+                                     torture_samba3_rootdirfid2);
        torture_suite_add_1smb_test(suite, "samba3checkfsp", torture_samba3_checkfsp);
        torture_suite_add_1smb_test(suite, "samba3oplocklogoff", torture_samba3_oplock_logoff);
        torture_suite_add_1smb_test(suite, "samba3badnameblob", torture_samba3_check_openX_badname);
index 2f484023bea813fa8a05af24103f7fc323ccbd5f..dda1fdd9eeb0c5d6cdfb9af21dbbc2c918d4206a 100644 (file)
@@ -986,6 +986,80 @@ bool torture_samba3_rootdirfid(struct torture_context *tctx, struct smbcli_state
        return ret;
 }
 
+bool torture_samba3_rootdirfid2(struct torture_context *tctx, struct smbcli_state *cli)
+{
+       int fnum;
+       uint16_t dnum;
+       union smb_open io;
+       const char *dirname1 = "dir1";
+       const char *dirname2 = "dir1/dir2";
+       const char *path = "dir1/dir2/testfile";
+       const char *relname = "dir2/testfile";
+       bool ret = false;
+
+       smbcli_deltree(cli->tree, dirname1);
+
+       torture_assert(tctx, torture_setup_dir(cli, dirname1), "creating test directory");
+       torture_assert(tctx, torture_setup_dir(cli, dirname2), "creating test directory");
+
+       fnum = smbcli_open(cli->tree, path, O_RDWR | O_CREAT, DENY_NONE);
+       if (fnum == -1) {
+               torture_result(tctx, TORTURE_FAIL,
+                       "Could not create file: %s",
+                        smbcli_errstr(cli->tree));
+               goto done;
+       }
+       smbcli_close(cli->tree, fnum);
+
+       ZERO_STRUCT(io);
+       io.generic.level = RAW_OPEN_NTCREATEX;
+       io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
+       io.ntcreatex.in.root_fid.fnum = 0;
+       io.ntcreatex.in.security_flags = 0;
+       io.ntcreatex.in.access_mask =
+               SEC_STD_SYNCHRONIZE | SEC_FILE_EXECUTE;
+       io.ntcreatex.in.alloc_size = 0;
+       io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
+       io.ntcreatex.in.share_access =
+               NTCREATEX_SHARE_ACCESS_READ
+               | NTCREATEX_SHARE_ACCESS_READ;
+       io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+       io.ntcreatex.in.create_options = 0;
+       io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+       io.ntcreatex.in.fname = dirname1;
+       torture_assert_ntstatus_equal_goto(tctx, smb_raw_open(cli->tree, tctx, &io),
+                                          NT_STATUS_OK,
+                                          ret, done, "smb_open on the directory failed: %s\n");
+
+       dnum = io.ntcreatex.out.file.fnum;
+
+       io.ntcreatex.in.flags =
+               NTCREATEX_FLAGS_REQUEST_OPLOCK
+               | NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
+       io.ntcreatex.in.root_fid.fnum = dnum;
+       io.ntcreatex.in.security_flags = 0;
+       io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+       io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+       io.ntcreatex.in.alloc_size = 0;
+       io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+       io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+       io.ntcreatex.in.create_options = 0;
+       io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+       io.ntcreatex.in.fname = relname;
+
+       torture_assert_ntstatus_equal_goto(tctx, smb_raw_open(cli->tree, tctx, &io),
+                                          NT_STATUS_OK,
+                                          ret, done, "smb_open on the file failed");
+
+       smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
+       smbcli_close(cli->tree, dnum);
+
+       ret = true;
+done:
+       smbcli_deltree(cli->tree, dirname1);
+       return ret;
+}
+
 bool torture_samba3_oplock_logoff(struct torture_context *tctx, struct smbcli_state *cli)
 {
        union smb_open io;