Nwfilter can be edited by the user and we don't want to overwrite the editings.
Also the filters in %{datadir} does not have UUIDs and these are generated on
libvirtd start. Thus this patch also fixes regeneration of UUIDs on libvirtd
update.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn(a)redhat.com>
---
It is a successor to PATCH v2[1].
Diff to v2:
- Misc changes according to Andrea's review
[1] PATCH v2
https://www.redhat.com/archives/libvir-list/2020-December/msg00399.html
libvirt.spec.in | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 880051b..f20a1c7 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1439,9 +1439,13 @@ fi
rm -rf %{_localstatedir}/lib/rpm-state/libvirt || :
%post daemon-config-nwfilter
-cp %{_datadir}/libvirt/nwfilter/*.xml %{_sysconfdir}/libvirt/nwfilter/
-# libvirt saves these files with mode 600
-chmod 600 %{_sysconfdir}/libvirt/nwfilter/*.xml
+for datadir_file in %{_datadir}/libvirt/nwfilter/*.xml; do
+ sysconfdir_file=%{_sysconfdir}/libvirt/nwfilter/$(basename "$datadir_file")
+ if [ ! -f "$sysconfdir_file" ]; then
+ # libvirt saves these files with mode 600
+ install -m 0600 "$datadir_file" "$sysconfdir_file"
+ fi
+done
# Make sure libvirt picks up the new nwfilter defininitons
mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || :
touch %{_localstatedir}/lib/rpm-state/libvirt/restart || :
--
1.8.3.1