From 82b51590fc7e9ef7f9b183a1483aa818d089ca16 Mon Sep 17 00:00:00 2001 From: Samson-W Date: Wed, 7 Nov 2018 16:02:44 +0800 Subject: [PATCH] Fix bug: the problem of errors that occur when there is a substring and a parent string containing it. --- lib/utils.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/utils.sh b/lib/utils.sh index deedbd2..3e0955d 100644 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -469,9 +469,8 @@ check_param_pair_by_pam() #OPTION="ocredit" #COMPARE="gt" #CONDITION="-1" - if [ -f "$LOCATION" ];then - RESULT=$(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' $LOCATION | grep "$KEYWORD.*$OPTION" | wc -l) + RESULT=$(sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' $LOCATION | grep -w "$KEYWORD.*$OPTION" | wc -l) echo $RESULT if [ "$RESULT" -eq 1 ]; then debug "$KEYWORD $OPTION is conf" @@ -563,7 +562,7 @@ add_option_to_session_check() add_option_to_auth_check() { #Example: - #local PAMPWDFILE="/etc/pam.d/common-password" + #local PAMPWDFILE="/etc/pam.d/common-auth" #local KEYWORD="pam_cracklib.so" #local OPTIONSTR="retry=3" local PAMPWDFILE=$1