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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{lib}/gcr-ssh-agent
@{att} = /att/gcr-ssh-agent/
profile gcr-ssh-agent /{,usr/}lib{,exec,32,64}/gcr-ssh-agent flags=(attach_disconnected,attach_disconnected.path=@{att}) {
  include <abstractions/attached/base>

  @{exec_path} mr,

  @{bin}/ssh-agent  rpx,
  @{bin}/ssh-add    rix,

  owner @{HOME}/@{XDG_SSH_DIR}/{,*} r,

  owner @{run}/user/@{uid}/gcr/.ssh rw,
  owner @{run}/user/@{uid}/gcr/ssh rw,
  owner @{run}/user/@{uid}/ssh-askpass.@{rand6}/{,*} rw,

  include if exists <local/gcr-ssh-agent>
}

# vim:syntax=apparmor
