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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{bin}/querybts
profile querybts @{exec_path} {
  include <abstractions/base>
  include <abstractions/gtk>
  include <abstractions/fonts>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/freedesktop.org>
  include <abstractions/nameservice-strict>
  include <abstractions/python>
  include <abstractions/ssl_certs>
  include <abstractions/common/apt>

  network inet dgram,
  network inet6 dgram,
  network inet stream,
  network inet6 stream,
  network netlink raw,

  @{exec_path} r,
  @{bin}/python3.@{int} r,

  @{bin}/ r,
  @{sh_path}        rix,
  @{bin}/stty       rix,
  @{bin}/ldconfig   rix,

  @{bin}/xdg-open   rCx -> open,

  @{bin}/dpkg       rPx -> child-dpkg,

  /etc/reportbug.conf r,
  owner @{HOME}/.reportbugrc r,

  /etc/mime.types r,
  /etc/inputrc r,

  /etc/dpkg/origins/ r,
  /etc/dpkg/origins/debian r,

  owner @{PROC}/@{pid}/mountinfo r,
  owner @{PROC}/@{pid}/mounts r,
  owner @{PROC}/@{pid}/fd/ r,

  /etc/fstab r,

  /var/lib/dbus/machine-id r,
  /etc/machine-id r,

  # Allowed apps to open
  @{lib}/firefox/firefox rPUx,


  profile open {
    include <abstractions/base>
    include <abstractions/xdg-open>

    @{bin}/xdg-open mr,

    @{sh_path}             rix,
    @{bin}/{m,g,}awk       rix,
    @{bin}/readlink        rix,
    @{bin}/basename        rix,

    owner @{HOME}/ r,

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

    # Allowed apps to open
    @{lib}/firefox/firefox rPUx,

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

  }

  include if exists <local/querybts>
}

# vim:syntax=apparmor
