# apparmor.d - Full set of apparmor profiles
# 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} = @{lib}/power-profiles-daemon
profile power-profiles-daemon @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/bus-system>
  include <abstractions/bus/org.freedesktop.login1>
  include <abstractions/bus/org.freedesktop.PolicyKit1>
  include <abstractions/nameservice-strict>

  capability dac_read_search,
  capability net_admin,
  capability sys_nice,

  network netlink raw,

  #aa:dbus own bus=system name=net.hadess.PowerProfiles
  #aa:dbus own bus=system name=org.freedesktop.UPower.PowerProfiles

  @{exec_path} mr,

  /var/lib/power-profiles-daemon/{,**} rw,

  @{run}/udev/data/+platform:* r,
  @{run}/udev/data/+power_supply:* r,

  @{sys}/bus/ r,
  @{sys}/bus/platform/devices/ r,
  @{sys}/class/ r,
  @{sys}/class/power_supply/ r,
  @{sys}/devices/**/power_supply/*/scope r,
  @{sys}/devices/**/uevent r,
  @{sys}/devices/system/cpu/*_pstate/{no_turbo,turbo_pct} r,
  @{sys}/devices/system/cpu/*_pstate/status r,
  @{sys}/devices/system/cpu/cpu@{int}/power/energy_perf_bias rw,
  @{sys}/devices/system/cpu/cpufreq/ r,
  @{sys}/devices/system/cpu/cpufreq/policy@{int}/energy_performance_preference rw,
  @{sys}/devices/system/cpu/cpufreq/policy@{int}/scaling_governor rw,
  @{sys}/firmware/acpi/platform_profile* rw,
  @{sys}/firmware/acpi/pm_profile* rw,

  include if exists <local/power-profiles-daemon>
}

# vim:syntax=apparmor
