Compare commits
No commits in common. "66fd9ed582f3b6dc9916d9dd3523a9fe64e3f122" and "a65d37f3bc968ac48b126c3cc4c8f82368c6d2b4" have entirely different histories.
66fd9ed582
...
a65d37f3bc
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,3 @@
|
|||||||
build/*
|
build/*
|
||||||
.clang-tidy
|
.clang-tidy
|
||||||
.cache
|
.cache
|
||||||
test/protected/*
|
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# fake-zenity: script that mocks the behavior of zenity based on the ./.fake-zenity-response file
|
|
||||||
|
|
||||||
if [[ $1 == "--set-fake-response" ]]; then
|
|
||||||
#someone knows we are fake :)
|
|
||||||
echo $2 >~/.fake_zenity_response
|
|
||||||
else
|
|
||||||
if [ -f ~/.fake_zenity_response ]; then
|
|
||||||
FAKE_ZENITY_RESPONSE=$(cat ~/.fake_zenity_response)
|
|
||||||
|
|
||||||
if [[ $FAKE_ZENITY_RESPONSE == "yes_tmp" ]]; then
|
|
||||||
printf "Allow this time\n"
|
|
||||||
exit 1
|
|
||||||
elif [[ $FAKE_ZENITY_RESPONSE == "no" ]]; then
|
|
||||||
exit 1
|
|
||||||
elif [[ $FAKE_ZENITY_RESPONSE == "yes" ]]; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit -1 # TODO: call actual zenity here
|
|
@ -2,14 +2,8 @@
|
|||||||
|
|
||||||
# clean what was left from previous tests
|
# clean what was left from previous tests
|
||||||
|
|
||||||
rm -rf ./protected
|
rm ./protected/first ./protected/second
|
||||||
mkdir protected
|
touch ./protected/this-only ./protected/do-not-remove ./protected/should-be-removed
|
||||||
touch ./protected/do-not-remove ./protected/should-be-removed
|
|
||||||
echo "Free code, free world." >./protected/this-only
|
|
||||||
|
|
||||||
# set up the fake-zenity
|
|
||||||
|
|
||||||
PATH="$(realpath ./mock/):$PATH"
|
|
||||||
|
|
||||||
# mount the filesystem
|
# mount the filesystem
|
||||||
|
|
||||||
@ -18,36 +12,40 @@ valgrind -s ../build/icfs -o default_permissions ./protected &
|
|||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
|
# set up the fake-zenity
|
||||||
|
|
||||||
|
#export PATH="$(realpath ./mock/):$PATH"
|
||||||
|
|
||||||
# Try to touch files in the directory
|
# Try to touch files in the directory
|
||||||
|
|
||||||
#echo \"manual\" >./protected/manual
|
#echo \"manual\" >./protected/manual
|
||||||
|
|
||||||
zenity --set-fake-response no
|
#export FAKE_ZENITY_RESPONSE="0"
|
||||||
echo "first" >./protected/first 2>/dev/null &&
|
parallel ::: "echo \"first\" >./protected/first 2> /dev/null \
|
||||||
echo "[ICFS-TEST]: echo can create protected/first despite access being denied!" ||
|
&& echo \"[ICFS-TEST]: echo can create protected/first despite access being denied!\" \
|
||||||
echo "[ICFS-TEST]: OK" # EACCESS
|
|| echo \"[ICFS-TEST]: OK\"" \
|
||||||
|
"sleep 0.7 && xdotool key Escape" # EACCESS
|
||||||
|
|
||||||
zenity --set-fake-response yes_tmp
|
parallel ::: "echo \"second\" >./protected/second 2> /dev/null \
|
||||||
echo "second" >./protected/second 2>/dev/null &&
|
&& echo \"[ICFS-TEST]: OK\" \
|
||||||
echo "[ICFS-TEST]: OK" ||
|
|| echo \"[ICFS-TEST]: echo cannot create protected/second despite access being permitted!\"" \
|
||||||
echo "[ICFS-TEST]: echo cannot create protected/second despite access being permitted!" # OK
|
"sleep 0.7 && xdotool key KP_Enter" # OK
|
||||||
|
|
||||||
# Test whether permissons work
|
# Test whether permissons work
|
||||||
|
|
||||||
zenity --set-fake-response yes_tmp
|
parallel ::: "cat ./protected/first > /dev/null 2> /dev/null \
|
||||||
cat ./protected/first >/dev/null 2>/dev/null &&
|
&& echo \"[ICFS-TEST]: cat can read a non-existant file ./protected/first!\" \
|
||||||
echo "[ICFS-TEST]: cat can read a non-existant file ./protected/first!" ||
|
|| echo \"[ICFS-TEST]: OK\"" # ENOENT
|
||||||
echo "[ICFS-TEST]: OK" # ENOENT
|
|
||||||
|
|
||||||
zenity --set-fake-response yes_tmp
|
parallel ::: "cat ./protected/second > /dev/null 2> /dev/null \
|
||||||
cat ./protected/second >/dev/null 2>/dev/null &&
|
&& echo \"[ICFS-TEST]: OK\" \
|
||||||
echo "[ICFS-TEST]: OK" ||
|
|| echo \"[ICFS-TEST]: cat cannot open protected/second despite access being permitted!\"" \
|
||||||
echo "[ICFS-TEST]: cat cannot open protected/second despite access being permitted!" # "second"
|
"sleep 0.7 && xdotool key KP_Enter" # "second"
|
||||||
|
|
||||||
zenity --set-fake-response yes_tmp
|
parallel ::: "cat ./protected/this-only > /dev/null 2> /dev/null \
|
||||||
cat ./protected/this-only >/dev/null 2>/dev/null &&
|
&& echo \"[ICFS-TEST]: OK\" \
|
||||||
echo "[ICFS-TEST]: OK" ||
|
|| echo \"[ICFS-TEST]: echo cannot create protected/second despite access being permitted!\"" \
|
||||||
echo "[ICFS-TEST]: echo cannot create protected/second despite access being permitted!" # "Free code, free world."
|
"sleep 0.7 && xdotool key KP_Enter" # "Free code, free world."
|
||||||
|
|
||||||
#parallel ::: "cat ./protected/sudo-only > /dev/null 2> /dev/null \
|
#parallel ::: "cat ./protected/sudo-only > /dev/null 2> /dev/null \
|
||||||
# && echo \"[ICFS-TEST]: cat can access files owned by root!\" \
|
# && echo \"[ICFS-TEST]: cat can access files owned by root!\" \
|
||||||
@ -55,19 +53,16 @@ cat ./protected/this-only >/dev/null 2>/dev/null &&
|
|||||||
|
|
||||||
# test the removal
|
# test the removal
|
||||||
|
|
||||||
zenity --set-fake-response no
|
parallel ::: "rm ./protected/do-not-remove > /dev/null 2> /dev/null \
|
||||||
rm ./protected/do-not-remove >/dev/null 2>/dev/null &&
|
&& echo \"[ICFS-TEST]: rm can unlink protected/do-not-remove despite access being denied!\" \
|
||||||
echo "[ICFS-TEST]: rm can unlink protected/do-not-remove despite access being denied!" ||
|
|| echo \"[ICFS-TEST]: OK\"" \
|
||||||
echo "[ICFS-TEST]: OK" # EACCESS
|
"sleep 0.7 && xdotool key Escape" # EACCESS
|
||||||
|
|
||||||
zenity --set-fake-response yes_tmp
|
parallel ::: "rm ./protected/should-be-removed > /dev/null 2> /dev/null \
|
||||||
rm ./protected/should-be-removed >/dev/null 2>/dev/null &&
|
&& echo \"[ICFS-TEST]: OK\" \
|
||||||
echo "[ICFS-TEST]: OK" ||
|
|| echo \"[ICFS-TEST]: rm cannot unlink protected/should-be-removed despite access being permitted!\"" \
|
||||||
echo "[ICFS-TEST]: rm cannot unlink protected/should-be-removed despite access being permitted!" # OK
|
"sleep 0.7 && xdotool key KP_Enter" # OK
|
||||||
|
|
||||||
# unmount
|
# unmount
|
||||||
|
|
||||||
sleep 0.5
|
|
||||||
#lsof +f -- $(realpath ./protected)
|
|
||||||
umount $(realpath ./protected)
|
umount $(realpath ./protected)
|
||||||
sleep 0.5
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user