add sanity test: count if we really processed all files

This commit is contained in:
Patrick Schleizer 2019-12-20 09:59:28 -05:00
parent e28da89253
commit 50b8f65490
No known key found for this signature in database
GPG Key ID: CB8D50BB77BB3C48

View File

@ -18,11 +18,12 @@ echo_wrapper() {
add_nosuid_statoverride_entry() {
fso_to_process="${fso_without_trailing_slash}/"
counter=0
should_be_counter="$(find "$fso_to_process" | wc -l)"
counter_actual=0
while read -r line; do
true "line: $line"
counter="$(( counter + 1 ))"
counter_actual="$(( counter_actual + 1 ))"
arr=($line)
@ -123,7 +124,13 @@ add_nosuid_statoverride_entry() {
## https://forums.whonix.org/t/kernel-hardening/7296/326
done < <( find "$fso_to_process" -print0 | xargs -I{} -0 stat -c "%n %a %U %G" {} )
echo "INFO: fso_to_process: '$fso_to_process' | counter: '$counter'"
## Sanity test.
if [ ! "$should_be_counter" = "$counter_actual" ]; then
echo "INFO: fso_to_process: '$fso_to_process' | counter_actual : '$counter_actual'"
echo "INFO: fso_to_process: '$fso_to_process' | should_be_counter: '$should_be_counter'"
exit_code=202
echo "ERROR: counter does not check out." >&2
fi
}
set_file_perms() {