summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2019-02-24 08:03:32 -0800
committerKarolin Seeger <kseeger@samba.org>2019-03-04 10:37:56 +0000
commitffb706ddbce86175b69bc5425cf9a4b86737f5ec (patch)
treec2562d11a1ed38e6ba8e1ceea33139ce10447588
parent4b58042f3fa2dbb4ac65efb565431b9ace862b4a (diff)
downloadsamba-ffb706ddbce86175b69bc5425cf9a4b86737f5ec.tar.gz
s3: torture: Add additional POSIX mkdir tests.
Ensure that if POSIX_foo exists as a file we return the correct error code NT_STATUS_OBJECT_PATH_NOT_FOUND if we try and traverse it as a directory. Also ensure creation/deletion of POSIX_foo/foo fails for directories and files with NT_STATUS_OBJECT_PATH_NOT_FOUND if the directory POSIX_foo/ doesn't exist. knownfail is back :-). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13803 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> (cherry picked from commit 632d0db8c42d50f5eecd002d9573f739cd945960)
-rw-r--r--selftest/knownfail1
-rw-r--r--source3/torture/torture.c102
2 files changed, 103 insertions, 0 deletions
diff --git a/selftest/knownfail b/selftest/knownfail
index baf3d57a31a..951fbdd758e 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -9,6 +9,7 @@
^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-REAUTH # expected to give ACCESS_DENIED SMB2.1 doesn't have encryption
^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-RECONNECT # expected to give CONNECTION_DISCONNECTED, we need to fix the test
^samba3.smbtorture_s3.*ad_dc_ntvfs.*SMB2-DIR-FSYNC.*
+^samba3.smbtorture_s3.*.POSIX-MKDIR
^samba3.smb2.session enc.reconnect # expected to give CONNECTION_DISCONNECTED, we need to fix the test
^samba3.raw.session enc # expected to give ACCESS_DENIED as SMB1 encryption isn't used
^samba3.smbtorture_s3.crypt_server # expected to give ACCESS_DENIED as SMB1 encryption isn't used
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 4959ed1f4f4..4e4f3760ddf 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -7269,6 +7269,7 @@ static bool run_posix_mkdir_test(int dummy)
bool correct = false;
NTSTATUS status;
TALLOC_CTX *frame = NULL;
+ uint16_t fnum = (uint16_t)-1;
frame = talloc_stackframe();
@@ -7295,6 +7296,102 @@ static bool run_posix_mkdir_test(int dummy)
cli_posix_rmdir(cli, fname_Foo_Foo);
cli_posix_rmdir(cli, fname_Foo);
+ /*
+ * Create a file POSIX_foo then try
+ * and use it in a directory path by
+ * doing mkdir POSIX_foo/bar.
+ * The mkdir should fail with
+ * NT_STATUS_OBJECT_PATH_NOT_FOUND
+ */
+
+ status = cli_posix_open(cli,
+ fname_foo,
+ O_RDWR|O_CREAT,
+ 0666,
+ &fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_posix_open of %s failed error %s\n",
+ fname_foo,
+ nt_errstr(status));
+ goto out;
+ }
+
+ status = cli_posix_mkdir(cli, fname_foo_foo, 0777);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND)) {
+ printf("cli_posix_mkdir of %s should fail with "
+ "NT_STATUS_OBJECT_PATH_NOT_FOUND got "
+ "%s instead\n",
+ fname_foo_foo,
+ nt_errstr(status));
+ goto out;
+ }
+
+ status = cli_close(cli, fnum);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_close failed %s\n", nt_errstr(status));
+ goto out;
+ }
+ fnum = (uint16_t)-1;
+
+ status = cli_posix_unlink(cli, fname_foo);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_posix_unlink of %s failed error %s\n",
+ fname_foo,
+ nt_errstr(status));
+ goto out;
+ }
+
+ /*
+ * Now we've deleted everything, posix_mkdir, posix_rmdir,
+ * posix_open, posix_unlink, on
+ * POSIX_foo/foo should return NT_STATUS_OBJECT_PATH_NOT_FOUND
+ * not silently create POSIX_foo/foo.
+ */
+
+ status = cli_posix_mkdir(cli, fname_foo_foo, 0777);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND)) {
+ printf("cli_posix_mkdir of %s should fail with "
+ "NT_STATUS_OBJECT_PATH_NOT_FOUND got "
+ "%s instead\n",
+ fname_foo_foo,
+ nt_errstr(status));
+ goto out;
+ }
+
+ status = cli_posix_rmdir(cli, fname_foo_foo);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND)) {
+ printf("cli_posix_rmdir of %s should fail with "
+ "NT_STATUS_OBJECT_PATH_NOT_FOUND got "
+ "%s instead\n",
+ fname_foo_foo,
+ nt_errstr(status));
+ goto out;
+ }
+
+ status = cli_posix_open(cli,
+ fname_foo_foo,
+ O_RDWR|O_CREAT,
+ 0666,
+ &fnum);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND)) {
+ printf("cli_posix_open of %s should fail with "
+ "NT_STATUS_OBJECT_PATH_NOT_FOUND got "
+ "%s instead\n",
+ fname_foo_foo,
+ nt_errstr(status));
+ goto out;
+ }
+
+ status = cli_posix_unlink(cli, fname_foo_foo);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND)) {
+ printf("cli_posix_unlink of %s should fail with "
+ "NT_STATUS_OBJECT_PATH_NOT_FOUND got "
+ "%s instead\n",
+ fname_foo_foo,
+ nt_errstr(status));
+ goto out;
+ }
+
status = cli_posix_mkdir(cli, fname_foo, 0777);
if (!NT_STATUS_IS_OK(status)) {
printf("cli_posix_mkdir of %s failed\n", fname_foo);
@@ -7336,6 +7433,11 @@ static bool run_posix_mkdir_test(int dummy)
out:
+ if (fnum != (uint16_t)-1) {
+ cli_close(cli, fnum);
+ fnum = (uint16_t)-1;
+ }
+
cli_posix_rmdir(cli, fname_foo_foo);
cli_posix_rmdir(cli, fname_foo_Foo);
cli_posix_rmdir(cli, fname_foo);