#!/bin/bash
#
# Capabilities get lost when creating the fai base.tar.xz image.
# Restore them here.
#

set -e

if [ -x $target/sbin/setcap ] ; then
    for FILE in /bin/ping /usr/bin/arping ; do
        if [ -x $target/$FILE ] ; then
            $ROOTCMD /sbin/setcap cap_net_raw+ep $FILE
        fi
    done
    if [ -x $target/usr/bin/systemd-detect-virt ] ; then
        $ROOTCMD /sbin/setcap cap_dac_override,cap_sys_ptrace+ep /usr/bin/systemd-detect-virt
    fi
fi
