<def-group>
  <definition class="compliance" id="file_ownership_var_log_audit" version="2">
    <metadata>
      <title>Verify /var/log/audit Ownership</title>
      <affected family="unix">
        <platform>multi_platform_all</platform>
      </affected>
      <description>Checks that all /var/log/audit files and directories are owned by the root user and group.</description>
      <reference source="JL" ref_id="RHEL6_20150814" ref_url="test_attestation" />
      <reference source="JL" ref_id="RHEL7_20150814" ref_url="test_attestation" />
      <reference source="JL" ref_id="FEDORA22_20150814" ref_url="test_attestation" />
    </metadata>
    <criteria operator="AND">
      <criterion test_ref="test_ownership_var_log_audit_files" />
      <criterion test_ref="test_ownership_var_log_audit_directories" />
    </criteria>
  </definition>

  <unix:file_test check="all" check_existence="none_exist" comment="/var/log/audit directories uid root gid root" id="test_ownership_var_log_audit_directories" version="1">
    <unix:object object_ref="object_ownership_var_log_audit_directories" />
  </unix:file_test>

  <unix:file_test check="all" check_existence="none_exist" comment="/var/log/audit files uid root gid root" id="test_ownership_var_log_audit_files" version="1">
    <unix:object object_ref="object_ownership_var_log_audit_files" />
  </unix:file_test>

  <unix:file_object comment="/var/log/audit directories" id="object_ownership_var_log_audit_directories" version="1">
    <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="all" />
    <unix:path operation="equals">/var/log/audit</unix:path>
    <unix:filename xsi:nil="true" />
    <filter action="include">state_owner_not_root_root_var_log_audit</filter>
  </unix:file_object>

  <unix:file_object comment="/var/log/audit files" id="object_ownership_var_log_audit_files" version="1">
    <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="all" />
    <unix:path operation="equals">/var/log/audit</unix:path>
    <unix:filename operation="pattern match">^.*$</unix:filename>
    <filter action="include">state_owner_not_root_root_var_log_audit</filter>
  </unix:file_object>

  <unix:file_state id="state_owner_not_root_root_var_log_audit" version="1" operator="OR">
    <unix:group_id datatype="int" operation="not equal">0</unix:group_id>
    <unix:user_id datatype="int" operation="not equal">0</unix:user_id>
  </unix:file_state>

</def-group>
