<def-group>
  <definition class="compliance" id="network_configure_name_resolution" version="1">
    {{{ oval_metadata("Multiple Domain Name System (DNS) Servers should be configured
      in /etc/resolv.conf.") }}}
    <criteria operator="OR">
      {{% if "ol" in product or "rhel" in product %}}
      <criteria comment="If the DNS entry is found on the host's line of the /etc/nsswitch.conf
        file, verify the operating system is configured to use two or more name servers for DNS
        resolution."
        operator="AND">
        <criterion comment="check if dns is set in host line in  /etc/nsswitch.conf"
        test_ref="test_host_line_dns_parameter_nsswitch" />
        <criterion comment="check if more than one nameserver in /etc/resolv.conf"
        test_ref="test_network_configure_name_resolution" />
      </criteria>
      <criteria comment="If the DNS entry is missing from the host's line in the /etc/nsswitch.conf
        file, the /etc/resolv.conf file must be empty. " operator="AND">
        <criterion comment="check that dns is not set in host line in  /etc/nsswitch.conf"
        test_ref="test_host_line_dns_parameter_nsswitch" negate="true"/>
        <criterion comment="check if /etc/resolv.conf is empty"
        test_ref="test_file_empty_resolv" />
      </criteria>
      {{% else %}}
      <criterion comment="check if more than one nameserver in /etc/resolv.conf"
      test_ref="test_network_configure_name_resolution" />
      {{% endif %}}
    </criteria>
  </definition>
  <ind:textfilecontent54_test check="all" check_existence="all_exist"
  comment="check if more than one nameserver in /etc/resolv.conf"
  id="test_network_configure_name_resolution" version="1">
    <ind:object object_ref="obj_network_configure_name_resolution" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="obj_network_configure_name_resolution" version="1">
    <ind:filepath>/etc/resolv.conf</ind:filepath>
    <ind:pattern operation="pattern match">^[\s]*nameserver[\s]+([0-9\.]+)$</ind:pattern>
    <!-- Make sure we have greater than 1 nameserver in resolv.conf -->
    <ind:instance datatype="int" operation="greater than">1</ind:instance>
  </ind:textfilecontent54_object>

  {{% if "ol" in product or "rhel" in product %}}
  <ind:textfilecontent54_test check="all" check_existence="all_exist"
  comment="check if dns is set in host line in  /etc/nsswitch.conf"
  id="test_host_line_dns_parameter_nsswitch" version="1">
    <ind:object object_ref="obj_host_line_dns_parameter_nsswitch" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="obj_host_line_dns_parameter_nsswitch" version="1">
    <ind:filepath>/etc/nsswitch.conf</ind:filepath>
    <ind:pattern operation="pattern match">^\s*hosts\s*:\s*.*dns.*$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>

  <unix:file_test id="test_file_empty_resolv" check="all" check_existence="all_exist"
    comment="check if /etc/resolv.conf is empty" version="1">
    <unix:object object_ref="obj_file_empty_resolv"/>
    <unix:state state_ref="state_file_empty_resolv"/>
  </unix:file_test>
  <unix:file_object id="obj_file_empty_resolv" version="1">
    <unix:filepath>/etc/resolv.conf</unix:filepath>
  </unix:file_object>
  <unix:file_state id="state_file_empty_resolv" version="1">
    <unix:size datatype="int">0</unix:size>
  </unix:file_state>

  {{% endif %}}
</def-group>
