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 while read -r line; do
[[ "$line" =~ ^#.*$ ]] && continue [[ "$line" =~ ^#.*$ ]] && continue
file="$(awk '{print $1}' <<< ${line})" if ! read -r file mode owner group capability <<< "${line}" ; then
mode="$(awk '{print $2}' <<< ${line})" echo "ERROR: cannot parse line: ${line}"
owner="$(awk '{print $3}' <<< ${line})" continue
group="$(awk '{print $4}' <<< ${line})" fi
capability="$(awk '{print $5}' <<< ${line})"
if ! [ -e "${file}" ]; then if ! [ -e "${file}" ]; then
echo "ERROR: File '${file}' does not exist!" echo "ERROR: File '${file}' does not exist!"