]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Revert "rm-rf: Add rm_rf_physical_and_close()" 25338/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 11 Nov 2022 09:05:32 +0000 (10:05 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 11 Nov 2022 09:19:18 +0000 (10:19 +0100)
This reverts commit 56e2bceddc7383c4abe1ef0110192e491c729de4.

Doing destructive cleanup operations via unreliable /proc path
lookups is unsafe and should be avoided so let's remove this function.

src/shared/rm-rf.h

index 86d3e57b0e543cbaf5a078a120f69c25272f8be5..24fd9a2aa2d2650984ac81cde2f4be13604ba658 100644 (file)
@@ -5,7 +5,6 @@
 
 #include "alloc-util.h"
 #include "errno-util.h"
-#include "fd-util.h"
 
 typedef enum RemoveFlags {
         REMOVE_ONLY_DIRECTORIES = 1 << 0, /* Only remove empty directories, no files */
@@ -52,19 +51,3 @@ static inline char *rm_rf_subvolume_and_free(char *p) {
         return mfree(p);
 }
 DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rm_rf_subvolume_and_free);
-
-static inline int rm_rf_physical_and_close(int fd) {
-        _cleanup_free_ char *p = NULL;
-
-        if (fd < 0)
-                return -1;
-
-        if (fd_get_path(fd, &p) < 0)
-                return safe_close(fd);
-
-        safe_close(fd);
-        (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_MISSING_OK|REMOVE_CHMOD);
-
-        return -1;
-}
-DEFINE_TRIVIAL_CLEANUP_FUNC(int, rm_rf_physical_and_close);