[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Sun Nov 29 08:13:22 MST 2009


The branch, master has been updated
       via  7bbee8d... s3: Add a regression test for bug 6898
       via  603a3ba... s3: Factor out torture_setup_unix_extensions
      from  51bedf9... lib/registry/util.c - Reorder the registry datatypes of the conversion functions

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


- Log -----------------------------------------------------------------
commit 7bbee8dc17744a838834ea21b2acb2b7f8366194
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Nov 29 16:05:36 2009 +0100

    s3: Add a regression test for bug 6898

commit 603a3ba19efb0d1757c7a9ef158d2fe907e48238
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Nov 29 16:04:21 2009 +0100

    s3: Factor out torture_setup_unix_extensions

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

Summary of changes:
 source3/Makefile.in                        |    3 +-
 source3/script/tests/test_smbtorture_s3.sh |    2 +-
 source3/torture/proto.h                    |    7 ++
 source3/torture/test_posix_append.c        |   97 ++++++++++++++++++++++++++++
 source3/torture/torture.c                  |   51 +++++++++------
 5 files changed, 139 insertions(+), 21 deletions(-)
 create mode 100644 source3/torture/test_posix_append.c


Changeset truncated at 500 lines:

diff --git a/source3/Makefile.in b/source3/Makefile.in
index 6b1b64b..29a5b3d 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -1043,7 +1043,8 @@ NMBLOOKUP_OBJ = utils/nmblookup.o $(PARAM_OBJ) $(LIBNMB_OBJ) \
                $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) $(LIBSAMBA_OBJ)
 
 SMBTORTURE_OBJ1 = torture/torture.o torture/nbio.o torture/scanner.o torture/utable.o \
-		torture/denytest.o torture/mangle_test.o
+		torture/denytest.o torture/mangle_test.o \
+		torture/test_posix_append.o
 
 SMBTORTURE_OBJ = $(SMBTORTURE_OBJ1) $(PARAM_OBJ) $(TLDAP_OBJ) \
 	$(LIBSMB_OBJ) $(LDB_OBJ) $(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) \
diff --git a/source3/script/tests/test_smbtorture_s3.sh b/source3/script/tests/test_smbtorture_s3.sh
index a6ac948..774ca94 100755
--- a/source3/script/tests/test_smbtorture_s3.sh
+++ b/source3/script/tests/test_smbtorture_s3.sh
@@ -32,7 +32,7 @@ tests="$tests DIR DIR1 TCON TCONDEV RW1 RW2 RW3"
 tests="$tests OPEN XCOPY RENAME DELETE PROPERTIES W2K"
 tests="$tests TCON2 IOCTL CHKPATH FDSESS LOCAL-SUBSTITUTE CHAIN1"
 tests="$tests GETADDRINFO POSIX UID-REGRESSION-TEST SHORTNAME-TEST"
-tests="$tests LOCAL-BASE64 LOCAL-GENCACHE"
+tests="$tests LOCAL-BASE64 LOCAL-GENCACHE POSIX-APPEND"
 
 skipped1="RANDOMIPC NEGNOWAIT NBENCH ERRMAPEXTRACT TRANS2SCAN NTTRANSSCAN"
 skipped2="DENY1 DENY2 OPENATTR CASETABLE EATEST"
diff --git a/source3/torture/proto.h b/source3/torture/proto.h
index 5d7504a..d78a39d 100644
--- a/source3/torture/proto.h
+++ b/source3/torture/proto.h
@@ -70,10 +70,17 @@ bool torture_cli_session_setup2(struct cli_state *cli, uint16 *new_vuid);
 bool torture_close_connection(struct cli_state *c);
 bool torture_ioctl_test(int dummy);
 bool torture_chkpath_test(int dummy);
+NTSTATUS torture_setup_unix_extensions(struct cli_state *cli);
 
 /* The following definitions come from torture/utable.c  */
 
 bool torture_utable(int dummy);
 bool torture_casetable(int dummy);
 
+/*
+ * Misc
+ */
+
+bool run_posix_append(int dummy);
+
 #endif /* __TORTURE_H__ */
