# 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>

@{exec_path} = @{bin}/nmap
profile nmap @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/nameservice-strict>

  capability net_bind_service,
  capability net_raw,

  network inet dgram,
  network inet6 dgram,
  network inet stream,
  network inet6 stream,
  network inet raw,
  network inet6 raw,
  network netlink raw,
  network packet raw,

  signal (receive) set=(term, kill) peer=zenmap,

  @{exec_path} mr,

  /usr/share/nmap/** r,

  owner @{tmp}/zenmap-stdout-* rw,
  owner @{tmp}/zenmap-*.xml rw,

  owner @{PROC}/@{pid}/net/dev r,
  owner @{PROC}/@{pid}/net/if_inet6 r,
  owner @{PROC}/@{pid}/net/ipv6_route r,
  owner @{PROC}/@{pid}/net/route r,

  # unprivileged
#  @{PROC}/@{pid}/net/dev r,
#  @{PROC}/@{pid}/net/if_inet6 r,
#  @{PROC}/@{pid}/net/route r,
#  @{PROC}/@{pid}/net/ipv6_route r,

  include if exists <local/nmap>
}

# vim:syntax=apparmor
