# 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
@{att} = ""
profile gpg-connect-agent /{,usr/}bin/gpg-connect-agent flags=(complain) {
  include <abstractions/base-strict>
  include <abstractions/consoles>

  @{exec_path} mr,

  @{bin}/gpg-agent rpx,

  /etc/inputrc r,

  owner @{run}/user/@{uid}/gnupg/ w,
  owner @{run}/user/@{uid}/gnupg/d.*/ rw,
  owner @{run}/user/@{uid}/gnupg/d.*/S.gpg-agent rw,
  owner @{run}/user/@{uid}/gnupg/S.dirmngr rw,
  owner @{run}/user/@{uid}/gnupg/S.gpg-agent 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},

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

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


# vim:syntax=apparmor
