# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2021-2022 Mikhail Morfikov
# 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} = @{lib}/{,gvfs/}gvfs-udisks2-volume-monitor
profile gvfs-udisks2-volume-monitor @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/bus-session>
  include <abstractions/bus-system>
  include <abstractions/bus/org.freedesktop.UDisks2>
  include <abstractions/bus/org.gtk.vfs.MountTracker>
  include <abstractions/dconf-write>
  include <abstractions/devices-usb>
  include <abstractions/disks-read>
  include <abstractions/freedesktop.org>
  include <abstractions/nameservice-strict>

  capability sys_ptrace,

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

  signal (send) set=(term, kill) peer=mount,

  ptrace (read),

  #aa:dbus own bus=session name=org.gtk.vfs.UDisks2VolumeMonitor interface=org.gtk.Private.RemoteVolumeMonitor path=/org/gtk/Private/RemoteVolumeMonitor
  #aa:dbus talk bus=system name=org.freedesktop.UDisks2 label=udisksd

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

  @{exec_path} mr,

  @{bin}/lsof   rix,

  @{bin}/mount  rPx,
  @{bin}/umount rPx,

  / r,
  /etc/fstab r,

  # Mount points
  @{MOUNTS}/ r,
  @{MOUNTS}/**/ r,
  @{HOME}/**/ r,

  owner @{MOUNTS}/autorun.inf r,

  owner @{desktop_config_dirs}/dconf/user r,

  @{run}/mount/utab r,

        @{PROC}/ r,
        @{PROC}/@{pids}/net/* r,
        @{PROC}/@{pids}/stat r,
        @{PROC}/1/cgroup r,
        @{PROC}/locks r,
  owner @{PROC}/@{pid}/cgroup r,
  owner @{PROC}/@{pid}/fd/ r,
  owner @{PROC}/@{pid}/fdinfo/@{int} r,
  owner @{PROC}/@{pid}/mountinfo r,
  owner @{PROC}/@{pid}/mounts r,

  /dev/dri/card@{int} r,
  /dev/input/event@{int} r,

  include if exists <local/gvfs-udisks2-volume-monitor>
}

# vim:syntax=apparmor
