summaryrefslogtreecommitdiffstats
path: root/src/basic/chase.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-04-16 22:19:07 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-04-18 20:28:34 +0200
commit24be89ebd8e9fbf97cb60c304b615ab26869c204 (patch)
treebd11a80e427d171dc59233f5a0dc7146128baa5e /src/basic/chase.c
parentchase: make chaseat() provides absolute path also when dir_fd points to the r... (diff)
downloadsystemd-24be89ebd8e9fbf97cb60c304b615ab26869c204.tar.xz
systemd-24be89ebd8e9fbf97cb60c304b615ab26869c204.zip
chase: make the result absolute when a symlink is absolute
As the path may be outside of the specified dir_fd.
Diffstat (limited to 'src/basic/chase.c')
-rw-r--r--src/basic/chase.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/basic/chase.c b/src/basic/chase.c
index a6a37978e8..2b8befc7f7 100644
--- a/src/basic/chase.c
+++ b/src/basic/chase.c
@@ -374,6 +374,11 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int
unsafe_transition(&st_child, &st))
return log_unsafe_transition(child, fd, path, flags);
+ /* When CHASE_AT_RESOLVE_IN_ROOT is not set, now the chased path may be
+ * outside of the specified dir_fd. Let's make the result absolute. */
+ if (!FLAGS_SET(flags, CHASE_AT_RESOLVE_IN_ROOT))
+ need_absolute = true;
+
r = free_and_strdup(&done, need_absolute ? "/" : NULL);
if (r < 0)
return r;