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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{bin}/update-initramfs
profile update-initramfs @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>

  ptrace (read) peer=unconfined,

  @{exec_path} rix,
  @{sh_path}           rix,

  @{bin}/             r,

  @{bin}/cat           rix,
  @{bin}/{m,g,}awk     rix,
  @{bin}/getopt        rix,
  @{bin}/ischroot      rix,
  @{bin}/ln            rix,
  @{bin}/mv            rix,
  @{bin}/rm            rix,
  @{bin}/sha1sum       rix,
  @{bin}/sync          rix,
  @{bin}/uname         rix,

  @{bin}/dpkg-trigger  rPx,
  @{bin}/linux-version rPx,
  @{bin}/mkinitramfs  rPx,

  /var/lib/initramfs-tools/* w,

  # For shell pwd
  / r,
  /etc/ r,
  /root/ r,

  /etc/initramfs-tools/update-initramfs.conf r,

        @{PROC}/1/mountinfo r,
  owner @{PROC}/@{pid}/mountinfo r,
  owner @{PROC}/@{pid}/mounts r,

  owner /boot/ r,
  owner /boot/initrd.img-* rw,
  owner /boot/initrd.img-*.dpkg-bak rwl -> /boot/initrd.img-*,

  include if exists <local/update-initramfs>
}

# vim:syntax=apparmor
