]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_fruit: delete ._ file when deleting the basefile
authorRalph Boehme <slow@samba.org>
Tue, 25 Aug 2015 15:06:52 +0000 (17:06 +0200)
committerKarolin Seeger <kseeger@samba.org>
Fri, 4 Sep 2015 11:02:19 +0000 (13:02 +0200)
0 byte resource fork streams are not listed by vfs_streaminfo, as a
result stream cleanup/deletion of file deletion doesn't remove the
resourcefork stream.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=11467

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_fruit.c

index c85e63c77d0195f223eb1415896f4a2db3315268..f60ec5eb62934a50a78a7de884cf89e245bc83dd 100644 (file)
@@ -2396,15 +2396,44 @@ static int fruit_unlink(vfs_handle_struct *handle,
 {
        int rc = -1;
        struct fruit_config_data *config = NULL;
-       char *adp = NULL;
-
-       if (!is_ntfs_stream_smb_fname(smb_fname)) {
-               return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
-       }
 
        SMB_VFS_HANDLE_GET_DATA(handle, config,
                                struct fruit_config_data, return -1);
 
+       if (!is_ntfs_stream_smb_fname(smb_fname)) {
+               char *adp = NULL;
+
+               rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+               if (rc != 0) {
+                       return -1;
+               }
+
+               if (config->rsrc != FRUIT_RSRC_ADFILE) {
+                       return 0;
+               }
+
+               /*
+                * 0 byte resource fork streams are not listed by
+                * vfs_streaminfo, as a result stream cleanup/deletion of file
+                * deletion doesn't remove the resourcefork stream.
+                */
+               rc = adouble_path(talloc_tos(),
+                                 smb_fname->base_name, &adp);
+               if (rc != 0) {
+                       return -1;
+               }
+
+               /* FIXME: direct unlink(), missing smb_fname */
+               DEBUG(1,("fruit_unlink: %s\n", adp));
+               rc = unlink(adp);
+               if ((rc == -1) && (errno == ENOENT)) {
+                       rc = 0;
+               }
+
+               TALLOC_FREE(adp);
+               return 0;
+       }
+
        if (is_afpinfo_stream(smb_fname)) {
                if (config->meta == FRUIT_META_STREAM) {
                        rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
@@ -2413,8 +2442,14 @@ static int fruit_unlink(vfs_handle_struct *handle,
                                                 smb_fname->base_name,
                                                 AFPINFO_EA_NETATALK);
                }
-       } else if (is_afpresource_stream(smb_fname)) {
+
+               return rc;
+       }
+
+       if (is_afpresource_stream(smb_fname)) {
                if (config->rsrc == FRUIT_RSRC_ADFILE) {
+                       char *adp = NULL;
+
                        rc = adouble_path(talloc_tos(),
                                          smb_fname->base_name, &adp);
                        if (rc != 0) {
@@ -2425,17 +2460,20 @@ static int fruit_unlink(vfs_handle_struct *handle,
                        if ((rc == -1) && (errno == ENOENT)) {
                                rc = 0;
                        }
+                       TALLOC_FREE(adp);
                } else {
                        rc = SMB_VFS_REMOVEXATTR(handle->conn,
-                                     smb_fname->base_name,
-                                     AFPRESOURCE_EA_NETATALK);
+                                                smb_fname->base_name,
+                                                AFPRESOURCE_EA_NETATALK);
                }
-       } else {
-               rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+
+               return rc;
        }
 
-       TALLOC_FREE(adp);
-       return rc;
+       return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+
+
+       return 0;
 }
 
 static int fruit_chmod(vfs_handle_struct *handle,