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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{bin}/konsole
profile konsole @{exec_path} flags=(attach_disconnected,mediate_deleted) {
  include <abstractions/base>
  include <abstractions/audio-client>
  include <abstractions/bus-accessibility>
  include <abstractions/bus-session>
  include <abstractions/consoles>
  include <abstractions/graphics>
  include <abstractions/kde-strict>
  include <abstractions/nameservice-strict>

  ptrace (read),

  signal (send) set=(hup),

  @{exec_path}                          mr,
  @{bin}/@{shells}                      rUx,
  @{browsers_path}                      rPx,

  #aa:exec utempter

  /usr/share/color-schemes/{,**} r,
  /usr/share/kf6/{,**} r,
  /usr/share/knotifications{5,6}/konsole.notifyrc r,
  /usr/share/knotifications{5,6}/plasma_workspace.notifyrc r,
  /usr/share/konsole/{,**} r,
  /usr/share/sounds/** r,

  /etc/xdg/konsolerc r,
  /etc/xdg/kshorturifilterrc r,
  /etc/xdg/menus/{,**} r,
  /etc/xdg/ui/ui_standards.rc r,

  owner @{HOME}/@{XDG_SSH_DIR}/config r,

  owner @{user_cache_dirs}/icon-cache.kcache rw,
  owner @{user_cache_dirs}/ksycoca{5,6}_* r,

  owner @{user_config_dirs}/#@{int} rwl,
  owner @{user_config_dirs}/breezerc r,
  owner @{user_config_dirs}/konsolerc{,*} rwlk,
  owner @{user_config_dirs}/konsolesshconfig rwl -> @{user_config_dirs}/#@{int},
  owner @{user_config_dirs}/konsolesshconfig.@{rand6} rwl -> @{user_config_dirs}/#@{int},
  owner @{user_config_dirs}/konsolesshconfig.lock rwk,
  owner @{user_config_dirs}/kservicemenurc r,
  owner @{user_config_dirs}/menus/{,**} r,

  owner @{user_share_dirs}/color-schemes/{,**} r,
  owner @{user_share_dirs}/konsole/ rw,
  owner @{user_share_dirs}/konsole/** rwlk,
  owner @{user_share_dirs}/kxmlgui5/konsole/{,**} r,

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

  @{PROC}/@{pid}/cmdline r,
  @{PROC}/@{pid}/stat r,

  /dev/ptmx rw,

  include if exists <local/konsole>
}

# vim:syntax=apparmor
