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

include <tunables/global>

@{exec_path} = @{bin}/chpasswd
profile chpasswd /{,usr/}{,s}bin/chpasswd flags=(complain) {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/nameservice-strict>

  capability chown,
  capability fsetid,
  capability setuid,

  @{exec_path} mr,

  /etc/.pwd.lock wk,
  /etc/login.defs r,
  /etc/passwd rw,
  /etc/passwd.@{int} w,
  /etc/passwd.lock l -> /etc/passwd.@{int},
  /etc/passwd.lock w,
  /etc/shadow rw,
  /etc/shadow- w,
  /etc/shadow.@{int} w,
  /etc/shadow.lock l -> /etc/shadow.@{int},
  /etc/shadow.lock w,
  /etc/shadow+ rw,

  include if exists <local/chpasswd>
}
