From 6efb1257d10cd1ecdae6208d083af36f15e4c05f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 28 Jan 2020 21:40:58 +0100 Subject: [PATCH 1478/1760] test: add test for the non-resolving of chase_symlink() root prefix Reference: https://github.com/systemd/systemd/commit/6efb1257d10cd1ecdae6208d083af36f15e4c05f Conflict: NA --- src/test/test-fs-util.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c index ac8b95a..d5492d9 100644 --- a/src/test/test-fs-util.c +++ b/src/test/test-fs-util.c @@ -371,6 +371,15 @@ static void test_chase_symlinks(void) { assert_se(streq("/usr", result)); result = mfree(result); + /* Make sure that symlinks in the "root" path are not resolved, but those below are */ + p = strjoina("/etc/..", temp, "/self"); + assert_se(symlink(".", p) >= 0); + q = strjoina(p, "/top/dot/dotdota"); + r = chase_symlinks(q, p, 0, &result); + assert_se(r > 0); + assert_se(path_equal(path_startswith(result, p), "usr")); + result = mfree(result); + cleanup: assert_se(rm_rf(temp, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0); } -- 1.8.3.1