# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2019-2021 Mikhail Morfikov
# 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}/gpg-connect-agent
profile gpg-connect-agent /{,usr/}{,s}bin/gpg-connect-agent flags=(complain) {
  include <abstractions/base>
  include <abstractions/consoles>

  @{exec_path} mr,

  @{bin}/gpg-agent rPx,

  /etc/inputrc r,

  owner @{PROC}/@{pid}/fd/ r,

  owner @{run}/user/@{uid}/gnupg/d.*/ rw,

  owner /tmp/tmp.*/.#lk0x@{hex}.*.@{pid} rw,
  owner /tmp/tmp.*/.#lk0x@{hex}.*.@{pid}x rwl -> /tmp/*/.#lk0x@{hex}.*.@{pid},
  owner /tmp/tmp.*/gnupg_spawn_agent_sentinel.lock rwl -> /tmp/*/.#lk0x@{hex}.*.@{pid},

  include if exists <local/gpg-connect-agent>
}

