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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{lib}/systemd/systemd-backlight
profile systemd-backlight @{exec_path} {
  include <abstractions/base>
  include <abstractions/common/systemd>

  capability net_admin,

  @{exec_path} mr,

  /var/lib/systemd/backlight/*backlight* rw,

  @{run}/udev/data/+backlight:* r,
  @{run}/udev/data/+leds:*backlight* r,
  @{run}/udev/data/+pci:* r,              # Identifies all PCI devices (CPU, GPU, Network, Disks, USB, etc.)

  @{sys}/bus/ r,
  @{sys}/bus/pci/devices/ r,
  @{sys}/class/ r,
  @{sys}/class/backlight/ r,

  @{sys}/devices/@{pci}/ r,
  @{sys}/devices/@{pci}/*_backlight/{,max_,actual_}brightness rw,
  @{sys}/devices/@{pci}/*_backlight/{uevent,type,enabled} r,
  @{sys}/devices/@{pci}/backlight/**/{,max_,actual_}brightness rw,
  @{sys}/devices/@{pci}/backlight/**/{uevent,type,enabled} r,
  @{sys}/devices/@{pci}/backlight/**/brightness rw,
  @{sys}/devices/@{pci}/class r,
  @{sys}/devices/@{pci}/drm/card@{int}/**/{,max_,actual_}brightness rw,
  @{sys}/devices/@{pci}/drm/card@{int}/**/{uevent,type,enabled} r,
  @{sys}/devices/@{pci}/drm/card@{int}/**/brightness rw,
  @{sys}/devices/@{pci}/uevent r,
  @{sys}/devices/**/leds/**/{,max_,actual_}brightness rw,
  @{sys}/devices/**/leds/**/{uevent,type,enabled} r,
  @{sys}/devices/**/leds/**/brightness_hw_changed r,

  include if exists <local/systemd-backlight>
}

# vim:syntax=apparmor
