[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Mon Feb 25 08:34:01 UTC 2019


The branch, master has been updated
       via  3f1a13a94a7 s3: smbd: filenames - ensure we replace the missing '/' if we error in an intermediate POSIX path.
       via  632d0db8c42 s3: torture: Add additional POSIX mkdir tests.
      from  c93430fe8fe ctdb-cluster-mutex: Separate out command and file handling

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 3f1a13a94a753c5cb3b9f2cf795df5adb0f74205
Author: Jeremy Allison <jra at samba.org>
Date:   Sun Feb 24 08:15:23 2019 -0800

    s3: smbd: filenames - ensure we replace the missing '/' if we error in an intermediate POSIX path.
    
    Previous regression test ensures we still return the correct
    error code for POSIX pathname operations.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13803
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Mon Feb 25 09:33:27 CET 2019 on sn-devel-144

commit 632d0db8c42d50f5eecd002d9573f739cd945960
Author: Jeremy Allison <jra at samba.org>
Date:   Sun Feb 24 08:03:32 2019 -0800

    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 at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

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

Summary of changes:
 source3/smbd/filename.c   |  18 ++++++++
 source3/torture/torture.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 120 insertions(+)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 098489abaa5..568bef897a0 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -937,6 +937,24 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 				 *
 				 * BUG: https://bugzilla.samba.org/show_bug.cgi?id=13803
 				 */
+				if (end != NULL) {
+					const char *morepath = NULL;
+					/*
+					 * If this is intermediate we must
+					 * restore the full path.
+					 */
+					*end = '/';
+					/*
+					 * If there are any more components
+					 * after the failed LSTAT we cannot
+					 * continue.
+					 */
+					morepath = strchr(end + 1, '/');
+					if (morepath != NULL) {
+						status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
+						goto fail;
+					}
+				}
 				if (errno == ENOENT) {
 					/* New file or directory. */
 					goto done;
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 0723fcb4e2b..b47f247356c 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -7271,6 +7271,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();
 
@@ -7297,6 +7298,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);
@@ -7338,6 +7435,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);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list