fs-util: chase_symlinks(): support empty root
The commit b1bfb84804
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.
This commit is contained in:
parent
8f2e968659
commit
22bc57c58a
|
@ -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
|
* function what to do when encountering a symlink with an absolute path as directory: prefix it by the
|
||||||
* specified path. */
|
* specified path. */
|
||||||
|
|
||||||
if (original_root) {
|
/* A root directory of "/" or "" is identical to none */
|
||||||
if (isempty(original_root)) /* What's this even supposed to mean? */
|
if (isempty(original_root) || path_equal(original_root, "/"))
|
||||||
return -EINVAL;
|
original_root = NULL;
|
||||||
|
|
||||||
if (path_equal(original_root, "/")) /* A root directory of "/" is identical to none */
|
|
||||||
original_root = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (original_root) {
|
if (original_root) {
|
||||||
r = path_make_absolute_cwd(original_root, &root);
|
r = path_make_absolute_cwd(original_root, &root);
|
||||||
|
|
Loading…
Reference in New Issue