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

Karolin Seeger kseeger at samba.org
Tue Mar 28 14:24:02 UTC 2017


The branch, v4-5-test has been updated
       via  78b188d selftest: tests for vfs_fruite file-id behavior
       via  d89cfae torture: add torture_assert_mem_not_equal_goto()
       via  42b77e9 vfs_fruit: document added zero_file_id parameter
       via  3722b06 vfs_fruit: enable zero file id
       via  a5c92d8 smbd: add zero_file_id flag
      from  cecab32 s3: libgpo: Allow skipping GPO objects that don't have the expected LDAP attributes.

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


- Log -----------------------------------------------------------------
commit 78b188d50c13e52cd46bc1de53ca8e3638335923
Author: Uri Simchoni <uri at samba.org>
Date:   Thu Mar 23 21:32:04 2017 +0200

    selftest: tests for vfs_fruite file-id behavior
    
    The test is in its own suite because it validates
    our hackish workaround rather than some reference
    implementation behavior.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12715
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Sun Mar 26 23:31:08 CEST 2017 on sn-devel-144
    
    (cherry picked from commit b6baf35ebde68db75515910ede26e74bb8313284)
    
    Autobuild-User(v4-5-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-5-test): Tue Mar 28 16:23:23 CEST 2017 on sn-devel-144

commit d89cfae311e6a65249ba0ac2c44724a05ba24a65
Author: Uri Simchoni <uri at samba.org>
Date:   Thu Mar 23 21:30:50 2017 +0200

    torture: add torture_assert_mem_not_equal_goto()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12715
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit f31fd41ca728d664ded940a7309ef1e32383bb66)

commit 42b77e93e2e9376dca1e11541d9565d417c8e4eb
Author: Uri Simchoni <uri at samba.org>
Date:   Thu Mar 23 14:51:32 2017 +0200

    vfs_fruit: document added zero_file_id parameter
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12715
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit e11d4eb4d5c6cfc6daa3dbdcc301a4fa83298f0e)

commit 3722b06f12b6ab8c81411704d3fe30b33aeac696
Author: Uri Simchoni <uri at samba.org>
Date:   Thu Mar 23 14:08:45 2017 +0200

    vfs_fruit: enable zero file id
    
    Enable zero_file_id if both conditions are met:
    - AAPL negotiated
    - fruit:zero_file_id is set
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12715
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 245a325532c9a46ec3e459ceca38e903b203f691)

commit a5c92d855d462f726f59dde42ec6a3a021eb2ab4
Author: Uri Simchoni <uri at samba.org>
Date:   Thu Mar 23 14:08:26 2017 +0200

    smbd: add zero_file_id flag
    
    This flag instructs the SMB layer to report a zero on-disk
    file identifier.
    
    According to [MS-SMB2] 3.3.5.9.9, the reported on-disk file ID
    SHOULD be unique. However, macOS clients seem to expect it to be
    unique over time as well, like the HFS+ CNID. Reporting a file ID
    of 0 seems to instruct the Mac client not to trust the server-reported
    file ID.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12715
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 6711522e1e57980e50e245f43167d0daf5a705ad)

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

Summary of changes:
 docs-xml/manpages/vfs_fruit.8.xml | 17 +++++++++
 lib/torture/torture.h             | 10 ++++++
 source3/modules/vfs_fruit.c       |  7 ++++
 source3/selftest/tests.py         |  4 ++-
 source3/smbd/globals.h            |  1 +
 source3/smbd/proto.h              |  1 +
 source3/smbd/trans2.c             | 14 ++++++++
 source4/torture/vfs/fruit.c       | 72 +++++++++++++++++++++++++++++++++++++++
 source4/torture/vfs/vfs.c         |  1 +
 9 files changed, 126 insertions(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/vfs_fruit.8.xml b/docs-xml/manpages/vfs_fruit.8.xml
index ea3d84a..e2e696c 100644
--- a/docs-xml/manpages/vfs_fruit.8.xml
+++ b/docs-xml/manpages/vfs_fruit.8.xml
@@ -145,6 +145,23 @@
 	    </listitem>
 	  </varlistentry>
 
+	  <varlistentry>
+	    <term>fruit:zero_file_id = yes | no</term>
+	    <listitem>
+	      <para>A <emphasis>global</emphasis> option whether to return
+	      zero to queries of on-disk file identifier, if the client
+	      has negotiated AAPL.</para>
+	      <para>Mac applications and / or the Mac SMB
+	      client code expect the on-disk file identifier to have the
+	      semantics of HFS+ Catalog Node Identifier (CNID). Samba
+	      doesn't provide those semantics, and that occasionally cause
+	      usability issues or even data loss. Returning a file identifier
+	      of zero causes the Mac client to stop using and trusting the
+	      file id returned from the server.</para>
+	      <para>The default is <emphasis>yes</emphasis>.</para>
+	    </listitem>
+	  </varlistentry>
+
 	</variablelist>
 </refsect1>
 
diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index b6d1301..668458a 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -367,6 +367,16 @@ void torture_result(struct torture_context *test,
 	} \
 	} while(0)
 
+#define torture_assert_mem_not_equal_goto(torture_ctx,got,expected,len,ret,label,cmt) \
+	do { const void *__got = (got), *__expected = (expected); \
+	if (memcmp(__got, __expected, len) == 0) { \
+		torture_result(torture_ctx, TORTURE_FAIL, \
+			       __location__": "#got" of len %d unexpectedly matches "#expected": %s", (int)len, cmt); \
+		ret = false; \
+		goto label; \
+	} \
+	} while(0)
+
 static inline void torture_dump_data_str_cb(const char *buf, void *private_data)
 {
 	char **dump = (char **)private_data;
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index d08409f..3f3f8c0 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -137,6 +137,7 @@ struct fruit_config_data {
 	bool copyfile_enabled;
 	bool veto_appledouble;
 	bool posix_rename;
+	bool aapl_zero_file_id;
 
 	/*
 	 * Additional options, all enabled by default,
@@ -1576,6 +1577,9 @@ static int init_fruit_config(vfs_handle_struct *handle)
 	config->posix_rename = lp_parm_bool(
 		SNUM(handle->conn), FRUIT_PARAM_TYPE_NAME, "posix_rename", true);
 
+	config->aapl_zero_file_id =
+	    lp_parm_bool(-1, FRUIT_PARAM_TYPE_NAME, "zero_file_id", true);
+
 	config->readdir_attr_rsize = lp_parm_bool(
 		SNUM(handle->conn), "readdir_attr", "aapl_rsize", true);
 
@@ -2221,6 +2225,9 @@ static NTSTATUS check_aapl(vfs_handle_struct *handle,
 				      blob);
 	if (NT_STATUS_IS_OK(status)) {
 		global_fruit_config.nego_aapl = true;
+		if (config->aapl_zero_file_id) {
+			aapl_force_zero_file_id(handle->conn->sconn);
+		}
 	}
 
 	return status;
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index e169506..d0b67fb 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -331,7 +331,7 @@ nbt = ["nbt.dgram" ]
 
 libsmbclient = ["libsmbclient"]
 
-vfs = ["vfs.fruit", "vfs.acl_xattr", "vfs.fruit_netatalk"]
+vfs = ["vfs.fruit", "vfs.acl_xattr", "vfs.fruit_netatalk", "vfs.fruit_file_id"]
 
 tests= base + raw + smb2 + rpc + unix + local + rap + nbt + libsmbclient + idmap + vfs
 
@@ -419,6 +419,8 @@ for t in tests:
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/vfs_fruit_stream_depot --option=torture:share2=vfs_wo_fruit_stream_depot -U$USERNAME%$PASSWORD', 'streams_depot')
     elif t == "vfs.fruit_netatalk":
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/vfs_fruit -U$USERNAME%$PASSWORD --option=torture:localdir=$SELFTEST_PREFIX/nt4_dc/share')
+    elif t == "vfs.fruit_file_id":
+        plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/vfs_fruit -U$USERNAME%$PASSWORD')
     elif t == "rpc.schannel_anon_setpw":
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$%', description="anonymous password set")
         plansmbtorture4testsuite(t, "nt4_dc_schannel", '//$SERVER_IP/tmp -U$%', description="anonymous password set (schannel enforced server-side)")
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 8ba564d..f39d12c 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -862,6 +862,7 @@ struct smbd_server_connection {
 	struct messaging_context *msg_ctx;
 	struct notify_context *notify_ctx;
 	bool using_smb2;
+	bool aapl_zero_file_id; /* Apple-specific */
 	int trans_num;
 
 	size_t num_users;
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 277dc6e..7d57844 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -1132,6 +1132,7 @@ NTSTATUS check_access(connection_struct *conn,
 				uint32_t access_mask);
 uint64_t smb_roundup(connection_struct *conn, uint64_t val);
 uint64_t get_FileIndex(connection_struct *conn, const SMB_STRUCT_STAT *psbuf);
+void aapl_force_zero_file_id(struct smbd_server_connection *sconn);
 bool samba_private_attr_name(const char *unix_ea_name);
 NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
 		      files_struct *fsp, const char *fname,
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index a01bb81..be2fada1 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -138,6 +138,9 @@ uint64_t smb_roundup(connection_struct *conn, uint64_t val)
 uint64_t get_FileIndex(connection_struct *conn, const SMB_STRUCT_STAT *psbuf)
 {
 	uint64_t file_index;
+	if (conn->sconn->aapl_zero_file_id) {
+		return 0;
+	}
 	if (conn->base_share_dev == psbuf->st_ex_dev) {
 		return (uint64_t)psbuf->st_ex_ino;
 	}
@@ -146,6 +149,17 @@ uint64_t get_FileIndex(connection_struct *conn, const SMB_STRUCT_STAT *psbuf)
 	return file_index;
 }
 
+
+/********************************************************************
+ Globally (for this connection / multi-channel) disable file-ID
+ calculation. This is required to be global because it serves
+ Macs in AAPL mode, which is globally set.
+********************************************************************/
+void aapl_force_zero_file_id(struct smbd_server_connection *sconn)
+{
+	sconn->aapl_zero_file_id = true;
+}
+
 /****************************************************************************
  Utility functions for dealing with extended attributes.
 ****************************************************************************/
diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c
index 2aa3d71..04e5ea4 100644
--- a/source4/torture/vfs/fruit.c
+++ b/source4/torture/vfs/fruit.c
@@ -3914,6 +3914,63 @@ done:
 	return ret;
 }
 
+static bool test_zero_file_id(struct torture_context *tctx,
+			      struct smb2_tree *tree)
+{
+	const char *fname = "filtest_file_id";
+	struct smb2_create create = {0};
+	NTSTATUS status;
+	bool ret = true;
+	uint8_t zero_file_id[8] = {0};
+
+	torture_comment(tctx, "Testing zero file id\n");
+
+	ret = torture_setup_file(tctx, tree, fname, false);
+	torture_assert_goto(tctx, ret == true, ret, done, "torture_setup_file");
+
+	ZERO_STRUCT(create);
+	create.in.desired_access = SEC_FILE_READ_ATTRIBUTE;
+	create.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+	create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+	create.in.create_disposition = NTCREATEX_DISP_OPEN;
+	create.in.fname = fname;
+	create.in.query_on_disk_id = true;
+
+	status = smb2_create(tree, tctx, &create);
+	torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret,
+					   done,
+					   "test file could not be opened");
+	torture_assert_mem_not_equal_goto(tctx, create.out.on_disk_id,
+					  zero_file_id, 8, ret, done,
+					  "unexpected zero file id");
+
+	smb2_util_close(tree, create.out.file.handle);
+
+	ret = enable_aapl(tctx, tree);
+	torture_assert(tctx, ret == true, "enable_aapl failed");
+
+	ZERO_STRUCT(create);
+	create.in.desired_access = SEC_FILE_READ_ATTRIBUTE;
+	create.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+	create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+	create.in.create_disposition = NTCREATEX_DISP_OPEN;
+	create.in.fname = fname;
+	create.in.query_on_disk_id = true;
+
+	status = smb2_create(tree, tctx, &create);
+	torture_assert_ntstatus_equal_goto(
+	    tctx, status, NT_STATUS_OK, ret, done,
+	    "test file could not be opened with AAPL");
+	torture_assert_mem_equal_goto(tctx, create.out.on_disk_id, zero_file_id,
+				      8, ret, done, "non-zero file id");
+
+	smb2_util_close(tree, create.out.file.handle);
+
+done:
+	smb2_util_unlink(tree, fname);
+	return ret;
+}
+
 /*
  * Note: This test depends on "vfs objects = catia fruit streams_xattr".  For
  * some tests torture must be run on the host it tests and takes an additional
@@ -3968,3 +4025,18 @@ struct torture_suite *torture_vfs_fruit_netatalk(void)
 
 	return suite;
 }
+
+struct torture_suite *torture_vfs_fruit_file_id(void)
+{
+	struct torture_suite *suite =
+	    torture_suite_create(talloc_autofree_context(), "fruit_file_id");
+
+	suite->description =
+	    talloc_strdup(suite, "vfs_fruit tests for on-disk file ID that "
+				 "require fruit:zero_file_id=yes");
+
+	torture_suite_add_1smb2_test(suite, "zero file id if AAPL negotiated",
+				     test_zero_file_id);
+
+	return suite;
+}
diff --git a/source4/torture/vfs/vfs.c b/source4/torture/vfs/vfs.c
index a4f8125..710e93b 100644
--- a/source4/torture/vfs/vfs.c
+++ b/source4/torture/vfs/vfs.c
@@ -111,6 +111,7 @@ NTSTATUS torture_vfs_init(void)
 	torture_suite_add_suite(suite, torture_vfs_fruit());
 	torture_suite_add_suite(suite, torture_vfs_fruit_netatalk());
 	torture_suite_add_suite(suite, torture_acl_xattr());
+	torture_suite_add_suite(suite, torture_vfs_fruit_file_id());
 
 	torture_register_suite(suite);
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list