#!/bin/bash # clean what was left from previous tests rm -rf ./protected mkdir protected 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 echo "Run $(date -u +%Y-%m-%dT%H:%M:%S) " valgrind -s ../build/icfs -o default_permissions ./protected & sleep 1 # Try to touch files in the directory #echo \"manual\" >./protected/manual zenity --set-fake-response no echo "first" >./protected/first 2>/dev/null && echo "[ICFS-TEST]: echo can create protected/first despite access being denied!" || echo "[ICFS-TEST]: OK" # EACCESS zenity --set-fake-response yes_tmp echo "second" >./protected/second 2>/dev/null && echo "[ICFS-TEST]: OK" || echo "[ICFS-TEST]: echo cannot create protected/second despite access being permitted!" # OK # Test whether permissons work zenity --set-fake-response yes_tmp cat ./protected/first >/dev/null 2>/dev/null && echo "[ICFS-TEST]: cat can read a non-existant file ./protected/first!" || echo "[ICFS-TEST]: OK" # ENOENT zenity --set-fake-response yes_tmp cat ./protected/second >/dev/null 2>/dev/null && echo "[ICFS-TEST]: OK" || echo "[ICFS-TEST]: cat cannot open protected/second despite access being permitted!" # "second" zenity --set-fake-response yes_tmp cat ./protected/this-only >/dev/null 2>/dev/null && echo "[ICFS-TEST]: OK" || echo "[ICFS-TEST]: echo cannot create protected/second despite access being permitted!" # "Free code, free world." #parallel ::: "cat ./protected/sudo-only > /dev/null 2> /dev/null \ # && echo \"[ICFS-TEST]: cat can access files owned by root!\" \ # || echo \"[ICFS-TEST]: OK\"" # EACCESS # test the removal zenity --set-fake-response no 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]: OK" # EACCESS zenity --set-fake-response yes_tmp rm ./protected/should-be-removed >/dev/null 2>/dev/null && echo "[ICFS-TEST]: OK" || echo "[ICFS-TEST]: rm cannot unlink protected/should-be-removed despite access being permitted!" # OK # unmount sleep 0.5 #lsof +f -- $(realpath ./protected) umount $(realpath ./protected) sleep 0.5