@@ -71,7 +71,7 @@ checks:
|
||||
# 检查pam_pwquality模块配置(推荐方法)
|
||||
# 按照标准检测方法:grep -E "password\s+(requisite|required)\s+pam_pwquality.so" /etc/pam.d/system-auth | grep -E "minlen=([8-9]|[1-9][0-9]+)"
|
||||
# 使用 || true 避免grep未找到匹配时导致脚本退出(set -e模式下)
|
||||
pwquality_config=$(grep -E "password\s+(requisite|required)\s+pam_pwquality.so" /etc/pam.d/system-auth 2>/dev/null || true)
|
||||
pwquality_config=$(grep -E "password\s+(requisite|required)\s+pam_pwquality.so" /etc/pam.d/system-auth 2>/dev/null | tr -s ' ' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' || true)
|
||||
|
||||
if [ -z "$pwquality_config" ]; then
|
||||
# 未配置pam_pwquality模块
|
||||
@@ -126,7 +126,7 @@ checks:
|
||||
# 检查pam_pwquality模块配置(推荐方法)
|
||||
# 按照标准检测方法:grep -E "password\s+(requisite|required)\s+pam_pwquality.so" /etc/pam.d/system-auth | grep -E "minclass=3.*enforce_for_root"
|
||||
# 使用 || true 避免grep未找到匹配时导致脚本退出(set -e模式下)
|
||||
pwquality_config=$(grep -E "password\s+(requisite|required)\s+pam_pwquality.so" /etc/pam.d/system-auth 2>/dev/null || true)
|
||||
pwquality_config=$(grep -E "password\s+(requisite|required)\s+pam_pwquality.so" /etc/pam.d/system-auth 2>/dev/null | tr -s ' ' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' || true)
|
||||
|
||||
if [ -z "$pwquality_config" ]; then
|
||||
# 未配置pam_pwquality模块
|
||||
@@ -211,7 +211,7 @@ checks:
|
||||
# 检查pam_unix.so模块配置
|
||||
# 按照标准检测方法:grep -E "password\s+(required|sufficient)\s+pam_unix.so" /etc/pam.d/system-auth | grep -E "remember=10"
|
||||
# 使用 || true 避免grep未找到匹配时导致脚本退出(set -e模式下)
|
||||
pam_unix_config=$(grep -E "password\s+(required|sufficient)\s+pam_unix.so" /etc/pam.d/system-auth 2>/dev/null || true)
|
||||
pam_unix_config=$(grep -E "password\s+(required|sufficient)\s+pam_unix.so" /etc/pam.d/system-auth 2>/dev/null | tr -s ' ' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' || true)
|
||||
|
||||
if [ -z "$pam_unix_config" ]; then
|
||||
# 未配置pam_unix.so模块
|
||||
|
||||
@@ -222,7 +222,7 @@ checks:
|
||||
# 检查是否包含 /var/log/secure
|
||||
if echo "$authpriv_lines" | grep -qE "authpriv\.\*\s+/var/log/secure"; then
|
||||
config_correct=true
|
||||
config_line=$(echo "$authpriv_lines" | grep -E "authpriv\.\*\s+/var/log/secure" | head -1)
|
||||
config_line=$(echo "$authpriv_lines" | grep -E "authpriv\.\*\s+/var/log/secure" | head -1 | tr -s ' ' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -236,7 +236,7 @@ checks:
|
||||
config_found=true
|
||||
if echo "$authpriv_lines" | grep -qE "authpriv\.\*\s+/var/log/secure"; then
|
||||
config_correct=true
|
||||
config_line=$(echo "$authpriv_lines" | grep -E "authpriv\.\*\s+/var/log/secure" | head -1)
|
||||
config_line=$(echo "$authpriv_lines" | grep -E "authpriv\.\*\s+/var/log/secure" | head -1 | tr -s ' ' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user