[SCM] Samba Shared Repository - branch v4-0-test updated - release-4-0-0alpha2-813-gf6cdf3f

Andrew Tridgell tridge at samba.org
Thu Feb 14 03:55:26 GMT 2008


The branch, v4-0-test has been updated
       via  f6cdf3f1177f63d80be757f007eb15380839b4f5 (commit)
      from  309cf408e01c36e2a12ed2d1462f2bbe407d4597 (commit)

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


- Log -----------------------------------------------------------------
commit f6cdf3f1177f63d80be757f007eb15380839b4f5
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu Feb 14 14:54:21 2008 +1100

    A better way to handle the different format of RenameInformation in SMB2
    
    We now define a separate info level RAW_SFILEINFO_RENAME_INFORMATION_SMB2
    and set that level when handling SMB2 packets. This makes the parsers clearer.

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

Summary of changes:
 source/libcli/raw/interfaces.h        |    5 +++-
 source/libcli/raw/rawsetfileinfo.c    |   11 +++++++++
 source/libcli/smb2/setinfo.c          |    6 +++++
 source/ntvfs/posix/pvfs_setfileinfo.c |    3 ++
 source/smb_server/blob.c              |   38 +++++++++++++++++++++-----------
 source/smb_server/smb2/fileinfo.c     |    5 ++++
 6 files changed, 54 insertions(+), 14 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/libcli/raw/interfaces.h b/source/libcli/raw/interfaces.h
index 16db17d..24e8ad4 100644
--- a/source/libcli/raw/interfaces.h
+++ b/source/libcli/raw/interfaces.h
@@ -902,7 +902,10 @@ enum smb_setfileinfo_level {
 	RAW_SFILEINFO_1029                    = SMB_SFILEINFO_1029,
 	RAW_SFILEINFO_1032                    = SMB_SFILEINFO_1032,
 	RAW_SFILEINFO_1039                    = SMB_SFILEINFO_1039,
-	RAW_SFILEINFO_1040                    = SMB_SFILEINFO_1040
+	RAW_SFILEINFO_1040                    = SMB_SFILEINFO_1040,
+	
+	/* cope with breakage in SMB2 */
+	RAW_SFILEINFO_RENAME_INFORMATION_SMB2 = SMB_SFILEINFO_RENAME_INFORMATION|0x80000000,
 };
 
 /* union used in setfileinfo() and setpathinfo() calls */
diff --git a/source/libcli/raw/rawsetfileinfo.c b/source/libcli/raw/rawsetfileinfo.c
index a9a1a35..f1e4ee3 100644
--- a/source/libcli/raw/rawsetfileinfo.c
+++ b/source/libcli/raw/rawsetfileinfo.c
@@ -75,6 +75,16 @@ bool smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
 		SIVAL(blob->data, 8, len - 2);
 		return true;
 
+	case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
+		NEED_BLOB(20);
+		SIVAL(blob->data, 0, parms->rename_information.in.overwrite);
+		SBVAL(blob->data, 8, parms->rename_information.in.root_fid);
+		len = smbcli_blob_append_string(NULL, mem_ctx, blob,
+						parms->rename_information.in.new_name, 
+						STR_UNICODE|STR_TERMINATE);
+		SIVAL(blob->data, 16, len - 2);
+		return true;
+
 	case RAW_SFILEINFO_POSITION_INFORMATION:
 		NEED_BLOB(8);
 		SBVAL(blob->data, 0, parms->position_information.in.position);
@@ -229,6 +239,7 @@ static bool smb_raw_setinfo_backend(struct smbcli_tree *tree,
 
 	case RAW_SFILEINFO_UNIX_LINK:
 	case RAW_SFILEINFO_UNIX_HLINK:
+	case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
 		break;
 	}
 
