From 22bc57c58a3ad7570209e2ead6fa17e7d9b006cc Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 19 Jan 2018 18:05:28 +0900 Subject: [PATCH] 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. --- src/basic/fs-util.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index cb56e03d15..4bf25e32e0 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -660,13 +660,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);