[SCM] Samba Shared Repository - branch v4-0-test updated - release-4-0-0alpha3-1738-g5c5c866

Stefan Metzmacher metze at samba.org
Fri May 23 10:57:53 GMT 2008


The branch, v4-0-test has been updated
       via  5c5c86683877337ff60526a40e7b689f604e40f8 (commit)
       via  1421b1cc0c442be839be702647009ed5295f34a3 (commit)
       via  47756129fdf01075bac06cdd24107d7dc8ba34af (commit)
       via  9ed7bb5afe6a73206bcba85f25305eb6630a5571 (commit)
      from  076e2cc356978ac313fcfdf8d8243f4ed1d629b0 (commit)

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


- Log -----------------------------------------------------------------
commit 5c5c86683877337ff60526a40e7b689f604e40f8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 23 09:39:50 2008 +0200

    RAW-STREAMS: better test the bahavior of streams on directories
    
    Note: this has a samba3 specific code path, which we should fixed.
    
    metze

commit 1421b1cc0c442be839be702647009ed5295f34a3
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 23 09:47:59 2008 +0200

    pvfs_open: return FILE_IS_A_DIRECTORY when opening a stream on a directory
    
    metze

commit 47756129fdf01075bac06cdd24107d7dc8ba34af
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 23 09:46:50 2008 +0200

    pvfs_resolve: stream_name = "" is only the same as NULL for files
    
    metze

commit 9ed7bb5afe6a73206bcba85f25305eb6630a5571
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 23 09:45:46 2008 +0200

    pvfs_streams: directories don't have streams
    
    metze

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

Summary of changes:
 source/ntvfs/posix/pvfs_fileinfo.c |    2 +
 source/ntvfs/posix/pvfs_open.c     |    9 +++-
 source/ntvfs/posix/pvfs_resolve.c  |    8 +++-
 source/ntvfs/posix/pvfs_streams.c  |    7 +++
 source/torture/raw/streams.c       |   95 ++++++++++++++++++++++++++++++++----
 5 files changed, 109 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/ntvfs/posix/pvfs_fileinfo.c b/source/ntvfs/posix/pvfs_fileinfo.c
