<def-group>
  <definition class="compliance" id="accounts_password_pam_unix_remember" version="1">
    <metadata>
      <title>Limit Password Reuse</title>
      <affected family="unix">
        <platform>CentOS 4</platform>
        <platform>CentOS 5</platform>
        <platform>Red Hat Enterprise Linux 4</platform>
        <platform>Red Hat Enterprise Linux 5</platform>
      </affected>
      <description>The passwords to remember should be set correctly.</description>
    </metadata>
    <criteria>
      <criterion comment="/etc/security/opasswd exists" test_ref="test_etc_security_opasswd" />
      <criterion comment="remember parameter is set to 0 in /etc/pam.d/system-auth" test_ref="test_accounts_password_pam_unix_remember" />
	  <criteria operator="OR">
		  <criterion comment="system-auth-ac is not included in /etc/pam.d/*" test_ref="test_systemauthac_not_included" />
		  <criterion comment="remember parameter is set to 0 in /etc/pam.d/system-auth-ac" test_ref="test_accounts_password_pam_unix_remember_systemauthac" />
	  </criteria>
    </criteria>
  </definition>

  <unix:file_test check="all" check_existence="all_exist" comment="/etc/security/opasswd exists" id="test_etc_security_opasswd" version="1">
    <unix:object object_ref="object_etc_security_opasswd" />
  </unix:file_test>
  <unix:file_object comment="/etc/security/opasswd exists" id="object_etc_security_opasswd" version="1">
    <unix:path operation="equals">/etc/security</unix:path>
    <unix:filename>opasswd</unix:filename>
  </unix:file_object>

  <ind:textfilecontent54_test check="all" check_existence="all_exist" comment="remember is set in /etc/pam.d/system-auth" id="test_accounts_password_pam_unix_remember" version="1">
    <ind:object object_ref="object_accounts_password_pam_unix_remember" />
    <ind:state state_ref="state_accounts_password_pam_unix_remember" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="object_accounts_password_pam_unix_remember" version="1">
    <ind:path>/etc/pam.d</ind:path>
    <ind:filename>system-auth</ind:filename>
    <ind:pattern operation="pattern match">^password[\s]+(?:sufficient|required)[\s]+(?:/lib/security/(?:\$ISA/)*)*(?:(?:pam_pwhistory\.so)|(?:pam_unix\.so)).*remember=([0-9]*).*$</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>
  <ind:textfilecontent54_state id="state_accounts_password_pam_unix_remember" version="1">
    <ind:subexpression datatype="int" operation="greater than or equal" var_ref="password_history_retain_number" />
  </ind:textfilecontent54_state>

   <ind:textfilecontent54_test check="all" check_existence="none_exist" comment="system-auth-ac is not included in /etc/pam.d/*" id="test_systemauthac_not_included" version="1">
    <ind:object object_ref="object_systemauthac_not_included" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="object_systemauthac_not_included" version="1">
    <ind:path>/etc/pam.d</ind:path>
    <ind:filename operation="pattern match">.*</ind:filename>
    <ind:pattern operation="pattern match">.*(system-auth-ac)</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>
 
  <ind:textfilecontent54_test check="all" check_existence="all_exist" comment="remember is set in /etc/pam.d/system-auth-ac" id="test_accounts_password_pam_unix_remember_systemauthac" version="1">
    <ind:object object_ref="object_accounts_password_pam_unix_remember_systemauthac" />
    <ind:state state_ref="state_accounts_password_pam_unix_remember_systemauthac" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="object_accounts_password_pam_unix_remember_systemauthac" version="1">
    <ind:path>/etc/pam.d</ind:path>
    <ind:filename>system-auth-ac</ind:filename>
    <ind:pattern operation="pattern match">^password[\s]+(?:sufficient|required)[\s]+(?:/lib/security/(?:\$ISA/)*)*(?:(?:pam_pwhistory\.so)|(?:pam_unix\.so)).*remember=([0-9]*).*$</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>
  <ind:textfilecontent54_state id="state_accounts_password_pam_unix_remember_systemauthac" version="1">
    <ind:subexpression datatype="int" operation="greater than or equal" var_ref="password_history_retain_number" />
  </ind:textfilecontent54_state>
  
  <external_variable comment="number of passwords that should be remembered" datatype="int" id="password_history_retain_number" version="1" />
</def-group>
