# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2021-2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{bin}/libvirt-dbus
profile libvirt-dbus @{exec_path} {
  include <abstractions/base>
  include <abstractions/bus-session>
  include <abstractions/bus-system>
  include <abstractions/nameservice-strict>

  #aa:dbus own bus=session name=org.libvirt
  #aa:dbus own bus=system name=org.libvirt

  @{exec_path} mr,

  @{bin}/libvirtd   rPx,
  @{bin}/virtqemud  rPx,

  /usr/share/dbus-1/interfaces/org.libvirt.*.xml r,

  owner @{user_cache_dirs}/libvirt/libvirtd.lock rwk,

  @{run}/user/@{uid}/libvirt/ rw,
  @{run}/user/@{uid}/libvirt/libvirtd.lock rwk,
  @{run}/user/@{uid}/libvirt/virtqemud.lock rwk,

  @{sys}/devices/system/node/ r,
  @{sys}/devices/system/node/node*/meminfo r,

  owner @{PROC}/@{pid}/fd/ r,

  include if exists <local/libvirt-dbus>
}

# vim:syntax=apparmor