index e35f42e..04f6ad7 100644
--- a/source/ntvfs/posix/pvfs_fileinfo.c
+++ b/source/ntvfs/posix/pvfs_fileinfo.c
@@ -58,6 +58,8 @@ NTSTATUS pvfs_fill_dos_info(struct pvfs_state *pvfs, struct pvfs_filename *name,
 	if (S_ISDIR(name->st.st_mode)) {
 		name->st.st_size = 0;
 		name->st.st_nlink = 1;
+	} else if (name->stream_id == 0) {
+		name->stream_name = NULL;
 	}
 
 	/* for now just use the simple samba mapping */
diff --git a/source/ntvfs/posix/pvfs_open.c b/source/ntvfs/posix/pvfs_open.c
index cc4f0ad..926c99d 100644
--- a/source/ntvfs/posix/pvfs_open.c
+++ b/source/ntvfs/posix/pvfs_open.c
@@ -182,12 +182,19 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
 	bool del_on_close;
 	uint32_t create_options;
 	uint32_t share_access;
+	bool forced;
 
 	create_options = io->generic.in.create_options;
 	share_access   = io->generic.in.share_access;
 
+	forced = (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY)?true:false;
+
 	if (name->stream_name) {
-		return NT_STATUS_NOT_A_DIRECTORY;
+		if (forced) {
+			return NT_STATUS_NOT_A_DIRECTORY;
+		} else {
+			return NT_STATUS_FILE_IS_A_DIRECTORY;
+		}
 	}
 
 	/* if the client says it must be a directory, and it isn't,
diff --git a/source/ntvfs/posix/pvfs_resolve.c b/source/ntvfs/posix/pvfs_resolve.c
index 325bc74..2e97925 100644
--- a/source/ntvfs/posix/pvfs_resolve.c
+++ b/source/ntvfs/posix/pvfs_resolve.c
@@ -202,7 +202,13 @@ static NTSTATUS parse_stream_name(struct pvfs_filename *name, const char *s)
 	}
 	*p = 0;
 	if (strcmp(name->stream_name, "") == 0) {
-		name->stream_name = NULL;
+		/*
+		 * we don't set stream_name to NULL, here
+		 * as this would be wrong for directories
+		 *
+		 * pvfs_fill_dos_info() will set it to NULL
+		 * if it's not a directory.
+		 */
 		name->stream_id = 0;
 	} else {
 		name->stream_id = pvfs_name_hash(name->stream_name, 
diff --git a/source/ntvfs/posix/pvfs_streams.c b/source/ntvfs/posix/pvfs_streams.c
index 7e6173e..3cd9952 100644
--- a/source/ntvfs/posix/pvfs_streams.c
+++ b/source/ntvfs/posix/pvfs_streams.c
@@ -36,6 +36,13 @@ NTSTATUS pvfs_stream_information(struct pvfs_state *pvfs,
 	int i;
 	NTSTATUS status;
 
+	/* directories don't have streams */
+	if (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
+		info->num_streams = 0;
+		info->streams = NULL;
+		return NT_STATUS_OK;
+	}
+
 	streams = talloc(mem_ctx, struct xattr_DosStreams);
 	if (streams == NULL) {
 		return NT_STATUS_NO_MEMORY;
diff --git a/source/torture/raw/streams.c b/source/torture/raw/streams.c
index 1dab36c..8b2d327 100644
--- a/source/torture/raw/streams.c
+++ b/source/torture/raw/streams.c
@@ -135,6 +135,11 @@ static bool check_stream_list(struct smbcli_state *cli, const char *fname,
 		goto fail;
 	}
 
+	if (num_exp == 0) {
+		ret = true;
+		goto fail;
+	}
+
 	exp_sort = talloc_memdup(tmp_ctx, exp, num_exp * sizeof(*exp));
 
 	if (exp_sort == NULL) {
@@ -170,7 +175,81 @@ static bool check_stream_list(struct smbcli_state *cli, const char *fname,
 }
 
 /*
-  test basic io on streams
+  test bahavior of streams on directories
+*/
+static bool test_stream_dir(struct torture_context *tctx,
+			   struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+{
+	NTSTATUS status;
+	union smb_open io;
+	const char *fname = BASEDIR "\\stream.txt";
+	const char *sname1;
+	bool ret = true;
+	const char *basedir_data;
+
+	basedir_data = talloc_asprintf(mem_ctx, "%s::$DATA", BASEDIR);
+	sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One");
+
+	printf("(%s) opening non-existant directory stream\n", __location__);
+	io.generic.level = RAW_OPEN_NTCREATEX;
+	io.ntcreatex.in.root_fid = 0;
+	io.ntcreatex.in.flags = 0;
+	io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
+	io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+	io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+	io.ntcreatex.in.share_access = 0;
+	io.ntcreatex.in.alloc_size = 0;
+	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+	io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+	io.ntcreatex.in.security_flags = 0;
+	io.ntcreatex.in.fname = sname1;
+	status = smb_raw_open(cli->tree, mem_ctx, &io);
+	CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
+
+	printf("(%s) opening basedir  stream\n", __location__);
+	io.generic.level = RAW_OPEN_NTCREATEX;
+	io.ntcreatex.in.root_fid = 0;
+	io.ntcreatex.in.flags = 0;
+	io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
+	io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+	io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
+	io.ntcreatex.in.share_access = 0;
+	io.ntcreatex.in.alloc_size = 0;
+	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+	io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+	io.ntcreatex.in.security_flags = 0;
+	io.ntcreatex.in.fname = basedir_data;
+	status = smb_raw_open(cli->tree, mem_ctx, &io);
+	CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
+
+	printf("(%s) opening basedir ::$DATA stream\n", __location__);
+	io.generic.level = RAW_OPEN_NTCREATEX;
+	io.ntcreatex.in.root_fid = 0;
+	io.ntcreatex.in.flags = 0x10;
+	io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
+	io.ntcreatex.in.create_options = 0;
+	io.ntcreatex.in.file_attr = 0;
+	io.ntcreatex.in.share_access = 0;
+	io.ntcreatex.in.alloc_size = 0;
+	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+	io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+	io.ntcreatex.in.security_flags = 0;
+	io.ntcreatex.in.fname = basedir_data;
+	status = smb_raw_open(cli->tree, mem_ctx, &io);
+	if (torture_setting_bool(tctx, "samba3", false)) {
+		CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+	} else {
+		CHECK_STATUS(status, NT_STATUS_FILE_IS_A_DIRECTORY);
+	}
+
+	printf("(%s) list the streams on the basedir\n", __location__);
+	ret &= check_stream_list(cli, BASEDIR, 0, NULL);
+done:
+	return ret;
+}
+
+/*
+  test basic behavior of streams on directories
 */
 static bool test_stream_io(struct torture_context *tctx,
 			   struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
@@ -191,12 +270,12 @@ static bool test_stream_io(struct torture_context *tctx,
 	sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One");
 	sname2 = talloc_asprintf(mem_ctx, "%s:%s:$DaTa", fname, "Second Stream");
 
-	printf("(%s) opening non-existant directory stream\n", __location__);
+	printf("(%s) creating a stream on a non-existant file\n", __location__);
 	io.generic.level = RAW_OPEN_NTCREATEX;
 	io.ntcreatex.in.root_fid = 0;
 	io.ntcreatex.in.flags = 0;
 	io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
-	io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+	io.ntcreatex.in.create_options = 0;
 	io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
 	io.ntcreatex.in.share_access = 0;
 	io.ntcreatex.in.alloc_size = 0;
@@ -205,12 +284,6 @@ static bool test_stream_io(struct torture_context *tctx,
 	io.ntcreatex.in.security_flags = 0;
 	io.ntcreatex.in.fname = sname1;
 	status = smb_raw_open(cli->tree, mem_ctx, &io);
-	CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
-
-	printf("(%s) creating a stream on a non-existant file\n", __location__);
-	io.ntcreatex.in.create_options = 0;
-	io.ntcreatex.in.fname = sname1;
-	status = smb_raw_open(cli->tree, mem_ctx, &io);
 	CHECK_STATUS(status, NT_STATUS_OK);
 	fnum = io.ntcreatex.out.file.fnum;
 
@@ -423,7 +496,7 @@ static bool test_stream_delete(struct torture_context *tctx,
 
 	sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One");
 
-	printf("(%s) opening non-existant directory stream\n", __location__);
+	printf("(%s) opening non-existant file stream\n", __location__);
 	io.generic.level = RAW_OPEN_NTCREATEX;
 	io.ntcreatex.in.root_fid = 0;
 	io.ntcreatex.in.flags = 0;
@@ -559,6 +632,8 @@ bool torture_raw_streams(struct torture_context *torture,
 		return false;
 	}
 
+	ret &= test_stream_dir(torture, cli, torture);
+	smb_raw_exit(cli->session);
 	ret &= test_stream_io(torture, cli, torture);
 	smb_raw_exit(cli->session);
 	ret &= test_stream_sharemodes(torture, cli, torture);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list