# 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}/cloud-init/ds-identify
profile systemd-generator-ds-identify @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/nameservice-strict>

  ptrace (read) peer=@{p_systemd},

  @{exec_path} mr,

  @{sh_path}                     rix,
  @{bin}/blkid                   rPx,
  @{bin}/systemd-detect-virt     rPx,
  @{bin}/tr                      rix,
  @{bin}/uname                   rix,

  /etc/cloud/{,**} r,

  @{run}/cloud-init/{,.}ds-identify.* rw,
  @{run}/cloud-init/cloud.cfg rw,

  @{sys}/devices/virtual/dmi/id/chassis_asset_tag r,
  @{sys}/devices/virtual/dmi/id/product_name r,
  @{sys}/devices/virtual/dmi/id/product_serial r,
  @{sys}/devices/virtual/dmi/id/product_uuid r,
  @{sys}/devices/virtual/dmi/id/sys_vendor r,

  @{PROC}/cmdline r,
  @{PROC}/uptime r,
  @{PROC}/@{pid}/environ r,

  include if exists <local/systemd-generator-ds-identify>
}


# vim:syntax=apparmor
