<def-group>
  <definition class="compliance" id="perms_var_log_audit" version="1">
    <metadata>
      <title>Directory /var/log/audit/ Permissions</title>
      <affected family="unix">
        <platform>CentOS 4</platform>
		<platform>CentOS 5</platform>
		<platform>Red Hat Enterprise Linux 4</platform>
		<platform>Red Hat Enterprise Linux 5</platform>
      </affected>
      <description>Directory permissions for /var/log/audit should be set to 0750 and files should be set to 0640.</description>
    </metadata>
    <criteria>
      <criterion test_ref="test_dir_perms_var_log_audit" />
      <criterion test_ref="test_perms_var_log_audit" negate="true" />
    </criteria>
  </definition>

  <unix:file_test check="all" check_existence="all_exist" comment="Testing directory permissions" id="test_dir_perms_var_log_audit" version="1">
    <unix:object object_ref="object_dir_perms_var_log_audit" />
    <unix:state state_ref="state_dir_perms_var_log_audit" />
  </unix:file_test>
  <unix:file_object comment="/var/log/audit/" id="object_dir_perms_var_log_audit" version="1">
    <unix:path>/var/log/audit</unix:path>
    <unix:filename xsi:nil="true" />
  </unix:file_object>
  <unix:file_state id="state_dir_perms_var_log_audit" version="1">
    <unix:gwrite datatype="boolean">false</unix:gwrite>
    <unix:oread datatype="boolean">false</unix:oread>
    <unix:owrite datatype="boolean">false</unix:owrite>
    <unix:oexec datatype="boolean">false</unix:oexec>
  </unix:file_state>

  <unix:file_test check="all" check_existence="at_least_one_exists" comment="/var/log/audit files mode 0640" id="test_perms_var_log_audit" version="1">
    <unix:object object_ref="object_var_log_audit_files" />
    <unix:state state_ref="state_not_mode_0640" />
  </unix:file_test>
  <unix:file_object comment="/var/log/audit files" id="object_var_log_audit_files" version="1">
    <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
    <unix:path operation="equals">/var/log/audit</unix:path>
    <unix:filename operation="pattern match">^.*$</unix:filename>
    <filter action="include">state_not_mode_0640</filter>
  </unix:file_object>
  <unix:file_state id="state_not_mode_0640" version="1" operator="OR">
    <!-- if any one of these is true then mode is NOT 0640 (hence the OR operator) -->
    <unix:suid datatype="boolean">true</unix:suid>
    <unix:sgid datatype="boolean">true</unix:sgid>
    <unix:sticky datatype="boolean">true</unix:sticky>
    <unix:uexec datatype="boolean">true</unix:uexec>
    <unix:gwrite datatype="boolean">true</unix:gwrite>
    <unix:gexec datatype="boolean">true</unix:gexec>
    <unix:oread datatype="boolean">true</unix:oread>
    <unix:owrite datatype="boolean">true</unix:owrite>
    <unix:oexec datatype="boolean">true</unix:oexec>
  </unix:file_state>
  
</def-group>
