<def-group><!-- The test will check if correct option is present in both active (/proc/mounts) and
       configured (/etc/fstab) mount points. It won't fail if the mount point is not currently
       active, but will consider absence of the mount point configuration as a failure unless
       MOUNT_HAS_TO_EXIST is set to `true` (the name is a bit controversial: it means that
       the mount point has to exist in the configuration file to be checked, and we don't care
       about it if it is not configured). -->

  <definition class="compliance" id="mount_option_proc_hidepid" version="2">
    <metadata>
        <title>Add hidepid Option to /proc</title>
        
    <affected family="unix">
    <platform>Ubuntu 22.04</platform>
    </affected>
        <description>/proc should be mounted with mount option hidepid.</description>
    </metadata>
    <criteria operator="AND">
      <criteria operator="OR">
         <criterion comment="hidepid on /proc"
           test_ref="test_proc_partition_hidepid_expected"/>
         <criterion comment="/proc does not exist"
           test_ref="test_proc_partition_hidepid_expected_exist"
           negate="true" />
      </criteria>
      <criteria operator="OR">
         <criterion comment="hidepid on /proc in /etc/fstab"
           test_ref="test_proc_partition_hidepid_expected_in_fstab"/>
    
      </criteria>
    </criteria>
  </definition>


  <linux:partition_object version="1"
    id="object_proc_partition_hidepid_expected">
    <linux:mount_point>/proc</linux:mount_point>
  </linux:partition_object>

  <ind:textfilecontent54_object version="1"
    id="object_proc_partition_hidepid_expected_in_fstab">
    <ind:filepath>/etc/fstab</ind:filepath>

    <ind:pattern operation="pattern match">^[\s]*(?!#)[\S]+[\s]+/proc[\s]+[\S]+[\s]+([\S]+)</ind:pattern>

    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>


  <linux:partition_state version="1"
    id="state_proc_partition_hidepid_expected">


    <linux:mount_options datatype="string" entity_check="at least one" operation="equals"
      var_ref="local_var_mountoption_hidepid_with_value"/>

  </linux:partition_state>



  <ind:textfilecontent54_state version="1"
    id="state_proc_partition_hidepid_expected_in_fstab">
    <ind:instance datatype="int">1</ind:instance>

    <ind:subexpression entity_check="at least one" operation="pattern match"
       var_ref="local_var_mountoption_hidepid_with_value"/>

  </ind:textfilecontent54_state>


  <external_variable datatype="string" id="var_mount_option_proc_hidepid" version="1"
                     comment="Variable defining the value the argument should have"/>

  <local_variable id="local_var_mountoption_hidepid_with_value"
    comment="Value used in hidepid option as defined in var_mount_option_proc_hidepid variable"
    datatype="string" version="1">
    <concat>
      <literal_component>hidepid=</literal_component>
      <variable_component var_ref="var_mount_option_proc_hidepid"/>
    </concat>
  </local_variable>



  <linux:partition_test check="all" check_existence="all_exist" version="2"
    comment="hidepid on /proc "
    id="test_proc_partition_hidepid_expected">
    <linux:object object_ref="object_proc_partition_hidepid_expected"/>
    <linux:state state_ref="state_proc_partition_hidepid_expected"/>
  </linux:partition_test>

  <ind:textfilecontent54_test check="all" check_existence="all_exist" version="1"
    comment="hidepid on /proc  in /etc/fstab"
    id="test_proc_partition_hidepid_expected_in_fstab">
    <ind:object object_ref="object_proc_partition_hidepid_expected_in_fstab" />
    <ind:state state_ref="state_proc_partition_hidepid_expected_in_fstab" />
  </ind:textfilecontent54_test>


  <linux:partition_test check="all" check_existence="all_exist" version="1"
    comment="/proc exists"
    id="test_proc_partition_hidepid_expected_exist">
    <linux:object object_ref="object_proc_partition_hidepid_expected"/>

  </linux:partition_test>


</def-group>