libvirt/tests
Jim Fehlig 4ed5ade753 security: Ensure file exists before attempting to restore label
When performing an install, it's common for tooling such as virt-install
to remove the install kernel/initrd once they are successfully booted and
the domain has been redefined to boot without them. After the installation
is complete and the domain is rebooted/shutdown, the DAC and selinux
security drivers attempt to restore labels on the now deleted files. It's
harmles wrt functionality, but results in error messages such as

Mar 08 12:40:37 virtqemud[5639]: internal error: child reported (status=125): unable to stat: /var/lib/libvirt/boot/vir>
Mar 08 12:40:37 virtqemud[5639]: unable to stat: /var/lib/libvirt/boot/virtinst-yvp19moo-linux: No such file or directo>
Mar 08 12:40:37 virtqemud[5639]: Unable to run security manager transaction

Add a check for file existence to the virSecurity*RestoreFileLabel functions,
and avoid relabeling if the file is no longer available. Skipping the restore
caused failures in qemusecuritytest, which mocks stat, chown, etc as part of
ensuring the security drivers properly restore labels. virFileExists is now
mocked in qemusecuritymock.c to return true when passed a file previously
seen by the mocked stat, chown, etc functions.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2024-04-08 10:38:25 -06:00
..
bhyveargv2xmldata bhyve: parse: Set video device model when parsing bhyve commandline 2020-10-19 11:50:49 +02:00
bhyvefirmwaredata
bhyvexml2argvdata
bhyvexml2xmloutdata
capabilityschemadata
chxml2xmlin
chxml2xmlout
commanddata
cputestdata
domainbackupxml2xmlin
domainbackupxml2xmlout
domaincapsdata qemucapabilitiestest: Update qemu-9.0 capabilities for RC1 2024-04-03 10:41:45 +02:00
domainconfdata
domainschemadata
fchostdata/fc_host
genericxml2xmlindata
genericxml2xmloutdata
interfaceschemadata
libxlxml2domconfigdata
lxcconf2xmldata
lxcxml2xmldata
lxcxml2xmloutdata
networkxml2confdata network: Generate TFTP config regardless of DHCP 2022-06-01 09:40:40 +02:00
networkxml2firewalldata
networkxml2xmlin
networkxml2xmlout conf: support manually specifying VFIO variant driver in <hostdev> XML 2024-01-08 01:00:08 -05:00
networkxml2xmlupdatein
networkxml2xmlupdateout
nodedevmdevctldata
nodedevschemadata
nodedevxml2xmlout
nssdata
nwfilterxml2firewalldata
nwfilterxml2xmlin
nwfilterxml2xmlout
qemuagentdata
qemublocktestdata
qemucapabilitiesdata qemucapabilitiestest: Update qemu-9.0 capabilities for RC1 2024-04-03 10:41:45 +02:00
qemucaps2xmloutdata Add test script for loongarch 2024-03-21 14:42:27 +01:00
qemudomaincheckpointxml2xmlin
qemudomaincheckpointxml2xmlout
qemudomainsnapshotxml2xmlin
qemudomainsnapshotxml2xmlout
qemufirmwaredata tests: Don't advertise features for edk2-loongarch64 2024-03-07 13:35:05 +01:00
qemuhotplugtestcpus
qemuhotplugtestdevices
qemuhotplugtestdomains
qemumemlockdata
qemumigparamsdata
qemumigrationcookiexmldata
qemumonitorjsondata
qemunbdkitdata
qemusecuritydata
qemustatusxml2xmldata
qemuvhostuserdata
qemuxmlactive2xmldata
qemuxmlconfdata qemucapabilitiestest: Update qemu-9.0 capabilities for RC1 2024-04-03 10:41:45 +02:00
schemas
secretxml2xmlin
securityselinuxhelperdata
securityselinuxlabeldata
storagepoolcapsschemadata
storagepoolschemadata
storagepoolxml2argvdata
storagepoolxml2xmlin
storagepoolxml2xmlout
storagevolschemadata
storagevolxml2argvdata storage: Upgrade default qcow2 verion to 1.1 2024-03-12 10:34:43 +01:00
storagevolxml2xmlin
storagevolxml2xmlout
sysinfodata
vboxsnapshotxmldata
viracpidata
vircaps2xmldata
vircgroupdata
virconfdata
virfilecachedata
virfiledata
virhostcpudata
virjsondata
virmacmaptestdata
virnetdaemondata
virnetdevopenvswitchdata
virnetdevtestdata/sys/class/net
virnetworkportxml2xmldata
virnwfilterbindingxml2xmldata
virpcitestdata
virprocessstatdata
virresctrldata
virscsidata
virshtestdata virshtest: Adapt virsh-uriprecedence test case 2024-04-02 14:24:30 +02:00
virstoragetestdata
virstorageutildata
virusbtestdata/sys_bus_usb/devices
virutiltestdata
vmwareverdata
vmx2xmldata
xlconfigdata
xmconfigdata xen: explicitly set hostdev driver.name at runtime, not in postparse 2024-01-07 23:59:00 -05:00
xml2vmxdata Rename iterface type='dummy' to type='null' 2022-08-25 13:27:04 +02:00
.valgrind.supp
bhyveargv2xmlmock.c
bhyveargv2xmltest.c
bhyvexml2argvmock.c
bhyvexml2argvtest.c
bhyvexml2xmltest.c
chxml2xmlmock.c tests: Introduce chxml2xmlmock 2024-03-12 17:37:51 +01:00
chxml2xmltest.c tests: Introduce chxml2xmlmock 2024-03-12 17:37:51 +01:00
commandhelper.c
commandtest.c
cputest.c
domaincapsmock.c
domaincapstest.c Add test script for loongarch 2024-03-21 14:42:27 +01:00
domainconftest.c
esxutilstest.c
eventtest.c
fchosttest.c
fdstreamtest.c
genericxml2xmltest.c
interfacexml2xmltest.c
libxlmock.c
libxlxml2domconfigtest.c
lxcconf2xmltest.c
lxcxml2xmltest.c
meson.build virshtest: Adapt virsh-uriprecedence test case 2024-04-02 14:24:30 +02:00
metadatatest.c
networkmetadatatest.c
networkxml2conftest.c
networkxml2firewalltest.c
networkxml2xmltest.c
networkxml2xmlupdatetest.c
nodedevmdevctltest.c
nodedevxml2xmltest.c
nsslinktest.c
nssmock.c tests: mock __open_2() 2024-03-14 15:17:48 +01:00
nsstest.c
nwfilterebiptablestest.c
nwfilterxml2firewalltest.c
nwfilterxml2xmltest.c
objecteventtest.c
openvzutilstest.c
openvzutilstest.conf
permitted_file_access.txt
pkix_asn1_tab.c
qemuagenttest.c
qemublocktest.c
qemucapabilitiestest.c
qemucaps2xmlmock.c
qemucaps2xmltest.c
qemucapsprobe.c
qemucapsprobemock.c
qemucommandutiltest.c
qemucpumock.c
qemudomaincheckpointxml2xmltest.c
qemudomainsnapshotxml2xmltest.c
qemufirmwaretest.c Add loongarch cpu support 2024-03-21 14:42:20 +01:00
qemuhotplugmock.c
qemuhotplugtest.c
qemumemlocktest.c
qemumigparamstest.c
qemumigrationcookiexmltest.c
qemumonitorjsontest.c
qemumonitortestutils.c
qemumonitortestutils.h
qemunbdkittest.c
qemusecuritymock.c security: Ensure file exists before attempting to restore label 2024-04-08 10:38:25 -06:00
qemusecuritytest.c
qemusecuritytest.h
qemuvhostusertest.c
qemuxml2argvmock.c
qemuxmlactivetest.c
qemuxmlconftest.c tests: Add testcase for usb-net 2024-04-03 10:40:32 +02:00
scsihosttest.c
seclabeltest.c
secretxml2xmltest.c
securityselinuxhelper.c
securityselinuxlabeltest.c
securityselinuxtest.c
shunloadhelper.c
shunloadtest.c
sockettest.c
ssh.c
storagepoolcapstest.c
storagepoolxml2argvtest.c
storagepoolxml2xmltest.c
storagevolxml2argvtest.c
storagevolxml2xmltest.c
sysinfotest.c
testutils.c
testutils.h
testutilshostcpus.h Add test script for loongarch 2024-03-21 14:42:27 +01:00
testutilslxc.c
testutilslxc.h
testutilsqemu.c
testutilsqemu.h
testutilsqemuschema.c
testutilsqemuschema.h
testutilsxen.c
testutilsxen.h
utiltest.c
vboxsnapshotxmltest.c
viracpitest.c
viralloctest.c
virauthconfigtest.c
virbitmaptest.c Use G_N_ELEMENTS() more 2023-03-13 13:29:07 +01:00
virbuftest.c
vircaps2xmltest.c tests: Add hostcpudata for machine with CPU clusters 2024-01-15 14:56:35 +01:00
vircgroupmock.c tests: mock __open_2() 2024-03-14 15:17:48 +01:00
vircgrouptest.c
virconftest.c tests: Remove unused includes 2022-06-16 06:43:58 +02:00
vircryptotest.c
virdnsmasqmock.c
virdriverconnvalidatetest.c
virdrivermoduletest.c
virendiantest.c
virerrortest.c
virfilecachemock.c
virfilecachetest.c
virfilemock.c
virfiletest.c
virfilewrapper.c tests: mock __open_2() 2024-03-14 15:17:48 +01:00
virfilewrapper.h
virfirewallmock.c
virfirewalltest.c
virgdbusmock.c
virhostcpumock.c
virhostcputest.c
virhostdevmock.c
virhostdevtest.c
virhostidmock.c
viridentitytest.c
viriscsitest.c
virjsontest.c
virkeycodetest.c
virkmodtest.c
virlockspacetest.c
virlogtest.c
virmacmaptest.c tests: vir: remove pointless labels 2021-09-09 18:06:13 +02:00
virmigtest.c
virmock.h tests: mock __open_2() 2024-03-14 15:17:48 +01:00
virmockstathelpers.c
virnetdaemonmock.c
virnetdaemontest.c
virnetdevbandwidthmock.c
virnetdevbandwidthtest.c
virnetdevmock.c
virnetdevopenvswitchtest.c
virnetdevtest.c
virnetmessagetest.c
virnetserverclientmock.c
virnetserverclienttest.c
virnetsockettest.c
virnettlscontexttest.c
virnettlshelpers.c
virnettlshelpers.h
virnettlssessiontest.c
virnetworkportxml2xmltest.c
virnumamock.c
virnwfilterbindingxml2xmltest.c
virpcimock.c tests: mock __open_2() 2024-03-14 15:17:48 +01:00
virpcitest.c
virpcivpdtest.c
virpolkittest.c
virportallocatormock.c
virportallocatortest.c
virprocessmock.c
virprocessstattest.c
virrandommock.c
virresctrltest.c
virrotatingfiletest.c
virschematest.c
virscsitest.c
virsh-auth
virsh-auth.xml
virshtest.c virshtest: Adapt virsh-uriprecedence test case 2024-04-02 14:24:30 +02:00
virstoragetest.c
virstorageutiltest.c
virstringtest.c
virsystemdtest.c
virt-aa-helper-test
virtestmock.c tests: mock __open_2() 2024-03-14 15:17:48 +01:00
virtimetest.c
virtypedparamtest.c
viruritest.c
virusbmock.c tests: mock __open_2() 2024-03-14 15:17:48 +01:00
virusbtest.c
vmwarevertest.c
vmx2xmltest.c
vshtabletest.c
xlconfigtest.c
xmconfigtest.c
xml2vmxtest.c