mirror of
https://github.com/Kicksecure/security-misc.git
synced 2025-07-14 18:00:54 +07:00
exit non-zero if some line cannot be parsed
therefore make systemd notice this therefore allow the sysadmin to notice this
This commit is contained in:
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
|
exit_code=0
|
||||||
|
|
||||||
config_file="/etc/permission-hardening.conf"
|
config_file="/etc/permission-hardening.conf"
|
||||||
|
|
||||||
shopt -s globstar
|
shopt -s globstar
|
||||||
@ -47,11 +49,13 @@ set_file_perms() {
|
|||||||
if [[ "$line" =~ [0-9a-zA-Z/] ]]; then
|
if [[ "$line" =~ [0-9a-zA-Z/] ]]; then
|
||||||
true OK
|
true OK
|
||||||
else
|
else
|
||||||
|
exit_code=200
|
||||||
echo "ERROR: cannot parse line with invalid character: ${line}" >&2
|
echo "ERROR: cannot parse line with invalid character: ${line}" >&2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! read -r file mode owner group capability <<< "${line}" ; then
|
if ! read -r file mode owner group capability <<< "${line}" ; then
|
||||||
|
exit_code=201
|
||||||
echo "ERROR: cannot parse line: ${line}" >&2
|
echo "ERROR: cannot parse line: ${line}" >&2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -107,3 +111,5 @@ set_file_perms() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_file_perms
|
set_file_perms
|
||||||
|
|
||||||
|
exit "$exit_code"
|
||||||
|
Reference in New Issue
Block a user