<def-group>
  <definition class="compliance" id="ensure_logrotate_activated" version="1">
    {{{ oval_metadata("
      The frequency of automatic log files rotation performed by the logrotate utility should be configured to run daily
      ") }}}
    <criteria comment="/etc/logrotate.conf contains daily setting and /etc/cron.daily/logrotate file exists" operator="AND">
      <criterion comment="Check if daily is set in /etc/logrotate.conf"
      test_ref="test_logrotate_conf_daily_setting" />
      <criterion comment="check that there is no weekly/monthly/yearly keyword in logrotate.conf"
      test_ref="test_logrotate_conf_no_other_keyword" />
      <criterion comment="Check if /etc/cron.daily/logrotate file exists (and calls logrotate)"
      test_ref="test_cron_daily_logrotate_existence" />
    </criteria>
  </definition>

  <ind:textfilecontent54_test check="all" check_existence="all_exist"
  comment="Tests the presence of daily setting in /etc/logrotate.conf file"
  id="test_logrotate_conf_daily_setting" version="1">
    <ind:object object_ref="object_logrotate_conf_daily_setting" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_logrotate_conf_daily_setting" version="2">
    <ind:filepath>/etc/logrotate.conf</ind:filepath>
    <ind:pattern operation="pattern match">^\s*daily[\s#]*$</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>

<ind:textfilecontent54_test check="all" check_existence="none_exist"
  comment="Test if there is no weekly/monthly/yearly keyword"
  id="test_logrotate_conf_no_other_keyword" version="1">
    <ind:object object_ref="object_logrotate_conf_no_other_keyword" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_logrotate_conf_no_other_keyword" version="2">
    <ind:filepath>/etc/logrotate.conf</ind:filepath>
    <ind:pattern operation="pattern match">^\s*(weekly|monthly|yearly)[\s#]*$</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>

  <ind:textfilecontent54_test check="all" check_existence="all_exist"
  comment="Tests the existence of /etc/cron.daily/logrotate file (and verify it actually calls logrotate utility)"
  id="test_cron_daily_logrotate_existence" version="1">
    <ind:object object_ref="object_cron_daily_logrotate_existence" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_cron_daily_logrotate_existence" version="1">
    <ind:filepath>/etc/cron.daily/logrotate</ind:filepath>
    <ind:pattern operation="pattern match">^[\s]*/usr/sbin/logrotate[\s\S]*/etc/logrotate.conf$</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>

</def-group>
