# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2018-2022 Mikhail Morfikov
# 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}/{,rtkit/}rtkit-daemon
@{att} = /att/rtkit-daemon/
profile rtkit-daemon /{,usr/}lib{,exec,32,64}/{,rtkit/}rtkit-daemon  flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/base>
  include <abstractions/bus-system>
  include <abstractions/bus/org.freedesktop.PolicyKit1>
  include <abstractions/nameservice-strict>

  capability dac_read_search,
  capability setgid,
  capability setuid,
  capability sys_chroot,
  capability sys_nice,
  capability sys_ptrace,

  include <abstractions/bus/system/own>

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

  @{exec_path} mr,

  # When applying policies to processes
  @{PROC}/@{pids}/stat r,
  @{PROC}/@{pids}/task/@{tid}/stat r,
  @{PROC}/@{pids}/limits r,

  include if exists <local/rtkit-daemon>
}

# vim:syntax=apparmor
