Modify check_password_by_pam function.
This commit is contained in:
parent
7c7e4ed1c2
commit
8c1a0e3f6d
31
lib/utils.sh
31
lib/utils.sh
|
@ -442,35 +442,40 @@ verify_integrity_all_packages()
|
||||||
}
|
}
|
||||||
|
|
||||||
check_password_by_pam()
|
check_password_by_pam()
|
||||||
{
|
{
|
||||||
OPTION=$1
|
OPTION=$1
|
||||||
COMPARE=$2
|
COMPARE=$2
|
||||||
CONDITION=$3
|
CONDITION=$3
|
||||||
|
|
||||||
LOCATION="/etc/pam.d/common-password"
|
LOCATION="/etc/pam.d/common-password"
|
||||||
#For debian is common-password ,for Gentoo and Red hat the file is system-auth
|
|
||||||
KEYWORD="pam_cracklib.so"
|
KEYWORD="pam_cracklib.so"
|
||||||
|
|
||||||
#Example:
|
#Example:
|
||||||
#OPTION="ocredit"
|
#OPTION="ocredit"
|
||||||
#COMPARE="gt"
|
#COMPARE="gt"
|
||||||
#CONDITION="-1"
|
#CONDITION="-1"
|
||||||
|
|
||||||
if [ -f "$LOCATION" ];then
|
if [ -f "$LOCATION" ];then
|
||||||
RESULT=$(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' $LOCATION | grep "$KEYWORD.*$OPTION")
|
RESULT=$(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' $LOCATION | grep "$KEYWORD.*$OPTION" | wc -l)
|
||||||
#above line is remove any comment in the configuration file and use grep to output a exit status
|
echo $RESULT
|
||||||
#if matched both $KEYWORD and $OPTION there is a success exit status: 0
|
if [ "$RESULT" -eq 1 ]; then
|
||||||
if [ $? -eq 0 ];then
|
debug "$KEYWORD $OPTION is conf"
|
||||||
if [ "$(echo $RESULT | tr "\t" "\n" | tr " " "\n" | sed -n "/$OPTION/p"| awk -F "=" '{printf $2}')" -$(echo $COMPARE) "$CONDITION" ];then
|
cndt_value=$(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' $LOCATION | grep "$KEYWORD.*$OPTION" | tr "\t" " " | tr " " "\n" | sed -n "/$OPTION/p" | awk -F "=" '{print $2}')
|
||||||
FNRET=1
|
if [ "$cndt_value" "-$COMPARE" "$CONDITION" ]; then
|
||||||
else
|
debug "$cndt_value -$COMPARE $CONDITION is ok"
|
||||||
FNRET=0
|
FNRET=0
|
||||||
fi
|
else
|
||||||
|
debug "$cndt_value -$COMPARE $CONDITION is not ok"
|
||||||
|
FNRET=1
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
debug "$KEYWORD $OPTION is not conf"
|
||||||
FNRET=1
|
FNRET=1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
FNRET=2
|
debug "$LOCATION is not exist"
|
||||||
|
FNRET=2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue