apparmor: Add support for local profile customizations

Apparmor profiles in /etc/apparmor.d/ are config files that can and should
be replaced on package upgrade, which introduces the potential to overwrite
any local changes. Apparmor supports local profile customizations via
/etc/apparmor.d/local/<service> [1].

This change makes the support explicit by adding libvirtd, virtqemud, and
virtxend profile customization stubs to /etc/apparmor.d/local/. The stubs
are conditionally included by the corresponding main profiles.

[1] https://ubuntu.com/server/docs/security-apparmor
See "Profile customization" section

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jim Fehlig 2023-06-06 11:05:50 -06:00
parent 17565ee0aa
commit 9b743ee190
7 changed files with 19 additions and 5 deletions

View File

@ -34,8 +34,10 @@ install_data(
install_dir: apparmor_dir / 'libvirt',
)
install_data(
'usr.lib.libvirt.virt-aa-helper.local',
install_dir: apparmor_dir / 'local',
rename: 'usr.lib.libvirt.virt-aa-helper',
)
foreach name : apparmor_gen_profiles
install_data(
'@0@.local'.format(name),
install_dir: apparmor_dir / 'local',
rename: name,
)
endforeach

View File

@ -139,4 +139,7 @@ profile libvirtd @sbindir@/libvirtd flags=(attach_disconnected) {
/usr/{lib,lib64,lib/qemu,libexec}/qemu-bridge-helper rmix,
}
# Site-specific additions and overrides. See local/README for details.
include if exists <local/usr.sbin.libvirtd>
}

View File

@ -0,0 +1 @@
# Site-specific additions and overrides for 'usr.sbin.libvirtd'

View File

@ -132,4 +132,7 @@ profile virtqemud @sbindir@/virtqemud flags=(attach_disconnected) {
/usr/{lib,lib64,lib/qemu,libexec}/qemu-bridge-helper rmix,
}
# Site-specific additions and overrides. See local/README for details.
include if exists <local/usr.sbin.virtqemud>
}

View File

@ -0,0 +1 @@
# Site-specific additions and overrides for 'usr.sbin.virtqemud'

View File

@ -52,4 +52,7 @@ profile virtxend @sbindir@/virtxend flags=(attach_disconnected) {
@libexecdir@/libvirt_iohelper ix,
/etc/libvirt/hooks/** rmix,
/etc/xen/scripts/** rmix,
# Site-specific additions and overrides. See local/README for details.
include if exists <local/usr.sbin.virtxend>
}

View File

@ -0,0 +1 @@
# Site-specific additions and overrides for 'usr.sbin.virtxend'