# apparmor.d - Full set of apparmor profiles
# 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} = @{lib}/xdg-desktop-portal-gtk
profile xdg-desktop-portal-gtk @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/bus-accessibility>
  include <abstractions/bus-session>
  include <abstractions/bus-system>
  include <abstractions/bus/org.a11y>
  include <abstractions/bus/org.freedesktop.Accounts>
  include <abstractions/bus/org.freedesktop.NetworkManager>
  include <abstractions/bus/org.freedesktop.portal.Desktop>
  include <abstractions/bus/org.gnome.ScreenSaver>
  include <abstractions/bus/org.gnome.SessionManager>
  include <abstractions/bus/org.gnome.Shell.Introspect>
  include <abstractions/bus/org.gtk.vfs.MountTracker>
  include <abstractions/dconf-write>
  include <abstractions/fontconfig-cache-write>
  include <abstractions/gnome-strict>
  include <abstractions/graphics>
  include <abstractions/nameservice-strict>
  include <abstractions/thumbnails-cache-read>
  include <abstractions/user-download-strict>

  signal receive set=term peer=gdm,

  unix (send, receive, connect) type=stream peer=(addr="@/tmp/.X11-unix/*", label=gnome-shell),

  #aa:dbus own bus=session name=org.freedesktop.impl.portal.desktop.gtk

  dbus receive bus=session path=/org/freedesktop/portal/desktop
       interface=org.freedesktop.impl.portal.Settings
       peer=(name=:*),
  dbus send bus=session path=/org/freedesktop/portal/desktop
       interface=org.freedesktop.impl.portal.Settings
       member=SettingChanged
       peer=(name=org.freedesktop.DBus, label=xdg-desktop-portal),

  dbus send bus=session path=/org/gtk/Notifications
       interface=org.freedesktop.DBus.Properties
       member=GetAll
       peer=(name=:*, label=gnome-shell),

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

  @{exec_path} mr,

  /usr/share/gdm/greeter-dconf-defaults r,

  / r,

  owner /var/lib/xkb/server-@{int}.xkm rw,

  owner @{gdm_config_dirs}/dconf/user r,

  owner @{tmp}/runtime-*/xauth_@{rand6} r,

  @{run}/mount/utab r,

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

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

  include if exists <local/xdg-desktop-portal-gtk>
}

# vim:syntax=apparmor
