# AppArmor profile that lets Sushi (the AppImage, or the .deb installed under /opt/Sushi) create the
# unprivileged user namespace that its Electron sandbox is built on.
#
# Ubuntu 23.10 and later, and Debian 13, restrict unprivileged user namespaces by default. Without
# a profile the sandbox cannot start and Sushi exits during launch. This profile is the answer,
# never `--no-sandbox`: switching the sandbox off would remove the boundary between a renderer and
# the rest of the computer, which is the reason the boundary exists.
#
# The .deb installs this file for you (electron-builder.yml, linux.deb.appArmorProfile) and removes it
# again on uninstall. For an AppImage, install it as root, then reload AppArmor:
#
#   sudo install -m 0644 sushi.apparmor /etc/apparmor.d/sushi
#   sudo systemctl reload apparmor
#
# The attachment path below covers the .deb's program (/opt/Sushi/sushi) and the usual places to
# keep an AppImage. If you keep yours somewhere else, edit the path to match before you install
# the profile.

abi <abi/4.0>,
include <tunables/global>

profile sushi "/{{home/*/{Applications,Desktop,Downloads,.local/bin},opt/Sushi}/Sushi*.AppImage,opt/Sushi/sushi}" flags=(unconfined) {
  userns,
  include if exists <local/sushi>
}
