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

Karolin Seeger kseeger at samba.org
Fri Nov 2 14:03:02 UTC 2018


The branch, v4-8-test has been updated
       via  3587cca vfs_fruit: optionally delete AppleDouble files without Resourcefork data
       via  5eb26a5 vfs_fruit: add option "delete_empty_adfiles"
       via  24fd9dd vfs_fruit: detect empty resource forks in ad_convert()
       via  1a378c1 vfs_fruit: add option "wipe_intentionally_left_blank_rfork"
       via  01a76b2 s4:torture: add test for AppleDouble ResourceFork conversion
       via  0f5b9f5 s3:selftest: list vfs testssuites one per line
       via  d7b77c8 docs:vfs_fruit: add "delete_empty_adfiles" option
       via  2a94015 docs:vfs_fruit: add "wipe_intentionally_left_blank_rfork" option
      from  bfa9fd3 vfs_fruit: remove check for number of xattrs from ad_convert_xattr

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


- Log -----------------------------------------------------------------
commit 3587cca9487074304b1fd7b8201cabff5a36ccab
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 9 14:54:31 2018 +0200

    vfs_fruit: optionally delete AppleDouble files without Resourcefork data
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 3649f1a41a299b14609318ef52b44e2d53cba4b5)
    
    Autobuild-User(v4-8-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-8-test): Fri Nov  2 15:02:42 CET 2018 on sn-devel-144

commit 5eb26a5e7c9a9b5ad4faf85d2ff70d9f1ec36f6e
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 3 12:01:00 2018 +0200

    vfs_fruit: add option "delete_empty_adfiles"
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit e00e61345ccd88022cd24e62ac29e2c56a8f6117)

commit 24fd9ddc3607c7e38df30823f737bc1dd7502ebf
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 2 16:05:28 2018 +0200

    vfs_fruit: detect empty resource forks in ad_convert()
    
    For some reason the macOS client often writes AppleDouble files with a
    non-zero sized resource fork, but the resource fork data is just
    boilerplate data with the following string close to the start
    
      This resource fork intentionally left blank
    
    A dump with apple_dump looks like this:
    
    Entry ID   : 00000002 : Resource Fork
    Offset     : 00000052 : 82
    Length     : 0000011E : 286
    
    -RAW DUMP--:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F : (ASCII)
    00000000   : 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 1E : ................
    00000010   : 54 68 69 73 20 72 65 73 6F 75 72 63 65 20 66 6F : This resource fo
    00000020   : 72 6B 20 69 6E 74 65 6E 74 69 6F 6E 61 6C 6C 79 : rk intentionally
    00000030   : 20 6C 65 66 74 20 62 6C 61 6E 6B 20 20 20 00 00 :  left blank   ..
    00000040   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    00000050   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    00000060   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    00000070   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    00000080   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    00000090   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    000000A0   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    000000B0   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    000000C0   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    000000D0   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    000000E0   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    000000F0   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    00000100   : 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 1E : ................
    00000110   : 00 00 00 00 00 00 00 00 00 1C 00 1E FF FF       : ..............
    
    We can safely discard this Resource Fork data.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 7be979f958295474f0c0df6a4db0b5bca9a6676d)

commit 1a378c1238499e6d03447f17cf12ee24f9b3fb0f
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 3 12:01:00 2018 +0200

    vfs_fruit: add option "wipe_intentionally_left_blank_rfork"
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 2dbb2d287399e9c829a4fd4908a6dfba9fdfd7e8)

commit 01a76b2b14520eb9f46b92c514818bcfe57a54a6
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 4 14:28:15 2018 +0200

    s4:torture: add test for AppleDouble ResourceFork conversion
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 6f022e61597994bc032e61876f24150d7acb3fc2)

commit 0f5b9f5a6db2a6641e2cd405535f57721b9f9a67
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 4 13:47:20 2018 +0200

    s3:selftest: list vfs testssuites one per line
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit c3a1f3ec9ba2402de2a876ca06086b2d53e122f0)

commit d7b77c85821c00b490a18bc516944343e9a7ec96
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 4 18:22:31 2018 +0200

    docs:vfs_fruit: add "delete_empty_adfiles" option
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 2a9574b138f620e0a65cd61a957b99653c8dcd78)

commit 2a94015b5caac82c483300ef3c8ef6b205546d56
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 2 16:31:15 2018 +0200

    docs:vfs_fruit: add "wipe_intentionally_left_blank_rfork" option
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit f7a98094f05dd4b9abf5dc9704222aa5a07584d4)

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

