[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Sat Oct 17 22:07:18 MDT 2009


The branch, master has been updated
       via  9ae4dae... s4-torture: fixed the streams tests for Samba4
       via  764c09e... s4-streams: fixed handling of stream rename and overwrite
       via  44612c7... s4-pvfs: rename with full name gives SHARING_VIOLATION
       via  83db71e... s4-pvfs: when reporting the file name, don't include the :$DATA suffix
       via  2d4ad4f... s4-pvfs: the STREAM_INFORMATION calls don't need any access flags
       via  edd0ea5... s4-pvfs: fixed update of stream sizes
      from  8d85757... Fix posix_unlink test. Was doing grep without quotes around the target string. Jeremy.

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


- Log -----------------------------------------------------------------
commit 9ae4daeb96ecf99f17f425678d2386758ab5aa35
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sun Oct 18 14:22:42 2009 +1100

    s4-torture: fixed the streams tests for Samba4
    
    In some cases we were not doing streams tests on s4 that we should. In
    others, we were calling tests that are known to fail on s4. Some of
    those are a bit puzzling.

commit 764c09e6bc92d8ccd33b44d6cc80e82a9b4d76f0
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sun Oct 18 14:19:27 2009 +1100

    s4-streams: fixed handling of stream rename and overwrite

commit 44612c74a6de8becd8f8dc51590616ba792ca13f
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sun Oct 18 14:15:48 2009 +1100

    s4-pvfs: rename with full name gives SHARING_VIOLATION

commit 83db71e9a71f01d6a9eea2d1436bd9ee28c250a0
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sun Oct 18 14:14:16 2009 +1100

    s4-pvfs: when reporting the file name, don't include the :$DATA suffix

commit 2d4ad4f5048269afcfeece446780855dd3cd5649
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sun Oct 18 14:13:45 2009 +1100

    s4-pvfs: the STREAM_INFORMATION calls don't need any access flags

commit edd0ea5225c61b889e48034cc9e10f22006716ce
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sun Oct 18 12:24:09 2009 +1100

    s4-pvfs: fixed update of stream sizes
    
    The data_blob_free() was changing the size we set the stream to

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

Summary of changes:
 source4/ntvfs/posix/pvfs_qfileinfo.c   |    5 +++
 source4/ntvfs/posix/pvfs_rename.c      |    3 +-
 source4/ntvfs/posix/pvfs_resolve.c     |   10 ++++++
 source4/ntvfs/posix/pvfs_setfileinfo.c |    7 +++-
 source4/ntvfs/posix/pvfs_streams.c     |   26 +++++++++++-----
 source4/torture/raw/streams.c          |   52 ++++++++++++++++++--------------
 source4/torture/smb2/streams.c         |   34 ++++++++++----------
 7 files changed, 86 insertions(+), 51 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/ntvfs/posix/pvfs_qfileinfo.c b/source4/ntvfs/posix/pvfs_qfileinfo.c
index bfc9a84..713925d 100644
--- a/source4/ntvfs/posix/pvfs_qfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_qfileinfo.c
@@ -45,6 +45,11 @@ static uint32_t pvfs_fileinfo_access(union smb_fileinfo *info)
 		needed = 0;
 		break;
 
+	case RAW_FILEINFO_STREAM_INFO:
+	case RAW_FILEINFO_STREAM_INFORMATION:
+		needed = 0;
+		break;
+
 	case RAW_FILEINFO_SEC_DESC:
 		needed = 0;
 		if (info->query_secdesc.in.secinfo_flags & (SECINFO_OWNER|SECINFO_GROUP)) {
diff --git a/source4/ntvfs/posix/pvfs_rename.c b/source4/ntvfs/posix/pvfs_rename.c
index 0616d38..d963357 100644
--- a/source4/ntvfs/posix/pvfs_rename.c
+++ b/source4/ntvfs/posix/pvfs_rename.c
@@ -515,7 +515,8 @@ static NTSTATUS pvfs_rename_stream(struct ntvfs_module_context *ntvfs,
 	NT_STATUS_NOT_OK_RETURN(status);
 
 	status = pvfs_stream_rename(pvfs, name1, -1, 
-				    ren->ntrename.in.new_name+1);
+				    ren->ntrename.in.new_name+1, 
+				    true);
 	NT_STATUS_NOT_OK_RETURN(status);
 	
 	return NT_STATUS_OK;
diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c
index 8c5806d..c01799e 100644
--- a/source4/ntvfs/posix/pvfs_resolve.c
+++ b/source4/ntvfs/posix/pvfs_resolve.c
@@ -263,6 +263,16 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
 	NTSTATUS status;
 
 	name->original_name = talloc_strdup(name, cifs_name);
+
+	/* remove any :$DATA */
+	p = strrchr(name->original_name, ':');
+	if (p && strcasecmp_m(p, ":$DATA") == 0) {
+		if (p > name->original_name && p[-1] == ':') {
+			p--;
+		}
+		*p = 0;
+	}
+
 	name->stream_name = NULL;
 	name->stream_id = 0;
 	name->has_wildcard = false;
diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c
index 2445483..b40ae9c 100644
--- a/source4/ntvfs/posix/pvfs_setfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_setfileinfo.c
@@ -89,8 +89,10 @@ static NTSTATUS pvfs_setfileinfo_rename_stream(struct pvfs_state *pvfs,
 	NTSTATUS status;
 	struct odb_lock *lck = NULL;
 
+	/* strangely, this gives a sharing violation, not invalid
+	   parameter */
 	if (info->rename_information.in.new_name[0] != ':') {
-		return NT_STATUS_INVALID_PARAMETER;
+		return NT_STATUS_SHARING_VIOLATION;
 	}
 
 	status = pvfs_access_check_simple(pvfs, req, name, SEC_FILE_WRITE_ATTRIBUTE);
@@ -106,7 +108,8 @@ static NTSTATUS pvfs_setfileinfo_rename_stream(struct pvfs_state *pvfs,
 
 
 	status = pvfs_stream_rename(pvfs, name, fd, 
-				    info->rename_information.in.new_name+1);
+				    info->rename_information.in.new_name+1,
+				    info->rename_information.in.overwrite);
 	return status;
 }
 
diff --git a/source4/ntvfs/posix/pvfs_streams.c b/source4/ntvfs/posix/pvfs_streams.c
index 381d203..4da9543 100644
--- a/source4/ntvfs/posix/pvfs_streams.c
+++ b/source4/ntvfs/posix/pvfs_streams.c
@@ -240,7 +240,7 @@ static NTSTATUS pvfs_stream_update_size(struct pvfs_state *pvfs, struct pvfs_fil
   rename a stream
 */
 NTSTATUS pvfs_stream_rename(struct pvfs_state *pvfs, struct pvfs_filename *name, int fd,
-			    const char *new_name)
+			    const char *new_name, bool overwrite)
 {
 	struct xattr_DosStreams *streams;
 	int i, found_old, found_new;
@@ -289,17 +289,27 @@ NTSTATUS pvfs_stream_rename(struct pvfs_state *pvfs, struct pvfs_filename *name,
 		struct xattr_DosStream *s = &streams->streams[found_old];
 		s->name = new_name;
 	} else {
-		/* remove the old one and replace with the new one */
-		streams->streams[found_old].name = new_name;
-		memmove(&streams->streams[found_new],
-			&streams->streams[found_new+1],
-			sizeof(streams->streams[0]) *
-			(streams->num_streams - (found_new+1)));
+		if (!overwrite) {
+			return NT_STATUS_OBJECT_NAME_COLLISION;
+		}
+		if (found_old != found_new) {
+			/* remove the old one and replace with the new one */
+			streams->streams[found_old].name = new_name;
+			memmove(&streams->streams[found_new],
+				&streams->streams[found_new+1],
+				sizeof(streams->streams[0]) *
+				(streams->num_streams - (found_new+1)));
+			streams->num_streams--;
+		}
 	}
 
 	status = pvfs_streams_save(pvfs, name, fd, streams);
 	talloc_free(streams);
 
+	/* update the in-memory copy of the name of the open file */
+	talloc_free(name->stream_name);
+	name->stream_name = talloc_strdup(name, new_name);
+
 	return status;
 }
 
@@ -532,11 +542,11 @@ NTSTATUS pvfs_stream_truncate(struct pvfs_state *pvfs,
 
 	status = pvfs_xattr_save(pvfs, name->full_name, fd, XATTR_DOSSTREAM_PREFIX,
 				 name->stream_name, &blob);
-	data_blob_free(&blob);
 
 	if (NT_STATUS_IS_OK(status)) {
 		status = pvfs_stream_update_size(pvfs, name, fd, blob.length);
 	}
+	data_blob_free(&blob);
 
 	return status;
 }
diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c
index 5c6bd63..5d2fb55 100644
--- a/source4/torture/raw/streams.c
+++ b/source4/torture/raw/streams.c
@@ -193,7 +193,7 @@ static bool check_stream_list(struct smbcli_state *cli, const char *fname,
 			d_fprintf(stderr, "(%s) expected stream name %s, got "
 				  "%s\n", __location__, exp_sort[i],
 				  stream_sort[i].stream_name.s);
-			goto fail;
+			goto show_streams;
 		}
 	}
 
@@ -201,6 +201,14 @@ static bool check_stream_list(struct smbcli_state *cli, const char *fname,
  fail:
 	talloc_free(tmp_ctx);
 	return ret;
+
+show_streams:
+	for (i=0; i<num_exp; i++) {
+		d_fprintf(stderr, "stream names '%s' '%s'\n",
+			  exp_sort[i], stream_sort[i].stream_name.s);
+	}
+	talloc_free(tmp_ctx);
+	return ret;
 }
 
 /*
@@ -360,10 +368,8 @@ static bool test_stream_io(struct torture_context *tctx,
 	ret &= check_stream(cli, __location__, mem_ctx, fname, "Stream One:$DATA", "test MORE DATA ");
 	ret &= check_stream(cli, __location__, mem_ctx, fname, "Stream One:", NULL);
 	ret &= check_stream(cli, __location__, mem_ctx, fname, "Second Stream", "SECOND STREAM");
-	if (!torture_setting_bool(tctx, "samba4", false)) {
-		ret &= check_stream(cli, __location__, mem_ctx, fname,
-				    "SECOND STREAM:$DATA", "SECOND STREAM");
-	}
+	ret &= check_stream(cli, __location__, mem_ctx, fname,
+			    "SECOND STREAM:$DATA", "SECOND STREAM");
 	ret &= check_stream(cli, __location__, mem_ctx, fname, "Second Stream:$DATA", "SECOND STREAM");
 	ret &= check_stream(cli, __location__, mem_ctx, fname, "Second Stream:", NULL);
 	ret &= check_stream(cli, __location__, mem_ctx, fname, "Second Stream:$FOO", NULL);
@@ -393,17 +399,15 @@ static bool test_stream_io(struct torture_context *tctx,
 
 	check_stream_list(cli, fname, 1, one);
 
-	if (!torture_setting_bool(tctx, "samba4", false)) {
-		io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
-		io.ntcreatex.in.fname = sname1;
-		status = smb_raw_open(cli->tree, mem_ctx, &io);
-		CHECK_STATUS(status, NT_STATUS_OK);
-		smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
-		io.ntcreatex.in.fname = sname2;
-		status = smb_raw_open(cli->tree, mem_ctx, &io);
-		CHECK_STATUS(status, NT_STATUS_OK);
-		smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
-	}
+	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+	io.ntcreatex.in.fname = sname1;
+	status = smb_raw_open(cli->tree, mem_ctx, &io);
+	CHECK_STATUS(status, NT_STATUS_OK);
+	smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
+	io.ntcreatex.in.fname = sname2;
+	status = smb_raw_open(cli->tree, mem_ctx, &io);
+	CHECK_STATUS(status, NT_STATUS_OK);
+	smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
 
 	printf("(%s) deleting file\n", __location__);
 	status = smbcli_unlink(cli->tree, fname);
@@ -774,10 +778,6 @@ static bool test_stream_names(struct torture_context *tctx,
 	smbcli_close(cli->tree, fnum2);
 	smbcli_close(cli->tree, fnum3);
 
-	if (torture_setting_bool(tctx, "samba4", true)) {
-		goto done;
-	}
-
 	finfo.generic.level = RAW_FILEINFO_ALL_INFO;
 	finfo.generic.in.file.path = fname;
 	status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);
@@ -845,7 +845,7 @@ static bool test_stream_names(struct torture_context *tctx,
 		status = smb_raw_fileinfo(cli->tree, mem_ctx, &stinfo);
 		CHECK_STATUS(status, NT_STATUS_OK);
 		if (!torture_setting_bool(tctx, "samba3", false)) {
-			CHECK_STR(rpath, stinfo.name_info.out.fname.s);
+			CHECK_STR(stinfo.name_info.out.fname.s, rpath);
 		}
 
 		write_time = finfo.all_info.out.write_time;
@@ -936,9 +936,15 @@ static bool test_stream_names(struct torture_context *tctx,
 	sinfo.rename_information.in.root_fid = 0;
 	sinfo.rename_information.in.new_name = ":MStream Two:$DATA";
 	status = smb_raw_setfileinfo(cli->tree, &sinfo);
-	CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+	if (torture_setting_bool(tctx, "samba4", false)) {
+		/* why should this rename be considered invalid?? */
+		CHECK_STATUS(status, NT_STATUS_OK);
+		ret &= check_stream_list(cli, fname, 4, four);
+	} else {
+		CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+		ret &= check_stream_list(cli, fname, 5, five2);
+	}
 
