# 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}/localectl
@{att} = /att/localectl/
profile localectl /{,usr/}bin/localectl  flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/base>
  include <abstractions/common/systemd>
  include <abstractions/bus-system>

  capability net_admin,

  signal send set=cont peer=child-pager,

  unix type=stream addr=none peer=(label="@{p_systemd_localed}", addr=none),

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

  @{exec_path} mr,

  @{pager_path} rpx -> child-pager,
  @{bin}/pkttyagent rpx,

  /usr/share/kbd/keymaps/{,**} r,

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

  include if exists <local/localectl>
}

# vim:syntax=apparmor
