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

abi <abi/4.0>,

include <tunables/global>

@{name} = brave{,-beta,-dev,-bin}
@{lib_dirs} = /opt/brave{-bin,.com}{,/@{name}}

@{exec_path} = @{lib_dirs}/brave-browser{,-beta,-dev}
profile brave-wrapper @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>

  @{exec_path} r,

  @{sh_path}                   rix,
  @{bin}/cat                   rix,
  @{bin}/dirname               rix,
  @{bin}/mkdir                 rix,
  @{bin}/readlink              rix,
  @{bin}/touch                 rix,
  @{bin}/which{,.debianutils}  rix,

  @{lib_dirs}/brave rPx,

  owner @{PROC}/@{pid}/fd/@{int} w,

  # Silencer
  deny @{user_share_dirs}/gvfs-metadata/* r,

  include if exists <local/brave-wrapper>
}

# vim:syntax=apparmor
