test-fs-util: add more tests for chase_symlinks()
This commit is contained in:
@@ -168,6 +168,26 @@ static void test_chase_symlinks(void) {
|
||||
assert_se(r > 0 && path_equal(result, "/etc"));
|
||||
result = mfree(result);
|
||||
|
||||
r = chase_symlinks("/../.././//../../etc", NULL, 0, &result);
|
||||
assert_se(r > 0);
|
||||
assert_se(streq(result, "/etc"));
|
||||
result = mfree(result);
|
||||
|
||||
r = chase_symlinks("/../.././//../../test-chase.fsldajfl", NULL, CHASE_NONEXISTENT, &result);
|
||||
assert_se(r == 0);
|
||||
assert_se(streq(result, "/test-chase.fsldajfl"));
|
||||
result = mfree(result);
|
||||
|
||||
r = chase_symlinks("/../.././//../../etc", "/", CHASE_PREFIX_ROOT, &result);
|
||||
assert_se(r > 0);
|
||||
assert_se(streq(result, "/etc"));
|
||||
result = mfree(result);
|
||||
|
||||
r = chase_symlinks("/../.././//../../test-chase.fsldajfl", "/", CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &result);
|
||||
assert_se(r == 0);
|
||||
assert_se(streq(result, "/test-chase.fsldajfl"));
|
||||
result = mfree(result);
|
||||
|
||||
r = chase_symlinks("/etc/machine-id/foo", NULL, 0, &result);
|
||||
assert_se(r == -ENOTDIR);
|
||||
result = mfree(result);
|
||||
|
||||
Reference in New Issue
Block a user