|
| 1 | +{{% if "sle12" in product or "debian" in product or "ubuntu" in product %}} |
| 2 | +{{%- set accounts_password_pam_file = '/etc/pam.d/common-password' -%}} |
| 3 | +{{% endif %}} |
| 4 | + |
| 5 | +<def-group> |
| 6 | + <definition class="compliance" id="{{{ rule_id }}}" version="2"> |
| 7 | + {{{ oval_metadata("The passwords to remember of pam_pwhistory should be set correctly.") }}} |
| 8 | + <criteria operator="AND" comment="Check if pam_pwhistory.so is properly configured"> |
| 9 | + <criterion test_ref="test_accounts_password_pam_pwhistory_enabled" |
| 10 | + comment="pam_pwhistory.so is properly defined in password section of PAM file"/> |
| 11 | + <criterion test_ref="test_accounts_password_pam_pwhistory_remember_parameter" |
| 12 | + comment="Remember parameter of pam_pwhistory.so is properly configured"/> |
| 13 | + </criteria> |
| 14 | + </definition> |
| 15 | + |
| 16 | + <external_variable comment="number of passwords that should be remembered" datatype="int" id="var_password_pam_remember" version="1" /> |
| 17 | + |
| 18 | + <!-- is pam_pwhistory.so enabled? --> |
| 19 | + <ind:textfilecontent54_test id="test_accounts_password_pam_pwhistory_enabled" |
| 20 | + check="all" version="1" comment="Check pam_pwhistory.so presence in PAM file"> |
| 21 | + <ind:object object_ref="object_accounts_password_pam_pwhistory_enabled"/> |
| 22 | + </ind:textfilecontent54_test> |
| 23 | + |
| 24 | + <ind:textfilecontent54_object id="object_accounts_password_pam_pwhistory_enabled" |
| 25 | + version="1"> |
| 26 | + <ind:filepath>{{{ accounts_password_pam_file }}}</ind:filepath> |
| 27 | + <ind:pattern var_ref="var_accounts_password_pam_pwhistory_module_regex" |
| 28 | + var_check="at least one" operation="pattern match"/> |
| 29 | + <ind:instance datatype="int">1</ind:instance> |
| 30 | + </ind:textfilecontent54_object> |
| 31 | + |
| 32 | + <!-- variables used to check the module implementation --> |
| 33 | + <local_variable id="var_accounts_password_pam_pwhistory_module_regex" |
| 34 | + datatype="string" version="1" |
| 35 | + comment="The regex is to confirm the pam_pwhistory.so module is enabled"> |
| 36 | + <literal_component>^[ \t]*password[ \t]+(?:(?:sufficient)|(?:required)|(?:requisite)|(?:\[.*\]))[ \t]+pam_pwhistory\.so.*$</literal_component> |
| 37 | + </local_variable> |
| 38 | + |
| 39 | + <ind:textfilecontent54_state id="state_accounts_password_pam_pwhistory_remember" version="1"> |
| 40 | + <ind:subexpression datatype="int" operation="greater than or equal" |
| 41 | + var_ref="var_password_pam_remember"/> |
| 42 | + </ind:textfilecontent54_state> |
| 43 | + |
| 44 | + <!-- Check the pam_pwhistory.so remember parameter --> |
| 45 | + <ind:textfilecontent54_test id="test_accounts_password_pam_pwhistory_remember_parameter" version="1" |
| 46 | + check="all" check_existence="all_exist" |
| 47 | + comment="Test if remember attribute of pam_pwhistory.so is set correctly in {{{ accounts_password_pam_file }}}"> |
| 48 | + <ind:object object_ref="object_accounts_password_pam_pwhistory_remember_parameter" /> |
| 49 | + <ind:state state_ref="state_accounts_password_pam_pwhistory_remember" /> |
| 50 | + </ind:textfilecontent54_test> |
| 51 | + |
| 52 | + <ind:textfilecontent54_object id="object_accounts_password_pam_pwhistory_remember_parameter" version="1"> |
| 53 | + <ind:filepath>{{{ accounts_password_pam_file }}}</ind:filepath> |
| 54 | + <ind:pattern operation="pattern match">^[ \t]*password[ \t]+(?:(?:sufficient)|(?:required)|(?:requisite)|(?:\[.*\]))[ \t]+pam_pwhistory\.so[ \t]+[^#\n\r]*\bremember=([0-9]*)\b.*$</ind:pattern> |
| 55 | + <ind:instance datatype="int">1</ind:instance> |
| 56 | + </ind:textfilecontent54_object> |
| 57 | + |
| 58 | +</def-group> |
0 commit comments