<def-group>
  <definition class="compliance" id="sysctl_kernel_exec_shield" version="2">
    {{{ oval_metadata("The kernel runtime parameter 'kernel.exec-shield' should not be disabled and set to 1 on 32-bit systems.") }}}
    <criteria operator="OR">
      {{# products that are available also in a 32 bits form #}}
      {{% if "rhel" not in product and product != "fedora" and "ol" not in families %}}
      <criteria operator="AND">
        <extend_definition comment="32-bit system" definition_ref="system_info_architecture_x86" />
        <criterion comment="kernel runtime parameter kernel.exec-shield set to 1" test_ref="test_runtime_sysctl_kernel_exec_shield" />
        <criterion comment="kernel /etc/sysctl.conf parameter kernel.exec-shield set to 1" test_ref="test_static_sysctl_kernel_exec_shield" />
      </criteria>
      {{% endif %}}
      <criteria operator="AND">
        <extend_definition comment="64-bit system" definition_ref="system_info_architecture_64bit" />
        <criterion comment="NX is supported and is not disabled" test_ref="test_nx_disabled_grub" />
      </criteria>
    </criteria>
  </definition>

  <!-- Check for 32bit systems  -->
  <unix:sysctl_test check="all" check_existence="all_exist" comment="kernel runtime parameter kernel.exec-shield set to 1" id="test_runtime_sysctl_kernel_exec_shield" version="1">
    <unix:object object_ref="object_sysctl_kernel_exec_shield" />
    <unix:state state_ref="state_sysctl_kernel_exec_shield" />
  </unix:sysctl_test>

  <ind:textfilecontent54_test check="all" check_existence="all_exist" comment="kernel.exec-shield static configuration" id="test_static_sysctl_kernel_exec_shield" version="1">
    <ind:object object_ref="object_static_sysctl_kernel_exec_shield" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_static_sysctl_kernel_exec_shield" version="1">
    <ind:filepath>/etc/sysctl.conf</ind:filepath>
    <ind:pattern operation="pattern match">^[\s]*kernel.exec-shield[\s]*=[\s]*1[\s]*$</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>

  <unix:sysctl_object id="object_sysctl_kernel_exec_shield" version="1">
    <unix:name>kernel.exec-shield</unix:name>
  </unix:sysctl_object>

  <unix:sysctl_state id="state_sysctl_kernel_exec_shield" version="1">
    <unix:value datatype="int" operation="equals">1</unix:value>
  </unix:sysctl_state>

  <!-- Check for 64-bit systems -->
  <ind:textfilecontent54_test check="all" check_existence="none_exist" comment="NX is disabled" id="test_nx_disabled_grub" version="1">
    <ind:object object_ref="object_nx_disabled_grub" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_nx_disabled_grub" version="1">
    <ind:filepath>{{{ grub2_boot_path }}}/grub.cfg</ind:filepath>
    <ind:pattern operation="pattern match">[\s]*noexec[\s]*=[\s]*off</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>
</def-group>
