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

abi <abi/3.0>,

include <tunables/global>

@{name} = signal-desktop{,-beta}
@{lib_dirs} = @{lib}/signal-desktop "/opt/Signal{, Beta}"
@{config_dirs} = "@{user_config_dirs}/Signal{, Beta}"
@{cache_dirs} = @{user_cache_dirs}/@{name}

@{exec_path} = @{lib_dirs}/@{name}
profile signal-desktop @{exec_path} {
  include <abstractions/base>
  include <abstractions/audio-client>
  include <abstractions/common/electron>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/user-download-strict>

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

  @{exec_path} mrix,

  @{bin}/getconf rix,
  @{bin}/xdg-settings rPx,

  @{lib_dirs}/chrome-sandbox rPx,
  @{lib_dirs}/chrome_crashpad_handler rix,

  /var/lib/dbus/machine-id r,
  /etc/machine-id r,

  @{run}/systemd/inhibit/*.ref rw,

  @{sys}/fs/cgroup/user.slice/user-@{uid}.slice/session-@{int}.scope/cpu.max r,
  @{sys}/fs/cgroup/user.slice/user-@{uid}.slice/session-@{int}.scope/memory.high r,
  @{sys}/fs/cgroup/user.slice/user-@{uid}.slice/session-@{int}.scope/memory.max r,

  @{PROC}/@{pid}/fd/ r,
  @{PROC}/vmstat r,

  include if exists <local/signal-desktop>
}

# vim:syntax=apparmor
