2017-05-01 20:11:28 +00:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
|
|
|
export test_description="Testing common operations on tomb"
|
|
|
|
|
|
|
|
source ./setup
|
|
|
|
|
2018-09-23 21:21:05 +00:00
|
|
|
_getaccess() { stat --format=%X "$1"; }
|
|
|
|
_getmodif() { stat --format=%Y "$1"; }
|
|
|
|
|
2017-05-01 20:11:28 +00:00
|
|
|
test_export "test" # Using already generated tomb
|
|
|
|
test_expect_success 'Testing open with wrong password ' '
|
|
|
|
test_must_fail tt_open --tomb-pwd wrongpassword
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'Testing open with good password ' '
|
|
|
|
tt_open --tomb-pwd $DUMMYPASS &&
|
|
|
|
tt_close
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'Testing open in read only mode' '
|
|
|
|
chmod -w $tomb &&
|
|
|
|
tt_open --tomb-pwd $DUMMYPASS -o ro,noatime,nodev &&
|
|
|
|
tt_close &&
|
|
|
|
chmod +w $tomb
|
|
|
|
'
|
|
|
|
|
2018-09-23 21:21:05 +00:00
|
|
|
test_expect_success 'Testing tomb files stat restoration' '
|
|
|
|
access=$(_getaccess $tomb_key) &&
|
|
|
|
modif=$(_getmodif $tomb_key) &&
|
|
|
|
tt_open --tomb-pwd $DUMMYPASS &&
|
|
|
|
tt_close &&
|
|
|
|
[[ "$access" == "$(_getaccess $tomb_key)" ]] &&
|
|
|
|
[[ "$modif" == "$(_getmodif $tomb_key)" ]]
|
|
|
|
'
|
|
|
|
|
2017-05-12 18:24:49 +00:00
|
|
|
if test_have_prereq LSOF; then
|
|
|
|
gcc -Wall -o $TMP/close_block $TEST_HOME/close_block.c
|
|
|
|
test_expect_success 'Testing functionality of the slam operation (use of lsof)' '
|
|
|
|
mkdir $TMP/testmount &&
|
|
|
|
tt_open $TMP/testmount --tomb-pwd $DUMMYPASS &&
|
|
|
|
tt_set_ownership $TMP/testmount &&
|
|
|
|
$TMP/close_block $TMP/testmount/occupied 20 &
|
|
|
|
tt slam
|
|
|
|
'
|
|
|
|
fi
|
|
|
|
|
2021-04-07 18:56:19 +00:00
|
|
|
if test_have_prereq SPHINX ORACLE; then
|
|
|
|
test_export "sphinx_test" # Using already generated tomb
|
|
|
|
test_expect_success 'Testing open with good password (sphinx)' '
|
|
|
|
tt_open --tomb-pwd $DUMMYPASS --sphx-user $DUMMYUSER --sphx-host $DUMMYHOST &&
|
|
|
|
tt_close
|
|
|
|
'
|
|
|
|
fi
|
2019-03-03 16:56:26 +00:00
|
|
|
|
2021-04-07 17:20:12 +00:00
|
|
|
if test_have_prereq DOAS; then
|
|
|
|
test_export "doas_test" # Using already generated tomb
|
|
|
|
test_expect_success 'Testing open with good password (using doas instead of sudo)' '
|
|
|
|
tt_open --sudo doas --tomb-pwd $DUMMYPASS &&
|
2021-04-07 18:11:04 +00:00
|
|
|
tt_close --sudo doas
|
2021-04-07 17:20:12 +00:00
|
|
|
'
|
|
|
|
fi
|
2019-03-03 16:56:26 +00:00
|
|
|
|
2017-05-01 20:11:28 +00:00
|
|
|
test_done
|