# apparmor.d - Full set of apparmor profiles
# 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}/xfce4-session
profile xfce-session @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/app-launcher-user>
  include <abstractions/graphics>
  include <abstractions/nameservice-strict>
  include <abstractions/xfce>

  signal (receive) set=(term) peer=lightdm,

  @{exec_path} mr,

  @{sh_path} rix,

  @{bin}/sleep rix,

  @{bin}/dbus-update-activation-environment            rCx -> dbus,
  @{bin}/systemctl                                     rCx -> systemctl,
  @{lib}/legacy-dist/deprecation-popup                rPUx,
  /usr/share/system-config-printer/applet.py           rPx,
  #aa:exec xfce-notifyd
  #aa:exec polkit-gnome-authentication-agent

  #aa:only whonix
  @{lib}/msgcollector/msgdispatcher_xdg_autostart      rPx,
  @{lib}/sdwdate-gui/start-maybe                       rPx,
  @{lib}/setup-wizard-dist/setup-dist_check_for_start  rPx,

  /usr/share/kde-power-savings-disable-in-vms/{,**} r,
  /usr/share/kde-screen-locker-disable-in-vms/{,**} r,

  #aa:only whonix
  /usr/share/anon-apps-config/{,**} r,
  /usr/share/open-link-confirmation/{,**} r,
  /usr/share/security-misc/{,**} r,
  /usr/share/torbrowser-default-browser/{,**} r,

  /etc/xdg/ r,
  /etc/xdg/autostart/ r,
  /etc/xdg/autostart/*.desktop r,

  owner @{user_cache_dirs}/sessions/{,**} rw,

  owner @{tmp}/.xfsm-ICE-@{rand6} rw,

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

  /dev/tty rw,

  profile systemctl flags=(attach_disconnected) {
    include <abstractions/base>
    include <abstractions/app/systemctl>

    include if exists <local/xfce-session_systemctl>
  }

  profile dbus flags=(attach_disconnected) {
    include <abstractions/base>
    include <abstractions/bus-session>

    @{bin}/dbus-update-activation-environment mr,

    owner @{user_share_dirs}/sddm/xorg-session.log rw,

    include if exists <local/xfce-session_dbus>
  }

  include if exists <local/xfce-session>
}

# vim:syntax=apparmor
