<def-group>
  <definition class="compliance" id="dir_ownership_binary_dirs" version="1">
  
    <metadata>
        <title>Verify that System Executable Have Root Ownership</title>
        
    <affected family="unix">
    <platform>Ubuntu 22.04</platform>
    </affected>
        <description>This test makes sure that /bin/, /sbin/, /usr/bin/, /usr/sbin/, /usr/local/bin/, /usr/local/sbin/ is owned by 0.</description>
    </metadata>
     <criteria>
   
     <criterion comment="Check file ownership of /bin/" test_ref="test_file_ownerdir_ownership_binary_dirs_0" />
   
     <criterion comment="Check file ownership of /sbin/" test_ref="test_file_ownerdir_ownership_binary_dirs_1" />
   
     <criterion comment="Check file ownership of /usr/bin/" test_ref="test_file_ownerdir_ownership_binary_dirs_2" />
   
     <criterion comment="Check file ownership of /usr/sbin/" test_ref="test_file_ownerdir_ownership_binary_dirs_3" />
   
     <criterion comment="Check file ownership of /usr/local/bin/" test_ref="test_file_ownerdir_ownership_binary_dirs_4" />
   
     <criterion comment="Check file ownership of /usr/local/sbin/" test_ref="test_file_ownerdir_ownership_binary_dirs_5" />
   
  
    </criteria>
  </definition>
  <local_variable id="var_file_ownerdir_ownership_binary_dirs_0_uid" comment="Set the uid to 0" datatype="int" version="1">
    <literal_component datatype="int">0</literal_component>
  </local_variable>

  
  <unix:file_test check="all" check_existence="none_exist" comment="Testing user ownership of /bin/" id="test_file_ownerdir_ownership_binary_dirs_0" version="1">
    <unix:object object_ref="object_file_ownerdir_ownership_binary_dirs_0" />
  </unix:file_test>

  <unix:file_object comment="/bin/" id="object_file_ownerdir_ownership_binary_dirs_0" version="1">
      <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
      <unix:path>/bin</unix:path>
      <unix:filename xsi:nil="true" />
    <filter action="exclude">symlink_file_owner</filter>
    
      <filter action="exclude">state_file_ownerdir_ownership_binary_dirs_0_0</filter>
    
  </unix:file_object>
  
    <unix:file_state id="state_file_ownerdir_ownership_binary_dirs_0_0" version="1">
      <unix:user_id datatype="int" operation="equals" var_ref="var_file_ownerdir_ownership_binary_dirs_0_uid"></unix:user_id>
    </unix:file_state>
  
  
  <unix:file_test check="all" check_existence="none_exist" comment="Testing user ownership of /sbin/" id="test_file_ownerdir_ownership_binary_dirs_1" version="1">
    <unix:object object_ref="object_file_ownerdir_ownership_binary_dirs_1" />
  </unix:file_test>

  <unix:file_object comment="/sbin/" id="object_file_ownerdir_ownership_binary_dirs_1" version="1">
      <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
      <unix:path>/sbin</unix:path>
      <unix:filename xsi:nil="true" />
    <filter action="exclude">symlink_file_owner</filter>
    
      <filter action="exclude">state_file_ownerdir_ownership_binary_dirs_0_0</filter>
    
  </unix:file_object>
  
    <unix:file_state id="state_file_ownerdir_ownership_binary_dirs_0_0" version="1">
      <unix:user_id datatype="int" operation="equals" var_ref="var_file_ownerdir_ownership_binary_dirs_0_uid"></unix:user_id>
    </unix:file_state>
  
  
  <unix:file_test check="all" check_existence="none_exist" comment="Testing user ownership of /usr/bin/" id="test_file_ownerdir_ownership_binary_dirs_2" version="1">
    <unix:object object_ref="object_file_ownerdir_ownership_binary_dirs_2" />
  </unix:file_test>

  <unix:file_object comment="/usr/bin/" id="object_file_ownerdir_ownership_binary_dirs_2" version="1">
      <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
      <unix:path>/usr/bin</unix:path>
      <unix:filename xsi:nil="true" />
    <filter action="exclude">symlink_file_owner</filter>
    
      <filter action="exclude">state_file_ownerdir_ownership_binary_dirs_0_0</filter>
    
  </unix:file_object>
  
    <unix:file_state id="state_file_ownerdir_ownership_binary_dirs_0_0" version="1">
      <unix:user_id datatype="int" operation="equals" var_ref="var_file_ownerdir_ownership_binary_dirs_0_uid"></unix:user_id>
    </unix:file_state>
  
  
  <unix:file_test check="all" check_existence="none_exist" comment="Testing user ownership of /usr/sbin/" id="test_file_ownerdir_ownership_binary_dirs_3" version="1">
    <unix:object object_ref="object_file_ownerdir_ownership_binary_dirs_3" />
  </unix:file_test>

  <unix:file_object comment="/usr/sbin/" id="object_file_ownerdir_ownership_binary_dirs_3" version="1">
      <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
      <unix:path>/usr/sbin</unix:path>
      <unix:filename xsi:nil="true" />
    <filter action="exclude">symlink_file_owner</filter>
    
      <filter action="exclude">state_file_ownerdir_ownership_binary_dirs_0_0</filter>
    
  </unix:file_object>
  
    <unix:file_state id="state_file_ownerdir_ownership_binary_dirs_0_0" version="1">
      <unix:user_id datatype="int" operation="equals" var_ref="var_file_ownerdir_ownership_binary_dirs_0_uid"></unix:user_id>
    </unix:file_state>
  
  
  <unix:file_test check="all" check_existence="none_exist" comment="Testing user ownership of /usr/local/bin/" id="test_file_ownerdir_ownership_binary_dirs_4" version="1">
    <unix:object object_ref="object_file_ownerdir_ownership_binary_dirs_4" />
  </unix:file_test>

  <unix:file_object comment="/usr/local/bin/" id="object_file_ownerdir_ownership_binary_dirs_4" version="1">
      <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
      <unix:path>/usr/local/bin</unix:path>
      <unix:filename xsi:nil="true" />
    <filter action="exclude">symlink_file_owner</filter>
    
      <filter action="exclude">state_file_ownerdir_ownership_binary_dirs_0_0</filter>
    
  </unix:file_object>
  
    <unix:file_state id="state_file_ownerdir_ownership_binary_dirs_0_0" version="1">
      <unix:user_id datatype="int" operation="equals" var_ref="var_file_ownerdir_ownership_binary_dirs_0_uid"></unix:user_id>
    </unix:file_state>
  
  
  <unix:file_test check="all" check_existence="none_exist" comment="Testing user ownership of /usr/local/sbin/" id="test_file_ownerdir_ownership_binary_dirs_5" version="1">
    <unix:object object_ref="object_file_ownerdir_ownership_binary_dirs_5" />
  </unix:file_test>

  <unix:file_object comment="/usr/local/sbin/" id="object_file_ownerdir_ownership_binary_dirs_5" version="1">
      <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
      <unix:path>/usr/local/sbin</unix:path>
      <unix:filename xsi:nil="true" />
    <filter action="exclude">symlink_file_owner</filter>
    
      <filter action="exclude">state_file_ownerdir_ownership_binary_dirs_0_0</filter>
    
  </unix:file_object>
  
    <unix:file_state id="state_file_ownerdir_ownership_binary_dirs_0_0" version="1">
      <unix:user_id datatype="int" operation="equals" var_ref="var_file_ownerdir_ownership_binary_dirs_0_uid"></unix:user_id>
    </unix:file_state>
  
  
  <unix:file_state id="symlink_file_owner" version="1">
    <unix:type operation="equals">symbolic link</unix:type>
  </unix:file_state>
</def-group>