diff --git a/source/libcli/smb2/setinfo.c b/source/libcli/smb2/setinfo.c
index d942568..a6e22d9 100644
--- a/source/libcli/smb2/setinfo.c
+++ b/source/libcli/smb2/setinfo.c
@@ -92,6 +92,12 @@ struct smb2_request *smb2_setinfo_file_send(struct smb2_tree *tree, union smb_se
 	ZERO_STRUCT(b);
 	b.in.level             = smb2_level;
 	b.in.file.handle       = io->generic.in.file.handle;
+
+	/* change levels so the parsers know it is SMB2 */
+	if (io->generic.level == RAW_SFILEINFO_RENAME_INFORMATION) {
+		io->generic.level = RAW_SFILEINFO_RENAME_INFORMATION_SMB2;
+	}
+
 	if (!smb_raw_setfileinfo_passthru(tree, io->generic.level, io, &b.in.blob)) {
 		return NULL;
 	}
diff --git a/source/ntvfs/posix/pvfs_setfileinfo.c b/source/ntvfs/posix/pvfs_setfileinfo.c
index ce97787..9c78699 100644
--- a/source/ntvfs/posix/pvfs_setfileinfo.c
+++ b/source/ntvfs/posix/pvfs_setfileinfo.c
@@ -64,6 +64,7 @@ static uint32_t pvfs_setfileinfo_access(union smb_setfileinfo *info)
 		break;
 
 	case RAW_SFILEINFO_RENAME_INFORMATION:
+	case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
 		needed = SEC_STD_DELETE;
 		break;
 
@@ -382,6 +383,7 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
 		break;
 
 	case RAW_SFILEINFO_RENAME_INFORMATION:
+	case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
 		return pvfs_setfileinfo_rename(pvfs, req, h->name, 
 					       info);
 
@@ -579,6 +581,7 @@ NTSTATUS pvfs_setpathinfo(struct ntvfs_module_context *ntvfs,
 		return NT_STATUS_OK;
 
 	case RAW_SFILEINFO_RENAME_INFORMATION:
+	case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
 		return pvfs_setfileinfo_rename(pvfs, req, name, 
 					       info);
 
diff --git a/source/smb_server/blob.c b/source/smb_server/blob.c
index 795e7ce..8c81320 100644
--- a/source/smb_server/blob.c
+++ b/source/smb_server/blob.c
@@ -563,20 +563,32 @@ NTSTATUS smbsrv_pull_passthru_sfileinfo(TALLOC_CTX *mem_ctx,
 		if (!bufinfo) {
 			return NT_STATUS_INTERNAL_ERROR;
 		}
-		if (bufinfo->flags & BUFINFO_FLAG_SMB2) {
-			/* SMB2 uses a different format for rename information */
-			BLOB_CHECK_MIN_SIZE(blob, 20);
-			st->rename_information.in.overwrite = CVAL(blob->data, 0);
-			st->rename_information.in.root_fid  = BVAL(blob->data, 4);
-			len                                 = IVAL(blob->data,16);
-			ofs                                 = 20;			
-		} else {
-			BLOB_CHECK_MIN_SIZE(blob, 12);
-			st->rename_information.in.overwrite = CVAL(blob->data, 0);
-			st->rename_information.in.root_fid  = IVAL(blob->data, 4);
-			len                                 = IVAL(blob->data, 8);
-			ofs                                 = 12;
+		BLOB_CHECK_MIN_SIZE(blob, 12);
+		st->rename_information.in.overwrite = CVAL(blob->data, 0);
+		st->rename_information.in.root_fid  = IVAL(blob->data, 4);
+		len                                 = IVAL(blob->data, 8);
+		ofs                                 = 12;
+		str_blob = *blob;
+		str_blob.length = MIN(str_blob.length, ofs+len);
+		smbsrv_blob_pull_string(bufinfo, &str_blob, ofs,
+					&st->rename_information.in.new_name,
+					STR_UNICODE);
+		if (st->rename_information.in.new_name == NULL) {
+			return NT_STATUS_FOOBAR;
+		}
+
+		return NT_STATUS_OK;
+
+	case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
+		/* SMB2 uses a different format for rename information */
+		if (!bufinfo) {
+			return NT_STATUS_INTERNAL_ERROR;
 		}
+		BLOB_CHECK_MIN_SIZE(blob, 20);
+		st->rename_information.in.overwrite = CVAL(blob->data, 0);
+		st->rename_information.in.root_fid  = BVAL(blob->data, 8);
+		len                                 = IVAL(blob->data,16);
+		ofs                                 = 20;			
 		str_blob = *blob;
 		str_blob.length = MIN(str_blob.length, ofs+len);
 		smbsrv_blob_pull_string(bufinfo, &str_blob, ofs,
diff --git a/source/smb_server/smb2/fileinfo.c b/source/smb_server/smb2/fileinfo.c
index e375b73..e652199 100644
--- a/source/smb_server/smb2/fileinfo.c
+++ b/source/smb_server/smb2/fileinfo.c
@@ -266,6 +266,11 @@ static NTSTATUS smb2srv_setinfo_file(struct smb2srv_setinfo_op *op, uint8_t smb2
 	io->generic.level		= smb2_level + 1000;
 	io->generic.in.file.ntvfs	= op->info->in.file.ntvfs;
 
+	/* handle cases that don't map directly */
+	if (io->generic.level == RAW_SFILEINFO_RENAME_INFORMATION) {
+		io->generic.level = RAW_SFILEINFO_RENAME_INFORMATION_SMB2;
+	}
+
 	status = smbsrv_pull_passthru_sfileinfo(io, io->generic.level, io,
 						&op->info->in.blob,
 						STR_UNICODE, &op->req->in.bufinfo);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list