<def-group>
  <definition class="compliance" id="file_permissions_home_dirs" version="1">
    <metadata>
      <title>Proper Permissions User Home Directories</title>
      <affected family="unix">
        <platform>multi_platform_all</platform>
      </affected>
      <description>File permissions should be set correctly for the home directories for all user accounts.</description>
      <reference source="JL" ref_id="RHEL6_20141106" ref_url="test_attestation"/>
      <reference source="JL" ref_id="RHEL7_20141106" ref_url="test_attestation"/>
      <reference source="JL" ref_id="Fedora20_20141106" ref_url="test_attestation"/>
    </metadata>
    <criteria >
      <criterion comment="home directories" test_ref="test_file_permissions_home_dirs" negate="true" />
    </criteria>
  </definition>

  <unix:file_test check="all" check_existence="at_least_one_exists" comment="home directories" id="test_file_permissions_home_dirs" version="1">
    <unix:object object_ref="object_file_permissions_home_dirs" />
    <unix:state state_ref="state_home_dirs_wrong_perm" />
  </unix:file_test>

  <unix:file_object comment="home directories" id="object_file_permissions_home_dirs" version="2">
    <unix:behaviors recurse="directories" recurse_direction="down" max_depth="1" recurse_file_system="all" />
    <unix:path operation="equals">/home</unix:path>
    <unix:filename xsi:nil="true" />
    <filter action="exclude">state_home_dirs_home_itself</filter>
    <filter action="include">state_home_dirs_wrong_perm</filter>
  </unix:file_object>

  <unix:file_state id="state_home_dirs_home_itself" version="1">
    <!-- Exclude /home directory itself from the check. Check /home/* directories only. -->
    <unix:path operation="equals">/home</unix:path>
  </unix:file_state>

  <unix:file_state id="state_home_dirs_wrong_perm" version="1" operator="OR">
    <unix:suid datatype="boolean">true</unix:suid>
    <unix:sgid datatype="boolean">true</unix:sgid>
    <unix:sticky datatype="boolean">true</unix:sticky>
    <unix:gwrite datatype="boolean">true</unix:gwrite>
    <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>
