Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test scenarios specific for CIS #7634

Merged
merged 2 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# packages = pam
# platform = Red Hat Enterprise Linux 7
# profiles = xccdf_org.ssgproject.content_profile_cis

remember_cnt=5
control_flag='required'

config_file=/etc/pam.d/password-auth

# is 'password required|requisite pam_pwhistory.so' here?
if grep -q "^password.*pam_pwhistory.so.*" $config_file; then
# is the remember option set?
option=$(sed -rn 's/^(.*pam_pwhistory\.so.*)(remember=[0-9]+)(.*)$/\2/p' $config_file)
if [[ -z $option ]]; then
# option is not set, append to module
sed -i --follow-symlinks "/pam_pwhistory.so/ s/$/ remember=$remember_cnt/"
else
# option is set, replace value
sed -r -i --follow-symlinks "s/^(.*pam_pwhistory\.so.*)(remember=[0-9]+)(.*)$/\1remember=$remember_cnt\3/" $config_file
fi
# ensure corect control is being used per os requirement
if ! grep -q "^password.*$control_flag.*pam_pwhistory.so.*" $config_file; then
#replace incorrect value
sed -r -i --follow-symlinks "s/(^password.*)(required|requisite)(.*pam_pwhistory\.so.*)$/\1$control_flag\3/" $config_file
fi
else
# no 'password required|requisite pam_pwhistory.so', add it
sed -i --follow-symlinks "/^password.*pam_unix.so.*/i password $control_flag pam_pwhistory.so use_authtok remember=$remember_cnt" $config_file
fi

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# packages = pam
# platform = Red Hat Enterprise Linux 7
# profiles = xccdf_org.ssgproject.content_profile_cis

remember_cnt=5
control_flag='required'

config_file=/etc/pam.d/system-auth

# is 'password required|requisite pam_pwhistory.so' here?
if grep -q "^password.*pam_pwhistory.so.*" $config_file; then
# is the remember option set?
option=$(sed -rn 's/^(.*pam_pwhistory\.so.*)(remember=[0-9]+)(.*)$/\2/p' $config_file)
if [[ -z $option ]]; then
# option is not set, append to module
sed -i --follow-symlinks "/pam_pwhistory.so/ s/$/ remember=$remember_cnt/"
else
# option is set, replace value
sed -r -i --follow-symlinks "s/^(.*pam_pwhistory\.so.*)(remember=[0-9]+)(.*)$/\1remember=$remember_cnt\3/" $config_file
fi
# ensure corect control is being used per os requirement
if ! grep -q "^password.*$control_flag.*pam_pwhistory.so.*" $config_file; then
#replace incorrect value
sed -r -i --follow-symlinks "s/(^password.*)(required|requisite)(.*pam_pwhistory\.so.*)$/\1$control_flag\3/" $config_file
fi
else
# no 'password required|requisite pam_pwhistory.so', add it
sed -i --follow-symlinks "/^password.*pam_unix.so.*/i password $control_flag pam_pwhistory.so use_authtok remember=$remember_cnt" $config_file
fi