[SCM] Samba Shared Repository - branch v4-6-test updated

Karolin Seeger kseeger at samba.org
Mon Aug 14 16:32:02 UTC 2017


The branch, v4-6-test has been updated
       via  ba9c6fb vfs_fruit: factor out common code from ad_get() and ad_fget()
       via  4afdcbf vfs_fruit: return fake pipe fd in fruit_open_meta_netatalk()
       via  4d7835f vfs_fruit: don't open basefile in ad_open() and simplify API
       via  f608905 vfs_fruit: use path based setxattr call in ad_fset()
       via  534ee86 s4/torture: additional tests for kernel-oplocks
       via  c3177ac s4/torture: reproducer for kernel oplocks issue with streams
       via  ef7ce21 vfs_streams_xattr: return a fake fd in streams_xattr_open()
       via  d811440 vfs_streams_xattr: implement all missing handle based VFS functions
       via  7754581 vfs_streams_xattr: always pass NULL as fsp arg to get_ea_value()
       via  29e8d5c vfs_streams_xattr: remove fsp argument from get_xattr_size()
       via  eddec63 vfs_streams_xattr: remove all uses of fd, use name based functions
       via  35924ef vfs_streams_xattr: invalidate stat info if xattr was not found
       via  a82411ac s3: torture: Add a test for cli_setpathinfo_basic() to smbtorture3.
       via  0a2ea71 s3: libsmb: Implement cli_smb2_setatr() by calling cli_smb2_setpathinfo().
       via  426c863 s3: libsmb: Add cli_smb2_setpathinfo(), to be called by cli_setpathinfo_basic().
       via  5386d7f s3: libsmbclient: Fix cli_setpathinfo_basic() to treat mode == -1 as no change.
       via  aafdd59 vfs_gpfs: handle EACCES when fetching DOS attributes from xattr
       via  d909d99 s3/smbd: handle EACCES when fetching DOS attributes from xattr
       via  e934f02 s3/smbd: handling of failed DOS attributes reading
       via  20ec061 s3: libsmb: Reverse sense of 'clear all attributes', ignore attribute change in SMB2 to match SMB1.
      from  0effa0f VERSION: Bump version up to 4.6.8...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-6-test


- Log -----------------------------------------------------------------
commit ba9c6fb379c706981c1171ed7e46c87eccf21427
Author: Ralph Boehme <slow at samba.org>
Date:   Wed May 24 09:17:19 2017 +0200

    vfs_fruit: factor out common code from ad_get() and ad_fget()
    
    As a result of the previous changes ad_get() and ad_fget() do completey
    the same, so factor out the common code to a new helper function. No
    change in behaviour.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Wed Aug  9 22:33:36 CEST 2017 on sn-devel-144
    
    (backported from commit d55c27abc5a7357f740c7065bbe12e7f36b57125)
    
    Autobuild-User(v4-6-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-6-test): Mon Aug 14 18:31:59 CEST 2017 on sn-devel-144

commit 4afdcbfcd138243ac23e39072cba6df4b6bfac80
Author: Ralph Boehme <slow at samba.org>
Date:   Tue May 23 17:44:16 2017 +0200

    vfs_fruit: return fake pipe fd in fruit_open_meta_netatalk()
    
    Do not open the basefile, that conflict with "kernel oplocks = yes". We
    just return a fake file fd based on dup'ing a pipe fd and ensure all VFS
    functions that go through vfs_fruit and work on the metadata stream can
    deal with it.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (backported from commit 7583ee6e1c558067e4c7a7351085fcc0e4240366)

commit 4d7835f64801ee6ac373bd7f1069590b4eee4c3c
Author: Ralph Boehme <slow at samba.org>
Date:   Tue May 23 17:31:47 2017 +0200

    vfs_fruit: don't open basefile in ad_open() and simplify API
    
    We never need an fd on the basefile when operating on the metadata, as
    we can always use path based syscalls. Opening the basefile conflicts
    with "kernel oplocks" so just don't do it.
    
    Additional changes:
    
    - remove the adouble_type_t argument to ad_open(), the type is passed
      and set when allocating a struct adouble with ad_alloc()
    
    - additionally pass an optional fsp to ad_open() (so the caller can pass
      NULL). With this change we can move the fd inheritance from fsp to ad
      into ad_open() itself where it belongs and remove it from the caller
      ad_fget()
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    (backported from commit e92a39255e66f655e2758f0a71a01eaf258cf711)

