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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{bin}/qtox
profile qtox @{exec_path} {
  include <abstractions/base>
  include <abstractions/audio-client>
  include <abstractions/desktop>
  include <abstractions/enchant>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/graphics>
  include <abstractions/nameservice-strict>
  include <abstractions/qt5>
  include <abstractions/qt5-settings-write>
  include <abstractions/user-download-strict>

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

  @{exec_path} mr,

  @{open_path}  rPx -> child-open,

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

  # For importing old profile
  owner @{HOME}/**.tox r,
  owner @{MOUNTS}/**.tox r,

  owner @{HOME}/ r,
  owner @{user_cache_dirs}/qTox/ rw,
  owner @{user_cache_dirs}/qTox/qtox.log rw,

  owner @{user_config_dirs}/tox/ rw,
  owner @{user_config_dirs}/tox/** rwkl -> @{user_config_dirs}/tox/**,

  owner @{user_config_dirs}/autostart/qTox*.desktop rw,

  owner @{user_share_dirs}/qTox/ rw,
  owner @{user_share_dirs}/qTox/** rw,

  owner @{PROC}/@{pid}/cmdline r,
        @{PROC}/sys/kernel/core_pattern r,  # for KCrash::initialize()

  owner @{tmp}/qipc_{systemsem,sharedmemory}_*@{hex} rw,

  /dev/ r,
  /dev/video@{int} rw,

  include if exists <local/qtox>
}
