test: add test for the non-resolving of chase_symlink() root prefix

This commit is contained in:
Lennart Poettering 2020-01-28 21:40:58 +01:00
parent c2595d3b02
commit 6efb1257d1
1 changed files with 9 additions and 0 deletions

View File

@ -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);
}