vfs_fruit: add fruit:convert_adouble parameter
authorRalph Boehme <slow@samba.org>
Mon, 22 May 2023 10:32:00 +0000 (12:32 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 26 May 2023 00:52:29 +0000 (00:52 +0000)
https://bugzilla.samba.org/show_bug.cgi?id=15378

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri May 26 00:52:29 UTC 2023 on atb-devel-224

docs-xml/manpages/vfs_fruit.8.xml
source3/modules/vfs_fruit.c

index 6950898a7d156d9ecbece4c11d1d3ed0da0c5106..2215f0313126f897700f13b1c15ff4ecf582aca2 100644 (file)
            </listitem>
          </varlistentry>
 
+         <varlistentry>
+           <term>fruit:convert_adouble = yes | no</term>
+           <listitem>
+             <para>Whether an attempt shall be made to convert ._ AppleDouble
+             sidecar files to native streams (xattrs when using
+             vfs_streams_xattr). The main use case for this conversion is
+             transparent migration from a server config without streams support
+             where the macOS client created those AppleDouble sidecar
+             files.</para>
+             <para>The default is <emphasis>yes</emphasis>.</para>
+           </listitem>
+         </varlistentry>
+
        </variablelist>
 </refsect1>
 
index 7ee6b4d9dd1cce08e1c667997dd2bbecb443f315..ce5ae38505e8d0b1e3a8d92038a9630446b2fba3 100644 (file)
@@ -131,6 +131,7 @@ struct fruit_config_data {
        const char *model;
        bool time_machine;
        off_t time_machine_max_size;
+       bool convert_adouble;
        bool wipe_intentionally_left_blank_rfork;
        bool delete_empty_adfiles;
 
@@ -381,6 +382,10 @@ static int init_fruit_config(vfs_handle_struct *handle)
                config->time_machine_max_size = conv_str_size(tm_size_str);
        }
 
+       config->convert_adouble = lp_parm_bool(
+               SNUM(handle->conn), FRUIT_PARAM_TYPE_NAME,
+               "convert_adouble", true);
+
        config->wipe_intentionally_left_blank_rfork = lp_parm_bool(
                SNUM(handle->conn), FRUIT_PARAM_TYPE_NAME,
                "wipe_intentionally_left_blank_rfork", false);
@@ -4290,7 +4295,10 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
        SMB_VFS_HANDLE_GET_DATA(handle, config, struct fruit_config_data,
                                return NT_STATUS_UNSUCCESSFUL);
 
-       if (is_apple_stream(smb_fname->stream_name) && !internal_open) {
+       if (is_apple_stream(smb_fname->stream_name) &&
+           !internal_open &&
+           config->convert_adouble)
+       {
                uint32_t conv_flags  = 0;
 
                if (config->wipe_intentionally_left_blank_rfork) {
@@ -4404,20 +4412,22 @@ static NTSTATUS fruit_freaddir_attr(struct vfs_handle_struct *handle,
 
        DBG_DEBUG("Path [%s]\n", fsp_str_dbg(fsp));
 
-       if (config->wipe_intentionally_left_blank_rfork) {
-               conv_flags |= AD_CONV_WIPE_BLANK;
-       }
-       if (config->delete_empty_adfiles) {
-               conv_flags |= AD_CONV_DELETE;
-       }
+       if (config->convert_adouble) {
+               if (config->wipe_intentionally_left_blank_rfork) {
+                       conv_flags |= AD_CONV_WIPE_BLANK;
+               }
+               if (config->delete_empty_adfiles) {
+                       conv_flags |= AD_CONV_DELETE;
+               }
 
-       ret = ad_convert(handle,
-                        fsp->fsp_name,
-                        macos_string_replace_map,
-                        conv_flags);
-       if (ret != 0) {
-               DBG_ERR("ad_convert(\"%s\") failed\n",
-                       fsp_str_dbg(fsp));
+               ret = ad_convert(handle,
+                                fsp->fsp_name,
+                                macos_string_replace_map,
+                                conv_flags);
+               if (ret != 0) {
+                       DBG_ERR("ad_convert(\"%s\") failed\n",
+                               fsp_str_dbg(fsp));
+               }
        }
 
        *pattr_data = talloc_zero(mem_ctx, struct readdir_attr_data);