basic/path-util: stop ignoring non-absolute paths
112cfb1814 tried to improve handling of
paths when root is specified. It said:
> To avoid answering what a relative path means when called with a root
> prefix path_strv_canonicalize is now path_strv_canonicalize_absolute
> and only considers absolute paths. Fortunately all users of already call
> path_strv_canonicalize with a list of absolute paths.
Of course, other users were added later and for example now
SYSTEMD_HOSTNAME_WORDLIST_PATH=build/hostname-wordlist/ ... doesn't
work as expected. If root is not specified, there is really no reason
to ignore relative paths. They work relative to CWD per the usual convention.
It's up to the user to not use relative paths in a context where they
should not be used. When root is specified, continue to ignore the relative
paths, since there is no clear interpreation what they mean, but emit
a debug message.
This commit is contained in:
@@ -264,20 +264,20 @@ char** path_strv_resolve(char **l, const char *root) {
|
||||
if (strv_isempty(l))
|
||||
return l;
|
||||
|
||||
/* Goes through every item in the string list and canonicalize
|
||||
* the path. This works in place and won't rollback any
|
||||
* changes on failure. */
|
||||
/* Go through every item in the string list and canonicalize the path.
|
||||
* This works in place and doesn't roll back any changes on failure. */
|
||||
|
||||
STRV_FOREACH(s, l) {
|
||||
_cleanup_free_ char *orig = NULL;
|
||||
char *t, *u;
|
||||
|
||||
if (!path_is_absolute(*s)) {
|
||||
free(*s);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (root) {
|
||||
if (!path_is_absolute(*s)) {
|
||||
log_debug("Ignoring non-absolute search path '%s'.", *s);
|
||||
free(*s);
|
||||
continue;
|
||||
}
|
||||
|
||||
orig = *s;
|
||||
t = path_join(root, orig);
|
||||
if (!t) {
|
||||
|
||||
Reference in New Issue
Block a user