<def-group>
  <!-- THIS FILE IS GENERATED by create_services_enabled.py according to RHEL-7 template
       from RHEL/7/input/checks/templates/template_service_enabled. DO NOT EDIT.

       IF REQUIRED INSTEAD OF EDITING THIS FILE RATHER EDIT THAT TEMPLATE DIRECTLY.
       AFTER THAT BE SURE TO REGENERATE ALL CORRESPONDING UNCOMMENTED CHECKS FROM
       service_enabled.csv CSV FILE AND PLACE THOSE NEW OVAL VERSIONS into
       RHEL/7/input/checks DIRECTORY REPLACING THE FORMER ONES
  -->

  <definition class="compliance" id="service_SERVICENAME_enabled" version="1">
    <metadata>
      <title>Service SERVICENAME Enabled</title>
      <affected family="unix">
        <platform>Red Hat Enterprise Linux 7</platform>
      </affected>
      <description>The SERVICENAME service should be enabled if possible.</description>
    </metadata>
    <criteria operator="AND" comment="package PACKAGENAME installed and service SERVICENAME is configured to start">
      <extend_definition comment="PACKAGENAME installed" definition_ref="package_PACKAGENAME_installed" />
      <criteria operator="AND" comment="service SERVICENAME is configured to start">
        <criterion comment="SERVICENAME not masked" test_ref="test_SERVICENAME_not_masked" />
        <criterion comment="SERVICENAME enabled on boot" test_ref="test_SERVICENAME_enabled_on_boot" />
      </criteria>
    </criteria>
  </definition>

  <!-- Test if SERVICENAME is not masked -->
  <unix:file_test id="test_SERVICENAME_not_masked" check="all" check_existence="none_exist" comment="Test if SERVICENAME is not masked" version="1">
    <unix:object object_ref="object_SERVICENAME_not_masked" />
  </unix:file_test>

  <unix:file_object id="object_SERVICENAME_not_masked" comment="/etc/systemd/system/SERVICENAME.service doesn't exist" version="1">
    <unix:filepath>/etc/systemd/system/SERVICENAME.service</unix:filepath>
  </unix:file_object>

  <!-- Test if SERVICENAME enabled on boot -->
  <unix:file_test id="test_SERVICENAME_enabled_on_boot" check="all" check_existence="at_least_one_exists" comment="Test if SERVICENAME not disabled on boot" version="1">
    <unix:object object_ref="object_SERVICENAME_enabled_on_boot" />
  </unix:file_test>

  <unix:file_object id="object_SERVICENAME_enabled_on_boot" comment="At least one /etc/systemd/system/*.wants/SERVICENAME.service exists" version="1">
    <!-- Don't follow symbolic links below to search just through /etc/systemd/system/* content -->
    <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
    <unix:path>/etc/systemd/system</unix:path>
    <unix:filename>SERVICENAME.service</unix:filename>
    <!-- Include all symbolic link entities in the /etc/systemd/system directory tree -->
    <filter action="include">state_SERVICENAME_symlink</filter>
    <!-- But exclude that one causing service to be masked -->
    <filter action="exclude">state_SERVICENAME_masked_symlink</filter>
  </unix:file_object>

  <unix:file_state id="state_SERVICENAME_symlink" version="1">
    <unix:type>symbolic link</unix:type>
  </unix:file_state>

  <unix:file_state id="state_SERVICENAME_masked_symlink" version="1">
    <unix:filepath>/etc/systemd/system/SERVICENAME.service</unix:filepath>
  </unix:file_state>

</def-group>
