restorecond: compatible with the use of EUID

The `EUID` does not exist in some shell environments. To ensure compatibility,
use `id -u` instead of `EUID` when `EUID` does not exist.

Signed-off-by: Huizhao Wang <wanghuizhao1@huawei.com>
Acked-by: Petr Lautrbach <lautrbach@redhat.com>
This commit is contained in:
Huizhao Wang 2023-08-05 15:06:50 +08:00 committed by James Carter
parent 6df403d597
commit ca76a8813e
1 changed files with 5 additions and 1 deletions

View File

@ -29,7 +29,11 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin
[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 7
# Check that we are root ... so non-root users stop here
test $EUID = 0 || exit 4
if [ $EUID ]; then
test $EUID = 0 || exit 4
else
test `id -u` = 0 || exit 4
fi
test -x /usr/sbin/restorecond || exit 5
test -f /etc/selinux/restorecond.conf || exit 6