# 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/4.0>,

include <tunables/global>

@{exec_path} = @{lib}/{,kf6/}kauth/{,libexec/}chargethresholdhelper
@{att} = /att/kauth-chargethresholdhelper/
profile kauth-chargethresholdhelper /{,usr/}lib{,exec,32,64}/{,kf6/}kauth/{,libexec/}chargethresholdhelper   flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/base>
  include <abstractions/bus-system>
  include <abstractions/bus/system/org.freedesktop.PolicyKit1>
  include <abstractions/attached/nameservice-strict>

  include <abstractions/bus/system/own>

  dbus bind bus=system name=org.kde.powerdevil.chargethresholdhelper{,.*},
  dbus receive bus=system path=/org/kde/powerdevil/chargethresholdhelper{,/**}
       interface=org.kde.powerdevil.chargethresholdhelper{,.*}
       peer=(name="@{busname}"),
  dbus send bus=system path=/org/kde/powerdevil/chargethresholdhelper{,/**}
       interface=org.kde.powerdevil.chargethresholdhelper{,.*}
       peer=(name="{@{busname},org.freedesktop.DBus}"),
  dbus (send receive) bus=system path=/org/kde/powerdevil/chargethresholdhelper{,/**}
       interface=org.freedesktop.DBus.Properties
       member={Get,GetAll,Set,PropertiesChanged}
       peer=(name="{@{busname},org.freedesktop.DBus}"),
  dbus receive bus=system path=/org/kde/powerdevil/chargethresholdhelper{,/**}
       interface=org.freedesktop.DBus.Introspectable
       member=Introspect
       peer=(name="{@{busname},org.freedesktop.DBus}"),
  dbus receive bus=system path=/org/kde/powerdevil/chargethresholdhelper{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       member=GetManagedObjects
       peer=(name="{@{busname},org.freedesktop.DBus}"),
  dbus send bus=system path=/org/kde/powerdevil/chargethresholdhelper{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       member={InterfacesAdded,InterfacesRemoved}
       peer=(name="{@{busname},org.freedesktop.DBus}"),
  unix type=stream peer=(label=kde-powerdevil),

  dbus (send receive) bus=system path=/
       interface=org.kde.kf5auth{,.*}
       peer=(name="{@{busname},org.kde.kf5auth{,.*}}", label=kde-powerdevil),
  dbus (send receive) bus=system path=/
       interface=org.freedesktop.DBus.Properties
       member={Get,GetAll,Set,PropertiesChanged}
       peer=(name="{@{busname},org.kde.kf5auth{,.*}}", label=kde-powerdevil),
  dbus send bus=system path=/
       interface=org.freedesktop.DBus.Introspectable
       member=Introspect
       peer=(name="{@{busname},org.kde.kf5auth{,.*}}", label=kde-powerdevil),
  dbus send bus=system path=/
       interface=org.freedesktop.DBus.ObjectManager
       member=GetManagedObjects
       peer=(name="{@{busname},org.kde.kf5auth{,.*}}", label=kde-powerdevil),
  dbus receive bus=system path=/
       interface=org.freedesktop.DBus.ObjectManager
       member={InterfacesAdded,InterfacesRemoved}
       peer=(name="{@{busname},org.kde.kf5auth{,.*}}", label=kde-powerdevil),

  @{exec_path} mr,

  /usr/share/icu/@{int}.@{int}/*.dat r,

  @{sys}/class/power_supply/ r,
  @{sys}/devices/**/power_supply/** r,
  @{sys}/devices/**/power_supply/BAT@{int}/charge_control_end_threshold w,
  @{sys}/devices/**/power_supply/BAT@{int}/charge_control_start_threshold w,

  include if exists <local/kauth-chargethresholdhelper>
}

# vim:syntax=apparmor
