Make the main field count check in permission-hardener a bit more elegant

This commit is contained in:
Aaron Rainbolt 2025-01-02 20:41:40 -05:00
parent 895c0f541f
commit 93ebf176c5
No known key found for this signature in database
GPG Key ID: A709160D73C79109

View File

@ -410,13 +410,14 @@ load_state() {
IFS=' ' read -r -a field_list <<< "${line}"
if (( ${#field_list[@]} != 2 )) \
&& (( ${#field_list[@]} != 4 )) \
&& (( ${#field_list[@]} != 5 )); then
exit_code=200
log error "Line contains an invalid number of fields: '${line}'" >&2
exit "${exit_code}"
fi
case "${#field_list[@]}" in
2|4|5) true;;
*)
exit_code=200
log error "Line contains an invalid number of fields: '${line}'" >&2
exit "${exit_code}"
;;
esac
# Strip trailing slash if appropriate
field_list[0]="${field_list[0]%/}"