Summary of changes:
 docs-xml/manpages/vfs_fruit.8.xml |  25 +++++
 selftest/target/Samba3.pm         |  18 ++++
 source3/modules/vfs_fruit.c       | 163 +++++++++++++++++++++++++++++++-
 source3/selftest/tests.py         |  12 ++-
 source4/torture/vfs/fruit.c       | 191 ++++++++++++++++++++++++++++++++++++++
 source4/torture/vfs/vfs.c         |   1 +
 6 files changed, 408 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/vfs_fruit.8.xml b/docs-xml/manpages/vfs_fruit.8.xml
index 7f6a0e7..fff89ab 100644
--- a/docs-xml/manpages/vfs_fruit.8.xml
+++ b/docs-xml/manpages/vfs_fruit.8.xml
@@ -378,6 +378,31 @@
 	    </listitem>
 	  </varlistentry>
 
+	  <varlistentry>
+	    <term>fruit:wipe_intentionally_left_blank_rfork = yes | no</term>
+	    <listitem>
+	      <para>Whether to wipe Resource Fork data that matches the special
+	      286 bytes sized placeholder blob that macOS client create on
+	      occasion. The blob contains a string <quote>This resource fork
+	      intentionally left blank</quote>, the remaining bytes being mostly
+	      zero. There being no one use of this data, it is probably safe to
+	      discard it. When this option is enabled, this module truncates the
+	      Resource Fork stream to 0 bytes.</para>
+	      <para>The default is <emphasis>no</emphasis>.</para>
+	    </listitem>
+	  </varlistentry>
+
+	  <varlistentry>
+	    <term>fruit:delete_empty_adfiles = yes | no</term>
+	    <listitem>
+	      <para>Whether to delete empty AppleDouble files. Empty means that
+	      the resource fork entry in the AppleDouble files is of size 0, or
+	      the size is exactly 286 bytes and the content matches a special
+	      boilerplate resource fork created my macOS.</para>
+	      <para>The default is <emphasis>no</emphasis>.</para>
+	    </listitem>
+	  </varlistentry>
+
 	</variablelist>
 </refsect1>
 
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index ca0d809..173d799 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -1981,6 +1981,24 @@ sub provision($$$$$$$$$)
 	fruit:time machine = yes
 	fruit:time machine max size = 32K
 
