libvirt/libvirt-utils-Canonicalize-paths-before-comparing-them.patch
Jiri Denemark 4a97ecd040 libvirt-10.10.0-7.el9
- qemu_migration: Refactor qemuMigrationSrcRestoreDomainState (RHEL-79168)
- qemu_migration: Do not automatically resume domain after I/O error (RHEL-79168)
- qemucapabilitiestest: Add data for the qemu-10.0 dev cycle on x86_64 (RHEL-79095)
- qemucapabilitiestest: Update 'caps_10.0.0_x86_64' to 'v9.2.0-1636-gffaf7f0376' (RHEL-79095)
- qemu: capabilies: Introduce QEMU_CAPS_BLOCKDEV_SET_ACTIVE (RHEL-79095)
- qemu: monitor: Add monitor backend for 'blockdev-set-active' (RHEL-79095)
- qemu: migration: Reactivate block nodes after migration if VM is left paused (RHEL-79095)
- conf: change virDomainHostdevInsert() to return void (RHEL-69455)
- qemu: fix qemu validation to forbid guest-side IP address for type='vdpa' (RHEL-69455)
- qemu: validate that model is virtio for vhostuser and vdpa interfaces in the same place (RHEL-69455)
- qemu: automatically set model type='virtio' for interface type='vhostuser' (RHEL-69455)
- qemu: do all vhostuser attribute validation in qemu driver (RHEL-69455)
- conf/qemu: make <source> element *almost* optional for type=vhostuser (RHEL-69455)
- qemu: use switch instead of if in qemuProcessPrepareDomainNetwork() (RHEL-69455)
- qemu: make qemuPasstCreateSocketPath() public (RHEL-69455)
- qemu: complete vhostuser + passt support (RHEL-69455)
- qemu: fail validation if a domain def has vhostuser/passt but no shared mem (RHEL-69455)
- docs: improve type='user' docs to higlight differences between SLIRP and passt (RHEL-69455)
- docs: document using passt backend with <interface type='vhostuser'> (RHEL-69455)
- utils: Canonicalize paths before comparing them (RHEL-79166)

Resolves: RHEL-69455, RHEL-79095, RHEL-79166, RHEL-79168
2025-02-17 21:30:50 +01:00

56 lines
2.0 KiB
Diff

From 4eacc6c63a2935cd25bb404639ce8c8bd0747866 Mon Sep 17 00:00:00 2001
Message-ID: <4eacc6c63a2935cd25bb404639ce8c8bd0747866.1739824250.git.jdenemar@redhat.com>
From: Andrea Bolognani <abologna@redhat.com>
Date: Thu, 13 Feb 2025 09:54:05 +0100
Subject: [PATCH] utils: Canonicalize paths before comparing them
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In virFileIsSharedFSOverride() we compare a path against a list
of overrides looking for a match.
All overrides are canonicalized ahead of time though, so e.g.
/var/run/foo will be turned into /run/foo due to /var/run being
a symlink on modern Linux systems. But the path we're trying to
match with the overrides doesn't get the same treatment, so in
this scenario the comparison will always fail.
Canonicalizing the path as well solves the issue.
Resolves: https://issues.redhat.com/browse/RHEL-79165
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit f2023e8018fe18550ad6aec66fe72bd1376f8522)
https://issues.redhat.com/browse/RHEL-79166
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
src/util/virfile.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 6ac0f4efb3..7cab3d0cd6 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3823,10 +3823,13 @@ virFileIsSharedFSOverride(const char *path,
if (!path || path[0] != '/' || !overrides)
return false;
- if (g_strv_contains((const char *const *) overrides, path))
- return true;
+ /* 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);
- dirpath = g_strdup(path);
+ if (g_strv_contains((const char *const *) overrides, dirpath))
+ return true;
/* Continue until we've scanned the entire path */
while (p != dirpath) {
--
2.48.1