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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{lib}/msgcollector/msgdispatcher
profile msgdispatcher @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/nameservice-strict>

  @{exec_path} mr,

  @{sh_path}                  rix,
  @{bin}/basename             rix,
  @{bin}/flock                rix,
  @{bin}/inotifywait          rix,
  @{bin}/mkdir                rix,
  @{bin}/mkfifo               rix,
  @{bin}/rm                   rix,
  @{bin}/cat                  rix,
  @{bin}/sleep                rix,
  @{bin}/touch                rix,
  @{bin}/whoami               rix,
  @{bin}/sudo                 rCx -> sudo,

  @{lib}/msgcollector/* r,
  @{lib}/msgcollector/msgdispatcher_dispatch_x rPx,

  owner @{HOME}/.xsession-errors w,

        @{run}/msgcollector/ r,
  owner @{run}/msgcollector/user/{,**} rwk,

  profile sudo {
    include <abstractions/base>
    include <abstractions/app/sudo>

    @{bin}/sudo mr,
    @{lib}/msgcollector/* rPx,

    owner @{run}/msgcollector/user/msgdispatcher_x_* r,

    include if exists <local/msgdispatcher_sudo>
  }

  include if exists <local/msgdispatcher>
}

# vim:syntax=apparmor
