From a237998cbd705186fd09cf82608d27c57603e2d8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 20 Jul 2016 11:25:20 -0700 Subject: [PATCH 1/2] s3: smbd: Change lp_set_posix_pathnames() to take a newval parameter and return the old one. Currently only used in one place, but we'll need to use it to temporarily change pathname processing to fix bug 12021. This (hack) is only needed for 4.4.x and below, it is fixed correctly in 4.5.x. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12021 Signed-off-by: Jeremy Allison --- source3/include/proto.h | 2 +- source3/param/loadparm.c | 9 +++++---- source3/smbd/trans2.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 0bd0c80..62cd257 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1020,7 +1020,7 @@ bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state); void set_use_sendfile(int snum, bool val); void lp_set_mangling_method(const char *new_method); bool lp_posix_pathnames(void); -void lp_set_posix_pathnames(void); +bool lp_set_posix_pathnames(bool newval); enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp); void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val); int lp_min_receive_file_size(void); diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 2ad1c6f..c40e478 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -4337,13 +4337,14 @@ bool lp_posix_pathnames(void) } /******************************************************************* - Change everything needed to ensure POSIX pathname processing (currently - not much). + Set posix pathnames to new value. Returns old value. ********************************************************************/ -void lp_set_posix_pathnames(void) +bool lp_set_posix_pathnames(bool newval) { - posix_pathnames = true; + bool oldval = posix_pathnames; + posix_pathnames = newval; + return oldval; } /******************************************************************* diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 1780d6f..7354bba 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -4152,7 +4152,7 @@ static void call_trans2setfsinfo(connection_struct *conn, /* Here is where we must switch to posix pathname processing... */ if (xconn->smb1.unix_info.client_cap_low & CIFS_UNIX_POSIX_PATHNAMES_CAP) { - lp_set_posix_pathnames(); + (void)lp_set_posix_pathnames(true); mangle_change_to_posix(); } -- 2.8.0.rc3.226.g39d4020 From 883b4af8ffeffd79e51ac2a697b0d19ccfc4ec25 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 20 Jul 2016 11:34:48 -0700 Subject: [PATCH 2/2] s3: smbd: Fix delete operations enumerating streams inside a file. This must always be done as a Windows operation. When using UNIX extensions to delete a file containing streams, the open for delete and close operations need to enumerate the contained streams and do CREATE and UNLINK operations on the stream names. These must always be done as Windows operations (use lp_set_posix_pathnames(false) to flip the processing) as the stream names are Windows paths. Without this the create operation under the unlink will recurse and cause the client to time out (or a server crash). This (hack) is only needed for 4.4.x and below, it is fixed correctly in 4.5.x. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12021 Signed-off-by: Jeremy Allison --- source3/smbd/close.c | 10 ++++++++++ source3/smbd/open.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 3ab04b7..271885e 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -168,6 +168,7 @@ NTSTATUS delete_all_streams(connection_struct *conn, const char *fname) unsigned int num_streams = 0; TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; + bool saved_posix_pathnames; status = vfs_streaminfo(conn, NULL, fname, talloc_tos(), &num_streams, &stream_info); @@ -192,6 +193,13 @@ NTSTATUS delete_all_streams(connection_struct *conn, const char *fname) return NT_STATUS_OK; } + /* + * Any stream names *must* be treated as Windows + * pathnames, even if we're using UNIX extensions. + */ + + saved_posix_pathnames = lp_set_posix_pathnames(false); + for (i=0; i