# 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/3.0>,

include <tunables/global>

@{lib_dirs} = @{HOME}/.tb/tor-browser/Browser/

@{exec_path} = @{lib_dirs}/start-tor-browser
profile torbrowser-start @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>

  @{exec_path} rm,

  @{bin}/bash                 rix,
  @{bin}/cp                   rix,
  @{bin}/dirname              rix,
  @{bin}/env                  r,
  @{bin}/expr                 rix,
  @{bin}/file                 rix,
  @{bin}/getconf              rix,
  @{bin}/grep                 rix,
  @{bin}/id                   rix,
  @{bin}/ln                   rix,
  @{bin}/mkdir                rix,
  @{bin}/rm                   rix,
  @{bin}/sed                  rix,
  @{bin}/sh                   rix,
  @{lib_dirs}/abicheck        rix,

  @{lib_dirs}/firefox{,.real} rPx,

  /etc/magic r,

  owner @{lib_dirs}/.config/ibus/{,**} rw,
  owner @{lib_dirs}/.local/* rw,
  owner @{lib_dirs}/sed@{rand6} rw,
  owner @{lib_dirs}/start-tor-browser.desktop rw,
  owner @{lib_dirs}/TorBrowser/Tor/tor r,

  owner @{HOME}/.tb/tor-browser/* rw,

  include if exists <local/torbrowser-start>
}
