# 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}/gsd-housekeeping
profile gsd-housekeeping @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/app-launcher-user>
  include <abstractions/bus-session>
  include <abstractions/bus/org.gnome.SessionManager>
  include <abstractions/bus/org.gtk.vfs.MountTracker>
  include <abstractions/dconf-write>
  include <abstractions/gnome-strict>
  include <abstractions/thumbnails-cache-write>

  signal (receive) set=(term, hup) peer=gdm*,
  signal (receive) set=(term, hup) peer=gnome*,

  #aa:dbus own bus=session name=org.gnome.SettingsDaemon.Housekeeping

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

  @{exec_path} mr,

  /etc/fstab r,

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

  owner @{GDM_HOME}/greeter-dconf-defaults r,
  owner @{gdm_config_dirs}/dconf/user r,
  owner @{gdm_share_dirs}/applications/ w,

  owner @{user_share_dirs}/applications/ rw,

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

  owner @{PROC}/@{pids}/cgroup r,
  owner @{PROC}/@{pids}/mountinfo r,

  owner /dev/tty@{int} rw,

  include if exists <local/gsd-housekeeping>
}

# vim:syntax=apparmor
