]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add test for the non-resolving of chase_symlink() root prefix
authorLennart Poettering <lennart@poettering.net>
Tue, 28 Jan 2020 20:40:58 +0000 (21:40 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 28 Jan 2020 21:53:59 +0000 (22:53 +0100)
src/test/test-fs-util.c

index ac8b95aece0eaed479a1d419a67fe8965909c97f..d5492d937b911cea8d253bf563ebcfcfd3adec13 100644 (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);
 }