4

I ran the following command:

sudo setcap cap_net_raw,cap_net_admin,cap_net_bind_service+eip `which nmap`

Now I'd like to add to my ~/.zshrc a line that detects such settings and exports NMAP_PRIVILEGED=1. How could I do that?

d33tah
  • 1,371
  • 14
  • 28

1 Answers1

4

Just use getcap:

if nmap --version >/dev/null && getcap `which nmap` | grep -q cap_net_raw; then
  export NMAP_PRIVILEGED="1"
else
  echo "WARNING: No Nmap with cap_net_raw in \$PATH!" >&2
fi
d33tah
  • 1,371
  • 14
  • 28