# 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}/pam-auth-update
profile pam-auth-update /{,usr/}{,s}bin/pam-auth-update flags=(complain) {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/perl>

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

  @{bin}/md5sum rix,
  @{bin}/cp     rix,

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

  /etc/pam.d/* rw,
  /var/lib/pam/* rw,
  /usr/share/pam{,-configs}/{,*} r,


  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}/pam-auth-update rPx,

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

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

    # The following is needed when debconf uses GUI frontends.
    include <abstractions/gtk>
    include <abstractions/fonts>
    include <abstractions/fontconfig-cache-read>
    include <abstractions/freedesktop.org>
    capability dac_read_search,
    @{bin}/lsb_release rPx -> lsb_release,
    @{bin}/hostname    rix,
    owner @{PROC}/@{pid}/mounts r,
    @{HOME}/.Xauthority r,

    /etc/shadow r,

  }

  include if exists <local/pam-auth-update>
}
