summaryrefslogtreecommitdiff
path: root/src/basic/fs-util.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-01-19 18:05:28 +0900
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:50:11 +0200
commit35078962d59391fba6e42c9f6675adff25b5e34b (patch)
treeda55c6470d0bf54202946ab712aa2ab61c1fabf8 /src/basic/fs-util.c
parent957510a4b6266fa5d8bb180d7980ea8f8afc558f (diff)
fs-util: chase_symlinks(): support empty root
The commit b1bfb848046e457f3cd623286b8cc1a5e5440023 makes chase_symlinks() recognize empty string for root as an invalid parameter. However, empty root is often used e.g. systemd-nspawn. This makes chase_symlinks() support empty string safely. Fixes #7927.
Diffstat (limited to 'src/basic/fs-util.c')
-rw-r--r--src/basic/fs-util.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
index bd7e3db64..07aeff0af 100644
--- a/src/basic/fs-util.c
+++ b/src/basic/fs-util.c
@@ -675,13 +675,9 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
* function what to do when encountering a symlink with an absolute path as directory: prefix it by the
* specified path. */
- if (original_root) {
- if (isempty(original_root)) /* What's this even supposed to mean? */
- return -EINVAL;
-
- if (path_equal(original_root, "/")) /* A root directory of "/" is identical to none */
- original_root = NULL;
- }
+ /* A root directory of "/" or "" is identical to none */
+ if (isempty(original_root) || path_equal(original_root, "/"))
+ original_root = NULL;
if (original_root) {
r = path_make_absolute_cwd(original_root, &root);