<def-group>
  <definition class="compliance" id="directory_ownership_var_log_audit" version="1">
    {{{ oval_metadata("Checks that all /var/log/audit directories are owned by the root user.") }}}
    <criteria comment="directories are root owned" operator="OR">
      <criteria operator="AND" comment="log_file set">
        <extend_definition comment="log_file set in auditd.conf" definition_ref="auditd_conf_log_file_not_set" negate="true" />
        <criterion test_ref="test_user_ownership_var_log_audit_path" />
      </criteria>
      <criteria operator="AND" comment="log_file not set">
        <extend_definition comment="log_file not set in auditd.conf" definition_ref="auditd_conf_log_file_not_set" />
        <criterion test_ref="test_user_ownership_var_log_audit_directories" />
      </criteria>
    </criteria>
  </definition>

  <unix:file_object comment="audit log files" id="object_directory_ownership_var_log_audit_file" version="1">
    <unix:filepath operation="pattern match" var_ref="audit_log_file_path" />
  </unix:file_object>

  <local_variable id="var_directory_ownership_var_log_audit_path" datatype="string" version="1"
      comment="Path to log_file">
    <object_component item_field="path" object_ref="object_directory_ownership_var_log_audit_file" />
  </local_variable>

  <unix:file_test check="all" check_existence="none_exist"
      comment="log_file's directory uid root gid root"
      id="test_user_ownership_var_log_audit_path" version="1">
    <unix:object object_ref="object_user_ownership_var_log_audit_path" />
  </unix:file_test>

  <unix:file_object comment="log_file's directory" 
      id="object_user_ownership_var_log_audit_path" version="1">
    <unix:path operation="equals" var_ref="var_directory_ownership_var_log_audit_path"/>
    <unix:filename xsi:nil="true" />
    <filter action="include">state_owner_not_root_var_log_audit_directories</filter>
  </unix:file_object>

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

  <unix:file_object comment="/var/log/audit directories" id="object_user_ownership_var_log_audit_directories" version="1">
    <unix:path operation="equals">/var/log/audit</unix:path>
    <unix:filename xsi:nil="true" />
    <filter action="include">state_owner_not_root_var_log_audit_directories</filter>
  </unix:file_object>

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

</def-group>
