]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: vfs_recycle: Change recycle_unlink_internal() to call UNLINKAT().
authorJeremy Allison <jra@samba.org>
Tue, 17 Sep 2019 00:30:49 +0000 (17:30 -0700)
committerRalph Boehme <slow@samba.org>
Thu, 26 Sep 2019 17:20:46 +0000 (17:20 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_recycle.c

index 8c663cb14da5ebd8b0a51ecf452b8232a59cda9f..371f7a3adc9f3b37f58a7595ba6242c0c9a5c5ca 100644 (file)
@@ -485,7 +485,10 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
        if(!repository || *(repository) == '\0') {
                DEBUG(3, ("recycle: repository path not set, purging %s...\n",
                          smb_fname_str_dbg(smb_fname)));
-               rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+               rc = SMB_VFS_NEXT_UNLINKAT(handle,
+                                       dirfsp,
+                                       smb_fname,
+                                       flags);
                goto done;
        }
 
@@ -493,7 +496,10 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
        if (strncmp(smb_fname->base_name, repository,
                    strlen(repository)) == 0) {
                DEBUG(3, ("recycle: File is within recycling bin, unlinking ...\n"));
-               rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+               rc = SMB_VFS_NEXT_UNLINKAT(handle,
+                                       dirfsp,
+                                       smb_fname,
+                                       flags);
                goto done;
        }
 
@@ -503,7 +509,10 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
         *
        if(fsize == 0) {
                DEBUG(3, ("recycle: File %s is empty, purging...\n", file_name));
-               rc = SMB_VFS_NEXT_UNLINK(handle,file_name);
+               rc = SMB_VFS_NEXT_UNLINKAT(handle,
+                                       dirfsp,
+                                       file_name,
+                                       flags);
                goto done;
        }
         */
@@ -516,14 +525,20 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
        if(maxsize > 0 && file_size > maxsize) {
                DEBUG(3, ("recycle: File %s exceeds maximum recycle size, "
                          "purging... \n", smb_fname_str_dbg(smb_fname)));
-               rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+               rc = SMB_VFS_NEXT_UNLINKAT(handle,
+                                       dirfsp,
+                                       smb_fname,
+                                       flags);
                goto done;
        }
        minsize = recycle_minsize(handle);
        if(minsize > 0 && file_size < minsize) {
                DEBUG(3, ("recycle: File %s lowers minimum recycle size, "
                          "purging... \n", smb_fname_str_dbg(smb_fname)));
-               rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+               rc = SMB_VFS_NEXT_UNLINKAT(handle,
+                                       dirfsp,
+                                       smb_fname,
+                                       flags);
                goto done;
        }
 
@@ -534,7 +549,10 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
        DEBUG(5, ("space_avail = %Lu, file_size = %Lu\n", space_avail, file_size));
        if(space_avail < file_size) {
                DEBUG(3, ("recycle: Not enough diskspace, purging file %s\n", file_name));
-               rc = SMB_VFS_NEXT_UNLINK(handle, file_name);
+               rc = SMB_VFS_NEXT_UNLINKAT(handle,
+                                       dirfsp,
+                                       file_name,
+                                       flags);
                goto done;
        }
         */
@@ -562,13 +580,19 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
 
        if (matchparam(recycle_exclude(handle), base)) {
                DEBUG(3, ("recycle: file %s is excluded \n", base));
-               rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+               rc = SMB_VFS_NEXT_UNLINKAT(handle,
+                                       dirfsp,
+                                       smb_fname,
+                                       flags);
                goto done;
        }
 
        if (matchdirparam(recycle_exclude_dir(handle), path_name)) {
                DEBUG(3, ("recycle: directory %s is excluded \n", path_name));
-               rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+               rc = SMB_VFS_NEXT_UNLINKAT(handle,
+                                       dirfsp,
+                                       smb_fname,
+                                       flags);
                goto done;
        }
 
@@ -590,7 +614,10 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
                        DEBUG(3, ("recycle: Could not create directory, "
                                  "purging %s...\n",
                                  smb_fname_str_dbg(smb_fname)));
-                       rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+                       rc = SMB_VFS_NEXT_UNLINKAT(handle,
+                                       dirfsp,
+                                       smb_fname,
+                                       flags);
                        goto done;
                }
        }
@@ -606,7 +633,10 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
                                        NULL,
                                        smb_fname->flags);
        if (smb_fname_final == NULL) {
-               rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+               rc = SMB_VFS_NEXT_UNLINKAT(handle,
+                                       dirfsp,
+                                       smb_fname,
+                                       flags);
                goto done;
        }
 
@@ -619,8 +649,10 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
                if (recycle_versions(handle) == False || matchparam(recycle_noversions(handle), base) == True) {
                        DEBUG(3, ("recycle: Removing old file %s from recycle "
                                  "bin\n", smb_fname_str_dbg(smb_fname_final)));
-                       if (SMB_VFS_NEXT_UNLINK(handle,
-                                               smb_fname_final) != 0) {
+                       if (SMB_VFS_NEXT_UNLINKAT(handle,
+                                               dirfsp,
+                                               smb_fname_final,
+                                               flags) != 0) {
                                DEBUG(1, ("recycle: Error deleting old file: %s\n", strerror(errno)));
                        }
                }
@@ -637,7 +669,10 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
                smb_fname_final->base_name = talloc_strdup(smb_fname_final,
                                                           final_name);
                if (smb_fname_final->base_name == NULL) {
-                       rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+                       rc = SMB_VFS_NEXT_UNLINKAT(handle,
+                                               dirfsp,
+                                               smb_fname,
+                                               flags);
                        goto done;
                }
        }
@@ -654,7 +689,10 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
                          "(%s)\n", errno, strerror(errno),
                          smb_fname_str_dbg(smb_fname),
                          smb_fname_str_dbg(smb_fname_final)));
-               rc = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
+               rc = SMB_VFS_NEXT_UNLINKAT(handle,
+                               dirfsp,
+                               smb_fname,
+                               flags);
                goto done;
        }