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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/swtpm_setup
profile swtpm_setup /{,usr/}{,s}bin/swtpm_setup flags=(complain) {
  include <abstractions/base>
  include <abstractions/nameservice-strict>

  @{exec_path} mr,

  @{bin}/swtpm          rPx,
  @{bin}/swtpm_localca  rPx,

  /etc/swtpm_setup.conf r,

  /var/log/swtpm/{,**} w,
  /var/lib/libvirt/swtpm/@{uuid}/tpm2/ r,

  owner /tmp/swtpm_setup.certs.*/ w,
  owner /tmp/swtpm_setup.certs.*/*.cert rw,
  owner /tmp/.swtpm_setup.pidfile* rw,

  include if exists <local/swtpm_setup>
}