我运行了以下命令:
sudo setcap cap_net_raw,cap_net_admin,cap_net_bind_service+eip `which nmap`
现在我想添加一行来~/.zshrc
检测此类设置并导出NMAP_PRIVILEGED=1
。我怎么能这么做呢?
答案1
只需使用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