# 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/4.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 /{{,usr/}lib{,exec,32,64}/*-linux-gnu*/{,libexec/}polkit-kde-authentication-agent-[0-9],{,usr/}lib{,exec,32,64}/polkit-kde-authentication-agent-[0-9]}  flags=(attach_disconnected,complain) {
  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,

  /usr/share/qt5ct/** r,

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

  owner @{user_config_dirs}/qt5ct/{,**} r,

  owner @{user_cache_dirs}/icon-cache.kcache rw,

  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,
  @{PROC}/sys/kernel/core_pattern r,

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