Blame SOURCES/scap-security-guide-0.1.61-update_accounts_password_template-PR_8164.patch

5fd106
diff --git a/docs/templates/template_reference.md b/docs/templates/template_reference.md
5fd106
index 65bc439225e..fef4679be39 100644
5fd106
--- a/docs/templates/template_reference.md
5fd106
+++ b/docs/templates/template_reference.md
5fd106
@@ -2,17 +2,20 @@
5fd106
 
5fd106
 #### accounts_password
5fd106
 -   Checks if PAM enforces password quality requirements. Checks the
5fd106
-    configuration in `/etc/pam.d/system-auth` (for RHEL 6 systems) or
5fd106
-    `/etc/security/pwquality.conf` (on other systems).
5fd106
+    configuration in `/etc/security/pwquality.conf`.
5fd106
 
5fd106
 -   Parameters:
5fd106
 
5fd106
-    -   **variable** - PAM `pam_cracklib` (on RHEL 6) or `pam_pwquality`
5fd106
-        (on other systems) module name, eg. `ucredit`, `ocredit`
5fd106
+    -   **variable** - PAM `pam_pwquality` password quality
5fd106
+        requirement, eg. `ucredit`, `ocredit`
5fd106
 
5fd106
     -   **operation** - OVAL operation, eg. `less than or equal`
5fd106
 
5fd106
--   Languages: OVAL
5fd106
+    -   **zero_comparison_operation** - (optional) OVAL operation, eg. `greater than`.
5fd106
+        When set, it will test if the **variable** value matches the OVAL operation
5fd106
+        when compared to zero.
5fd106
+
5fd106
+-   Languages: Ansible, Bash, OVAL
5fd106
 
5fd106
 #### auditd_lineinfile
5fd106
 -   Checks configuration options of the Audit Daemon in
ff1465
diff --git a/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/rule.yml b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/rule.yml
5fd106
index 912c783650a..9a829ac5119 100644
ff1465
--- a/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/rule.yml
ff1465
+++ b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/rule.yml
5fd106
@@ -47,7 +47,7 @@ ocil_clause: 'that is not the case'
ff1465
 ocil: |-
ff1465
     To check the value for maximum consecutive repeating characters, run the following command:
ff1465
     
$ grep maxclassrepeat /etc/security/pwquality.conf
ff1465
-    For DoD systems, the output should show <tt>maxclassrepeat</tt>=4.
ff1465
+    For DoD systems, the output should show <tt>maxclassrepeat</tt>=4 or less but greater than zero.
ff1465
 
ff1465
 platform: pam
ff1465
 
5fd106
@@ -56,3 +56,4 @@ template:
ff1465
     vars:
ff1465
         variable: maxclassrepeat
ff1465
         operation: less than or equal
