# 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} = @{lib}/systemd/systemd-oomd
profile systemd-oomd @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/bus-system>
  include <abstractions/common/systemd>

  capability dac_override,
  capability kill,

  unix (bind) type=stream addr=@@{udbus}/bus/systemd-oomd/bus-api-oom,

  #aa:dbus own bus=system name=org.freedesktop.oom1

  @{exec_path} mr,

  /etc/systemd/oomd.conf r,
  /etc/systemd/oomd.conf.d/{,**} r,

  @{att}/@{run}/systemd/notify w,
  @{att}/@{run}/systemd/io.systemd.ManagedOOM rw,

  @{run}/systemd/io.system.ManagedOOM rw,
  @{run}/systemd/io.systemd.ManagedOOM rw,

  @{sys}/fs/cgroup/cgroup.controllers r,
  @{sys}/fs/cgroup/memory.* r,
  @{sys}/fs/cgroup/system.slice/memory.* r,
  @{sys}/fs/cgroup/user.slice/{,**/}memory.* r,

  @{PROC}/pressure/cpu r,
  @{PROC}/pressure/io r,
  @{PROC}/pressure/memory r,

  include if exists <local/systemd-oomd>
}

# vim:syntax=apparmor
