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

0c1482
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
0c1482
index 912c783650a..9a829ac5119 100644
0c1482
--- a/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/rule.yml
0c1482
+++ b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/rule.yml
0c1482
@@ -47,7 +47,7 @@ ocil_clause: 'that is not the case'
0c1482
 ocil: |-
0c1482
     To check the value for maximum consecutive repeating characters, run the following command:
0c1482
     
$ grep maxclassrepeat /etc/security/pwquality.conf
0c1482
-    For DoD systems, the output should show <tt>maxclassrepeat</tt>=4.
0c1482
+    For DoD systems, the output should show <tt>maxclassrepeat</tt>=4 or less but greater than zero.
0c1482
 
0c1482
 platform: pam
0c1482
 
0c1482
@@ -56,3 +56,4 @@ template:
0c1482
     vars:
0c1482
         variable: maxclassrepeat
0c1482
         operation: less than or equal
0c1482
+        zero_comparison_operation: greater than
0c1482
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
0c1482
new file mode 100644
0c1482
index 00000000000..5d91559d4a2
0c1482
--- /dev/null
0c1482
+++ b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/correct_value.pass.sh
0c1482
@@ -0,0 +1,8 @@
0c1482
+#!/bin/bash
0c1482
+
0c1482
+if grep -q 'maxclassrepeat' /etc/security/pwquality.conf; then
0c1482
+	sed -i 's/.*maxclassrepeat.*/maxclassrepeat = 4/' /etc/security/pwquality.conf
0c1482
+else
0c1482
+	echo "maxclassrepeat = 4" >> /etc/security/pwquality.conf
0c1482
+fi
0c1482
+
0c1482
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
0c1482
new file mode 100644
0c1482
index 00000000000..4bd8070eb7e
0c1482
--- /dev/null
0c1482
+++ 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
0c1482
@@ -0,0 +1,8 @@
0c1482
+#!/bin/bash
0c1482
+
0c1482
+if grep -q 'maxclassrepeat' /etc/security/pwquality.conf; then
0c1482
+	sed -i 's/.*maxclassrepeat.*/maxclassrepeat = 2/' /etc/security/pwquality.conf
0c1482
+else
0c1482
+	echo "maxclassrepeat = 2" >> /etc/security/pwquality.conf
0c1482
+fi
0c1482
+
0c1482
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
0c1482
new file mode 100644
0c1482
index 00000000000..61538a4945f
0c1482
--- /dev/null
0c1482
+++ b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/negative_value.fail.sh
0c1482
@@ -0,0 +1,7 @@
0c1482
+#!/bin/bash
0c1482
+
0c1482
+if grep -q 'maxclassrepeat' /etc/security/pwquality.conf; then
0c1482
+	sed -i 's/.*maxclassrepeat.*/maxclassrepeat = -1/' /etc/security/pwquality.conf
0c1482
+else
0c1482
+	echo "maxclassrepeat = -1" >> /etc/security/pwquality.conf
0c1482
+fi
0c1482
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
0c1482
new file mode 100644
0c1482
index 00000000000..2218250ec7b
0c1482
--- /dev/null
0c1482
+++ b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/wrong_value.fail.sh
0c1482
@@ -0,0 +1,8 @@
0c1482
+#!/bin/bash
0c1482
+
0c1482
+if grep -q 'maxclassrepeat' /etc/security/pwquality.conf; then
0c1482
+	sed -i 's/.*maxclassrepeat.*/maxclassrepeat = 5/' /etc/security/pwquality.conf
0c1482
+else
0c1482
+	echo "maxclassrepeat = 5" >> /etc/security/pwquality.conf
0c1482
+fi
0c1482
+
0c1482
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
0c1482
new file mode 100644
0c1482
index 00000000000..780873c6a86
0c1482
--- /dev/null
0c1482
+++ b/linux_os/guide/system/accounts/accounts-pam/password_quality/password_quality_pwquality/accounts_password_pam_maxclassrepeat/tests/wrong_value_0.fail.sh
0c1482
@@ -0,0 +1,8 @@
0c1482
+#!/bin/bash
0c1482
+
0c1482
+if grep -q 'maxclassrepeat' /etc/security/pwquality.conf; then
0c1482
+	sed -i 's/.*maxclassrepeat.*/maxclassrepeat = 0/' /etc/security/pwquality.conf
0c1482
+else
0c1482
+	echo "maxclassrepeat = 0" >> /etc/security/pwquality.conf
0c1482
+fi
0c1482
+
0c1482
diff --git a/shared/templates/accounts_password/oval.template b/shared/templates/accounts_password/oval.template
0c1482
index 332a2800317..b995db11ea4 100644
0c1482
--- a/shared/templates/accounts_password/oval.template
0c1482
+++ b/shared/templates/accounts_password/oval.template
0c1482
@@ -7,11 +7,14 @@
0c1482
     </criteria>
0c1482
   </definition>
0c1482
 
0c1482
-  
0c1482
+  
0c1482
   comment="check the configuration of /etc/security/pwquality.conf"
0c1482
   id="test_password_pam_pwquality_{{{ VARIABLE }}}" version="3">
0c1482
     <ind:object object_ref="obj_password_pam_pwquality_{{{ VARIABLE }}}" />
0c1482
     <ind:state state_ref="state_password_pam_{{{ VARIABLE }}}" />
0c1482
+  {{%- if ZERO_COMPARISON_OPERATION %}}
0c1482
+    <ind:state state_ref="state_password_pam_{{{ VARIABLE }}}_zero_comparison" />
0c1482
+  {{%- endif %}}
0c1482
   </ind:textfilecontent54_test>
0c1482
 
0c1482
   <ind:textfilecontent54_object id="obj_password_pam_pwquality_{{{ VARIABLE }}}" version="3">
0c1482
@@ -24,5 +27,11 @@
0c1482
     <ind:subexpression datatype="int" operation="{{{ OPERATION }}}" var_ref="var_password_pam_{{{ VARIABLE }}}" />
0c1482
   </ind:textfilecontent54_state>
0c1482
 
0c1482
+  {{%- if ZERO_COMPARISON_OPERATION %}}
0c1482
+  <ind:textfilecontent54_state id="state_password_pam_{{{ VARIABLE }}}_zero_comparison" version="1">
0c1482
+    <ind:subexpression datatype="int" operation="{{{ ZERO_COMPARISON_OPERATION }}}" >0</ind:subexpression>
0c1482
+  </ind:textfilecontent54_state>
0c1482
+  {{%- endif %}}
0c1482
+
0c1482
   <external_variable comment="External variable for pam_{{{ VARIABLE }}}" datatype="int" id="var_password_pam_{{{ VARIABLE }}}" version="3" />
0c1482
 </def-group>
0c1482
diff --git a/shared/templates/accounts_password/template.py b/shared/templates/accounts_password/template.py
0c1482
index 65c25ec7991..ab849d1fa72 100644
0c1482
--- a/shared/templates/accounts_password/template.py
0c1482
+++ b/shared/templates/accounts_password/template.py
0c1482
@@ -1,4 +1,7 @@
0c1482
+from ssg.utils import parse_template_boolean_value
0c1482
+
0c1482
 def preprocess(data, lang):
0c1482
     if lang == "oval":
0c1482
         data["sign"] = "-?" if data["variable"].endswith("credit") else ""
0c1482
+    data["zero_comparison_operation"] = data.get("zero_comparison_operation", None)
0c1482
     return data