check string length of permission variable

https://forums.whonix.org/t/kernel-hardening/7296/322
This commit is contained in:
Patrick Schleizer 2019-12-20 02:39:53 -05:00
parent a89befd902
commit 2c163bf439
No known key found for this signature in database
GPG Key ID: CB8D50BB77BB3C48

View File

@ -25,7 +25,14 @@ add_statoverride_entry() {
fi fi
if test -u "${file_name}" || test -g "${file_name}"; then if test -u "${file_name}" || test -g "${file_name}"; then
echo "suid - file_name: '${file_name}' | existing_mode: '${existing_mode}' | existing_mode:1: '${existing_mode:1}'" string_length_of_existing_mode="${#existing_mode}"
if [ "$string_length_of_existing_mode" = "4" ]; then
newmode="${existing_mode:1}"
else
newmode="${existing_mode}"
fi
echo "suid - file_name: '${file_name}' | existing_mode: '${existing_mode}' | newmode: '$newmode'"
if dpkg-statoverride --list | grep -q "${file_name}"; then 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