# 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} = @{bin}/kwin_x11
profile kwin_x11 @{exec_path} {
  include <abstractions/base>
  include <abstractions/bus-system>
  include <abstractions/graphics>
  include <abstractions/kde-strict>
  include <abstractions/nameservice-strict>
  include <abstractions/qt5-shader-cache>
  include <abstractions/thumbnails-cache-read>

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

  @{exec_path} mrix,

  @{sh_path}                 rix,
  @{lib}/kwin_killer_helper  rix,

  #aa:exec drkonqi

  /usr/share/kwin/{,**} r,
  /usr/share/plasma/desktoptheme/{,**} r,

  /etc/machine-id r,
  /etc/xdg/plasmarc r,

  owner @{user_cache_dirs}/ r,
  owner @{user_cache_dirs}/#@{int} rw,
  owner @{user_cache_dirs}/icon-cache.kcache rw,
  owner @{user_cache_dirs}/kcrash-metadata/*.ini rw,
  owner @{user_cache_dirs}/ksvg-elements r,
  owner @{user_cache_dirs}/kwin/{,**} rwl,
  owner @{user_cache_dirs}/plasma_theme_*.kcache rw,
  owner @{user_cache_dirs}/plasma-svgelements rw,
  owner @{user_cache_dirs}/plasma-svgelements.@{rand6} rwl -> @{user_cache_dirs}/#@{int},
  owner @{user_cache_dirs}/plasma-svgelements.lock rwk,
  owner @{user_cache_dirs}/plasmarc r,
  owner @{user_cache_dirs}/session/#@{int} rw,

  owner @{user_config_dirs}/#@{int} rw,
  owner @{user_config_dirs}/kdedefaults/plasmarc r,
  owner @{user_config_dirs}/kwinoutputconfig.json r,
  owner @{user_config_dirs}/kwinrc.lock rwk,
  owner @{user_config_dirs}/kwinrc{,.@{rand6}} rwl,
  owner @{user_config_dirs}/kwinrulesrc r,
  owner @{user_config_dirs}/kxkbrc r,
  owner @{user_config_dirs}/plasmarc r,
  owner @{user_config_dirs}/session/#@{int} rw,
  owner @{user_config_dirs}/session/kwin_* rwk,

  owner @{user_share_dirs}/kwin/scripts/ r,

  owner @{tmp}/#@{int} rw,
  owner @{tmp}/kwin.@{rand6} rwl,

  owner @{run}/user/@{uid}/kcrash_@{int} rw,

  @{sys}/devices/system/node/ r,
  @{sys}/devices/system/node/node@{int}/meminfo r,

  /dev/tty rw,

  include if exists <local/kwin_x11>
}

# vim:syntax=apparmor
