# 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/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/nm-online
@{att} = /att/nm-online/
profile nm-online /{,usr/}bin/nm-online  flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/base>
  include <abstractions/bus-system>
  include <abstractions/bus/org.freedesktop.NetworkManager>
  include <abstractions/attached/consoles>

  dbus receive bus=system path=/org/freedesktop/NetworkManager/ActiveConnection/@{int}
       interface=org.freedesktop.NetworkManager.Connection.Active
       member=StateChanged
       peer=(name=@{busname}, label=NetworkManager),

  dbus send bus=system path=/org/freedesktop/NetworkManager/Settings/@{int}
       interface=org.freedesktop.NetworkManager.Settings.Connection
       member=GetSettings
       peer=(name=@{busname}, label=NetworkManager),

  @{exec_path} mr,

  include if exists <local/nm-online>
}

# vim:syntax=apparmor
