# 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} = /etc/cron.{hourly,daily,weekly,monthly}/debsums
@{att} = ""
profile cron-debsums /etc/cron.{hourly,daily,weekly,monthly}/debsums flags=(complain) {
  include <abstractions/base-strict>

  @{exec_path} mr,

  @{sh_path}        rix,
  @{bin}/{,e}grep   rix,
  @{bin}/debsums    rpx,
  @{bin}/ionice     rix,
  @{bin}/logger     rix,
  @{bin}/sed        rix,
  @{bin}/tee        rcx -> tee,
  @{bin}/true       rix,

  /etc/ r,
  /etc/default/debsums r,
  /etc/debsums-ignore r,

  # For shell pwd
  / r,

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

    capability dac_override,

    @{bin}/tee mr,

    owner @{PROC}/@{pid}/fd/@{int} rw,

    include if exists <local/cron-debsums_tee>
  }

  include if exists <local/cron-debsums>
}

# vim:syntax=apparmor
