# 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/}backlighthelper
@{att} = /att/kauth-backlighthelper/
profile kauth-backlighthelper /{,usr/}lib{,exec,32,64}/{,kf6/}kauth/{,libexec/}backlighthelper   flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/base>
  include <abstractions/backlight>
  include <abstractions/bus-system>
  include <abstractions/bus/system/org.freedesktop.PolicyKit1>
  include <abstractions/attached/nameservice-strict>
  include <abstractions/qt5>

  capability net_admin,

  include <abstractions/bus/system/own>

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

  @{exec_path} mr,

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

  /dev/tty r,

  include if exists <local/kauth-backlighthelper>
}

# vim:syntax=apparmor
