CHORE(2.1x): use "readlink -e" instead of custom func

Removed get_partition_from_symlink()
This commit is contained in:
Charles Herlin 2019-02-26 15:06:51 +01:00
parent 8031c388c6
commit de7dfe5956
7 changed files with 12 additions and 20 deletions

View File

@ -24,7 +24,7 @@ OPTION="nodev"
# This function will be called if the script status is on enabled / audit mode # This function will be called if the script status is on enabled / audit mode
audit () { audit () {
info "Verifying that $PARTITION is a partition" info "Verifying that $PARTITION is a partition"
get_partition_from_symlink "$PARTITION" PARTITION=$(readlink -e "$PARTITION")
FNRET=0 FNRET=0
is_a_partition "$PARTITION" is_a_partition "$PARTITION"
if [ $FNRET -gt 0 ]; then if [ $FNRET -gt 0 ]; then

View File

@ -24,7 +24,7 @@ OPTION="nosuid"
# This function will be called if the script status is on enabled / audit mode # This function will be called if the script status is on enabled / audit mode
audit () { audit () {
info "Verifying that $PARTITION is a partition" info "Verifying that $PARTITION is a partition"
get_partition_from_symlink "$PARTITION" PARTITION=$(readlink -e "$PARTITION")
FNRET=0 FNRET=0
is_a_partition "$PARTITION" is_a_partition "$PARTITION"
if [ $FNRET -gt 0 ]; then if [ $FNRET -gt 0 ]; then

View File

@ -24,7 +24,7 @@ OPTION="noexec"
# This function will be called if the script status is on enabled / audit mode # This function will be called if the script status is on enabled / audit mode
audit () { audit () {
info "Verifying that $PARTITION is a partition" info "Verifying that $PARTITION is a partition"
get_partition_from_symlink "$PARTITION" PARTITION=$(readlink -e "$PARTITION")
FNRET=0 FNRET=0
is_a_partition "$PARTITION" is_a_partition "$PARTITION"
if [ $FNRET -gt 0 ]; then if [ $FNRET -gt 0 ]; then

View File

@ -288,20 +288,6 @@ 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 # Verify $1 is a partition declared in fstab
is_a_partition() { is_a_partition() {

View File

@ -10,8 +10,10 @@ test_audit() {
describe Partition symlink describe Partition symlink
register_test retvalshouldbe 1 register_test retvalshouldbe 1
register_test contain "[WARN] /run/shm actually is /dev/shm"
run resolved /opt/debian-cis/bin/hardening/"${script}".sh --audit-all run resolved /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
# Cleanup
rm /run/shm
# TODO fill comprehensive tests # TODO fill comprehensive tests
} }

View File

@ -10,8 +10,10 @@ test_audit() {
describe Partition symlink describe Partition symlink
register_test retvalshouldbe 1 register_test retvalshouldbe 1
register_test contain "[WARN] /run/shm actually is /dev/shm"
run resolved /opt/debian-cis/bin/hardening/"${script}".sh --audit-all run resolved /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
# Cleanup
rm /run/shm
# TODO fill comprehensive tests # TODO fill comprehensive tests
} }

View File

@ -10,8 +10,10 @@ test_audit() {
describe Partition symlink describe Partition symlink
register_test retvalshouldbe 1 register_test retvalshouldbe 1
register_test contain "[WARN] /run/shm actually is /dev/shm"
run resolved /opt/debian-cis/bin/hardening/"${script}".sh --audit-all run resolved /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
# Cleanup
rm /run/shm
# TODO fill comprehensive tests # TODO fill comprehensive tests
} }