diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-10-04 17:34:03 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-10-26 17:54:56 +0200 |
commit | 8c4a8ea2ac2569eb9f376ad17f8baea3e836b8ba (patch) | |
tree | 2b7ed7a2f57a74ebcc7c783edc26800dda9f293a /src/basic/fs-util.c | |
parent | f7c9f4a2a9bdb476b6b0e0e88291fa8d5e9fc0de (diff) | |
download | systemd-8c4a8ea2ac2569eb9f376ad17f8baea3e836b8ba.tar.gz |
fs-util: small tweak in chase_symlinks()
If we follow an absolute symlink there's no need to prefix the path with
a "/", since by definition it already has one.
This helps suppressing double "/" in resolved paths containing absolute
symlinks.
Diffstat (limited to 'src/basic/fs-util.c')
-rw-r--r-- | src/basic/fs-util.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index b90f343ed3..946f779a32 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -766,12 +766,11 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags, return -ENOMEM; } - } - - /* Prefix what's left to do with what we just read, and start the loop again, - * but remain in the current directory. */ - - joined = strjoin("/", destination, todo); + /* Prefix what's left to do with what we just read, and start the loop again, but + * remain in the current directory. */ + joined = strjoin(destination, todo); + } else + joined = strjoin("/", destination, todo); if (!joined) return -ENOMEM; |