From: Jiri Denemark <jdenemar(a)redhat.com>
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: f2023e8018fe18550ad6aec66fe72bd1376f8522
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/util/virfile.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index ef1bc0bbf3..06e8e08ddc 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -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;
--
2.49.0