# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 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}/lxqt-session
profile lxqt-session @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/app-launcher-user>
  include <abstractions/bus-accessibility>
  include <abstractions/dconf>
  include <abstractions/lxqt>
  include <abstractions/qt5-shader-cache>
  include <abstractions/nameservice-strict>

  network netlink raw,

  signal (send),
  signal (receive) set=(kill, term) peer=startlxqt,
  signal (receive) set=(kill, term) peer=sddm,

  ptrace (read),

  @{exec_path} mr,

  @{sh_path}                          rix,
  @{bin}/sed                          rix,
  @{bin}/readlink                     rix,
  @{bin}/dirname                      rix,
  @{bin}/system-config-printer-applet rPx,
  @{bin}/dbus-update-activation-environment rCx -> dbus,
  @{bin}/systemctl                    rCx -> systemctl,

  @{bin}/pavucontrol                  rPx,
  @{lib}/geoclue-2.0/demos/agent      rPx,
  @{bin}/nm-connection-editor         rPx,
  @{bin}/nm-applet                    rPx,
  @{bin}/openbox                      rix,
  @{bin}/dconf-editor                 rPx,
  @{bin}/setxkbmap                    rix,
  @{bin}/start-pulseaudio-x11         rPx,
  @{bin}/xrdb                         rPx,
  @{bin}/xdg-user-dirs-update         rPx,

  /usr/share/                         r,
  /usr/share/mime/                    r,
  /usr/share/cursors/                 r,
  /usr/share/backintime/common/*      r,
  /usr/share/desktop-directories/*    r,
  /usr/share/system-config-printer/*  r,

  /etc/xdg/                           r,
  /etc/xdg/autostart/                 r,
  /etc/xdg/autostart/*.desktop        r,
  /etc/xdg/menus/lxqt-*               r,
  /etc/xdg/openbox/*                  r,
  /etc/udev/udev.conf                 r,

  owner @{user_config_dirs}/autostart/ r,
  owner @{user_config_dirs}/autostart/*.desktop r,
  owner @{user_cache_dirs}/openbox/   rw,
  owner @{user_cache_dirs}/openbox/sessions/          rw,
  owner @{user_cache_dirs}/openbox/openbox.log        rwk,
  owner @{user_config_dirs}/mimeapps.list{,.@{rand6}} rw,
  owner @{user_config_dirs}/openbox/rc.xml            r,

  @{att}/@{run}/systemd/inhibit/@{int}.ref rw,

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

  /dev/tty                             rw,

  profile systemctl {
    include <abstractions/base>
    include <abstractions/app/systemctl>

    include if exists <local/lxqt-session_systemctl>
  }
  profile dbus {
    include <abstractions/base>
    include <abstractions/bus-session>

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

    include if exists <local/lxqt-session_dbus>
  }

  include if exists <local/lxqt-session>
}

# vim:syntax=apparmor
