improved detecting fails and errors.

This commit is contained in:
Pierre Gode 2019-04-02 13:41:09 +02:00
parent 44c81e2b07
commit 35cde14551

View File

@ -199,7 +199,7 @@ else
echo "Checking sudoers file.. ${RED_TEXT}FAIL${END}" echo "Checking sudoers file.. ${RED_TEXT}FAIL${END}"
fi fi
grouPs=$(grep -i "$myhost" /etc/sudoers.d/sudoers | cut -d '%' -f2 | awk '{print $1}' | head -1) grouPs=$(grep -i "$myhost" /etc/sudoers.d/sudoers | cut -d '%' -f2 | awk '{print $1}' | head -1)
if [ $grouPs = "$myhost""sudoers" ] if [ "$grouPs" = "$myhost""sudoers" ]
then then
echo "Checking sudoers user groups.. ${INTRO_TEXT}OK${END}" echo "Checking sudoers user groups.. ${INTRO_TEXT}OK${END}"
else else
@ -393,7 +393,7 @@ else
echo "Checking sudoers file.. FAIL" echo "Checking sudoers file.. FAIL"
fi fi
grouPs=$(grep -i "$myhost" /etc/sudoers.d/sudoers | cut -d '%' -f2 | awk '{print $1}' | head -1) grouPs=$(grep -i "$myhost" /etc/sudoers.d/sudoers | cut -d '%' -f2 | awk '{print $1}' | head -1)
if [ $grouPs = "$myhost""sudoers" ] if [ "$grouPs" = "$myhost""sudoers" ]
then then
echo "Checking sudoers user groups.. OK" echo "Checking sudoers user groups.. OK"
else else
@ -755,7 +755,7 @@ else
echo checking sudoers file.. "${RED_TEXT}FAIL not configured${END}" echo checking sudoers file.. "${RED_TEXT}FAIL not configured${END}"
fi fi
grouPs=$(grep -i "$myhost" /etc/sudoers.d/sudoers | cut -d '%' -f2 | cut -d '=' -f1 | sed -e 's/\<ALL\>//g') grouPs=$(grep -i "$myhost" /etc/sudoers.d/sudoers | cut -d '%' -f2 | cut -d '=' -f1 | sed -e 's/\<ALL\>//g')
if [ $grouPs = "$myhost""sudoers" ] if [ "$grouPs" = "$myhost""sudoers" ]
then then
echo "Checking sudoers users.. ${INTRO_TEXT}OK${END}" echo "Checking sudoers users.. ${INTRO_TEXT}OK${END}"
else else
@ -1163,7 +1163,7 @@ if [ -f /etc/sudoers.d/admins ] < /dev/null > /dev/null 2>&1
then then
echo Checking sudoers file.. "${INTRO_TEXT}OK${END}" echo Checking sudoers file.. "${INTRO_TEXT}OK${END}"
grouPs=$(grep -i "$myhost" /etc/sudoers.d/sudoers | cut -d '%' -f2 | cut -d '=' -f1 | sed -e 's/\<ALL\>//g') grouPs=$(grep -i "$myhost" /etc/sudoers.d/sudoers | cut -d '%' -f2 | cut -d '=' -f1 | sed -e 's/\<ALL\>//g')
if [ $grouPs = "$myhost""sudoers" ] if [ "$grouPs" = "$myhost""sudoers" ]
then then
echo Checking sudoers users.. "${INTRO_TEXT}OK${END}" echo Checking sudoers users.. "${INTRO_TEXT}OK${END}"
else else
@ -1174,7 +1174,7 @@ if [ -f /etc/sudoers.d/sudoers ] < /dev/null > /dev/null 2>&1
then then
echo Checking sudoers file.. "${INTRO_TEXT}OK${END}" echo Checking sudoers file.. "${INTRO_TEXT}OK${END}"
grouPs1=$(grep -i "$myhost" /etc/sudoers.d/sudoers | cut -d '%' -f2 | cut -d '=' -f1 | sed -e 's/\<ALL\>//g' | head -1) grouPs1=$(grep -i "$myhost" /etc/sudoers.d/sudoers | cut -d '%' -f2 | cut -d '=' -f1 | sed -e 's/\<ALL\>//g' | head -1)
if [ $grouPs1 = "$myhost""sudoers" ] if [ "$grouPs"1 = "$myhost""sudoers" ]
then then
echo Checking sudoers user groups.. "${INTRO_TEXT}OK${END}" echo Checking sudoers user groups.. "${INTRO_TEXT}OK${END}"
else else
@ -1228,7 +1228,7 @@ if [ -f /etc/sudoers.d/admins ] < /dev/null > /dev/null 2>&1
then then
echo "Checking sudoers file.. OK" echo "Checking sudoers file.. OK"
grouPs=$(grep -i "$myhost" /etc/sudoers.d/admins | cut -d '%' -f2 | cut -d '=' -f1 | sed -e 's/\<ALL\>//g') grouPs=$(grep -i "$myhost" /etc/sudoers.d/admins | cut -d '%' -f2 | cut -d '=' -f1 | sed -e 's/\<ALL\>//g')
if [ $grouPs = "$myhost""sudoers" ] if [ "$grouPs" = "$myhost""sudoers" ]
then then
echo "Checking sudoers users.. OK" echo "Checking sudoers users.. OK"
else else
@ -1239,7 +1239,7 @@ if [ -f /etc/sudoers.d/sudoers ] < /dev/null > /dev/null 2>&1
then then
echo "Checking sudoers file.. OK" echo "Checking sudoers file.. OK"
grouPs1=$(grep -i "$myhost" /etc/sudoers.d/sudoers | cut -d '%' -f2 | cut -d '=' -f1 | sed -e 's/\<ALL\>//g' | head -1) grouPs1=$(grep -i "$myhost" /etc/sudoers.d/sudoers | cut -d '%' -f2 | cut -d '=' -f1 | sed -e 's/\<ALL\>//g' | head -1)
if [ $grouPs1 = "$myhost""sudoers" ] if [ "$grouPs"1 = "$myhost""sudoers" ]
then then
echo "Checking sudoers user groups.. OK" echo "Checking sudoers user groups.. OK"
else else