Questions about smbd option "strict rename"
Jeremy Allison
jra at samba.org
Wed Nov 25 16:57:52 UTC 2015
On Wed, Nov 25, 2015 at 03:50:25PM +0100, Ralph Boehme wrote:
> On Tue, Nov 24, 2015 at 10:01:11AM -0800, Jeremy Allison wrote:
> > On Tue, Nov 24, 2015 at 06:50:47PM +0100, Ralph Boehme wrote:
> > > Jeremy, how to proceed wrt that attaching POSIX rename behaviour to
> > > POSIX pathnames is wrong imo. We need a seperate flag for this.
> >
> > I don't think it is wrong. We have behaved that way
> > for a *very* long time and in the same way we
> > attach POSIX delete behavior to POSIX pathnames
> > too. Changing that will break UNIX extensions.
>
> sorry if you got the impression I would want to change semantics, I
> don't! I merely want to tweak the internal handling by allowing more
> fine grained control *without* changing existing CIFS UNIX extensions.
>
> > Now you might want an additional flag in order to
> > get POSIX-rename (and maybe POSIX-delete) behavior
> > for MacOSX clients that don't currently negotiate
> > UNIX extensions, but that's different from changing
> > the current smbd behavior.
>
> Again, I don't want to change existing behaviour.
>
> Maybe the attached patch makes clearer what I have in mind.
Oh, that makes much more sense, thanks !
I still have adding fields into files_struct
as a kitchen sink for underlying behavior.
Maybe we can add one linked list pointer,
instead, allowing enhancements to files struct
to be added by underlying VFS modules -
essentially a way for VFS modules to request
specific behavior from the upper layer code.
But I'm off for US Thanksgiving right now
so this might be a confused mess as I'm
juggling turkey and cooking tasks :-).
Jeremy.
> From 1f8cef28494c7cb4c23ba08db34383b0ab3ad407 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/3] s3:smbd: file_struct: seperate POSIX directory rename cap
> from posix_open
>
> We need more fine grained control over which POSIX semantics we'd like
> to enable per file handle. Currently posix_open is a kitchensink for all
> kinds of stuff like:
>
> - POSIX unlink
> - POSIX byte-range locks
> - POSIX rename
> - delayed writetime update
> - more...
>
> This is in preperation of SMB2 UNIX extensions, where we may want to be
> more fine grained then in the CIFS UNIX extensions, and for OS X clients
> with AAPL.
>
> For CIFS UNIX extensions we enable posix_dir_rename when we enable
> posix_open so semantics are preserved.
>
> 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/open.c | 5 ++++-
> source3/smbd/reply.c | 2 +-
> 3 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/source3/include/vfs.h b/source3/include/vfs.h
> index 9945375..d8d1da8 100644
> --- a/source3/include/vfs.h
> +++ b/source3/include/vfs.h
> @@ -256,6 +256,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/open.c b/source3/smbd/open.c
> index c34742e..c5b1dda 100644
> --- a/source3/smbd/open.c
> +++ b/source3/smbd/open.c
> @@ -3569,7 +3569,10 @@ static NTSTATUS open_directory(connection_struct *conn,
> fsp->oplock_type = NO_OPLOCK;
> fsp->sent_oplock_break = NO_BREAK_SENT;
> fsp->is_directory = True;
> - fsp->posix_open = (file_attributes & FILE_FLAG_POSIX_SEMANTICS) ? True : False;
> + if (file_attributes & FILE_FLAG_POSIX_SEMANTICS) {
> + fsp->posix_open = true;
> + fsp->posix_dir_rename = true;
> + }
> status = fsp_set_smb_fname(fsp, smb_dname);
> if (!NT_STATUS_IS_OK(status)) {
> file_free(req, fsp);
> diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
> index efef613..ee3347a 100644
> --- a/source3/smbd/reply.c
> +++ b/source3/smbd/reply.c
> @@ -2669,7 +2669,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_dir_rename) {
> return NT_STATUS_OK;
> }
>
> --
> 2.5.0
>
>
> From 20c77cde84ca4226b5d14fdc1c64f3d654964fd9 Mon Sep 17 00:00:00 2001
> From: Ralph Boehme <slow at samba.org>
> Date: Wed, 25 Nov 2015 09:12:55 +0100
> Subject: [PATCH 2/3] vfs_fruit: add a flag that tracks whether use of AAPL was
> negotiated
>
> Signed-off-by: Ralph Boehme <slow at samba.org>
> ---
> source3/modules/vfs_fruit.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
> index bd71ff1..a80015f 100644
> --- a/source3/modules/vfs_fruit.c
> +++ b/source3/modules/vfs_fruit.c
> @@ -125,7 +125,8 @@ struct fruit_config_data {
> enum fruit_meta meta;
> enum fruit_locking locking;
> enum fruit_encoding encoding;
> - bool use_aapl;
> + bool use_aapl; /* config from smb.conf */
> + bool nego_aapl; /* client negotiated AAPL */
> bool use_copyfile;
> bool readdir_attr_enabled;
> bool unix_info_enabled;
> @@ -3386,6 +3387,10 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
> if (!NT_STATUS_IS_OK(status)) {
> return status;
> }
> + if (!config->nego_aapl) {
> + return status;
> + }
> +
> fsp = *result;
>
> if (config->copyfile_enabled) {
> --
> 2.5.0
>
>
> From 88715eec0b5b09094e3de81994f9c30c31468a7c 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 3/3] 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 | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
> index a80015f..528215d 100644
> --- a/source3/modules/vfs_fruit.c
> +++ b/source3/modules/vfs_fruit.c
> @@ -3419,6 +3419,14 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
> }
> }
>
> + if ((*result)->is_directory) {
> + /*
> + * Enable POSIX directory rename behaviour
> + */
> + (*result)->posix_dir_rename = true;
> + return status;
> + }
> +
> if (is_ntfs_stream_smb_fname(smb_fname)
> || fsp->is_directory) {
> return status;
> --
> 2.5.0
>
More information about the samba-technical
mailing list