summaryrefslogtreecommitdiff
path: root/src/basic/fs-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-01-17 12:00:40 +0100
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:50:10 +0200
commit6bfd45823cd36620dabd4f6c979d784041a20dec (patch)
treed38ac14d43571539c276392607d7e3c04601e3ea /src/basic/fs-util.c
parentd24d415d801b89ff2804e82c62209436fc3a3a25 (diff)
fs-util: refuse taking a relative path to chase if "root" is specified and CHASE_PREFIX_ROOT is set
If we take a relative path we first make it absolute, based on the current working directory. But if CHASE_PREFIX_ROOT is passe we are supposed to make the path absolute taking the specified root path into account, but that makes no sense if we talk about the current working directory as that is relative to the host's root in any case. Hence, let's refuse this politely.
Diffstat (limited to 'src/basic/fs-util.c')
-rw-r--r--src/basic/fs-util.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
index bbc464e31..bd7e3db64 100644
--- a/src/basic/fs-util.c
+++ b/src/basic/fs-util.c
@@ -688,8 +688,14 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
if (r < 0)
return r;
- if (flags & CHASE_PREFIX_ROOT)
+ if (flags & CHASE_PREFIX_ROOT) {
+
+ /* We don't support relative paths in combination with a root directory */
+ if (!path_is_absolute(path))
+ return -EINVAL;
+
path = prefix_roota(root, path);
+ }
}
r = path_make_absolute_cwd(path, &buffer);