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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{bin}/spice-vdagent
profile spice-vdagent @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/audio-client>
  include <abstractions/audio-server>
  include <abstractions/bus-accessibility>
  include <abstractions/bus-session>
  include <abstractions/bus-system>
  include <abstractions/bus/org.a11y>
  include <abstractions/bus/org.freedesktop.portal.Desktop>
  include <abstractions/bus/org.freedesktop.RealtimeKit1>
  include <abstractions/bus/org.gnome.Mutter.DisplayConfig>
  include <abstractions/bus/org.gtk.vfs.MountTracker>
  include <abstractions/graphics>
  include <abstractions/fontconfig-cache-write>
  include <abstractions/desktop>
  include <abstractions/nameservice-strict>

  dbus send bus=session path=/org/freedesktop/portal/desktop
       interface=org.freedesktop.portal.Realtime
       member=MakeThreadRealtimeWithPID
       peer=(name=org.freedesktop.portal.Desktop, label=xdg-desktop-portal),

  dbus receive bus=session path=/
       interface=org.freedesktop.DBus.Introspectable
       member=Introspect 
       peer=(name=:*, label=gnome-shell),

  @{exec_path} mr,

  owner @{desktop_config_dirs}/user-dirs.dirs r,
  owner @{user_config_dirs}/user-dirs.dirs r,

  @{run}/spice-vdagentd/spice-vdagent-sock rw,

  @{sys}/devices/virtual/dmi/id/product_name r,
  @{sys}/devices/virtual/dmi/id/sys_vendor r,

  owner @{PROC}/@{pids}/task/@{tid}/comm rw,

  owner /dev/tty@{int} rw,

  include if exists <local/spice-vdagent>
}

# vim:syntax=apparmor
