# 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>

@{lib_dirs} = @{lib}/ /snap/snapd/@{int}@{lib}

@{exec_path} = @{bin}/apparmor_parser @{lib_dirs}/snapd/apparmor_parser
profile apparmor_parser @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/consoles>

  capability mac_admin,

  @{exec_path} mr,

  @{lib_dirs}/snapd/apparmor.d/{,**} r,
  @{lib_dirs}/snapd/apparmor/{,**} r,

  /etc/apparmor.d/{,**} r,
  /etc/apparmor.d/cache.d/{,**} rw,
  /etc/apparmor/{,**} r,
  /etc/apparmor/cache.d/{,**} rw,
  /etc/apparmor/earlypolicy/{,**} rw,

  /usr/share/apparmor-features/{,**} r,
  /usr/share/apparmor/{,**} r,

  owner /snap/core@{int}/@{int}/etc/apparmor.d/{,**} r,
  owner /snap/core@{int}/@{int}/etc/apparmor/* r,
  owner /var/cache/apparmor/{,**} rw,
  owner /var/lib/docker/tmp/docker-default@{int} r,
  owner /var/lib/snapd/apparmor/{,**} r,
  owner /var/snap/lxd/common/lxd/security/apparmor/{,**} rw,

  owner @{tmp}/cri-containerd.apparmor.d@{int} r,

        @{sys}/kernel/security/apparmor/{,**} r,
  owner @{sys}/kernel/security/apparmor/.{remove,replace,load,access} rw,

        @{PROC}/sys/kernel/osrelease r,
  owner @{PROC}/@{pid}/mounts r,

  include if exists <local/apparmor_parser>
}

# vim:syntax=apparmor
