summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/check_and_open-tests.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/tests/check_and_open-tests.c b/src/tests/check_and_open-tests.c
index 59879cc9..8e1bc988 100644
--- a/src/tests/check_and_open-tests.c
+++ b/src/tests/check_and_open-tests.c
@@ -100,7 +100,7 @@ START_TEST(test_symlink)
ret = symlink(filename, newpath);
fail_unless(ret == 0, "symlink failed [%d][%s]", ret, strerror(errno));
- ret = check_file(newpath, uid, gid, mode, CHECK_REG, NULL);
+ ret = check_file(newpath, uid, gid, mode, CHECK_REG, NULL, false);
unlink(newpath);
fail_unless(ret == EINVAL,
@@ -108,6 +108,32 @@ START_TEST(test_symlink)
}
END_TEST
+START_TEST(test_follow_symlink)
+{
+ int ret;
+ char *newpath;
+ size_t newpath_length;
+
+ newpath_length = strlen(filename) + strlen(SUFFIX) + 1;
+ newpath = malloc((newpath_length) * sizeof(char));
+ fail_unless(newpath != NULL, "malloc failed");
+
+ ret = snprintf(newpath, newpath_length, "%s%s", filename, SUFFIX);
+ fail_unless(ret == newpath_length - 1,
+ "snprintf failed: expected [%d] got [%d]", newpath_length -1,
+ ret);
+
+ ret = symlink(filename, newpath);
+ fail_unless(ret == 0, "symlink failed [%d][%s]", ret, strerror(errno));
+
+ ret = check_file(newpath, uid, gid, mode, CHECK_REG, NULL, true);
+ unlink(newpath);
+
+ fail_unless(ret == EOK,
+ "check_and_open_readonly failed on symlink with follow=true");
+}
+END_TEST
+
START_TEST(test_not_regular_file)
{
int ret;
@@ -196,6 +222,7 @@ Suite *check_and_open_suite (void)
tcase_add_test (tc_check_and_open_readonly, test_wrong_filename);
tcase_add_test (tc_check_and_open_readonly, test_not_regular_file);
tcase_add_test (tc_check_and_open_readonly, test_symlink);
+ tcase_add_test (tc_check_and_open_readonly, test_follow_symlink);
tcase_add_test (tc_check_and_open_readonly, test_wrong_uid);
tcase_add_test (tc_check_and_open_readonly, test_wrong_gid);
tcase_add_test (tc_check_and_open_readonly, test_wrong_permission);