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

abi <abi/4.0>,

include <tunables/global>

@{exec_path}  = @{bin}/Xwayland
profile xwayland /{,usr/}{,s}bin/Xwayland  flags=(attach_disconnected,complain) {
  include <abstractions/base>
  include <abstractions/nameservice-strict>
  include <abstractions/graphics>
  include <abstractions/X-strict>

  signal (receive) set=(term hup) peer=gdm*,
  signal (receive) set=(term hup) peer=gnome-shell,
  signal (receive) set=(term hup) peer=kwin_wayland,
  signal (receive) set=(term hup) peer=login,

  unix (send,receive) type=stream addr=none peer=(label=gnome-shell),

  @{exec_path} mrix,

  @{sh_path}        rix,
  @{bin}/xkbcomp    rPx,

  /usr/share/fonts/{,**} r,
  /usr/share/ghostscript/fonts/{,**} r,

  owner /tmp/server-@{int}.xkm rwk,
  owner @{run}/user/@{uid}/.mutter-Xwaylandauth.@{rand6} rw,
  owner @{run}/user/@{uid}/server-@{int}.xkm rw,
  owner @{run}/user/@{uid}/xwayland-shared-@{rand6} rw,

  @{PROC}/@{pids}/cmdline r,

  /dev/tty@{int} rw,
  /dev/tty rw,

  include if exists <local/xwayland>
}