diff --git a/source3/torture/test_posix_append.c b/source3/torture/test_posix_append.c
new file mode 100644
index 0000000..36336aa
--- /dev/null
+++ b/source3/torture/test_posix_append.c
@@ -0,0 +1,97 @@
+/*
+   Unix SMB/CIFS implementation.
+   async getpwsid
+   Copyright (C) Volker Lendecke 2009
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "torture/proto.h"
+
+/*
+ * Make sure that GENERIC_WRITE does not trigger append. See
+ * https://bugzilla.samba.org/show_bug.cgi?id=6898
+ */
+
+bool run_posix_append(int dummy)
+{
+	struct cli_state *cli;
+	const char *fname = "append";
+	NTSTATUS status;
+	uint16_t fnum;
+	ssize_t written;
+	SMB_OFF_T size;
+	char c = '\0';
+	bool ret = false;
+
+	printf("Starting POSIX_APPEND\n");
+
+	if (!torture_open_connection(&cli, 0)) {
+		return false;
+	}
+
+	status = torture_setup_unix_extensions(cli);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("torture_setup_unix_extensions failed: %s\n",
+		       nt_errstr(status));
+		goto fail;
+	}
+
+	status = cli_ntcreate(
+		cli, fname, 0,
+		GENERIC_WRITE_ACCESS|GENERIC_READ_ACCESS|DELETE_ACCESS,
+		FILE_ATTRIBUTE_NORMAL|FILE_FLAG_POSIX_SEMANTICS,
+		FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+		FILE_OVERWRITE_IF,
+		FILE_NON_DIRECTORY_FILE|FILE_DELETE_ON_CLOSE,
+		0, &fnum);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("cli_ntcreate failed: %s\n", nt_errstr(status));
+		goto fail;
+	}
+
+	/*
+	 * Write two bytes at offset 0. With bug 6898 we would end up
+	 * with a file of 2 byte length.
+	 */
+
+	written = cli_write(cli, fnum, 0, &c, 0, sizeof(c));
+	if (written != sizeof(c)) {
+		printf("cli_write failed\n");
+		goto fail;
+	}
+	written = cli_write(cli, fnum, 0, &c, 0, sizeof(c));
+	if (written != sizeof(c)) {
+		printf("cli_write failed\n");
+		goto fail;
+	}
+
+	status = cli_getattrE(cli, fnum, NULL, &size, NULL, NULL, NULL);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("cli_getatrE failed: %s\n", nt_errstr(status));
+		goto fail;
+	}
+
+	if (size != sizeof(c)) {
+		printf("BUG: Writing with O_APPEND!!\n");
+		goto fail;
+	}
+
+	ret = true;
+fail:
+	torture_close_connection(cli);
+	return ret;
+}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 39f5559..5a0a300 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -4347,6 +4347,36 @@ static bool run_opentest(int dummy)
 	return correct;
 }
 
+NTSTATUS torture_setup_unix_extensions(struct cli_state *cli)
+{
+	uint16 major, minor;
+	uint32 caplow, caphigh;
+	NTSTATUS status;
+
+	if (!SERVER_HAS_UNIX_CIFS(cli)) {
+		printf("Server doesn't support UNIX CIFS extensions.\n");
+		return NT_STATUS_NOT_SUPPORTED;
+	}
+
+	status = cli_unix_extensions_version(cli, &major, &minor, &caplow,
+					     &caphigh);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("Server didn't return UNIX CIFS extensions: %s\n",
+		       nt_errstr(status));
+		return status;
+	}
+
+	status = cli_set_unix_extensions_capabilities(cli, major, minor,
+						      caplow, caphigh);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("Server doesn't support setting UNIX CIFS extensions: "
+		       "%s.\n", nt_errstr(status));
+		return status;
+        }
+
+	return NT_STATUS_OK;
+}
+
 /*
   Test POSIX open /mkdir calls.
  */
@@ -4359,8 +4389,6 @@ static bool run_simple_posix_open_test(int dummy)
 	const char *dname = "posix:dir";
 	char buf[10];
 	char namebuf[11];
-	uint16 major, minor;
-	uint32 caplow, caphigh;
 	uint16_t fnum1 = (uint16_t)-1;
 	SMB_STRUCT_STAT sbuf;
 	bool correct = false;
@@ -4374,27 +4402,11 @@ static bool run_simple_posix_open_test(int dummy)
 
 	cli_sockopt(cli1, sockops);
 
-	if (!SERVER_HAS_UNIX_CIFS(cli1)) {
-		printf("Server doesn't support UNIX CIFS extensions.\n");
-		return false;
-	}
-
-	status = cli_unix_extensions_version(cli1, &major, &minor, &caplow,
-					     &caphigh);
+	status = torture_setup_unix_extensions(cli1);
 	if (!NT_STATUS_IS_OK(status)) {
-		printf("Server didn't return UNIX CIFS extensions: %s\n",
-		       nt_errstr(status));
 		return false;
 	}
 
-	status = cli_set_unix_extensions_capabilities(cli1, major, minor,
-						      caplow, caphigh);
-	if (!NT_STATUS_IS_OK(status)) {
-		printf("Server doesn't support setting UNIX CIFS extensions: "
-		       "%s.\n", nt_errstr(status));
-		return false;
-        }
-
 	cli_setatr(cli1, fname, 0, 0);
 	cli_posix_unlink(cli1, fname);
 	cli_setatr(cli1, dname, 0, 0);
@@ -7164,6 +7176,7 @@ static struct {
 	{"RW3",  run_readwritelarge, 0},
 	{"OPEN", run_opentest, 0},
 	{"POSIX", run_simple_posix_open_test, 0},
+	{"POSIX-APPEND", run_posix_append, 0},
 	{ "UID-REGRESSION-TEST", run_uid_regression_test, 0},
 	{ "SHORTNAME-TEST", run_shortname_test, 0},
 #if 1


-- 
Samba Shared Repository


More information about the samba-cvs mailing list