Skip to content

Commit e4607f2

Browse files
committed
Allow offline test suite to be executed under root,
without setcap-blessed oscap binary
1 parent bcdfd1b commit e4607f2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/test_common.sh.in

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,14 @@ set_chroot_offline_test_mode() {
196196
echo "Skipping test '${FUNCNAME[1]}' as '$OSCAP_CHROOTABLE_EXEC' doesn't have the chroot capability." >&2
197197
return 255
198198
fi
199+
_OSCAP_BEFORE="$OSCAP"
200+
OSCAP="$OSCAP_CHROOTABLE"
201+
elif test $(id -u) -eq 0; then
202+
: # Running offline tests as root is acceptable too
199203
else
200204
echo "Skipping test '${FUNCNAME[1]}' as '$OSCAP_CHROOTABLE_EXEC' oscap which is supposed to have chroot capability doesn't exist." >&2
201205
return 255
202206
fi
203-
_OSCAP_BEFORE="$OSCAP"
204-
OSCAP="$OSCAP_CHROOTABLE"
205207
set_offline_chroot_dir "$1"
206208
return 0
207209
}
@@ -216,13 +218,11 @@ set_offline_chroot_dir() {
216218
}
217219

218220
unset_chroot_offline_test_mode() {
219-
if ! test -n "$_OSCAP_BEFORE"; then
220-
echo "Not in the offline test mode!" >&2
221-
return
221+
if test -n "$_OSCAP_BEFORE"; then
222+
OSCAP="$_OSCAP_BEFORE"
223+
_OSCAP_BEFORE=
222224
fi
223-
OSCAP="$_OSCAP_BEFORE"
224225
set_offline_chroot_dir ""
225-
_OSCAP_BEFORE=
226226
}
227227

228228
export -f assert_exists

0 commit comments

Comments
 (0)