# 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}/systemd-tmpfiles
profile systemd-tmpfiles @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/common/systemd>
  include <abstractions/nameservice-strict>

  capability chown,
  capability dac_override,
  capability dac_read_search,
  capability fowner,
  capability fsetid,
  capability mknod,
  capability net_admin,
  capability sys_resource,
  capability syslog,

  @{exec_path} mr,

  /etc/machine-id r,
  /etc/brlapi.key w,

  # Config file locations
  /etc/tmpfiles.d/{,*.conf} r,
  @{run}/tmpfiles.d/{,*.conf} r,
  /usr/lib/tmpfiles.d/{,*.conf} r,
  @{user_config_dirs}/user-tmpfiles.d/{,*.conf} r,
  @{run}/user/@{uid}/user-tmpfiles.d/{,*.conf} r,
  @{user_share_dirs}/user-tmpfiles.d/{,*.conf} r,
  /usr/share/user-tmpfiles.d/{,*.conf} r,

  # Where the tmpfiles can be created,
  /{,*} rw,
  /dev/{,**} rw,
  /etc/{,**} rw,
  /home/ rw,
  /opt/{,**} rw,
  /run/{,**} rw,
  /srv/{,**} rw,
  /tmp/{,**} rwk,
  /usr/{,**} rw,
  /var/{,**} rwk,
  @{sys}/kernel/security/ r,
  @{sys}/kernel/security/{,**} rw,

  @{sys}/class/net/ r,
  @{sys}/devices/system/cpu/microcode/reload w,

  @{PROC}/@{pid}/net/unix r,
  @{PROC}/1/cmdline r,
  @{PROC}/sched_debug w,

  include if exists <local/systemd-tmpfiles>
}

# vim:syntax=apparmor
