# 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} = @{etc_ro}/needrestart/restart.d/*
@{att} = ""
profile needrestart-restart /{,usr/}etc/needrestart/restart.d/* flags=(complain) {
  include <abstractions/base-strict>

  @{exec_path} mr,

  @{bin}/systemctl cx -> systemctl,
  @{sh_path} r,

  /var/log/unattended-upgrades/unattended-upgrades-dpkg.log rw,

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

    capability net_admin,
    capability sys_ptrace,

    include if exists <local/needrestart-restart_systemctl>
  }

  include if exists <local/needrestart-restart>
}

# vim:syntax=apparmor
