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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/xdg-settings
@{att} = /att/xdg-settings/
profile xdg-settings /{,usr/}bin/xdg-settings  flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/base>
  include <abstractions/attached/consoles>
  include <abstractions/freedesktop.org>

  @{exec_path} r,

  @{sh_path}        mr,
  @{bin}/{,e}grep  rix,
  @{bin}/basename  rix,
  @{bin}/cat        ix,
  @{bin}/cut       rix,
  @{bin}/head       ix,
  @{bin}/mkdir      ix,
  @{bin}/mktemp     ix,
  @{bin}/mv         ix,
  @{bin}/readlink   ix,
  @{bin}/realpath  rix,
  @{bin}/rm         ix,
  @{bin}/sed        ix,
  @{bin}/sleep      ix,
  @{bin}/sort       ix,
  @{bin}/touch      ix,
  @{bin}/tr         ix,
  @{bin}/uname      ix,
  @{bin}/wc         ix,

  # To set/get DE information
  @{bin}/gconftool{,-2}       ix,
  @{bin}/kde{,4}-config       ix,
  @{bin}/kwriteconfig{,5,6}   ix,
  @{bin}/qtxdg-mat            ix,

  @{bin}/dbus-send            cx -> bus,
  @{bin}/kreadconfig{,5}      px,
  @{bin}/xdg-mime             px,
  @{bin}/xprop                px,

  owner @{user_config_dirs}/xfce4/helpers.rc{,.@{rand6}} rw,
  owner @{user_share_dirs}/applications/{,**} rw,

  @{PROC}/version r,

  owner /dev/pts/@{int} rw,

  profile bus  flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
    include <abstractions/attached/base>
    include <abstractions/app/bus>
    include <abstractions/bus-session>

    include if exists <local/xdg-settings_bus>
  }

  include if exists <local/xdg-settings>
}

# vim:syntax=apparmor
