Closed mgedmin closed 5 years ago
Here's a working implementation
check_ownership() {
info_check check_ownership "$@"
user=${1%:*}
group=${1#*:}
filename=$2
if [ -n "$user" ]; then
actual_user=$(stat -c %U $filename)
[ "$user" = "$actual_user" ] || warn "$filename: bad ownership ($actual_user instead of $user)"
fi
if [ -n "$group" ]; then
actual_group=$(stat -c %G $filename)
[ "$group" = "$actual_group" ] || warn "$filename: bad group ownership ($actual_user instead of $user)"
fi
}
It lacks some error handling perhaps.
I don't currently need this.
I want to check for incorrect file permissions. Scifi: