#!/usr/bin/env bash
## kola:
##   # This test only runs on FCOS because `systemd-resolved` is not installed on
##   # RHCOS
##   distros:  fcos
##   exclusive: false
##   description: Verify that the stub-resolv.conf file has the correct
##     selinux context.

# See
# - https://github.com/fedora-selinux/selinux-policy/pull/509#issuecomment-744540382
# - https://github.com/systemd/systemd/pull/17976

set -xeuo pipefail

# shellcheck disable=SC1091
. "$KOLA_EXT_DATA/commonlib.sh"

context=$(stat --format "%C" /run/systemd/resolve/stub-resolv.conf)
if [ "$context" != "system_u:object_r:net_conf_t:s0" ]; then
    fatal "SELinux context on stub-resolv.conf is wrong"
fi
ok "SELinux context on stub-resolv.conf is correct"
