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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{bin}/gpgconf
profile gpgconf @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/nameservice-strict>

  capability dac_read_search,

  @{exec_path} mrix,

  @{bin}/dirmngr           rPx,
  @{bin}/gpg-agent         rPx,
  @{bin}/gpg-connect-agent rPx,
  @{bin}/gpg{,2}           rPx,
  @{bin}/gpgsm             rPx,
  @{bin}/pinentry-*        rPx,
  @{bin}/scdaemon          rPx,
  @{lib}/{,gnupg/}scdaemon rPx,
  @{lib}/keyboxd          rPUx,

  /etc/gcrypt/hwf.deny r,
  /etc/gnupg/gpgconf.conf r,

  owner @{HOME}/@{XDG_GPG_DIR}/** rwkl -> @{HOME}/@{XDG_GPG_DIR}/**,
  owner @{run}/user/@{uid}/gnupg/ w,
  owner @{run}/user/@{uid}/gnupg/** rwkl -> @{run}/user/@{uid}/gnupg/**,

  owner @{PROC}/@{pid}/task/@{tid}/stat rw,
  owner @{PROC}/@{pid}/task/@{tid}/comm rw,
  owner @{PROC}/@{pid}/fd/ r,

  /etc/inputrc r,

  # file_inherit
  owner @{HOME}/.xsession-errors w,

  include if exists <local/gpgconf>
}

# vim:syntax=apparmor
