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

abi <abi/4.0>,

include <tunables/global>

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

  @{exec_path} r,

  @{sh_path}       rix,
  @{bin}/{,e}grep   ix,
  @{bin}/basename   ix,
  @{bin}/cat        ix,
  @{bin}/cut        ix,
  @{bin}/env        ix,
  @{bin}/readlink   ix,
  @{bin}/realpath   ix,
  @{bin}/sed        ix,
  @{bin}/tr         ix,
  @{bin}/uname      ix,

  # To get DE information
  @{bin}/kde{,4}-config       ix,

  @{bin}/dbus-send            cx -> bus,
  @{bin}/gdbus                cx -> bus,
  @{bin}/xprop                px,
  @{bin}/xdg-mime             px,
  @{open_path}                px -> child-open-any,

  @{PROC}/version r,

  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-open_bus>
  }

  include if exists <local/xdg-open>
}

# vim:syntax=apparmor
