193 lines
5.3 KiB
Text
193 lines
5.3 KiB
Text
# apparmor.d - Full set of apparmor profiles
|
|
# Copyright (C) 2019-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>
|
|
|
|
@{DISCORD_LIBDIR} = /usr/share/discord
|
|
@{DISCORD_LIBDIR} += /usr/share/discord-ptb /opt/discord
|
|
@{DISCORD_HOMEDIR} = @{user_config_dirs}/discord
|
|
@{DISCORD_HOMEDIR} += @{user_config_dirs}/discordptb
|
|
@{DISCORD_CACHEDIR} = @{user_cache_dirs}/discord
|
|
|
|
@{exec_path} = @{DISCORD_LIBDIR}/Discord{,PTB} @{bin}/discord{,-ptb}
|
|
profile discord @{exec_path} {
|
|
include <abstractions/base>
|
|
include <abstractions/consoles>
|
|
include <abstractions/opencl-intel>
|
|
include <abstractions/gtk>
|
|
include <abstractions/freedesktop.org>
|
|
include <abstractions/fonts>
|
|
include <abstractions/fontconfig-cache-read>
|
|
include <abstractions/nameservice-strict>
|
|
include <abstractions/audio>
|
|
include <abstractions/mesa>
|
|
include <abstractions/user-download-strict>
|
|
include <abstractions/thumbnails-cache-read>
|
|
include <abstractions/chromium-common>
|
|
|
|
# userns,
|
|
|
|
signal (send) set=(kill, term) peer=@{profile_name}//lsb_release,
|
|
|
|
# Needed for Game Activity
|
|
deny capability sys_ptrace,
|
|
deny ptrace (read),
|
|
|
|
network inet dgram,
|
|
network inet6 dgram,
|
|
network inet stream,
|
|
network inet6 stream,
|
|
network netlink raw,
|
|
|
|
@{exec_path} mrix,
|
|
|
|
@{sh_path} rix,
|
|
|
|
@{bin}/xdg-open rCx -> open,
|
|
#@{bin}/lsb_release rCx -> lsb_release,
|
|
#@{bin}/xdg-mime rCx -> xdg-mime,
|
|
deny @{bin}/lsb_release mrx,
|
|
deny @{bin}/xdg-mime mrx,
|
|
|
|
@{DISCORD_LIBDIR}/ r,
|
|
@{DISCORD_LIBDIR}/** r,
|
|
# @{DISCORD_LIBDIR}/**.so mr,
|
|
@{DISCORD_LIBDIR}/libEGL.so mr,
|
|
@{DISCORD_LIBDIR}/libGLESv2.so mr,
|
|
@{DISCORD_LIBDIR}/libffmpeg.so mr,
|
|
# @{DISCORD_LIBDIR}/swiftshader/libEGL.so mr,
|
|
# @{DISCORD_LIBDIR}/swiftshader/libGLESv2.so mr,
|
|
@{DISCORD_LIBDIR}/chrome-sandbox rPx,
|
|
|
|
owner @{DISCORD_HOMEDIR}/ rw,
|
|
owner @{DISCORD_HOMEDIR}/** rwk,
|
|
owner @{DISCORD_HOMEDIR}/@{int}/modules/discord_[a-z]*/*.node mrwk,
|
|
owner @{DISCORD_HOMEDIR}/@{int}/modules/discord_[a-z]*/lib*.so.[0-9] mrw,
|
|
|
|
# Reading of the /proc/ dir is needed to start discord.
|
|
# Otherwise it returns the following error:
|
|
# [:FATAL:proc_util.cc(36)] : Permission denied (13)
|
|
@{PROC}/ r,
|
|
owner @{PROC}/@{pid}/fd/ r,
|
|
deny @{PROC}/vmstat r,
|
|
deny owner @{PROC}/@{pid}/oom_{,score_}adj rw,
|
|
owner @{PROC}/@{pids}/clear_refs w,
|
|
owner @{PROC}/@{pids}/task/ r,
|
|
@{PROC}/@{pids}/task/@{tid}/status r,
|
|
deny @{PROC}/@{pids}/stat r,
|
|
# Needed to remove the following error:
|
|
# Error occurred in handler for 'DISCORD_PROCESS_UTILS_GET_MEMORY_INFO': [Error: Failed to
|
|
# create memory dump]
|
|
owner @{PROC}/@{pids}/statm r,
|
|
#
|
|
deny @{PROC}/@{pids}/cmdline r,
|
|
@{PROC}/sys/kernel/yama/ptrace_scope r,
|
|
@{PROC}/sys/fs/inotify/max_user_watches r,
|
|
owner @{PROC}/@{pid}/mountinfo r,
|
|
owner @{PROC}/@{pid}/mounts r,
|
|
|
|
/etc/fstab r,
|
|
|
|
deny @{sys}/devices/system/cpu/cpufreq/policy[0-9]/cpuinfo_max_freq r,
|
|
deny @{sys}/devices/virtual/tty/tty@{int}/active r,
|
|
# To remove the following error:
|
|
# pcilib: Cannot open /sys/bus/pci/devices/0000:03:00.0/irq: Permission denied
|
|
@{sys}/devices/@{pci}/irq r,
|
|
|
|
deny /dev/ r,
|
|
|
|
owner /tmp/net-export/ rw,
|
|
owner /tmp/discord.sock rw,
|
|
owner "/tmp/Discord Crashes/" rw,
|
|
|
|
owner @{run}/user/@{uid}/discord-ipc-[0-9] rw,
|
|
|
|
/var/lib/dbus/machine-id r,
|
|
/etc/machine-id r,
|
|
|
|
# Allowed apps to open
|
|
@{lib}/firefox/firefox rPx,
|
|
|
|
# file_inherit
|
|
owner /dev/tty@{int} rw,
|
|
|
|
|
|
profile xdg-mime {
|
|
include <abstractions/base>
|
|
include <abstractions/freedesktop.org>
|
|
|
|
@{bin}/xdg-mime mr,
|
|
|
|
@{sh_path} rix,
|
|
@{bin}/{m,g,}awk rix,
|
|
@{bin}/cut rix,
|
|
@{bin}/{,e}grep rix,
|
|
@{bin}/head rix,
|
|
@{bin}/sed rix,
|
|
|
|
# file_inherit
|
|
/usr/share/discord/** r,
|
|
owner /dev/shm/.org.chromium.Chromium.* rw,
|
|
owner @{user_config_dirs}/discord/GPUCache/data_[0-9] rw,
|
|
owner @{user_config_dirs}/discord/*/modules/discord_desktop_core/core.asar r,
|
|
owner @{user_config_dirs}/discord/GPUCache/index rw,
|
|
|
|
}
|
|
|
|
profile lsb_release {
|
|
include <abstractions/base>
|
|
include <abstractions/consoles>
|
|
include <abstractions/python>
|
|
|
|
signal (receive) set=(kill, term) peer=discord,
|
|
|
|
@{bin}/lsb_release r,
|
|
@{bin}/python3.@{int} r,
|
|
|
|
@{bin}/ r,
|
|
@{bin}/apt-cache rPx,
|
|
|
|
owner @{PROC}/@{pid}/fd/ r,
|
|
|
|
/etc/debian_version r,
|
|
/etc/dpkg/origins/debian r,
|
|
/usr/share/distro-info/debian.csv r,
|
|
|
|
# file_inherit
|
|
deny /usr/share/discord/** r,
|
|
deny owner /dev/shm/.org.chromium.Chromium.* rw,
|
|
deny owner @{user_config_dirs}/discord/GPUCache/data_[0-9] rw,
|
|
deny owner @{user_config_dirs}/discord/*/modules/discord_desktop_core/core.asar r,
|
|
deny owner @{user_config_dirs}/discord/GPUCache/index rw,
|
|
|
|
}
|
|
|
|
profile open {
|
|
include <abstractions/base>
|
|
include <abstractions/xdg-open>
|
|
|
|
@{bin}/xdg-open mr,
|
|
|
|
@{sh_path} rix,
|
|
@{bin}/{m,g,}awk rix,
|
|
@{bin}/readlink rix,
|
|
@{bin}/basename rix,
|
|
|
|
owner @{HOME}/ r,
|
|
|
|
owner @{run}/user/@{uid}/ r,
|
|
|
|
# Allowed apps to open
|
|
@{lib}/firefox/firefox rPx,
|
|
|
|
# file_inherit
|
|
owner @{HOME}/.xsession-errors w,
|
|
|
|
}
|
|
|
|
include if exists <local/discord>
|
|
}
|