commit f6089059301d948aa8d6f69801f3e5fd56893b0e
Author: Ralph Boehme <slow at samba.org>
Date:   Tue May 23 17:39:46 2017 +0200

    vfs_fruit: use path based setxattr call in ad_fset()
    
    This allows later commits to remove opening of the basefile which
    conflict with "kernel oplocks = yes".
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (backported from commit aff6fc49f4ac244aef162200a37bd846719e1e4f)

commit 534ee869f7bf5b147c745858a7ba2f5e01df2351
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 18 13:17:38 2017 +0200

    s4/torture: additional tests for kernel-oplocks
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    (backported from commit bbc225de83e7b0e5eaeb1b843532d1f0fca91a3c)

commit c3177accbcbf190e65e96e53e9c87db4c75f8e0b
Author: Ralph Boehme <slow at samba.org>
Date:   Wed May 10 11:38:06 2017 +0200

    s4/torture: reproducer for kernel oplocks issue with streams
    
    test_smb2_kernel_oplocks3() wouldn't have failed without the patches,
    I'm just adding it to have at least one test that tests with 2
    clients. All other tests use just one client.
    
    test_smb2_kernel_oplocks4() is the reproducer.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    (backported from commit a334fff8a8c779704ee04ae784024efb67a6e9c9)

commit ef7ce21c9d7d225c82ecc4b3cfb91d3ac38e0799
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 11 18:08:56 2017 +0200

    vfs_streams_xattr: return a fake fd in streams_xattr_open()
    
    The final step in changing vfs_streams_xattr to not call open() on the
    basefile anymore. Instead, we just return a fake file fd based on
    dup'ing a pipe fd. Previous commits ensured all calls to VFS API
    functions use pathname based versions to do their work.
    
    This ensures we don't trigger kernel oplock breaks for client "open
    stream" requests when needlessly opening the basefile.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 0a8559d4c9e4fc73c30a06b5f45f3b870afe4439)

commit d811440cebf69978364ffd3eb59e824657c30d8c
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 11 18:05:18 2017 +0200

    vfs_streams_xattr: implement all missing handle based VFS functions
    
    Implement all missing handle based VFS function. If the call is on a
    named stream, implement the appropriate action for the VFS function, in
    most cases a no-op.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (backported from commit 9647af6bec62c9f61d541aad4a9b8f25fd5bc627)

commit 7754581838c0250ed3a4eef6530ece0bfc61ae03
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 11 17:38:00 2017 +0200

    vfs_streams_xattr: always pass NULL as fsp arg to get_ea_value()
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (backported from commit 0ed3075ee7edfecde7455a2c64e9df882828343b)

commit 29e8d5cdf2fea2136981c563fbaea0e5349494ef
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 11 17:36:15 2017 +0200

    vfs_streams_xattr: remove fsp argument from get_xattr_size()
    
    Still in the process of changing all handle based operations to use path
    based operations.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (backported from commit 4cc59e6d011cd3804499ba82bb4071973aa9d494)

commit eddec63813cb5b0fdb5c17adc6da234c5431fa09
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 11 15:05:23 2017 +0200

    vfs_streams_xattr: remove all uses of fd, use name based functions
    
    We don't really need an fd in this module, all calls to the VFS xattr
    API can just use the name based versions.
    
    This paves the way for removing the open of the basefile in
    streams_xattr_open() in a later commit.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (backported from commit ea906bb476516c05e7cbda478afd32acb443c03e)

commit 35924efedd1545078331422cd2bf9e2e5b7818ef
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 11 07:59:20 2017 +0200

    vfs_streams_xattr: invalidate stat info if xattr was not found
    
    We stat the basefile so we leave valid stat info from the base file
    behind, even though the xattr for the stream was not there.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (backported from commit ec32f33ea6d50d9cb504400c3ef1e78643502e1a)

