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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = /usr/share/kdump-tools/kdump_mem_estimator
@{att} = ""
profile kdump_mem_estimator /usr/share/kdump-tools/kdump_mem_estimator flags=(complain) {
  include <abstractions/base-strict>

  @{exec_path} mr,

  @{sh_path} r,
  @{bin}/cat                               ix,
  @{bin}/mkdir                             ix,
  @{bin}/uname                             ix,
  @{bin}/systemctl                         cx -> systemctl,
  @{bin}/uname                             ix,

  owner /var/lib/kdump/mem* w,

  profile systemctl flags=(complain) {
    include <abstractions/base-strict>
    include <abstractions/app/systemctl>

    capability net_admin,

    ptrace read peer=@{p_systemd},

    include if exists <local/kdump_mem_estimator_systemctl>
  }

  include if exists <local/kdump_mem_estimator>
}

# vim:syntax=apparmor
