# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2017-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}/telegram-desktop
profile telegram-desktop @{exec_path} {
  include <abstractions/base>
  include <abstractions/audio-client>
  include <abstractions/common/electron>
  include <abstractions/consoles>
  include <abstractions/enchant>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/nameservice-strict>
  include <abstractions/qt5-compose-cache-write>
  include <abstractions/qt5-settings-write>
  include <abstractions/qt5-shader-cache>
  include <abstractions/user-download-strict>

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

  @{exec_path} mrix,

  @{sh_path}             rix,

  @{open_path} rPx -> child-open,

  /usr/share/TelegramDesktop/{,**} r,

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

  owner @{user_config_dirs}/autostart/telegramdesktop.desktop rw,

  owner @{tmp}/@{hex}-* rwk,
  owner @{run}/user/@{uid}/@{hex}-* rwk,
  owner /dev/shm/#@{int} rw,

  owner @{PROC}/@{pid}/cmdline r,
  owner @{PROC}/@{pid}/fd/ r,
  owner @{PROC}/@{pid}/mountinfo r,
  owner @{PROC}/@{pid}/mounts r,

  owner /dev/tty@{int} rw,

  include if exists <local/telegram-desktop>
}

# vim:syntax=apparmor