commit a82411ac3964732e771a0f5457733232d96e6f9e
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Jul 21 15:11:08 2017 -0700

    s3: torture: Add a test for cli_setpathinfo_basic() to smbtorture3.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12913
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit bfa07323590357542eb06ad5faa2dc5a5736e3f1)

commit 0a2ea71ae42c60cd36f9ede78ee5608586faf615
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Jul 21 12:46:23 2017 -0700

    s3: libsmb: Implement cli_smb2_setatr() by calling cli_smb2_setpathinfo().
    
    This removes duplicate code paths and ensures we have only one
    function calling the underlying smb2cli_set_info() for setting
    info levels by path.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12913
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit b1e5b894b089433e59c96915a27559d179bdb6c5)

commit 426c86370d450b5f7fcbac209c7f788de649ff5e
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Jul 21 12:41:11 2017 -0700

    s3: libsmb: Add cli_smb2_setpathinfo(), to be called by cli_setpathinfo_basic().
    
    Fix to prevent libsmbclient from accidently making SMB1 calls inside an SMB2
    connection.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12913
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 2a15c70603bb23a68a2e3de0b00bfd98508f78e0)

commit 5386d7f4be3f13f9c9e4e6ea952ebcdab4754e3a
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Jul 21 09:56:45 2017 -0700

    s3: libsmbclient: Fix cli_setpathinfo_basic() to treat mode == -1 as no change.
    
    This is only called from SMBC_setatr(), so bring it into line with
    the specification for that function.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12913
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 812006fa8f26004609901b0ddef1c3ed05eff35e)

commit aafdd597c56a2e60ebcc94d57b73864fa3106366
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Jun 8 19:18:36 2017 +0200

    vfs_gpfs: handle EACCES when fetching DOS attributes from xattr
    
    When trying to fetch the DOS attributes via gpfswrap_get_winattrs_path()
    if the filesystem doesn't grant READ_ATTR to the file the function fails
    with EACCESS.
    
    But according to MS-FSA 2.1.5.1.2.1 "Algorithm to Check Access to an
    Existing File" FILE_LIST_DIRECTORY on a directory implies
    FILE_READ_ATTRIBUTES for directory entries.
    
    So if the user can open the parent directory for reading this implies
    FILE_LIST_DIRECTORY and we can safely call gpfswrap_get_winattrs_path()
    with DAC_OVERRIDE_CAPABILITY.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12944
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Wed Aug  9 01:21:14 CEST 2017 on sn-devel-144
    
    (cherry picked from commit 62d73f5b936550d623ef4f31c7438ac3c90105b9)

commit d909d9986cee56e09825fe85d5db30d6f2fe49d2
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Jun 8 19:10:20 2017 +0200

    s3/smbd: handle EACCES when fetching DOS attributes from xattr
    
    When trying to fetch the DOS attributes xattr via SMB_VFS_GETXATTR() if
    the filesystem doesn't grant read access to the file the xattr read
    request fails with EACCESS.
    
    But according to MS-FSA 2.1.5.1.2.1 "Algorithm to Check Access to an
    Existing File" FILE_LIST_DIRECTORY on a directory implies
    FILE_READ_ATTRIBUTES for directory entries.
    
    So if the user can open the parent directory for reading this implies
    FILE_LIST_DIRECTORY and we can safely call SMB_VFS_GETXATTR() as root,
    ensuring we can read the DOS attributes xattr.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12944
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    (backported from commit c54fcb7cbd0de244eed4134e877da6e9c16e7aab)

commit e934f0274fd79395150835a18d12f4bab9a1fb50
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Jun 8 19:05:48 2017 +0200

    s3/smbd: handling of failed DOS attributes reading
    
    Only fall back to using UNIX modes if we get NOT_IMPLEMENTED. This is
    exactly what we already do when setting DOS attributes.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12944
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    (cherry picked from commit 9de1411d9e7c7ac3da544345d4dea7fd73dff01b)

