mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
security: AppArmor: Implement per-image seclabel restore
Refactor the existing code to allow re-using it for the per-image label restore too.
This commit is contained in:
parent
7077cfeff4
commit
15cad6577f
@ -683,15 +683,23 @@ AppArmorClearSecuritySocketLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
|
|
||||||
/* Called when hotplugging */
|
/* Called when hotplugging */
|
||||||
|
static int
|
||||||
|
AppArmorRestoreSecurityImageLabel(virSecurityManagerPtr mgr,
|
||||||
|
virDomainDefPtr def,
|
||||||
|
virStorageSourcePtr src)
|
||||||
|
{
|
||||||
|
if (!virStorageSourceIsLocalStorage(src))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return reload_profile(mgr, def, NULL, false);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
AppArmorRestoreSecurityDiskLabel(virSecurityManagerPtr mgr,
|
AppArmorRestoreSecurityDiskLabel(virSecurityManagerPtr mgr,
|
||||||
virDomainDefPtr def,
|
virDomainDefPtr def,
|
||||||
virDomainDiskDefPtr disk)
|
virDomainDiskDefPtr disk)
|
||||||
{
|
{
|
||||||
if (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_NETWORK)
|
return AppArmorRestoreSecurityImageLabel(mgr, def, disk->src);
|
||||||
return 0;
|
|
||||||
|
|
||||||
return reload_profile(mgr, def, NULL, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called when hotplugging */
|
/* Called when hotplugging */
|
||||||
@ -975,6 +983,8 @@ virSecurityDriver virAppArmorSecurityDriver = {
|
|||||||
.domainSetSecurityDiskLabel = AppArmorSetSecurityDiskLabel,
|
.domainSetSecurityDiskLabel = AppArmorSetSecurityDiskLabel,
|
||||||
.domainRestoreSecurityDiskLabel = AppArmorRestoreSecurityDiskLabel,
|
.domainRestoreSecurityDiskLabel = AppArmorRestoreSecurityDiskLabel,
|
||||||
|
|
||||||
|
.domainRestoreSecurityImageLabel = AppArmorRestoreSecurityImageLabel,
|
||||||
|
|
||||||
.domainSetSecurityDaemonSocketLabel = AppArmorSetSecurityDaemonSocketLabel,
|
.domainSetSecurityDaemonSocketLabel = AppArmorSetSecurityDaemonSocketLabel,
|
||||||
.domainSetSecuritySocketLabel = AppArmorSetSecuritySocketLabel,
|
.domainSetSecuritySocketLabel = AppArmorSetSecuritySocketLabel,
|
||||||
.domainClearSecuritySocketLabel = AppArmorClearSecuritySocketLabel,
|
.domainClearSecuritySocketLabel = AppArmorClearSecuritySocketLabel,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user