# 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}/debsums
profile debsums @{exec_path} {
  include <abstractions/base>
  include <abstractions/perl>

  # Needed to read files owned by other users than root.
  capability dac_read_search,

  @{exec_path} r,

  @{sh_path}        rix,
  @{bin}/{m,g,}awk  rix,

  # Do not strip env to avoid errors like the following:
  #  ERROR: ld.so: object 'libfakeroot-sysv.so' from LD_PRELOAD cannot be preloaded (cannot open
  #  shared object file): ignored.
  @{bin}/dpkg-query  rpx,
  #
  @{bin}/dpkg        rPx -> child-dpkg,
  @{bin}/dpkg-divert rPx -> child-dpkg-divert,

  /etc/dpkg/dpkg.cfg.d/{,*} r,
  /etc/dpkg/dpkg.cfg r,

  /etc/locale.nopurge r,

  /var/lib/dpkg/info/* r,

  # For shell pwd
  / r,
  /root/ r,

  # Scanning files
  @{bin}/{,*} r,
  /usr/{,**} r,
  /etc/{,**} r,
  /var/lib/{,**} r,
  /opt/{,**} r,
  /boot/{,**} r,
  /lib*/{,**} r,

  include if exists <local/debsums>
}

# vim:syntax=apparmor
