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

# Confine gstreamer related processes.

# Note: This profile does not specify an attachment path because it is
# intended to be used only via "px -> gstreamer" exec transitions from other profiles.

abi <abi/4.0>,

include <tunables/global>

@{att} = /att/gstreamer/
profile gstreamer flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/base>
  include <abstractions/bus-session>
  include <abstractions/bus/session/org.gtk.vfs.MountTracker>
  include <abstractions/camera>
  include <abstractions/attached/consoles>
  include <abstractions/fontconfig-cache>
  include <abstractions/fonts>
  include <abstractions/graphics>
  include <abstractions/gstreamer>
  include <abstractions/media-control>
  include <abstractions/wayland>
  include <abstractions/X-strict>

  network (bind create getattr setopt getopt) netlink raw,

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

  @{gstreamer_path} mr,

  /usr/share/ladspa/rdf/{,**} r,

  owner @{DESKTOP_HOME}/.nv/ w,
  owner @{DESKTOP_HOME}/.nv/ComputeCache/ w,
  owner @{desktop_cache_dirs}/nvidia/GLCache/ rw,
  owner @{desktop_cache_dirs}/nvidia/GLCache/** rwk,

  @{run}/udev/data/c@{dynamic}:@{int} r,  # For dynamic assignment range 234 to 254, 384 to 511

  @{sys}/devices/**/uevent r,

        @{PROC}/devices r,
  owner @{PROC}/@{pid}/task/@{tid}/comm rw,

  /dev/char/@{dynamic}:@{int} w,          # For dynamic assignment range 234 to 254, 384 to 511

  include if exists <local/gstreamer>
}

# vim:syntax=apparmor
