# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2018-2022 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>

@{exec_path} = @{bin}/chromium
@{att} = /att/chromium-wrapper/
profile chromium-wrapper /{,usr/}bin/chromium  flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/base>
  include <abstractions/freedesktop.org>
  include <abstractions/mesa>

  @{exec_path} r,

  @{lib}/chromium/chromium rpx,

  @{sh_path}        rix,
  @{bin}/{,e}grep   rix,
  @{bin}/cat        rix,
  @{bin}/cut        rix,
  @{bin}/expr       rix,
  @{bin}/ls         rix,
  @{bin}/mktemp     rix,
  @{bin}/rm         rix,
  @{bin}/sed        rix,
  @{bin}/tr         rix,
  @{bin}/uname      rix,

  @{bin}/man       rpux, #  For "chromium --help"
  # @{bin}/gdb   rpux,

  /usr/share/chromium/extensions/ r,

  /etc/chromium.d/{,*} r,
  /etc/debian_version r,

  owner @{HOME}/.xsession-errors w,

  owner @{tmp}/chromiumargs.@{rand6} rw,

  owner /dev/tty@{int} rw,

  # Silencer
  deny @{user_share_dirs}/gvfs-metadata/* r,
  deny @{user_share_dirs}/gnome-shell/session.gvdb rw,

  include if exists <local/chromium-wrapper>
}

# vim:syntax=apparmor