-	ret &= check_stream_list(cli, fname, 5, five2);
 
 	/* TODO: we need to test more rename combinations */
 
diff --git a/source4/torture/smb2/streams.c b/source4/torture/smb2/streams.c
index f186a54..4029ec8 100644
--- a/source4/torture/smb2/streams.c
+++ b/source4/torture/smb2/streams.c
@@ -415,10 +415,8 @@ static bool test_stream_io(struct torture_context *tctx,
 	ret &= check_stream(tree, __location__, mem_ctx, fname,
 			    "Second Stream", "SECOND STREAM");
 
-	if (!torture_setting_bool(tctx, "samba4", false)) {
-		ret &= check_stream(tree, __location__, mem_ctx, fname,
-				    "SECOND STREAM:$DATA", "SECOND STREAM");
-	}
+	ret &= check_stream(tree, __location__, mem_ctx, fname,
+			    "SECOND STREAM:$DATA", "SECOND STREAM");
 	ret &= check_stream(tree, __location__, mem_ctx, fname,
 			    "Second Stream:$DATA", "SECOND STREAM");
 
@@ -482,11 +480,11 @@ static bool test_stream_io(struct torture_context *tctx,
 		status = smb2_create(tree, mem_ctx, &(io.smb2));
 		CHECK_STATUS(status, NT_STATUS_OK);
 		smb2_util_close(tree, io.ntcreatex.out.file.handle);
+		torture_comment(tctx, "(%s) deleting file\n", __location__);
+		status = smb2_util_unlink(tree, fname);
+		CHECK_STATUS(status, NT_STATUS_OK);
 	}
 
-	torture_comment(tctx, "(%s) deleting file\n", __location__);
-	status = smb2_util_unlink(tree, fname);
-	CHECK_STATUS(status, NT_STATUS_OK);
 
 done:
 	smb2_util_close(tree, h2);
@@ -610,7 +608,7 @@ static bool test_stream_delete(struct torture_context *tctx,
 	struct smb2_handle h, h1;
 	struct smb2_read r;
 
-	if (!torture_setting_bool(tctx, "samba4", true)) {
+	if (torture_setting_bool(tctx, "samba4", false)) {
 		torture_comment(tctx, "Skipping test as samba4 is enabled\n");
 		goto done;
 	}
@@ -1355,15 +1353,17 @@ static bool test_stream_rename2(struct torture_context *tctx,
 	status = smb2_setinfo_file(tree, &sinfo);
 	CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
 
-	/*
-	 * Check SMB2 rename to the default stream using :<stream>.
-	 */
-	torture_comment(tctx, "(%s) Checking SMB2 rename to defaualt stream "
-			"using :<stream>\n", __location__);
-	sinfo.rename_information.in.file.handle = h1;
-	sinfo.rename_information.in.new_name = stream_name_default;
-	status = smb2_setinfo_file(tree, &sinfo);
-	CHECK_STATUS(status, NT_STATUS_OK);
+	if (!torture_setting_bool(tctx, "samba4", false)) {
+		/*
+		 * Check SMB2 rename to the default stream using :<stream>.
+		 */
+		torture_comment(tctx, "(%s) Checking SMB2 rename to default stream "
+				"using :<stream>\n", __location__);
+		sinfo.rename_information.in.file.handle = h1;
+		sinfo.rename_information.in.new_name = stream_name_default;
+		status = smb2_setinfo_file(tree, &sinfo);
+		CHECK_STATUS(status, NT_STATUS_OK);
+	}
 
 	smb2_util_close(tree, h1);
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list