From 839ab724dc2d204bfbb0693aeed64f6f83a4266b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Feb 2008 12:30:31 +1100 Subject: Fixed SMB2 rename operations from Vista clients We needed a flag in bufinfo to mark packets as SMB2, as it seems that SMB2 uses a different format for the RenameInformation buffer than SMB does Also handle the fact that SMB2 clients give the full path to the target file in the rename, not a relative path (This used to be commit 52d7972d95ddc19d22a4187b4d4428a6c3ed32d5) --- source4/ntvfs/posix/pvfs_setfileinfo.c | 37 ++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'source4/ntvfs/posix/pvfs_setfileinfo.c') diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c index 340913cd4d..2a936ad8a7 100644 --- a/source4/ntvfs/posix/pvfs_setfileinfo.c +++ b/source4/ntvfs/posix/pvfs_setfileinfo.c @@ -63,6 +63,10 @@ static uint32_t pvfs_setfileinfo_access(union smb_setfileinfo *info) } break; + case RAW_SFILEINFO_RENAME_INFORMATION: + needed = SEC_STD_DELETE; + break; + default: needed = SEC_FILE_WRITE_ATTRIBUTE; break; @@ -84,7 +88,8 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs, char *new_name, *p; /* renames are only allowed within a directory */ - if (strchr_m(info->rename_information.in.new_name, '\\')) { + if (strchr_m(info->rename_information.in.new_name, '\\') && + (req->ctx->protocol != PROTOCOL_SMB2)) { return NT_STATUS_NOT_SUPPORTED; } @@ -100,22 +105,28 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs, /* w2k3 does not appear to allow relative rename */ if (info->rename_information.in.root_fid != 0) { - return NT_STATUS_INVALID_PARAMETER; + DEBUG(1,("WARNING: got invalid root_fid in rename_information.\n")); } /* construct the fully qualified windows name for the new file name */ - new_name = talloc_strdup(req, name->original_name); - if (new_name == NULL) { - return NT_STATUS_NO_MEMORY; - } - p = strrchr_m(new_name, '\\'); - if (p == NULL) { - return NT_STATUS_OBJECT_NAME_INVALID; - } - *p = 0; + if (req->ctx->protocol == PROTOCOL_SMB2) { + /* SMB2 sends the full path of the new name */ + new_name = talloc_asprintf(req, "\\%s", info->rename_information.in.new_name); + } else { + new_name = talloc_strdup(req, name->original_name); + if (new_name == NULL) { + return NT_STATUS_NO_MEMORY; + } + p = strrchr_m(new_name, '\\'); + if (p == NULL) { + return NT_STATUS_OBJECT_NAME_INVALID; + } else { + *p = 0; + } - new_name = talloc_asprintf(req, "%s\\%s", new_name, - info->rename_information.in.new_name); + new_name = talloc_asprintf(req, "%s\\%s", new_name, + info->rename_information.in.new_name); + } if (new_name == NULL) { return NT_STATUS_NO_MEMORY; } -- cgit From 039f85835d60ae48c4176891598cf24e18d0cd0a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Feb 2008 12:50:11 +1100 Subject: we need to refuse a root_fid in rename on SMB but not SMB2 (This used to be commit 9a139c35b7f1326616d26ce13bbdc7d6b22cd9b5) --- source4/ntvfs/posix/pvfs_setfileinfo.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/posix/pvfs_setfileinfo.c') diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c index 2a936ad8a7..ce977873c8 100644 --- a/source4/ntvfs/posix/pvfs_setfileinfo.c +++ b/source4/ntvfs/posix/pvfs_setfileinfo.c @@ -103,9 +103,11 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs, return NT_STATUS_INVALID_PARAMETER; } - /* w2k3 does not appear to allow relative rename */ - if (info->rename_information.in.root_fid != 0) { - DEBUG(1,("WARNING: got invalid root_fid in rename_information.\n")); + /* w2k3 does not appear to allow relative rename. On SMB2, vista sends it sometimes, + but I suspect it is just uninitialised memory */ + if (info->rename_information.in.root_fid != 0 && + (req->ctx->protocol != PROTOCOL_SMB2)) { + return NT_STATUS_INVALID_PARAMETER; } /* construct the fully qualified windows name for the new file name */ -- cgit From 4a04a5e620a4666fc123d04cb96ef391de72c469 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Feb 2008 14:54:21 +1100 Subject: 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. (This used to be commit f6cdf3f1177f63d80be757f007eb15380839b4f5) --- source4/ntvfs/posix/pvfs_setfileinfo.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/ntvfs/posix/pvfs_setfileinfo.c') diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c index ce977873c8..9c78699edb 100644 --- a/source4/ntvfs/posix/pvfs_setfileinfo.c +++ b/source4/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); -- cgit