From ffcc94d429acb79b5739f7ade02aa77a906bbda6 Mon Sep 17 00:00:00 2001 From: Ralph Boehme 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 --- 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 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 --- 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