[SCM] Samba Shared Repository - branch v3-6-test updated

Jeremy Allison jra at samba.org
Tue Jan 18 17:56:01 MST 2011


The branch, v3-6-test has been updated
       via  6197253 Add DELETE-LN test to show bug #7863 - Unlink may unlink wrong file when hardlinks are involved (cherry picked from commit 0ab05aabc2a9d51821b2b4238b97b7e516a2e450)
      from  bf352d2 Fix "net usersidlist" not to skip every other user

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 6197253ad8ca5b8bba63865156911cecb1e1907b
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jan 18 16:57:25 2011 -0800

    Add DELETE-LN test to show bug #7863 - Unlink may unlink wrong file when hardlinks are involved
    (cherry picked from commit 0ab05aabc2a9d51821b2b4238b97b7e516a2e450)

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

Summary of changes:
 source3/torture/torture.c |  111 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 111 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index ba0e6b8..9822923 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -3998,6 +3998,116 @@ static bool run_deletetest(int dummy)
 	return correct;
 }
 
+static bool run_deletetest_ln(int dummy)
+{
+	struct cli_state *cli;
+	const char *fname = "\\delete1";
+	const char *fname_ln = "\\delete1_ln";
+	uint16_t fnum;
+	uint16_t fnum1;
+	NTSTATUS status;
+	bool correct = true;
+	time_t t;
+
+	printf("starting deletetest-ln\n");
+
+	if (!torture_open_connection(&cli, 0)) {
+		return false;
+	}
+
+	cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+	cli_unlink(cli, fname_ln, aSYSTEM | aHIDDEN);
+
+	cli_sockopt(cli, sockops);
+
+	/* Create the file. */
+	if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
+		printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+		return false;
+	}
+
+	if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
+		printf("close1 failed (%s)\n", cli_errstr(cli));
+		return false;
+	}
+
+	/* Now create a hardlink. */
+	if (!NT_STATUS_IS_OK(cli_nt_hardlink(cli, fname, fname_ln))) {
+		printf("nt hardlink failed (%s)\n", cli_errstr(cli));
+		return false;
+	}
+
+	/* Open the original file. */
+	status = cli_ntcreate(cli, fname, 0, FILE_READ_DATA,
+			FILE_ATTRIBUTE_NORMAL,
+			FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+			FILE_OPEN_IF, 0, 0, &fnum);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("ntcreate of %s failed (%s)\n", fname, nt_errstr(status));
+		return false;
+	}
+
+	/* Unlink the hard link path. */
+	status = cli_ntcreate(cli, fname_ln, 0, DELETE_ACCESS,
+			FILE_ATTRIBUTE_NORMAL,
+			FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+			FILE_OPEN_IF, 0, 0, &fnum1);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("ntcreate of %s failed (%s)\n", fname_ln, nt_errstr(status));
+		return false;
+	}
+	status = cli_nt_delete_on_close(cli, fnum1, true);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_printf("(%s) failed to set delete_on_close %s: %s\n",
+			__location__, fname_ln, nt_errstr(status));
+		return false;
+	}
+
+	status = cli_close(cli, fnum1);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("close %s failed (%s)\n",
+			fname_ln, nt_errstr(status));
+		return false;
+	}
+
+	status = cli_close(cli, fnum);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("close %s failed (%s)\n",
+			fname, nt_errstr(status));
+		return false;
+	}
+
+	/* Ensure the original file is still there. */
+        status = cli_getatr(cli, fname, NULL, NULL, &t);
+        if (!NT_STATUS_IS_OK(status)) {
+                printf("%s getatr on file %s failed (%s)\n",
+			__location__,
+			fname,
+			nt_errstr(status));
+                correct = False;
+        }
+
+	/* Ensure the link path is gone. */
+	status = cli_getatr(cli, fname_ln, NULL, NULL, &t);
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+                printf("%s, getatr for file %s returned wrong error code %s "
+			"- should have been deleted\n",
+			__location__,
+			fname_ln, nt_errstr(status));
+                correct = False;
+        }
+
+	cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
+	cli_unlink(cli, fname_ln, aSYSTEM | aHIDDEN);
+
+	if (!torture_close_connection(cli)) {
+		correct = false;
+	}
+
+	printf("finished deletetest-ln\n");
+
+	return correct;
+}
 
 /*
   print out server properties
@@ -7970,6 +8080,7 @@ static struct {
 	{"XCOPY", run_xcopy, 0},
 	{"RENAME", run_rename, 0},
 	{"DELETE", run_deletetest, 0},
+	{"DELETE-LN", run_deletetest_ln, 0},
 	{"PROPERTIES", run_properties, 0},
 	{"MANGLE", torture_mangle, 0},
 	{"MANGLE1", run_mangle1, 0},


-- 
Samba Shared Repository


More information about the samba-cvs mailing list