From fd618df85452ca67c11918f50e3fa276eb6829dc Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Mon, 22 Jan 2024 09:45:51 -0600 Subject: [PATCH] DAOS-14219 dfs: checker should not follow symlinks (#13625) The DFS checker should mark the symlink oid and not dereference the symlink value. the value can be invalid anyway and if a valid path in the container, it would be reachable from the hardlink path. Signed-off-by: Mohamad Chaarawi --- src/client/dfs/dfs.c | 2 +- src/tests/suite/dfs_unit_test.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/client/dfs/dfs.c b/src/client/dfs/dfs.c index 27005c01ade..e8f79ffc153 100644 --- a/src/client/dfs/dfs.c +++ b/src/client/dfs/dfs.c @@ -6591,7 +6591,7 @@ oit_mark_cb(dfs_t *dfs, dfs_obj_t *parent, const char name[], void *args) } /** open the entry name and get the oid */ - rc = dfs_lookup_rel(dfs, parent, name, O_RDONLY, &obj, NULL, NULL); + rc = dfs_lookup_rel(dfs, parent, name, O_RDONLY | O_NOFOLLOW, &obj, NULL, NULL); if (rc) { D_ERROR("dfs_lookup_rel() of %s failed: %d\n", name, rc); return rc; diff --git a/src/tests/suite/dfs_unit_test.c b/src/tests/suite/dfs_unit_test.c index 8e587b1e42e..8a10bbd38c6 100644 --- a/src/tests/suite/dfs_unit_test.c +++ b/src/tests/suite/dfs_unit_test.c @@ -2432,7 +2432,7 @@ dfs_test_checker(void **state) test_arg_t *arg = *state; dfs_t *dfs; int nr = 100, i; - dfs_obj_t *root, *lf; + dfs_obj_t *root, *lf, *sym; daos_obj_id_t root_oid; daos_handle_t root_oh; daos_handle_t coh; @@ -2503,6 +2503,12 @@ dfs_test_checker(void **state) assert_int_equal(rc, 0); } + /** create a symlink with a non-existent target in the container */ + rc = dfs_open(dfs, NULL, "SL1", S_IFLNK | S_IWUSR | S_IRUSR, O_RDWR | O_CREAT | O_EXCL, 0, + 0, "/usr/local", &sym); + assert_int_equal(rc, 0); + rc = dfs_release(sym); + rc = dfs_disconnect(dfs); assert_int_equal(rc, 0); /** have to call fini to release the cached container handle for the checker to work */