# 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} = @{bin}/gnome-music
@{att} = /att/gnome-music/
profile gnome-music /{,usr/}bin/gnome-music  flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/base>
  include <abstractions/audio-client>
  include <abstractions/bus-system>
  include <abstractions/bus/system/org.freedesktop.login1>
  include <abstractions/common/gnome>
  include <abstractions/gstreamer>
  include <abstractions/nameservice-strict>
  include <abstractions/p11-kit>
  include <abstractions/python>
  include <abstractions/sqlite>
  include <abstractions/ssl_certs>

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

  unix type=stream addr=none peer=(label=tracker-writeback, addr=none),

  dbus (send receive) bus=session path=/org/freedesktop/Tracker3/Writeback{,/**}
       interface=org.freedesktop.Tracker3.Writeback{,.*}
       peer=(name="{@{busname},org.freedesktop.Tracker3.Writeback{,.*}}", label=tracker-writeback),
  dbus (send receive) bus=session path=/org/freedesktop/Tracker3/Writeback{,/**}
       interface=org.freedesktop.DBus.Properties
       member={Get,GetAll,Set,PropertiesChanged}
       peer=(name="{@{busname},org.freedesktop.Tracker3.Writeback{,.*}}", label=tracker-writeback),
  dbus send bus=session path=/org/freedesktop/Tracker3/Writeback{,/**}
       interface=org.freedesktop.DBus.Introspectable
       member=Introspect
       peer=(name="{@{busname},org.freedesktop.Tracker3.Writeback{,.*}}", label=tracker-writeback),
  dbus send bus=session path=/org/freedesktop/Tracker3/Writeback{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       member=GetManagedObjects
       peer=(name="{@{busname},org.freedesktop.Tracker3.Writeback{,.*}}", label=tracker-writeback),
  dbus receive bus=session path=/org/freedesktop/Tracker3/Writeback{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       member={InterfacesAdded,InterfacesRemoved}
       peer=(name="{@{busname},org.freedesktop.Tracker3.Writeback{,.*}}", label=tracker-writeback),

  @{exec_path} mr,

  @{open_path}  rpx -> child-open-help,

  @{bin}/ r,
  @{bin}/env r,
  @{python_path} rix,
  @{lib}/@{python_name}/site-packages/gnomemusic/__pycache__/{,**} rw,

  /usr/share/grilo-plugins/grl-lua-factory/{,*} r,
  /usr/share/org.gnome.Music/{,**} r,
  /usr/share/tracker3/{,**} r,

  /etc/machine-id r,

  owner @{user_music_dirs}/{,**} r,

  owner @{user_cache_dirs}/media-art/{,*} rw,
  owner @{user_share_dirs}/grilo-plugins/ rwk,
  owner @{user_share_dirs}/grilo-plugins/*.db{,-shm,-journal,-wal} rwk,

  @{att}@{run}/systemd/inhibit/@{int}.ref rw,

  owner @{tmp}/grilo-plugin-cache-[0-9A-Z]*/ rw,

        @{PROC}/sys/net/ipv6/conf/all/disable_ipv6 r,
  owner @{PROC}/@{pid}/mounts r,

  deny owner @{user_share_dirs}/gvfs-metadata/{,*} r,

  include if exists <local/gnome-music>
}

# vim:syntax=apparmor
