# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2023-2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{lib}/gnome-initial-setup
profile gnome-initial-setup @{exec_path} {
  include <abstractions/base>
  include <abstractions/bus-accessibility>
  include <abstractions/bus-session>
  include <abstractions/bus-system>
  include <abstractions/bus/org.a11y>
  include <abstractions/bus/org.freedesktop.Accounts>
  include <abstractions/bus/org.freedesktop.NetworkManager>
  include <abstractions/bus/org.gtk.vfs.MountTracker>
  include <abstractions/dconf-write>
  include <abstractions/disks-read>
  include <abstractions/gnome-strict>
  include <abstractions/graphics>
  include <abstractions/nameservice-strict>
  include <abstractions/ssl_certs>

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

  #aa:dbus own bus=session name=org.gnome.InitialSetup interface=org.gtk.Actions

  @{exec_path} mr,

  @{bin}/df      rPx,
  @{bin}/dpkg    rPx -> child-dpkg,
  @{bin}/locale  rix,
  @{bin}/lscpu   rPx,
  @{bin}/lspci   rPx,
  @{bin}/xrandr  rPx,

  @{lib}/gnome-initial-setup-goa-helper rix,

  /usr/share/dconf/profile/gdm r,
  /usr/share/gnome-initial-setup/{,**} r,
  /usr/share/xml/iso-codes/{,**} r,

  /etc/security/pwquality.conf r,
  /etc/security/pwquality.conf.d/{,**} r,
  /etc/timezone r,

  /etc/gdm{,3}/custom.conf r,

  /var/log/installer/telemetry r, #aa:only ubuntu

  owner @{GDM_HOME}/greeter-dconf-defaults r,

  #aa:only ubuntu
  owner @{user_cache_dirs}/ubuntu-report/ rw,
  owner @{user_cache_dirs}/ubuntu-report/* rw,

  owner @{user_config_dirs}/gnome-initial-setup-done w,
  owner @{user_config_dirs}/gnome-initial-setup-done.@{rand6} rw,

  owner @{user_config_dirs}/ibus/bus/ r,
  owner @{user_config_dirs}/ibus/bus/@{hex32}-unix-{,wayland-}@{int} r,

  owner @{run}/user/@{uid}/avatar.png rw,

  @{run}/snapd.socket rw,

  @{run}/systemd/sessions/@{int} r,
  @{run}/systemd/users/@{uid} r,

  owner @{sys}/fs/cgroup/user.slice/user-@{uid}.slice/user@@{uid}.service/app.slice/gnome-initial-setup-first-login.service/memory.* r,

  @{sys}/devices/virtual/dmi/id/bios_vendor r,
  @{sys}/devices/virtual/dmi/id/bios_version r,
  @{sys}/devices/virtual/dmi/id/product_family r,
  @{sys}/devices/virtual/dmi/id/product_name r,
  @{sys}/devices/virtual/dmi/id/sys_vendor r,

        @{PROC}/zoneinfo r,
  owner @{PROC}/@{pid}/cgroup r,

  include if exists <local/gnome-initial-setup>
}

# vim:syntax=apparmor
