# apparmor.d - Full set of apparmor profiles
# 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}/login
profile login @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/authentication>
  include <abstractions/bus-system>
  include <abstractions/bus/org.freedesktop.login1>
  include <abstractions/consoles>
  include <abstractions/nameservice-strict>
  include <abstractions/wutmp>

  capability audit_write,
  capability chown,
  capability dac_override,
  capability dac_read_search,
  capability fowner,
  capability fsetid,
  capability kill,
  capability net_admin,
  capability setgid,
  capability setuid,
  capability sys_resource,
  capability sys_tty_config,

  network netlink raw,

  signal (send) set=(hup term),

  ptrace read,

  @{exec_path} mr,

  @{bin}/@{shells}     rUx,

  @{etc_ro}/environment r,
  @{etc_ro}/security/limits.d/{,*} r,
  /etc/default/locale r,
  /etc/legal r,
  /etc/machine-id r,
  /etc/motd r,
  /etc/motd.d/ r,
  /etc/security/group.conf r,
  /etc/security/limits.conf r,
  /etc/security/pam_env.conf r,
  /etc/shells r,

  /var/log/btmp{,.@{int}} r,

  owner @{user_cache_dirs}/motd.legal-displayed rw,

  @{run}/motd.d/{,*} r,
  @{run}/dbus/system_bus_socket rw,
  @{run}/faillock/* rwk,
  @{run}/motd.dynamic{,.new} rw,
  @{run}/systemd/sessions/*.ref rw,

        @{PROC}/@{pids}/cgroup r,
        @{PROC}/1/limits r,
  owner @{PROC}/@{pid}/loginuid rw,
  owner @{PROC}/@{pid}/uid_map r,

  /dev/tty@{int} rw,

  include if exists <local/login>
}
