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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/startlxqt
profile startlxqt @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/lxqt>

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

  @{exec_path} mr,

  @{bin}/xrdb               rPx,
  @{bin}/xsetroot           rPx,
  @{bin}/xprop              rpx,
  @{bin}/mkdir              rix,
  @{sh_path}                rix,
  @{bin}/lxqt-session       rPx,

  @{bin}/systemctl  rCx -> systemctl,
  @{bin}/dbus-update-activation-environment  rCx -> dbus,

  /usr/share/color-schemes/{,**} r,
  /usr/share/desktop-directories/{,**} r,
  /usr/share/kservices5/{,**} r,
  /usr/share/mime/{,**} r,

  /etc/machine-id r,
  /etc/xdg/menus/{,**} r,

  @{HOME}/ r,

  owner @{user_cache_dirs}/#@{int} rw,
        @{user_cache_dirs}/ksycoca5_* rwkl -> @{user_cache_dirs}/#@{int},

  owner @{user_config_dirs}/#@{int} rw,
  owner @{user_config_dirs}/lxqt/ rw,
  owner @{user_config_dirs}/menus/{,**} r,

  owner @{user_share_dirs}/kservices5/{,**} r,
  owner @{user_share_dirs}/sddm/wayland-session.log rw,
  owner @{user_share_dirs}/sddm/xorg-session.log rw,

  owner /tmp/#@{int} rw,
  owner /tmp/startlxqt.@{rand6} rwl -> /tmp/#@{int},

  owner @{run}/user/@{uid}/ r,

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

  /dev/tty rw,
  /dev/tty@{int} rw,

  include if exists <local/startlxqt>

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

    include if exists <local/startlxqt_systemctl>
  }

  profile dbus {
    include <abstractions/base>

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

    owner @{HOME}/.xsession-errors w,

    include if exists <local/startlxqt_dbus>
  }
}

# vim:syntax=apparmor
