# 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/3.0>,

include <tunables/global>

@{exec_path}  = @{lib}/xdg-desktop-portal-kde
@{exec_path} += @{lib}/@{multiarch}/{,libexec/}xdg-desktop-portal-kde
profile xdg-desktop-portal-kde @{exec_path} {
  include <abstractions/base>
  include <abstractions/graphics>
  include <abstractions/kde-strict>
  include <abstractions/nameservice-strict>

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

  @{exec_path} mr,

  #aa:exec kioworker

  owner @{desktop_config_dirs}/user-dirs.dirs r,

  owner @{user_cache_dirs}/*.kcache r,

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

  owner @{user_config_dirs}/#@{int} rw,
  owner @{user_config_dirs}/autostart/org.kde.*.desktop r,
  owner @{user_config_dirs}/breezerc r,
  owner @{user_config_dirs}/kdeglobals{,.*} rwlk,
  owner @{user_config_dirs}/xdg-desktop-portal-kderc{,.*} rwlk,

  owner @{run}/user/@{uid}/xdg-desktop-portal-kde@{rand6}.*.socket rw,

  /dev/tty r,

  include if exists <local/xdg-desktop-portal-kde>
}

# vim:syntax=apparmor
