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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{lib}/systemd/system-sleep/nvidia
profile systemd-sleep-nvidia @{exec_path} {
  include <abstractions/base>
  include <abstractions/nameservice-strict>

  capability sys_admin,
  capability sys_tty_config,

  @{exec_path} mr,

  @{sh_path}              rix,
  @{bin}/nvidia-sleep.sh  rix,
  @{bin}/chvt             rix,
  @{bin}/cat              rix,
  @{bin}/rm               rix,

  @{run}/nvidia-sleep/* rw,

  @{PROC}/driver/nvidia/suspend w,

  /dev/tty rw,
  /dev/tty@{int} rw,

  include if exists <local/systemd-sleep-nvidia>
}