# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2018-2021 Mikhail Morfikov
# Copyright (C) 2023-2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only

abi <abi/3.0>,

include <tunables/global>

@{exec_path}  = @{lib}/@{multiarch}/{,libexec/}polkit-kde-authentication-agent-[0-9]
@{exec_path} += @{lib}/polkit-kde-authentication-agent-[0-9]
profile polkit-kde-authentication-agent @{exec_path} flags=(attach_disconnected,mediate_deleted) {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/graphics>
  include <abstractions/kde-strict>
  include <abstractions/nameservice-strict>
  include <abstractions/qt5-compose-cache-write>

  network inet dgram,
  network inet stream,
  network inet6 dgram,
  network inet6 stream,
  network netlink raw,

  signal (send) set=(term, kill) peer=polkit-agent-helper,

  @{exec_path} mr,

  @{lib}/polkit-[0-9]/polkit-agent-helper-[0-9] rPx,

  /etc/machine-id r,
  /var/lib/dbus/machine-id r,

  owner @{user_config_dirs}/breezerc r,
  owner @{user_config_dirs}/kdedefaults/plasmarc r,

  owner @{user_cache_dirs}/icon-cache.kcache rw,
  owner @{user_cache_dirs}/polkit-kde-authentication-agent-@{int}/ rw,
  owner @{user_cache_dirs}/polkit-kde-authentication-agent-@{int}/** rwk,
  owner link @{user_cache_dirs}/polkit-kde-authentication-agent-@{int}/** -> @{user_cache_dirs}/polkit-kde-authentication-agent-@{int}/**,
  owner @{user_cache_dirs}/qtshadercache-*/* r,
  
  owner @{tmp}/#@{int} rw,
  owner @{tmp}/polkit-kde-authentication-agent-[0-9].* rwl -> /tmp/#@{int},
  # owner /tmp/xauth_@{rand6} r,

  /dev/shm/#@{int} rw,

  @{run}/systemd/users/@{uid} r,

  @{PROC}/@{pid}/cgroup r,
  @{PROC}/@{pid}/cmdline r,
  @{PROC}/@{pid}/fd/ r,

  include if exists <local/polkit-kde-authentication-agent>
}

# vim:syntax=apparmor