+[vfs_fruit_wipe_intentionally_left_blank_rfork]
+	path = $shrdir
+	vfs objects = fruit streams_xattr acl_xattr xattr_tdb
+	fruit:resource = file
+	fruit:metadata = stream
+	fruit:wipe_intentionally_left_blank_rfork = true
+	fruit:delete_empty_adfiles = false
+	fruit:veto_appledouble = no
+
+[vfs_fruit_delete_empty_adfiles]
+	path = $shrdir
+	vfs objects = fruit streams_xattr acl_xattr xattr_tdb
+	fruit:resource = file
+	fruit:metadata = stream
+	fruit:wipe_intentionally_left_blank_rfork = true
+	fruit:delete_empty_adfiles = true
+	fruit:veto_appledouble = no
+
 [badname-tmp]
 	path = $badnames_shrdir
 	guest ok = yes
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 44fa50d..e8c45f1 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -142,6 +142,8 @@ struct fruit_config_data {
 	const char *model;
 	bool time_machine;
 	off_t time_machine_max_size;
+	bool wipe_intentionally_left_blank_rfork;
+	bool delete_empty_adfiles;
 
 	/*
 	 * Additional options, all enabled by default,
@@ -467,6 +469,45 @@ static const uint32_t set_eid[] = {
 	AD_DEV, AD_INO, AD_SYN, AD_ID
 };
 
+static char empty_resourcefork[] = {
+	0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E,
+	0x54, 0x68, 0x69, 0x73, 0x20, 0x72, 0x65, 0x73,
+	0x6F, 0x75, 0x72, 0x63, 0x65, 0x20, 0x66, 0x6F,
+	0x72, 0x6B, 0x20, 0x69, 0x6E, 0x74, 0x65, 0x6E,
+	0x74, 0x69, 0x6F, 0x6E, 0x61, 0x6C, 0x6C, 0x79,
+	0x20, 0x6C, 0x65, 0x66, 0x74, 0x20, 0x62, 0x6C,
+	0x61, 0x6E, 0x6B, 0x20, 0x20, 0x20, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x1C, 0x00, 0x1E, 0xFF, 0xFF
+};
+
 struct fio {
 	/* tcon config handle */
 	struct fruit_config_data *config;
@@ -1281,6 +1322,107 @@ static bool ad_convert_truncate(struct adouble *ad,
 	return true;
 }
 
+static bool ad_convert_blank_rfork(struct adouble *ad,
+				   bool *blank)
+{
+	struct fruit_config_data *config = NULL;
+	uint8_t *map = MAP_FAILED;
+	size_t maplen;
+	int cmp;
+	ssize_t len;
+	int rc;
+	bool ok;
+
+	*blank = false;
+
+	SMB_VFS_HANDLE_GET_DATA(ad->ad_handle, config,
+				struct fruit_config_data, return false);
+
+	if (!config->wipe_intentionally_left_blank_rfork) {
+		return true;
+	}
+
+	if (ad_getentrylen(ad, ADEID_RFORK) != sizeof(empty_resourcefork)) {
+		return true;
+	}
+
+	maplen = ad_getentryoff(ad, ADEID_RFORK) +
+		ad_getentrylen(ad, ADEID_RFORK);
+
+	/* FIXME: direct use of mmap(), vfs_aio_fork does it too */
+	map = mmap(NULL, maplen, PROT_READ|PROT_WRITE, MAP_SHARED,
+		   ad->ad_fd, 0);
+	if (map == MAP_FAILED) {
+		DBG_ERR("mmap AppleDouble: %s\n", strerror(errno));
+		return false;
+	}
+
+	cmp = memcmp(map + ADEDOFF_RFORK_DOT_UND,
+		     empty_resourcefork,
+		     sizeof(empty_resourcefork));
+	rc = munmap(map, maplen);
+	if (rc != 0) {
+		DBG_ERR("munmap failed: %s\n", strerror(errno));
+		return false;
+	}
+
+	if (cmp != 0) {
+		return true;
+	}
+
+	ad_setentrylen(ad, ADEID_RFORK, 0);
+
+	ok = ad_pack(ad);
+	if (!ok) {
+		return false;
+	}
+
+	len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0);
+	if (len != AD_DATASZ_DOT_UND) {
+		return false;
+	}
+
+	*blank = true;
+	return true;
+}
+
+static bool ad_convert_delete_adfile(struct adouble *ad,
+				     const struct smb_filename *smb_fname)
+{
+	struct fruit_config_data *config = NULL;
+	struct smb_filename *ad_name = NULL;
+	int rc;
+
+	if (ad_getentrylen(ad, ADEID_RFORK) > 0) {
+		return true;
+	}
+
+	SMB_VFS_HANDLE_GET_DATA(ad->ad_handle, config,
+				struct fruit_config_data, return false);
+
+	if (!config->delete_empty_adfiles) {
+		return true;
+	}
+
+	rc = adouble_path(talloc_tos(), smb_fname, &ad_name);
+	if (rc != 0) {
+		return false;
+	}
+
+	rc = SMB_VFS_NEXT_UNLINK(ad->ad_handle, ad_name);
+	if (rc != 0) {
+		DBG_ERR("Unlinking [%s] failed: %s\n",
+			smb_fname_str_dbg(ad_name), strerror(errno));
+		TALLOC_FREE(ad_name);
+		return false;
+	}
+
+	DBG_WARNING("Unlinked [%s] after conversion\n", smb_fname_str_dbg(ad_name));
+	TALLOC_FREE(ad_name);
+
+	return true;
+}
+
 /**
  * Convert from Apple's ._ file to Netatalk
  *
@@ -1295,13 +1437,19 @@ static int ad_convert(struct adouble *ad,
 {
 	bool ok;
 	bool converted_xattr = false;
+	bool blank;
 
 	ok = ad_convert_xattr(ad, smb_fname, &converted_xattr);
 	if (!ok) {
 		return -1;
 	}
 
-	if (converted_xattr) {
+	ok = ad_convert_blank_rfork(ad, &blank);
+	if (!ok) {
+		return -1;
+	}
+
+	if (converted_xattr || blank) {
 		ok = ad_convert_truncate(ad, smb_fname);
 		if (!ok) {
 			return -1;
@@ -1315,6 +1463,11 @@ static int ad_convert(struct adouble *ad,
 		return -1;
 	}
 
+	ok = ad_convert_delete_adfile(ad, smb_fname);
+	if (!ok) {
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -2094,6 +2247,14 @@ static int init_fruit_config(vfs_handle_struct *handle)
 		config->time_machine_max_size = conv_str_size(tm_size_str);
 	}
 
+	config->wipe_intentionally_left_blank_rfork = lp_parm_bool(
+		SNUM(handle->conn), FRUIT_PARAM_TYPE_NAME,
+		"wipe_intentionally_left_blank_rfork", false);
+
+	config->delete_empty_adfiles = lp_parm_bool(
+		SNUM(handle->conn), FRUIT_PARAM_TYPE_NAME,
+		"delete_empty_adfiles", false);
+
 	SMB_VFS_HANDLE_SET_DATA(handle, config,
 				NULL, struct fruit_config_data,
 				return -1);
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 4526ac1..c6909c3 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -418,7 +418,14 @@ nbt = ["nbt.dgram" ]
 
 libsmbclient = ["libsmbclient"]
 
-vfs = ["vfs.fruit", "vfs.acl_xattr", "vfs.fruit_netatalk", "vfs.fruit_file_id", "vfs.fruit_timemachine"]
+vfs = [
+    "vfs.fruit",
+    "vfs.acl_xattr",
+    "vfs.fruit_netatalk",
+    "vfs.fruit_file_id",
+    "vfs.fruit_timemachine",
+    "vfs.fruit_conversion",
+]
 
 tests= base + raw + smb2 + rpc + unix + local + rap + nbt + libsmbclient + idmap + vfs
 
@@ -527,6 +534,9 @@ for t in tests:
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/vfs_fruit_timemachine -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 == "vfs.fruit_conversion":
+        plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD --option=torture:share2=vfs_fruit_wipe_intentionally_left_blank_rfork --option=torture:delete_empty_adfiles=false', 'wipe_intentionally_left_blank_rfork')
+        plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD --option=torture:share2=vfs_fruit_delete_empty_adfiles --option=torture:delete_empty_adfiles=true', 'delete_empty_adfiles')
     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/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c
index 3e95b74..b0bec2a 100644
--- a/source4/torture/vfs/fruit.c
+++ b/source4/torture/vfs/fruit.c
@@ -5407,3 +5407,194 @@ struct torture_suite *torture_vfs_fruit_timemachine(TALLOC_CTX *ctx)
 
 	return suite;
 }
+
+static bool test_convert_xattr_and_empty_rfork_then_delete(
+	struct torture_context *tctx,
+	struct smb2_tree *tree1,
+	struct smb2_tree *tree2)
+{
+	TALLOC_CTX *mem_ctx = talloc_new(tctx);
+	const char *fname = BASEDIR "\\test_adouble_conversion";
+	const char *adname = BASEDIR "/._test_adouble_conversion";
+	const char *rfork = BASEDIR "\\test_adouble_conversion" AFPRESOURCE_STREAM_NAME;
+	NTSTATUS status;
+	struct smb2_handle testdirh;
+	bool ret = true;
+	const char *streams[] = {
+		"::$DATA",
+		AFPINFO_STREAM,
+		":com.apple.metadata" "\xef\x80\xa2" "_kMDItemUserTags:$DATA",
+		":foo" "\xef\x80\xa2" "bar:$DATA", /* "foo:bar:$DATA" */
+	};
+	struct smb2_create create;
+	struct smb2_find find;
+	unsigned int count;
+	union smb_search_data *d;
+	bool delete_empty_adfiles;
+	int expected_num_files;
+
+	delete_empty_adfiles = torture_setting_bool(tctx,
+						    "delete_empty_adfiles",
+						    false);
+
+	smb2_deltree(tree1, BASEDIR);
+
+	status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"torture_smb2_testdir failed\n");
+	smb2_util_close(tree1, testdirh);
+
+	ret = torture_setup_file(tctx, tree1, fname, false);
+	torture_assert_goto(tctx, ret == true, ret, done,
+			    "torture_setup_file failed\n");
+
+	ret = torture_setup_file(tctx, tree1, adname, false);
+	torture_assert_goto(tctx, ret == true, ret, done,
+			    "torture_setup_file failed\n");
+
+	ret = write_stream(tree1, __location__, tctx, mem_ctx,
+			   adname, NULL,
+			   0, sizeof(osx_adouble_w_xattr), osx_adouble_w_xattr);
+	torture_assert_goto(tctx, ret == true, ret, done,
+			    "write_stream failed\n");
+
+	ret = enable_aapl(tctx, tree2);
+	torture_assert_goto(tctx, ret == true, ret, done, "enable_aapl failed");
+
+	/*
+	 * Issue a smb2_find(), this triggers the server-side conversion
+	 */
+
+	create = (struct smb2_create) {
+		.in.desired_access = SEC_RIGHTS_DIR_READ,
+		.in.create_options = NTCREATEX_OPTIONS_DIRECTORY,
+		.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY,
+		.in.share_access = NTCREATEX_SHARE_ACCESS_READ,
+		.in.create_disposition = NTCREATEX_DISP_OPEN,
+		.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS,
+		.in.fname = BASEDIR,
+	};
+
+	status = smb2_create(tree2, tctx, &create);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_create failed\n");
+
+	find = (struct smb2_find) {
+		.in.file.handle = create.out.file.handle,
+		.in.pattern = "*",
+		.in.max_response_size = 0x1000,
+		.in.level = SMB2_FIND_ID_BOTH_DIRECTORY_INFO,
+	};
+
+	status = smb2_find_level(tree2, tree2, &find, &count, &d);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_find_level failed\n");
+
+	status = smb2_util_close(tree2, create.out.file.handle);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_util_close failed");
+
+	/*
+	 * Check number of streams
+	 */
+
+	ret = check_stream_list(tree2, tctx, fname, 4, streams, false);
+	torture_assert_goto(tctx, ret == true, ret, done, "check_stream_list");
+
+	/*
+	 * Check Resource Fork is gone
+	 */
+
+	create = (struct smb2_create) {
+		.in.desired_access = SEC_RIGHTS_FILE_READ|SEC_RIGHTS_FILE_WRITE,
+		.in.file_attributes = FILE_ATTRIBUTE_NORMAL,
+		.in.share_access = NTCREATEX_SHARE_ACCESS_READ,
+		.in.create_disposition = NTCREATEX_DISP_OPEN,
+		.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS,
+		.in.fname = rfork,
+	};
+
+	status = smb2_create(tree2, mem_ctx, &create);
+	torture_assert_ntstatus_equal_goto(
+		tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND,
+		ret, done, "Bad smb2_create return\n");
+
+	/*
+	 * Check xattr data has been migrated from the AppleDouble file to
+	 * streams.
+	 */
+
+	ret = check_stream(tree2, __location__, tctx, mem_ctx,
+			   fname, AFPINFO_STREAM,
+			   0, 60, 16, 8, "TESTSLOW");
+	torture_assert_goto(tctx, ret == true, ret, done,
+			    "check AFPINFO_STREAM failed\n");
+
+	ret = check_stream(tree2, __location__, tctx, mem_ctx,
+			   fname, ":foo" "\xef\x80\xa2" "bar", /* foo:bar */
+			   0, 3, 0, 3, "baz");
+	torture_assert_goto(tctx, ret == true, ret, done,
+			    "check foo stream failed\n");
+
+	/*
+	 * Now check number of files. If delete_empty_adfiles is set, the
+	 * AppleDouble files should have been deleted.
+	 */
+
+	create = (struct smb2_create) {
+		.in.desired_access = SEC_RIGHTS_DIR_READ,
+		.in.create_options = NTCREATEX_OPTIONS_DIRECTORY,
+		.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY,
+		.in.share_access = NTCREATEX_SHARE_ACCESS_READ,
+		.in.create_disposition = NTCREATEX_DISP_OPEN,
+		.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS,
+		.in.fname = BASEDIR,
+	};
+
+	status = smb2_create(tree2, tctx, &create);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_create failed\n");
+
+	find = (struct smb2_find) {
+		.in.file.handle = create.out.file.handle,
+		.in.pattern = "*",
+		.in.max_response_size = 0x1000,
+		.in.level = SMB2_FIND_ID_BOTH_DIRECTORY_INFO,
+	};
+
+	status = smb2_find_level(tree2, tree2, &find, &count, &d);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_find_level failed\n");
+
+	status = smb2_util_close(tree2, create.out.file.handle);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_util_close failed");
+
+	if (delete_empty_adfiles) {
+		expected_num_files = 3;
+	} else {
+		expected_num_files = 4;
+	}
+	torture_assert_int_equal_goto(tctx, count, expected_num_files, ret, done,
+				      "Wrong number of files\n");
+
+done:
+	smb2_deltree(tree1, BASEDIR);
+	talloc_free(mem_ctx);
+	return ret;
+}
+
+struct torture_suite *torture_vfs_fruit_conversion(TALLOC_CTX *ctx)
+{
+	struct torture_suite *suite = torture_suite_create(
+		ctx, "fruit_conversion");
+


-- 
Samba Shared Repository



More information about the samba-cvs mailing list