From: Zbigniew Jędrzejewski-Szmek Date: Sat, 17 Jun 2017 16:41:08 +0000 (-0400) Subject: basic/rm-rf: allow a symlink to / to be removed X-Git-Tag: chiark/234.4-1+devuan1.1+iwj1~106 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0cd0e2ee1908a1432b06e637168f7fc8531643ec;p=elogind.git basic/rm-rf: allow a symlink to / to be removed We open the target path with O_DIRECTORY|O_NOFOLLOW, and if that doesn't work, we call unlink() on the path. In neither case we will follow the symlink, so we can relax our check to also not follow symlinks. Fixes #5864. --- diff --git a/src/basic/rm-rf.c b/src/basic/rm-rf.c index 225a21296..156366c7d 100644 --- a/src/basic/rm-rf.c +++ b/src/basic/rm-rf.c @@ -184,7 +184,7 @@ int rm_rf(const char *path, RemoveFlags flags) { /* We refuse to clean the root file system with this * call. This is extra paranoia to never cause a really * seriously broken system. */ - if (path_equal_or_files_same(path, "/", 0)) { + if (path_equal_or_files_same(path, "/", AT_SYMLINK_NOFOLLOW)) { log_error("Attempted to remove entire root file system, and we can't allow that."); return -EPERM; }