IMP(2.1x): Retrieve actual partition when symlink

Add function to retrieve actual partition from symlink in lib/utils.sh
Using this func in all 3 audit scripts

Improved tests to test this func

Apply shellcheck recommendations
Trim trailing spaces
This commit is contained in:
Charles Herlin
2019-02-22 12:22:14 +01:00
parent 217895dfe6
commit 7408216957
7 changed files with 67 additions and 17 deletions

View File

@ -258,9 +258,23 @@ is_kernel_option_enabled() {
}
#
# Mounting point
# Mounting point
#
get_partition_from_symlink() {
local local_partition="$1"
if [ ! -e "$local_partition" ]; then
return
fi
filetype=$(stat -c %F "$local_partition")
if [ "$filetype" == "symbolic link" ]; then
actual_partition=$(readlink "$local_partition" )
warn "$local_partition actually is $actual_partition"
local_partition="$actual_partition"
fi
PARTITION="$local_partition"
}
# Verify $1 is a partition declared in fstab
is_a_partition() {