summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-06-17 12:41:08 -0400
committerSven Eden <yamakuzure@gmx.net>2017-07-25 09:46:52 +0200
commit0cd0e2ee1908a1432b06e637168f7fc8531643ec (patch)
tree2fd801585b11a1c49c06f73c2768026a7fde06fe /src
parent15f07f3172e69e87b1c6d3d03911e3dc38b0110c (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/basic/rm-rf.c2
1 files changed, 1 insertions, 1 deletions
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;
}