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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/virtsecretd
profile virtsecretd @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/nameservice-strict>

  network netlink raw,

  ptrace (read) peer=virtqemud,

  @{exec_path} mr,

  owner @{user_config_dirs}/libvirt/secrets/ rw,
  owner @{user_config_dirs}/libvirt/secrets/run/{,*} rwk,

  @{att}/@{run}/systemd/inhibit/@{int}.ref rw,

  owner @{run}/user/@{uid}/libvirt/common/system.token rwk,
  owner @{run}/user/@{uid}/libvirt/secrets/ rw,
  owner @{run}/user/@{uid}/libvirt/secrets/run/{,*} rwk,
  owner @{run}/user/@{uid}/libvirt/virtsecretd* rwk,

  @{run}/utmp rk,

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

  owner @{PROC}/@{pids}/stat r,

  include if exists <local/virtsecretd>
}

# vim:syntax=apparmor
