Windows vs POSIX directory rename with open files behaviour

Ralph Böhme rb at sernet.de
Thu Jan 29 11:19:58 MST 2015


On Thu, Jan 29, 2015 at 07:18:02PM +0100, Ralph Böhme wrote:
> On Thu, Jan 29, 2015 at 09:24:34AM -0800, Jeremy Allison wrote:
> > On Thu, Jan 29, 2015 at 02:55:01PM +0100, Ralph Böhme wrote:
> > > On Mon, Jan 26, 2015 at 11:49:37AM -0800, Jeremy Allison wrote:
> > > > On Mon, Jan 26, 2015 at 09:34:41PM +0200, Jussi Uosukainen wrote:
> > > > > For what it's worth, I would really like for samba (or vfs_fruit) to
> > > > > be bug compatible with OS X Server. It makes it easier to implement
> > > > > samba environments to replace mac server environments.
> > > > 
> > > > OK, but we already have a problem with this.
> > > > 
> > > > OS X server allows open file rename over SMB1 with
> > > > no AAPL create context or UNIX extensions. Windows
> > > > doesn't.
> > > > 
> > > > Who should we be bug compatible with here ?
> > > 
> > > 
> > > With both! :) With my change to vfs_fruit every OS get's its desired
> > > behaviour, not for SMB1, but at least for SMB2.
> > 
> > OK, post it again :-).
> 
> Attached.

here it is.

-Ralph

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de,mailto:kontakt@sernet.de
-------------- next part --------------
From ffcc94d429acb79b5739f7ade02aa77a906bbda6 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Thu, 22 Jan 2015 10:00:15 +0100
Subject: [PATCH 1/2] s3:smbd: allow POSIX directory rename semantics

Add flag "posix_dir_rename" to files_struct allowing for POSIX directory
rename behaviour, ie allow a rename when there are open files in the
directory.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=11065

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 source3/include/vfs.h | 1 +
 source3/smbd/reply.c  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 321c48c..a83adbd 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -250,6 +250,7 @@ typedef struct files_struct {
 	bool initial_delete_on_close; /* Only set at NTCreateX if file was created. */
 	bool delete_on_close;
 	bool posix_open;
+	bool posix_dir_rename;
 	bool is_sparse;
 	bool backup_intent; /* Handle was successfully opened with backup intent
 				and opener has privilege to do so. */
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 0b6c102..ddebacc 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -2649,7 +2649,7 @@ static NTSTATUS can_rename(connection_struct *conn, files_struct *fsp,
 	}
 
 	if (S_ISDIR(fsp->fsp_name->st.st_ex_mode)) {
-		if (fsp->posix_open) {
+		if (fsp->posix_open || fsp->posix_dir_rename) {
 			return NT_STATUS_OK;
 		}
 
-- 
1.9.3


From 7ac4fc472494481fa35546d0c9b428e6426928b3 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Thu, 22 Jan 2015 10:07:56 +0100
Subject: [PATCH 2/2] vfs:fruit: enable POSIX directory rename semantics

Bug: https://bugzilla.samba.org/show_bug.cgi?id=11065

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 source3/modules/vfs_fruit.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 4eace1e..30736db 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -3163,9 +3163,18 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
 		return status;
 	}
 
-	if (is_ntfs_stream_smb_fname(smb_fname)
-	    || (*result == NULL)
-	    || ((*result)->is_directory)) {
+	if ((*result)->is_directory) {
+		/*
+		 * Implement POSIX directory rename behaviour: in an
+		 * SMB2 connection with AAPL extension change
+		 * behaviour from preventing directory renames to
+		 * allowing it.
+		 */
+		(*result)->posix_dir_rename = true;
+		return status;
+	}
+
+	if (is_ntfs_stream_smb_fname(smb_fname)) {
 		return status;
 	}
 
-- 
1.9.3



More information about the samba-technical mailing list