# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2021 Mikhail Morfikov
# 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}/{,gvfs/}gvfsd-recent
profile gvfsd-recent @{exec_path} {
  include <abstractions/base>
  include <abstractions/bus-session>
  include <abstractions/bus/org.gtk.vfs.Daemon>
  include <abstractions/bus/org.gtk.vfs.MountTracker>
  include <abstractions/deny-sensitive-home>
  include <abstractions/freedesktop.org>
  include <abstractions/nameservice-strict>
  include <abstractions/thumbnails-cache-read>

  #aa:dbus own bus=session name=org.gtk.vfs.mountpoint_@{int}

  dbus receive bus=session path=/org/gtk/vfs/mountable
       interface=org.gtk.vfs.Mountable
       member=Mount
       peer=(name=:*, label=gvfsd),
  dbus send bus=session path=/org/gtk/gvfs/exec_spaw/@{int}
       interface=org.gtk.vfs.Spawner
       member=Spawned
       peer=(name=:*, label=gvfsd),
  dbus send bus=session path=/org/gtk/vfs/mounttracker
       interface=org.gtk.vfs.MountTracker
       member=RegisterMount
       peer=(name=:*, label=gvfsd),

  @{exec_path} mr,

  # Full access to user's data
  owner @{HOME}/{,**} rw, # FIXME: ?
  owner @{MOUNTS}/{,**} rw,

  owner @{HOME}/.zshenv r,
  owner @{user_share_dirs}/gvfs-metadata/{,*} r,

  owner @{run}/user/@{uid}/gvfsd/ rw,
  owner @{run}/user/@{uid}/gvfsd/socket-@{rand8} rw,

  @{run}/mount/utab r,

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

  include if exists <local/gvfsd-recent>
}

# vim:syntax=apparmor
