diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-01-28 21:40:58 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-01-28 22:53:59 +0100 |
commit | 6efb1257d10cd1ecdae6208d083af36f15e4c05f (patch) | |
tree | b272e6bd00f867477a3d461cf2b44a81926e9c79 | |
parent | fs-util: when calling chase_symlinks() with root path, leave root part unresolved (diff) | |
download | systemd-6efb1257d10cd1ecdae6208d083af36f15e4c05f.tar.xz systemd-6efb1257d10cd1ecdae6208d083af36f15e4c05f.zip |
test: add test for the non-resolving of chase_symlink() root prefix
-rw-r--r-- | src/test/test-fs-util.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c index ac8b95aece0..d5492d937b9 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, NULL); + 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); } |