s3: vfs: Remove files/directories after the streams are deleted.
authorJeremy Allison <jra@samba.org>
Wed, 19 Oct 2016 18:56:49 +0000 (11:56 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 20 Oct 2016 23:04:10 +0000 (01:04 +0200)
By the time we get to SMB_VFS_UNLINK/SMB_VFS_RMDIR the ACL
checks have already been done.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12384

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
source3/modules/vfs_streams_depot.c

index 83c9d9743ae8262c6f0be4792f1f3ce4e35f68e4..d874514bf22c65851085fe03c14317312fc216be 100644 (file)
@@ -725,8 +725,12 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
                return -1;
        }
 
-       ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
-       if (ret == 0) {
+       /*
+        * We know the unlink should succeed as the ACL
+        * check is already done in the caller. Remove the
+        * file *after* the streams.
+        */
+       {
                char *dirname = stream_dir(handle, smb_fname_base,
                                           &smb_fname_base->st, false);
 
@@ -749,6 +753,7 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
                TALLOC_FREE(dirname);
        }
 
+       ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
        TALLOC_FREE(smb_fname_base);
        return ret;
 }
@@ -787,8 +792,12 @@ static int streams_depot_rmdir(vfs_handle_struct *handle,
                return -1;
        }
 
-       ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base);
-       if (ret == 0) {
+       /*
+        * We know the rmdir should succeed as the ACL
+        * check is already done in the caller. Remove the
+        * directory *after* the streams.
+        */
+       {
                char *dirname = stream_dir(handle, smb_fname_base,
                                           &smb_fname_base->st, false);
 
@@ -811,6 +820,7 @@ static int streams_depot_rmdir(vfs_handle_struct *handle,
                TALLOC_FREE(dirname);
        }
 
+       ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base);
        TALLOC_FREE(smb_fname_base);
        return ret;
 }