use read (built-in) rather than awk (external)

This commit is contained in:
Patrick Schleizer 2019-12-09 02:31:10 -05:00
parent 02165201ab
commit c258376b7e
No known key found for this signature in database
GPG Key ID: CB8D50BB77BB3C48

9
usr/lib/security-misc/permission-hardening Normal file → Executable file
View File

@ -6,11 +6,10 @@ set_file_perms() {
while read -r line; do
[[ "$line" =~ ^#.*$ ]] && continue
file="$(awk '{print $1}' <<< ${line})"
mode="$(awk '{print $2}' <<< ${line})"
owner="$(awk '{print $3}' <<< ${line})"
group="$(awk '{print $4}' <<< ${line})"
capability="$(awk '{print $5}' <<< ${line})"
if ! read -r file mode owner group capability <<< "${line}" ; then
echo "ERROR: cannot parse line: ${line}"
continue
fi
if ! [ -e "${file}" ]; then
echo "ERROR: File '${file}' does not exist!"