X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbasic%2Frm-rf.c;h=156366c7d1487f419697d7ae3808829ccfd1b578;hp=565f240e120d0e6750eda66ffc91a0706fb616b1;hb=d93247127eb2e073a6d3b5bcc67bcc4048d674fe;hpb=99b26b4267937bb2f77f964b8e72038f6e90d6da diff --git a/src/basic/rm-rf.c b/src/basic/rm-rf.c index 565f240e1..156366c7d 100644 --- a/src/basic/rm-rf.c +++ b/src/basic/rm-rf.c @@ -184,19 +184,12 @@ 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(path, "/")) { + 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; } #if 0 /// elogind does not support BTRFS this directly - /* Another safe-check. Removing "/path/.." could easily remove entire root as well. - * It's especially easy to do using globs in tmpfiles, like "/path/.*", which the glob() - * function expands to both "/path/." and "/path/..". - * Return -EINVAL to be consistent with rmdir("/path/."). */ - if (endswith(path, "/..") || endswith(path, "/../")) - return -EINVAL; - if ((flags & (REMOVE_SUBVOLUME|REMOVE_ROOT|REMOVE_PHYSICAL)) == (REMOVE_SUBVOLUME|REMOVE_ROOT|REMOVE_PHYSICAL)) { /* Try to remove as subvolume first */ r = btrfs_subvol_remove(path, BTRFS_REMOVE_RECURSIVE|BTRFS_REMOVE_QUOTA);