commit 20ec0611639c0442c108288c4342718ce364a019
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jul 17 10:37:15 2017 -0700

    s3: libsmb: Reverse sense of 'clear all attributes', ignore attribute change in SMB2 to match SMB1.
    
    SMB1 uses attr == 0 to clear all attributes
    on a file (end up with FILE_ATTRIBUTE_NORMAL),
    and attr == FILE_ATTRIBUTE_NORMAL to mean ignore
    request attribute change.
    
    SMB2 uses exactly the reverse. Unfortunately as the
    cli_setatr() ABI is exposed inside libsmbclient,
    we must make the SMB2 cli_smb2_setatr() call
    export the same ABI as the SMB1 cli_setatr()
    which calls it. This means reversing the sense
    of the requested attr argument if it's zero
    or FILE_ATTRIBUTE_NORMAL.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12899
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    (cherry picked from commit f1cc79a46d56bda99c392d491d88479cd6427a32)

-----------------------------------------------------------------------

Summary of changes:
 source3/libsmb/cli_smb2_fnum.c      |  96 ++++--
 source3/libsmb/cli_smb2_fnum.h      |   5 +
 source3/libsmb/clirap.c             |  27 +-
 source3/modules/vfs_fruit.c         | 258 ++++++----------
 source3/modules/vfs_gpfs.c          |  69 ++++-
 source3/modules/vfs_streams_xattr.c | 574 ++++++++++++++++++++++++++++++------
 source3/smbd/dosmode.c              |  43 ++-
 source3/torture/torture.c           | 137 +++++++++
 source4/torture/smb2/oplock.c       | 346 ++++++++++++++++++++++
 9 files changed, 1259 insertions(+), 296 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 848e077..cb62c90 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -1519,20 +1519,20 @@ NTSTATUS cli_smb2_qpathinfo_streams(struct cli_state *cli,
 }
 
 /***************************************************************
- Wrapper that allows SMB2 to set pathname attributes.
+ Wrapper that allows SMB2 to set SMB_FILE_BASIC_INFORMATION on
+ a pathname.
  Synchronous only.
 ***************************************************************/
 
