From c626290673d44b2a6485aeb24888f35c3782c151 Mon Sep 17 00:00:00 2001 From: Patrick Schleizer Date: Fri, 20 Dec 2019 03:02:26 -0500 Subject: [PATCH] refactoring --- usr/lib/security-misc/permission-hardening | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/usr/lib/security-misc/permission-hardening b/usr/lib/security-misc/permission-hardening index 11f0cc3..c5e65d6 100755 --- a/usr/lib/security-misc/permission-hardening +++ b/usr/lib/security-misc/permission-hardening @@ -45,17 +45,17 @@ add_statoverride_entry() { echo "suid - file_name: '$file_name' | existing_mode: '$existing_mode' | new_mode: '$new_mode'" if dpkg-statoverride --list | grep -q "$file_name"; then - if ! dpkg-statoverride --list | grep -q "${owner} ${group} ${existing_mode:1} $file_name"; then + if ! dpkg-statoverride --list | grep -q "$owner $group ${existing_mode:1} $file_name"; then echo_wrapper dpkg-statoverride --remove "$file_name" - echo_wrapper dpkg-statoverride --add --update "${owner}" "${group}" "${existing_mode:1}" "$file_name" + echo_wrapper dpkg-statoverride --add --update "$owner" "$group" "${existing_mode:1}" "$file_name" fi else - echo_wrapper dpkg-statoverride --add --update "${owner}" "${group}" "${existing_mode:1}" "$file_name" + echo_wrapper dpkg-statoverride --add --update "$owner" "$group" "${existing_mode:1}" "$file_name" fi fi done < <( stat -c "%n %a %U %G" "${fso%/}/"** ) else - echo_wrapper dpkg-statoverride --add --update "${owner}" "${group}" "$mode" "${fso%/}" + echo_wrapper dpkg-statoverride --add --update "$owner" "$group" "$mode" "${fso%/}" fi } @@ -73,13 +73,13 @@ set_file_perms() { true OK 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 fi - if ! read -r fso mode owner group capability <<< "${line}" ; then + if ! read -r fso mode owner group capability <<< "$line" ; then exit_code=201 - echo "ERROR: cannot parse line: ${line}" >&2 + echo "ERROR: cannot parse line: $line" >&2 continue fi @@ -98,12 +98,12 @@ set_file_perms() { if [ ! "$mode" = "nosuid" ]; then if ! getent passwd | grep -q "^${owner}:"; then - echo "ERROR: User '${owner}' does not exist!" >&2 + echo "ERROR: User '$owner' does not exist!" >&2 continue fi if ! getent group | grep -q "^${group}:"; then - echo "ERROR: Group '${group}' does not exist!" >&2 + echo "ERROR: Group '$group' does not exist!" >&2 continue fi fi @@ -112,7 +112,7 @@ set_file_perms() { if dpkg-statoverride --list | grep -q "${fso%/}"; then ## If there is an entry for the fso, but the owner/group/mode do not ## match, we remove and re-add the entry to update it. - if ! dpkg-statoverride --list | grep -q "${owner} ${group} ${mode:1} ${fso%/}"; then + if ! dpkg-statoverride --list | grep -q "$owner $group ${mode:1} ${fso%/}"; then echo_wrapper dpkg-statoverride --remove "${fso}" add_statoverride_entry fi