# 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} = ""
profile kauth-chargethresholdhelper /{,usr/}lib{,exec,32,64}/{,kf6/}kauth/{,libexec/}chargethresholdhelper flags=(complain) {
  include <abstractions/base-strict>
  include <abstractions/bus-system>
  include <abstractions/nameservice-strict>
  include <abstractions/bus/org.freedesktop.PolicyKit1>

  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}"),
  dbus receive bus=system path=/org/kde/powerdevil/chargethresholdhelper{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       member=GetManagedObjects
       peer=(name="{@{busname},org.kde.powerdevil.chargethresholdhelper{,.*}}"),
  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 addr=none peer=(label=kde-powerdevil, addr=none),

  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,

  include if exists <local/kauth-chargethresholdhelper>
}

# vim:syntax=apparmor
