# 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/3.0>,

include <tunables/global>

@{exec_path} = @{lib}/{,evolution-data-server/}evolution-source-registry
profile evolution-source-registry @{exec_path} {
  include <abstractions/base>
  include <abstractions/bus-session>
  include <abstractions/bus/org.gtk.vfs.MountTracker>
  include <abstractions/dconf-write>
  include <abstractions/nameservice-strict>
  include <abstractions/p11-kit>
  include <abstractions/ssl_certs>

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

  #aa:dbus own bus=session name=org.gnome.evolution.dataserver.Sources@{int}

  dbus receive bus=session path=/org/gnome/evolution/dataserver/SourceManager{,/**}
       interface={org.freedesktop.DBus.ObjectManager,org.freedesktop.DBus.Properties}
       peer=(name=:*),
  dbus receive bus=session path=/org/gnome/evolution/dataserver/SourceManager{,/**}
       interface=org.gnome.evolution.dataserver.Source{,.*}
       peer=(name=:*),
  dbus send bus=session path=/org/gnome/evolution/dataserver/SourceManager{,/**}
       interface=org.freedesktop.DBus.Properties
       peer=(name=org.freedesktop.DBus),

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

  dbus send bus=session path=/org/gnome/OnlineAccounts
       interface=org.freedesktop.DBus.ObjectManager
       member=GetManagedObjects
       peer=(name=:*, label=goa-daemon),

  @{exec_path} mr,

  /usr/share/glib-2.0/schemas/gschemas.compiled r,

  owner @{user_cache_dirs}/evolution/{,**} rwk,
  owner @{user_config_dirs}/evolution/sources/{,*} rw,
  owner @{user_share_dirs}/evolution/{,**} r,
  owner @{user_share_dirs}/gvfs-metadata/{,*} r,

  owner @{user_config_dirs}/evolution/{,**/} w,
  owner @{user_share_dirs}/evolution/{,**/} w,

  @{PROC}/sys/kernel/osrelease r,
  @{PROC}/cmdline r,

  include if exists <local/evolution-source-registry>
}
