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

abi <abi/4.0>,

include <tunables/global>

@{config_dirs} = @{user_config_dirs}/protonmail/{,bridge-v3}
@{cache_dirs} = @{user_cache_dirs}/protonmail/{,bridge-v3} "@{user_cache_dirs}/Proton AG/{,Proton Mail Bridge}"
@{share_dirs} = @{user_share_dirs}/protonmail/{,bridge-v3}

@{exec_path} = @{lib}/protonmail/bridge/bridge-gui
profile protonmail-bridge @{exec_path} {
  include <abstractions/base>
  include <abstractions/dconf-write>
  include <abstractions/desktop>
  include <abstractions/graphics>
  include <abstractions/nameservice-strict>
  include <abstractions/qt5-shader-cache>

  # network inet dgram,
  # network inet6 dgram,
  network inet stream,
  network inet6 stream,
  # network netlink raw,

  @{exec_path} mr,

  @{lib}/protonmail/bridge/bridge  rPx,
  @{open_path}                     rPx -> child-open-strict,

  /etc/machine-id r,

  owner @{config_dirs}/ rw,
  owner @{config_dirs}/** rwlk -> @{config_dirs}/**,

  owner @{cache_dirs}/ rw,
  owner @{cache_dirs}/** rwlk -> @{cache_dirs}/**,

  owner @{share_dirs}/ rw,
  owner @{share_dirs}/** rwlk -> @{share_dirs}/**,

  owner @{tmp}/@{uuid}.txt w,

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

  include if exists <local/protonmail-bridge>
}

# vim:syntax=apparmor
