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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/updatectl
@{att} = /att/updatectl/
profile updatectl /{,usr/}bin/updatectl flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/base>
  include <abstractions/bus-system>
  include <abstractions/attached/consoles>

  signal send set=(cont term winch) peer=child-pager,
  signal send set=(cont term winch) peer=pkttyagent,

  unix type=stream peer=(label=systemd-sysupdated),

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

  @{exec_path} mr,

  @{bin}/pkttyagent rpx,

        @{PROC}/1/cgroup r,
        @{PROC}/sys/kernel/random/boot_id r,
  owner @{PROC}/@{pid}/cgroup r,
  owner @{PROC}/@{pid}/stat r,

  include if exists <local/updatectl>
}

# vim:syntax=apparmor