ff1465
+        zero_comparison_operation: greater than
ff1465
diff --git a/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/correct_value.pass.sh b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/correct_value.pass.sh
ff1465
new file mode 100644
5fd106
index 00000000000..5d91559d4a2
ff1465
--- /dev/null
ff1465
+++ b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/correct_value.pass.sh
ff1465
@@ -0,0 +1,8 @@
ff1465
+#!/bin/bash
ff1465
+
ff1465
+if grep -q 'maxclassrepeat' /etc/security/pwquality.conf; then
ff1465
+	sed -i 's/.*maxclassrepeat.*/maxclassrepeat = 4/' /etc/security/pwquality.conf
ff1465
+else
ff1465
+	echo "maxclassrepeat = 4" >> /etc/security/pwquality.conf
ff1465
+fi
ff1465
+
ff1465
diff --git a/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/correct_value_less_than_variable.pass.sh b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/correct_value_less_than_variable.pass.sh
ff1465
new file mode 100644
5fd106
index 00000000000..4bd8070eb7e
ff1465
--- /dev/null
ff1465
+++ b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/correct_value_less_than_variable.pass.sh
ff1465
@@ -0,0 +1,8 @@
ff1465
+#!/bin/bash
ff1465
+
ff1465
+if grep -q 'maxclassrepeat' /etc/security/pwquality.conf; then
ff1465
+	sed -i 's/.*maxclassrepeat.*/maxclassrepeat = 2/' /etc/security/pwquality.conf
ff1465
+else
ff1465
+	echo "maxclassrepeat = 2" >> /etc/security/pwquality.conf
ff1465
+fi
ff1465
+
ff1465
diff --git a/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/negative_value.fail.sh b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/negative_value.fail.sh
ff1465
new file mode 100644
5fd106
index 00000000000..61538a4945f
ff1465
--- /dev/null
ff1465
+++ b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/negative_value.fail.sh
ff1465
@@ -0,0 +1,7 @@
ff1465
+#!/bin/bash
ff1465
+
ff1465
+if grep -q 'maxclassrepeat' /etc/security/pwquality.conf; then
ff1465
+	sed -i 's/.*maxclassrepeat.*/maxclassrepeat = -1/' /etc/security/pwquality.conf
ff1465
+else
ff1465
+	echo "maxclassrepeat = -1" >> /etc/security/pwquality.conf
ff1465
+fi
ff1465
diff --git a/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/wrong_value.fail.sh b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/wrong_value.fail.sh
ff1465
new file mode 100644
5fd106
index 00000000000..2218250ec7b
ff1465
--- /dev/null
ff1465
+++ b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/wrong_value.fail.sh
ff1465
@@ -0,0 +1,8 @@
ff1465
+#!/bin/bash
ff1465
+
ff1465
+if grep -q 'maxclassrepeat' /etc/security/pwquality.conf; then
ff1465
+	sed -i 's/.*maxclassrepeat.*/maxclassrepeat = 5/' /etc/security/pwquality.conf
ff1465
+else
ff1465
+	echo "maxclassrepeat = 5" >> /etc/security/pwquality.conf
ff1465
+fi
ff1465
+
ff1465
diff --git a/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/wrong_value_0.fail.sh b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/wrong_value_0.fail.sh
ff1465
new file mode 100644
5fd106
index 00000000000..780873c6a86
ff1465
--- /dev/null
ff1465
+++ b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/wrong_value_0.fail.sh
ff1465
@@ -0,0 +1,8 @@
ff1465
+#!/bin/bash
ff1465
+
ff1465
+if grep -q 'maxclassrepeat' /etc/security/pwquality.conf; then
ff1465
+	sed -i 's/.*maxclassrepeat.*/maxclassrepeat = 0/' /etc/security/pwquality.conf
ff1465
+else
ff1465
+	echo "maxclassrepeat = 0" >> /etc/security/pwquality.conf
ff1465
+fi
ff1465
+
ff1465
diff --git a/shared/templates/accounts_password/oval.template b/shared/templates/accounts_password/oval.template
5fd106
index 332a2800317..b995db11ea4 100644
ff1465
--- a/shared/templates/accounts_password/oval.template
ff1465
+++ b/shared/templates/accounts_password/oval.template
ff1465
@@ -7,11 +7,14 @@
ff1465
     </criteria>
ff1465
   </definition>
ff1465
 
ff1465
-  
ff1465
+  
ff1465
   comment="check the configuration of /etc/security/pwquality.conf"
ff1465
   id="test_password_pam_pwquality_{{{ VARIABLE }}}" version="3">
ff1465
     <ind:object object_ref="obj_password_pam_pwquality_{{{ VARIABLE }}}" />
ff1465
     <ind:state state_ref="state_password_pam_{{{ VARIABLE }}}" />
ff1465
+  {{%- if ZERO_COMPARISON_OPERATION %}}
ff1465
+    <ind:state state_ref="state_password_pam_{{{ VARIABLE }}}_zero_comparison" />
ff1465
+  {{%- endif %}}
ff1465
   </ind:textfilecontent54_test>
ff1465
 
ff1465
   <ind:textfilecontent54_object id="obj_password_pam_pwquality_{{{ VARIABLE }}}" version="3">
ff1465
@@ -24,5 +27,11 @@
ff1465
     <ind:subexpression datatype="int" operation="{{{ OPERATION }}}" var_ref="var_password_pam_{{{ VARIABLE }}}" />
ff1465
   </ind:textfilecontent54_state>
ff1465
 
ff1465
+  {{%- if ZERO_COMPARISON_OPERATION %}}
ff1465
+  <ind:textfilecontent54_state id="state_password_pam_{{{ VARIABLE }}}_zero_comparison" version="1">
ff1465
+    <ind:subexpression datatype="int" operation="{{{ ZERO_COMPARISON_OPERATION }}}" >0</ind:subexpression>
ff1465
+  </ind:textfilecontent54_state>
ff1465
+  {{%- endif %}}
ff1465
+
ff1465
   <external_variable comment="External variable for pam_{{{ VARIABLE }}}" datatype="int" id="var_password_pam_{{{ VARIABLE }}}" version="3" />
ff1465
 </def-group>
ff1465
diff --git a/shared/templates/accounts_password/template.py b/shared/templates/accounts_password/template.py
5fd106
index 65c25ec7991..ab849d1fa72 100644
ff1465
--- a/shared/templates/accounts_password/template.py
ff1465
+++ b/shared/templates/accounts_password/template.py
ff1465
@@ -1,4 +1,7 @@
ff1465
+from ssg.utils import parse_template_boolean_value
ff1465
+
ff1465
 def preprocess(data, lang):
ff1465
     if lang == "oval":
ff1465
         data["sign"] = "-?" if data["variable"].endswith("credit") else ""
ff1465
+    data["zero_comparison_operation"] = data.get("zero_comparison_operation", None)
ff1465
     return data