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

abi <abi/4.0>,

include <tunables/global>

@{name} = firefox{,.sh,-esr,-bin}
@{lib_dirs} = @{lib}/@{name} /opt/@{name}
@{config_dirs} = @{HOME}/.mozilla/
@{cache_dirs} = @{user_cache_dirs}/mozilla/

@{exec_path} = @{lib_dirs}/crashhelper
@{att} = /att/firefox-crashhelper/
profile firefox-crashhelper /{{,usr/}lib{,exec,32,64}/firefox{,.sh,-esr,-bin}/crashhelper,opt/firefox{,.sh,-esr,-bin}/crashhelper}  flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/base>

  unix type=seqpacket peer=(label=firefox),

  @{exec_path} mr,

  owner "@{config_dirs}/firefox/Crash Reports/" rw,
  owner "@{config_dirs}/firefox/Crash Reports/crash_helper_server.log" rw,

  # file_inherit
  deny owner @{user_share_dirs}/gnome-shell/session.gvdb rw,

  include if exists <local/firefox-crashhelper>
}

# vim:syntax=apparmor
