Modification of fix for bug 6876 - Delete of an object whose parent folder does not...
authorJeremy Allison <jra@samba.org>
Sun, 17 Jan 2010 01:03:06 +0000 (17:03 -0800)
committerJeremy Allison <jra@samba.org>
Sun, 17 Jan 2010 01:03:06 +0000 (17:03 -0800)
Suggested by Volker. Reduce the surface area of the
become_root() unbecome_root() code to reduce the chance
of errors.

Jeremy.

source3/modules/vfs_acl_common.c

index aeb9ce37eaee4aea718470dd80add9f261f27e8a..30a59e20246a5ea2cda30fbf4820e3b86ba7e98c 100644 (file)
@@ -821,11 +821,14 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
                goto out;
        }
 
+       become_root();
        if (is_directory) {
                ret = SMB_VFS_NEXT_RMDIR(handle, final_component);
        } else {
                ret = SMB_VFS_NEXT_UNLINK(handle, &local_fname);
        }
+       unbecome_root();
+
        if (ret == -1) {
                saved_errno = errno;
        }
@@ -854,12 +857,9 @@ static int rmdir_acl_common(struct vfs_handle_struct *handle,
                return ret;
        }
 
-       become_root();
-       ret = acl_common_remove_object(handle,
+       return acl_common_remove_object(handle,
                                        path,
                                        true);
-       unbecome_root();
-       return ret;
 }
 
 static NTSTATUS create_file_acl_common(struct vfs_handle_struct *handle,
@@ -977,10 +977,7 @@ static int unlink_acl_common(struct vfs_handle_struct *handle,
                return ret;
        }
 
-       become_root();
-       ret = acl_common_remove_object(handle,
+       return acl_common_remove_object(handle,
                                        smb_fname->base_name,
                                        false);
-       unbecome_root();
-       return ret;
 }