-NTSTATUS cli_smb2_setatr(struct cli_state *cli,
+NTSTATUS cli_smb2_setpathinfo(struct cli_state *cli,
 			const char *name,
-			uint16_t attr,
-			time_t mtime)
+			uint8_t in_info_type,
+			uint8_t in_file_info_class,
+			const DATA_BLOB *p_in_data)
 {
 	NTSTATUS status;
 	uint16_t fnum = 0xffff;
 	struct smb2_hnd *ph = NULL;
-	uint8_t inbuf_store[40];
-	DATA_BLOB inbuf = data_blob_null;
 	TALLOC_CTX *frame = talloc_stackframe();
 
 	if (smbXcli_conn_has_async_calls(cli->conn)) {
@@ -1564,29 +1564,13 @@ NTSTATUS cli_smb2_setatr(struct cli_state *cli,
 		goto fail;
 	}
 
-	/* setinfo on the handle with info_type SMB2_SETINFO_FILE (1),
-	   level 4 (SMB_FILE_BASIC_INFORMATION - 1000). */
-
-	inbuf.data = inbuf_store;
-	inbuf.length = sizeof(inbuf_store);
-	data_blob_clear(&inbuf);
-
-	SSVAL(inbuf.data, 32, attr);
-	if (mtime != 0) {
-		put_long_date((char *)inbuf.data + 16,mtime);
-	}
-	/* Set all the other times to -1. */
-	SBVAL(inbuf.data, 0, 0xFFFFFFFFFFFFFFFFLL);
-	SBVAL(inbuf.data, 8, 0xFFFFFFFFFFFFFFFFLL);
-	SBVAL(inbuf.data, 24, 0xFFFFFFFFFFFFFFFFLL);
-
 	status = smb2cli_set_info(cli->conn,
 				cli->timeout,
 				cli->smb2.session,
 				cli->smb2.tcon,
-				1, /* in_info_type */
-				SMB_FILE_BASIC_INFORMATION - 1000, /* in_file_info_class */
-				&inbuf, /* in_input_buffer */
+				in_info_type,
+				in_file_info_class,
+				p_in_data, /* in_input_buffer */
 				0, /* in_additional_info */
 				ph->fid_persistent,
 				ph->fid_volatile);
@@ -1602,6 +1586,68 @@ NTSTATUS cli_smb2_setatr(struct cli_state *cli,
 	return status;
 }
 
+
+/***************************************************************
+ Wrapper that allows SMB2 to set pathname attributes.
+ Synchronous only.
+***************************************************************/
+
+NTSTATUS cli_smb2_setatr(struct cli_state *cli,
+			const char *name,
+			uint16_t attr,
+			time_t mtime)
+{
+	uint8_t inbuf_store[40];
+	DATA_BLOB inbuf = data_blob_null;
+
+	/* setinfo on the handle with info_type SMB2_SETINFO_FILE (1),
+	   level 4 (SMB_FILE_BASIC_INFORMATION - 1000). */
+
+	inbuf.data = inbuf_store;
+	inbuf.length = sizeof(inbuf_store);
+	data_blob_clear(&inbuf);
+
+	/*
+	 * SMB1 uses attr == 0 to clear all attributes
+	 * on a file (end up with FILE_ATTRIBUTE_NORMAL),
+	 * and attr == FILE_ATTRIBUTE_NORMAL to mean ignore
+	 * request attribute change.
+	 *
+	 * SMB2 uses exactly the reverse. Unfortunately as the
+	 * cli_setatr() ABI is exposed inside libsmbclient,
+	 * we must make the SMB2 cli_smb2_setatr() call
+	 * export the same ABI as the SMB1 cli_setatr()
+	 * which calls it. This means reversing the sense
+	 * of the requested attr argument if it's zero
+	 * or FILE_ATTRIBUTE_NORMAL.
+	 *
+	 * See BUG: https://bugzilla.samba.org/show_bug.cgi?id=12899
+	 */
+
+	if (attr == 0) {
+		attr = FILE_ATTRIBUTE_NORMAL;
+	} else if (attr == FILE_ATTRIBUTE_NORMAL) {
+		attr = 0;
+	}
+
+	SSVAL(inbuf.data, 32, attr);
+	if (mtime != 0) {
+		put_long_date((char *)inbuf.data + 16,mtime);
+	}
+	/* Set all the other times to -1. */
+	SBVAL(inbuf.data, 0, 0xFFFFFFFFFFFFFFFFLL);
+	SBVAL(inbuf.data, 8, 0xFFFFFFFFFFFFFFFFLL);
+	SBVAL(inbuf.data, 24, 0xFFFFFFFFFFFFFFFFLL);
+
+	return cli_smb2_setpathinfo(cli,
+				name,
+				1, /* in_info_type */
+				/* in_file_info_class */
+				SMB_FILE_BASIC_INFORMATION - 1000,
+				&inbuf);
+}
+
+
 /***************************************************************
  Wrapper that allows SMB2 to set file handle times.
  Synchronous only.
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index 12c42a2..c92c5c9 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -107,6 +107,11 @@ NTSTATUS cli_smb2_qpathinfo_streams(struct cli_state *cli,
 			TALLOC_CTX *mem_ctx,
 			unsigned int *pnum_streams,
 			struct stream_struct **pstreams);
+NTSTATUS cli_smb2_setpathinfo(struct cli_state *cli,
+			const char *name,
+			uint8_t in_info_type,
+			uint8_t in_file_info_class,
+			const DATA_BLOB *p_in_data);
 NTSTATUS cli_smb2_setatr(struct cli_state *cli,
 			const char *fname,
 			uint16_t attr,
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c
index dd2c30e..e80dfc9 100644
--- a/source3/libsmb/clirap.c
+++ b/source3/libsmb/clirap.c
@@ -29,6 +29,7 @@
 #include "libsmb/clirap.h"
 #include "trans2.h"
 #include "../libcli/smb/smbXcli_base.h"
+#include "cli_smb2_fnum.h"
 
 #define PIPE_LANMAN   "\\PIPE\\LANMAN"
 
@@ -732,8 +733,17 @@ NTSTATUS cli_setpathinfo_basic(struct cli_state *cli, const char *fname,
         put_long_date(p, change_time);
         p += 8;
 
-        /* Add attributes */
-        SIVAL(p, 0, mode);
+	if (mode == (uint16_t)-1 || mode == FILE_ATTRIBUTE_NORMAL) {
+		/* No change. */
+		mode = 0;
+	} else if (mode == 0) {
+		/* Clear all existing attributes. */
+		mode = FILE_ATTRIBUTE_NORMAL;
+	}
+
+	/* Add attributes */
+	SIVAL(p, 0, mode);
+
         p += 4;
 
         /* Add padding */
@@ -742,6 +752,19 @@ NTSTATUS cli_setpathinfo_basic(struct cli_state *cli, const char *fname,
 
         data_len = PTR_DIFF(p, data);
 
+	if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+		DATA_BLOB in_data = data_blob_const(data, data_len);
+		/*
+		 * Split out SMB2 here as we need to select
+		 * the correct info type and level.
+		 */
+		return cli_smb2_setpathinfo(cli,
+				fname,
+				1, /* SMB2_SETINFO_FILE */
+				SMB_FILE_BASIC_INFORMATION - 1000,
+				&in_data);
+	}
+
 	return cli_setpathinfo(cli, SMB_FILE_BASIC_INFORMATION, fname,
 			       (uint8_t *)data, data_len);
 }
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index df0a700..e328471 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -857,11 +857,6 @@ exit:
 	return ealen;
 }
 
