<def-group>
  <definition class="compliance" id="kernel_config_legacy_ptys"
  version="1">
    <metadata>
        <title>Disable legacy (BSD) PTY support</title>
            <affected family="unix">
                <platform>multi_platform_all</platform>
            </affected>
        <description>The kernel CONFIG_LEGACY_PTYS should have value n</description>
    </metadata>
    <criteria operator="OR">
      <criteria operator="AND">
        <criterion comment="Check presence of build configuration of installed kernels"
        test_ref="test_kernel_config_legacy_ptys" />
        <criterion comment="Ensure all kernels have the config"
        test_ref="test_all_kernels_config_legacy_ptys_compliant" />
      </criteria>

      <criterion comment="Check absense of build configuration of installed kernels"
      test_ref="test_kernel_config_legacy_ptys_absence" />

    </criteria>
  </definition>

  <ind:textfilecontent54_test check="all"
  comment="Check /boot/config-.* files for CONFIG_LEGACY_PTYS=n"
  id="test_kernel_config_legacy_ptys" version="1">
    <ind:object object_ref="object_kernel_config_legacy_ptys" />
    <ind:state state_ref="state_kernel_config_legacy_ptys" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_kernel_config_legacy_ptys" version="1">
    <ind:filepath operation="pattern match">^/boot/config-.*$</ind:filepath>
    <ind:pattern operation="pattern match">^CONFIG_LEGACY_PTYS="?(.*?)"?$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>
  <ind:textfilecontent54_state id="state_kernel_config_legacy_ptys" version="1">
    <ind:subexpression operation="equals" datatype="string">n</ind:subexpression>
  </ind:textfilecontent54_state>



  <ind:textfilecontent54_test check="all" check_existence="none_exist"
  comment="Check /boot/config-.* files for absence of CONFIG_LEGACY_PTYS"
  id="test_kernel_config_legacy_ptys_absence" version="1">
    <ind:object object_ref="object_kernel_config_legacy_ptys" />
  </ind:textfilecontent54_test>


  <ind:variable_test check="all" check_existence="all_exist"
  comment="Check if all installed kernels are compliant"
  id="test_all_kernels_config_legacy_ptys_compliant" version="1">
    <ind:object object_ref="object_var_kernel_config_legacy_ptys_count" />
    <ind:state state_ref="state_var_kernel_config_legacy_ptys" />
  </ind:variable_test>

  <ind:variable_object id="object_var_kernel_config_legacy_ptys_count" version="1">
    <ind:var_ref>local_var_config_legacy_ptys_count_kernels_installed</ind:var_ref>
  </ind:variable_object>

  <ind:variable_state id="state_var_kernel_config_legacy_ptys" version="1">
    <ind:value operation="equals" datatype="int"
    var_ref="local_var_config_legacy_ptys_count_compliant_configs" />
  </ind:variable_state>

  <local_variable comment="Count number of kernels installed" datatype="int"
  id="local_var_config_legacy_ptys_count_kernels_installed" version="1">
    <count>
      <unique>
        <object_component object_ref="object_kernel_config_legacy_ptys_files"
        item_field="filepath" />
      </unique>
    </count>
  </local_variable>

  <local_variable comment="Count number of configs found" datatype="int"
  id="local_var_config_legacy_ptys_count_compliant_configs" version="1">
    <count>
      <unique>
        <object_component object_ref="object_kernel_config_legacy_ptys"
        item_field="filepath" />
      </unique>
    </count>
  </local_variable>

  <unix:file_object comment="Collect the kernel config files" id="object_kernel_config_legacy_ptys_files" version="1">
      <unix:path>/boot</unix:path>
      <unix:filename operation="pattern match">^config-.*$</unix:filename>
  </unix:file_object>
</def-group>