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

abi <abi/3.0>,

include <tunables/global>

@{share_dirs}  = /usr/share/gnome-shell/extensions/gsconnect@andyholmes.github.io
@{share_dirs} += @{user_share_dirs}/gnome-shell/extensions/gsconnect@andyholmes.github.io

@{exec_path} = @{share_dirs}/service/daemon.js
profile gnome-extension-gsconnect @{exec_path} {
  include <abstractions/base>
  include <abstractions/audio-client>
  include <abstractions/bus-accessibility>
  include <abstractions/bus-session>
  include <abstractions/bus-system>
  include <abstractions/dconf-write>
  include <abstractions/gnome-strict>
  include <abstractions/nameservice-strict>
  include <abstractions/p11-kit>
  include <abstractions/ssl_certs>

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

  @{exec_path} mr,

  @{sh_path}          rix,
  @{bin}/env          rix,
  @{bin}/gjs-console  rix,
  @{bin}/openssl      rix,
  @{bin}/ssh-add      rix,

  @{bin}/ssh-keygen rPx,
  @{bin}/xdg-screensaver rPx,

  @{lib}/gio/modules/*.so* rm,
  @{lib}/girepository-1.0/* r,

  @{open_path}  rPx -> child-open-help,

  @{share_dirs}/{,**} r,
  @{share_dirs}/gsconnect-preferences rix,

  owner @{user_cache_dirs}/gsconnect/{,**} rw,

  owner @{user_config_dirs}/gsconnect/{,**} rw,
  owner @{user_config_dirs}/mimeapps.list w,
  owner @{user_config_dirs}/mimeapps.list.@{rand6} rw,

  owner @{run}/user/@{uid}/gsconnect/ w,

  @{sys}/devices/virtual/dmi/id/chassis_type r,

  owner @{PROC}/@{pid}/mounts r,
  owner @{PROC}/@{pid}/stat r,
  owner @{PROC}/@{pid}/status r,
  owner @{PROC}/@{pid}/task/@{tid}/stat r,

  /dev/shm/ r,

  include if exists <local/gnome-extension-gsconnect>
}

# vim:syntax=apparmor
