mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
util: Fix virFileIsSharedFSOverride on nonexistent paths
Commit v11.0.0-162-gf2023e8018 added path canonicalization to
virFileIsSharedFSOverride to make sure we can properly match shared
filesystem override paths which include symlinks. But
virFileCanonicalizePath only works on existing paths, while
virFileIsSharedFSOverride may be called on paths that do not exist yet.
Matching paths against overrides has always worked even for nonexistent
paths. To fix the regression we need to first get the longest existing
sub-path and canonicalize only this part and use the result for
searching in overrides. Clearly any portion of the path we dynamically
create is not going to end up on a different filesystem to what the
parent directory is stored in. So checking just the existing parent is
enough.
https://issues.redhat.com/browse/RHEL-86592
Fixes: f2023e8018
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
1 parent
05526b5090
commit
94fb348d67
1 file changed
+12
-1
+12
-1
@@ -3821,15 +3821,26 @@ virFileIsSharedFSOverride(const char *path,
|
||||
char *const *overrides)
|
||||
{
|
||||
g_autofree char *dirpath = NULL;
|
||||
g_autofree char *existing = NULL;
|
||||
char *p = NULL;
|
||||
|
||||
if (!path || path[0] != '/' || !overrides)
|
||||
return false;
|
||||
|
||||
/* We only care about the longest existing sub-path. Further components
|
||||
* may will later be created by libvirt will not magically become a shared
|
||||
* filesystem. */
|
||||
if (!(existing = virFileGetExistingParent(path)))
|
||||
return false;
|
||||
|
||||
/* Overrides have been canonicalized ahead of time, so we need to
|
||||
* do the same for the provided path or we'll never be able to
|
||||
* find a match if symlinks are involved */
|
||||
dirpath = virFileCanonicalizePath(path);
|
||||
if (!(dirpath = virFileCanonicalizePath(existing))) {
|
||||
VIR_DEBUG("Cannot canonicalize parent '%s' of path '%s'",
|
||||
existing, path);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (g_strv_contains((const char *const *) overrides, dirpath))
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user