-static int ad_open_meta(const char *path, int flags, mode_t mode)
-{
-	return open(path, flags, mode);
-}
-
 static int ad_open_rsrc_xattr(const char *path, int flags, mode_t mode)
 {
 #ifdef HAVE_ATTROPEN
@@ -910,33 +905,44 @@ static int ad_open_rsrc(vfs_handle_struct *handle,
 	return fd;
 }
 
+/*
+ * Here's the deal: for ADOUBLE_META we can do without an fd as we can issue
+ * path based xattr calls. For ADOUBLE_RSRC however we need a full-fledged fd
+ * for file IO on the ._ file.
+ */
 static int ad_open(vfs_handle_struct *handle,
 		   struct adouble *ad,
+		   files_struct *fsp,
 		   const char *path,
-		   adouble_type_t t,
 		   int flags,
 		   mode_t mode)
 {
 	int fd;
 
 	DBG_DEBUG("Path [%s] type [%s]\n",
-		  path, t == ADOUBLE_META ? "meta" : "rsrc");
+		  path, ad->ad_type == ADOUBLE_META ? "meta" : "rsrc");
 
-	if (t == ADOUBLE_META) {
-		fd = ad_open_meta(path, flags, mode);
-	} else {
-		fd = ad_open_rsrc(handle, path, flags, mode);
+	if (ad->ad_type == ADOUBLE_META) {
+		return 0;
+	}
+
+	if ((fsp != NULL) && (fsp->fh != NULL) && (fsp->fh->fd != -1)) {
+		ad->ad_fd = fsp->fh->fd;
+		ad->ad_opened = false;
+		return 0;
 	}
 
-	if (fd != -1) {
-		ad->ad_opened = true;
-		ad->ad_fd = fd;
+	fd = ad_open_rsrc(handle, path, flags, mode);
+	if (fd == -1) {
+		return -1;
 	}
+	ad->ad_opened = true;
+	ad->ad_fd = fd;
 
 	DBG_DEBUG("Path [%s] type [%s] fd [%d]\n",
-		  path, t == ADOUBLE_META ? "meta" : "rsrc", fd);
+		  path, ad->ad_type == ADOUBLE_META ? "meta" : "rsrc", fd);
 
-	return fd;
+	return 0;
 }
 
 static ssize_t ad_read_rsrc_xattr(struct adouble *ad,
@@ -1222,25 +1228,21 @@ static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle,
 	return ad;
 }
 
-/**
- * Return AppleDouble data for a file
- *
- * @param[in] ctx      talloc context
- * @param[in] handle   vfs handle
- * @param[in] path     pathname to file or directory
- * @param[in] type     type of AppleDouble, ADOUBLE_META or ADOUBLE_RSRC
- *
- * @return             talloced struct adouble or NULL on error
- **/
-static struct adouble *ad_get(TALLOC_CTX *ctx, vfs_handle_struct *handle,
-			      const char *path, adouble_type_t type)
+static struct adouble *ad_get_internal(TALLOC_CTX *ctx,
+				       vfs_handle_struct *handle,
+				       files_struct *fsp,
+				       const char *path,
+				       adouble_type_t type)
 {
 	int rc = 0;
 	ssize_t len;
 	struct adouble *ad = NULL;
-	int fd;
 	int mode;
 
+	if (fsp != NULL) {
+		path = fsp->base_fsp->fsp_name->base_name;
+	}
+
 	DEBUG(10, ("ad_get(%s) called for %s\n",
 		   type == ADOUBLE_META ? "meta" : "rsrc", path));
 
@@ -1250,28 +1252,18 @@ static struct adouble *ad_get(TALLOC_CTX *ctx, vfs_handle_struct *handle,
 		goto exit;
 	}
 
-	/*
-	 * Here's the deal: for ADOUBLE_META we can do without an fd
-	 * as we can issue path based xattr calls. For ADOUBLE_RSRC
-	 * however we need a full-fledged fd for file IO on the ._
-	 * file.
-	 */
-	if (type == ADOUBLE_RSRC) {
-		/* Try rw first so we can use the fd in ad_convert() */
-		mode = O_RDWR;
-
-		fd = ad_open(handle, ad, path, ADOUBLE_RSRC, mode, 0);
-		if (fd == -1 && ((errno == EROFS) || (errno == EACCES))) {
-			mode = O_RDONLY;
-			fd = ad_open(handle, ad, path, ADOUBLE_RSRC, mode, 0);
-		}
+	/* Try rw first so we can use the fd in ad_convert() */
+	mode = O_RDWR;
 
-		if (fd == -1) {
-			DBG_DEBUG("ad_open [%s] error [%s]\n",
-				  path, strerror(errno));
-			rc = -1;
-			goto exit;
-		}
+	rc = ad_open(handle, ad, fsp, path, mode, 0);
+	if (rc == -1 && ((errno == EROFS) || (errno == EACCES))) {
+		mode = O_RDONLY;
+		rc = ad_open(handle, ad, fsp, path, mode, 0);
+	}
+	if (rc == -1) {
+		DBG_DEBUG("ad_open [%s] error [%s]\n",
+			  path, strerror(errno));
+		goto exit;
 	}
 
 	len = ad_read(ad, path);
@@ -1296,6 +1288,24 @@ exit:
  *
  * @param[in] ctx      talloc context
  * @param[in] handle   vfs handle
+ * @param[in] path     pathname to file or directory
+ * @param[in] type     type of AppleDouble, ADOUBLE_META or ADOUBLE_RSRC
+ *
+ * @return             talloced struct adouble or NULL on error
+ **/
+static struct adouble *ad_get(TALLOC_CTX *ctx,
+			      vfs_handle_struct *handle,
+			      const char *path,
+			      adouble_type_t type)
+{
+	return ad_get_internal(ctx, handle, NULL, path, type);
+}
+
+/**
+ * Return AppleDouble data for a file
+ *
+ * @param[in] ctx      talloc context
+ * @param[in] handle   vfs handle
  * @param[in] fsp      fsp to use for IO
  * @param[in] type     type of AppleDouble, ADOUBLE_META or ADOUBLE_RSRC
  *
@@ -1304,70 +1314,7 @@ exit:
 static struct adouble *ad_fget(TALLOC_CTX *ctx, vfs_handle_struct *handle,
 			       files_struct *fsp, adouble_type_t type)
 {
-	int rc = 0;
-	ssize_t len;
-	struct adouble *ad = NULL;
-	char *path = fsp->base_fsp->fsp_name->base_name;
-
-	DBG_DEBUG("ad_get(%s) path [%s]\n",
-		  type == ADOUBLE_META ? "meta" : "rsrc",
-		  fsp_str_dbg(fsp));
-
-	ad = ad_alloc(ctx, handle, type);
-	if (ad == NULL) {
-		rc = -1;
-		goto exit;
-	}
-
-	if ((fsp->fh != NULL) && (fsp->fh->fd != -1)) {
-		ad->ad_fd = fsp->fh->fd;
-	} else {
-		/*
-		 * Here's the deal: for ADOUBLE_META we can do without an fd
-		 * as we can issue path based xattr calls. For ADOUBLE_RSRC
-		 * however we need a full-fledged fd for file IO on the ._
-		 * file.
-		 */
-		int fd;
-		int mode;
-
-		if (type == ADOUBLE_RSRC) {
-			/* Try rw first so we can use the fd in ad_convert() */
-			mode = O_RDWR;
-
-			fd = ad_open(handle, ad, path, ADOUBLE_RSRC, mode, 0);
-			if (fd == -1 &&
-			    ((errno == EROFS) || (errno == EACCES)))
-			{
-				mode = O_RDONLY;
-				fd = ad_open(handle, ad, path, ADOUBLE_RSRC,
-					     mode, 0);
-			}
-
-			if (fd == -1) {
-				DBG_DEBUG("error opening AppleDouble for %s\n", path);
-				rc = -1;
-				goto exit;
-			}
-		}
-	}
-
-	len = ad_read(ad, path);
-	if (len == -1) {
-		DBG_DEBUG("error reading AppleDouble for %s\n", path);
-		rc = -1;
-		goto exit;
-	}
-
-exit:
-	DBG_DEBUG("ad_get(%s) path [%s] rc [%d]\n",
-		  type == ADOUBLE_META ? "meta" : "rsrc",
-		  fsp_str_dbg(fsp), rc);
-
-	if (rc != 0) {
-		TALLOC_FREE(ad);
-	}
-	return ad;
+	return ad_get_internal(ctx, handle, fsp, NULL, type);
 }
 
 /**
@@ -1437,11 +1384,11 @@ static int ad_fset(struct adouble *ad, files_struct *fsp)
 
 	switch (ad->ad_type) {
 	case ADOUBLE_META:
-		rc = SMB_VFS_NEXT_FSETXATTR(ad->ad_handle,
-					    fsp,
-					    AFPINFO_EA_NETATALK,
-					    ad->ad_data,
-					    AD_DATASZ_XATTR, 0);
+		rc = SMB_VFS_NEXT_SETXATTR(ad->ad_handle,
+					   fsp->fsp_name->base_name,
+					   AFPINFO_EA_NETATALK,
+					   ad->ad_data,
+					   AD_DATASZ_XATTR, 0);
 		break;
 
 	case ADOUBLE_RSRC:
@@ -2722,56 +2669,24 @@ static int fruit_open_meta_netatalk(vfs_handle_struct *handle,
 				    int flags,
 				    mode_t mode)
 {
-	int rc = 0;
-	struct smb_filename *smb_fname_base = NULL;
-	int baseflags;
-	int hostfd = -1;
+	int rc;
+	int fakefd = -1;
 	struct adouble *ad = NULL;
+	int fds[2];
 
 	DBG_DEBUG("Path [%s]\n", smb_fname_str_dbg(smb_fname));
 
-	/* Create an smb_filename with stream_name == NULL. */
-	smb_fname_base = synthetic_smb_fname(talloc_tos(),
-					smb_fname->base_name,
-					NULL,
-					NULL,
-					smb_fname->flags);
-
-	if (smb_fname_base == NULL) {
-		errno = ENOMEM;
-		rc = -1;
-		goto exit;
-	}
-
-	/*
-	 * We use baseflags to turn off nasty side-effects when opening the
-	 * underlying file.
-	 */
-	baseflags = flags;
-	baseflags &= ~O_TRUNC;
-	baseflags &= ~O_EXCL;
-	baseflags &= ~O_CREAT;
-
-	hostfd = SMB_VFS_NEXT_OPEN(handle, smb_fname_base, fsp,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list