# 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}/agetty
profile agetty @{exec_path} {
  include <abstractions/base>
  include <abstractions/nameservice-strict>
  include <abstractions/wutmp>

  capability checkpoint_restore,
  capability fsetid,
  capability sys_admin,
  capability sys_tty_config,
  capability chown,

  network netlink raw,

  @{exec_path} mr,

  @{bin}/login rPx,

  @{etc_rw}/issue r,
  /{,usr/}lib/os-release r,
  /{etc,run,lib,usr/lib}/issue r,
  /{etc,run,lib,usr/lib}/issue.d/{,*} r,
  /etc/inittab r,
  /etc/login.defs r,
  /etc/login.defs.d/{,*} r,
  /etc/os-release r,
  /usr/etc/login.defs r,

        @{run}/credentials/getty@tty@{int}.service/ r,
        @{run}/credentials/serial-getty@ttyS@{int}.service/ r,
  owner @{run}/agetty.reload rw,

        /dev/tty@{int}   rw,
  owner /dev/ttyGS@{int} rw,
  owner /dev/ttyS@{int}  rw,

  include if exists <local/agetty>
}

# vim:syntax=apparmor
