<def-group>
  <definition class="compliance" id="file_permissions_binary_dirs" version="1">
    <metadata>
      <title>Verify that System Executables Have Restrictive 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>Checks that /etc, /bin, /usr/bin, /usr/lbin, /usr/usb, /sbin, /usr/sbin and objects therein, have permissions of 755 or less.</description>
    </metadata>
    <criteria operator="AND">
      <criterion test_ref="test_perms_etc_files" />
      <criterion test_ref="test_perms_bin_files" />
      <criterion test_ref="test_perms_usr_bin_files" />
      <criterion test_ref="test_perms_usr_lbin_files" />
      <criterion test_ref="test_perms_usr_usb_files" />
      <criterion test_ref="test_perms_sbin_files" />
      <criterion test_ref="test_perms_usr_sbin_files" />
    </criteria>
  </definition>

<!-- /etc directory and file tests -->
  <unix:file_test check="all" check_existence="none_exist" comment="/etc files go-w" id="test_perms_etc_files" version="1">
    <unix:object object_ref="object_file_permissions_etc_files" />
  </unix:file_test>
  <unix:file_object comment="/etc files" id="object_file_permissions_etc_files" version="1">
    <unix:behaviors recurse="symlinks and directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
    <unix:path operation="equals">/etc</unix:path>
    <unix:filename operation="pattern match">^.*$</unix:filename>
    <filter action="include">state_permissions_binary_dirs</filter>
    <filter action="exclude">state_permissions_binary_dirs_symlink</filter>
  </unix:file_object>
<!-- end /etc directory and file tests -->

<!-- /bin directory and file tests -->
  <unix:file_test check="all" check_existence="none_exist" comment="/bin files go-w" id="test_perms_bin_files" version="1">
    <unix:object object_ref="object_file_permissions_bin_files" />
  </unix:file_test>
  <unix:file_object comment="/bin files" id="object_file_permissions_bin_files" version="1">
    <unix:behaviors recurse="symlinks and directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
    <unix:path operation="equals">/bin</unix:path>
    <unix:filename operation="pattern match">^.*$</unix:filename>
    <filter action="include">state_permissions_binary_dirs</filter>
    <filter action="exclude">state_permissions_binary_dirs_symlink</filter>
  </unix:file_object>
<!-- end /bin directory and file tests -->

<!-- /usr/bin directory and file tests -->
  <unix:file_test check="all" check_existence="none_exist" comment="/usr/bin files go-w" id="test_perms_usr_bin_files" version="1">
    <unix:object object_ref="object_file_permissions_usr_bin_files" />
  </unix:file_test>
  <unix:file_object comment="/usr/bin files" id="object_file_permissions_usr_bin_files" version="1">
    <unix:behaviors recurse="symlinks and directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
    <unix:path operation="equals">/usr/bin</unix:path>
    <unix:filename operation="pattern match">^.*$</unix:filename>
    <filter action="include">state_permissions_binary_dirs</filter>
    <filter action="exclude">state_permissions_binary_dirs_symlink</filter>
  </unix:file_object>
<!-- end /usr/bin directory and file tests -->

<!-- /usr/lbin directory and file tests -->
  <unix:file_test check="all" check_existence="none_exist" comment="/usr/lbin files go-w" id="test_perms_usr_lbin_files" version="1">
    <unix:object object_ref="object_file_permissions_usr_lbin_files" />
  </unix:file_test>
  <unix:file_object comment="/usr/lbin files" id="object_file_permissions_usr_lbin_files" version="1">
    <unix:behaviors recurse="symlinks and directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
    <unix:path operation="equals">/usr/lbin</unix:path>
    <unix:filename operation="pattern match">^.*$</unix:filename>
    <filter action="include">state_permissions_binary_dirs</filter>
    <filter action="exclude">state_permissions_binary_dirs_symlink</filter>
  </unix:file_object>
<!-- end /usr/lbin directory and file tests -->

<!-- /usr/usb directory and file tests -->
  <unix:file_test check="all" check_existence="none_exist" comment="/usr/usb files go-w" id="test_perms_usr_usb_files" version="1">
    <unix:object object_ref="object_file_permissions_usr_usb_files" />
  </unix:file_test>
  <unix:file_object comment="/usr/usb files" id="object_file_permissions_usr_usb_files" version="1">
    <unix:behaviors recurse="symlinks and directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
    <unix:path operation="equals">/usr/usb</unix:path>
    <unix:filename operation="pattern match">^.*$</unix:filename>
    <filter action="include">state_permissions_binary_dirs</filter>
    <filter action="exclude">state_permissions_binary_dirs_symlink</filter>
  </unix:file_object>
<!-- end /usr/usb directory and file tests -->

<!-- /sbin directory and file tests -->
  <unix:file_test check="all" check_existence="none_exist" comment="/sbin files go-w" id="test_perms_sbin_files" version="1">
    <unix:object object_ref="object_file_permissions_sbin_files" />
  </unix:file_test>
  <unix:file_object comment="/sbin files" id="object_file_permissions_sbin_files" version="1">
    <unix:behaviors recurse="symlinks and directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
    <unix:path operation="equals">/sbin</unix:path>
    <unix:filename operation="pattern match">^.*$</unix:filename>
    <filter action="include">state_permissions_binary_dirs</filter>
    <filter action="exclude">state_permissions_binary_dirs_symlink</filter>
  </unix:file_object>
<!-- end /sbin directory and file tests -->

<!-- /usr/sbin directory and file tests -->
  <unix:file_test check="all" check_existence="none_exist" comment="/usr/sbin files go-w" id="test_perms_usr_sbin_files" version="1">
    <unix:object object_ref="object_file_permissions_usr_sbin_files" />
  </unix:file_test>
  <unix:file_object comment="/usr/sbin files" id="object_file_permissions_usr_sbin_files" version="1">
    <unix:behaviors recurse="symlinks and directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
    <unix:path operation="equals">/usr/sbin</unix:path>
    <unix:filename operation="pattern match">^.*$</unix:filename>
    <filter action="include">state_permissions_binary_dirs</filter>
    <filter action="exclude">state_permissions_binary_dirs_symlink</filter>
  </unix:file_object>
<!-- end /usr/sbin directory and file tests -->

  <unix:file_state id="state_permissions_binary_dirs_symlink" version="1">
    <unix:type operation="equals">symbolic link</unix:type>
  </unix:file_state>
  <unix:file_state id="state_permissions_binary_dirs" version="1" operator="OR">
    <unix:gwrite datatype="boolean">true</unix:gwrite>
    <unix:owrite datatype="boolean">true</unix:owrite>
  </unix:file_state>

</def-group>
