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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/linux-check-removal
profile linux-check-removal /{,usr/}{,s}bin/linux-check-removal flags=(complain) {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/perl>

  @{exec_path} r,
  @{bin}/perl r,

  # Think what to do about this (#FIXME#)
  /usr/share/debconf/frontend         rPx,
  #/usr/share/debconf/frontend        rCx -> frontend,


  profile frontend flags=(complain) {
    include <abstractions/base>
    include <abstractions/consoles>
    include <abstractions/perl>
    include <abstractions/nameservice-strict>

    /usr/share/debconf/frontend r,
    @{bin}/perl r,

    @{bin}/linux-check-removal rPx,

    @{sh_path}        rix,
    @{bin}/stty       rix,
    @{bin}/locale     rix,

    # The following is needed when debconf uses dialog/whiptail frontend.
    @{bin}/whiptail   rPx,
    owner /tmp/file* w,

    /usr/share/debconf/confmodule r,

    /etc/debconf.conf r,
    owner /var/cache/debconf/{config,passwords,templates}.dat{,-new,-old} rwk,
    /usr/share/debconf/templates/adequate.templates r,

  }

  include if exists <local/linux-check-removal>
}
