mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 00:51:24 +03:00
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.
This commit is contained in:
parent
e3f791a2b3
commit
7cb53855dc
@ -182,7 +182,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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user