From 0fd8455c66ae574e479f9d9a645f2e8366bac993 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Sun, 9 Apr 2017 19:49:17 -0400 Subject: unlink_file: strip trailing slashes If the user replaces a directory with a symlink, libalpm would get confused because the trailing slash causes system calls to resolve the symlink. This leads to errors and a misleading message during upgrades. Even though libalpm does not support this, it should not be giving misleading errors. Also adds an overflow check. Fixes FS#51377 Signed-off-by: Andrew Gregory (cherry picked from commit 16b91f798faf6413f9b043543c5c0c3467b6fdbf) --- test/pacman/tests/TESTS | 1 + .../tests/remove-directory-replaced-with-symlink.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/pacman/tests/remove-directory-replaced-with-symlink.py (limited to 'test') diff --git a/test/pacman/tests/TESTS b/test/pacman/tests/TESTS index 81078a58..9da24589 100644 --- a/test/pacman/tests/TESTS +++ b/test/pacman/tests/TESTS @@ -109,6 +109,7 @@ TESTS += test/pacman/tests/querycheck002.py TESTS += test/pacman/tests/querycheck_fast_file_type.py TESTS += test/pacman/tests/reason001.py TESTS += test/pacman/tests/remove-assumeinstalled.py +TESTS += test/pacman/tests/remove-directory-replaced-with-symlink.py TESTS += test/pacman/tests/remove-optdepend-of-installed-package.py TESTS += test/pacman/tests/remove-recursive-cycle.py TESTS += test/pacman/tests/remove001.py diff --git a/test/pacman/tests/remove-directory-replaced-with-symlink.py b/test/pacman/tests/remove-directory-replaced-with-symlink.py new file mode 100644 index 00000000..37be7579 --- /dev/null +++ b/test/pacman/tests/remove-directory-replaced-with-symlink.py @@ -0,0 +1,16 @@ +self.description = "remove a package with a directory that has been replaced with a symlink" + +self.filesystem = [ "var/", "srv -> var/" ] + +lpkg = pmpkg("pkg1") +lpkg.files = ["srv/"] +self.addpkg2db("local", lpkg) + +self.args = "-R %s" % (lpkg.name) + +self.addrule("PACMAN_RETCODE=0") +self.addrule("DIR_EXIST=var/") +self.addrule("!LINK_EXIST=srv") +self.addrule("!FILE_EXIST=srv") +self.addrule("!DIR_EXIST=srv") +self.addrule("!PACMAN_OUTPUT=cannot remove") -- cgit v1.2.3-70-g09d2