<def-group>
  <definition class="compliance" id="file_groupowner_var_log_journal" version="1">
   
      <metadata>
        <title>Verify Group Who Owns /var/log/*.journal(~) File</title>
        
    <affected family="unix">
    <platform>Ubuntu 22.04</platform>
    </affected>
        <description>This test makes sure that /var/log/ is group owned by systemd-journal or root.</description>
    </metadata>
      <criteria>
    
      <criterion comment="Check file group ownership of /var/log/" test_ref="test_file_groupowner_var_log_journal_0" />
    
   
    </criteria>
  </definition>
    

      <ind:textfilecontent54_object id="object_file_groupowner_var_log_journal_systemd-journal_gid_etc" version="1" comment="gid of the systemd-journal group (from /etc/group)">
        <ind:filepath>/etc/group</ind:filepath>
        <ind:pattern operation="pattern match">^systemd-journal:\w+:(\w+):.*</ind:pattern>
        <ind:instance datatype="int" operation="equals">1</ind:instance>
      </ind:textfilecontent54_object>

      <ind:textfilecontent54_object id="object_file_groupowner_var_log_journal_systemd-journal_gid_usr" version="1" comment="gid of the systemd-journal group (from /usr/lib/group)">
        <ind:filepath>/usr/lib/group</ind:filepath>
        <ind:pattern operation="pattern match">^systemd-journal:\w+:(\w+):.*</ind:pattern>
        <ind:instance datatype="int" operation="equals">1</ind:instance>
      </ind:textfilecontent54_object>

  <ind:textfilecontent54_object id="object_file_groupowner_var_log_journal_systemd-journal_gid" version="1" comment="gid of the systemd-journal group (from /etc/group or /usr/lib/group)">
    <set>
      <object_reference>object_file_groupowner_var_log_journal_systemd-journal_gid_etc</object_reference>
      <object_reference>object_file_groupowner_var_log_journal_systemd-journal_gid_usr</object_reference>
    </set>
  </ind:textfilecontent54_object>

      <local_variable id="var_file_groupowner_var_log_journal_systemd-journal_gid" datatype="int" version="1" comment="Retrieve the gid of systemd-journal from either /etc/group or /usr/lib/group">
        <object_component item_field="subexpression" object_ref="object_file_groupowner_var_log_journal_systemd-journal_gid"/>
      </local_variable>
    

      <ind:textfilecontent54_object id="object_file_groupowner_var_log_journal_root_gid_etc" version="1" comment="gid of the root group (from /etc/group)">
        <ind:filepath>/etc/group</ind:filepath>
        <ind:pattern operation="pattern match">^root:\w+:(\w+):.*</ind:pattern>
        <ind:instance datatype="int" operation="equals">1</ind:instance>
      </ind:textfilecontent54_object>

      <ind:textfilecontent54_object id="object_file_groupowner_var_log_journal_root_gid_usr" version="1" comment="gid of the root group (from /usr/lib/group)">
        <ind:filepath>/usr/lib/group</ind:filepath>
        <ind:pattern operation="pattern match">^root:\w+:(\w+):.*</ind:pattern>
        <ind:instance datatype="int" operation="equals">1</ind:instance>
      </ind:textfilecontent54_object>

  <ind:textfilecontent54_object id="object_file_groupowner_var_log_journal_root_gid" version="1" comment="gid of the root group (from /etc/group or /usr/lib/group)">
    <set>
      <object_reference>object_file_groupowner_var_log_journal_root_gid_etc</object_reference>
      <object_reference>object_file_groupowner_var_log_journal_root_gid_usr</object_reference>
    </set>
  </ind:textfilecontent54_object>

      <local_variable id="var_file_groupowner_var_log_journal_root_gid" datatype="int" version="1" comment="Retrieve the gid of root from either /etc/group or /usr/lib/group">
        <object_component item_field="subexpression" object_ref="object_file_groupowner_var_log_journal_root_gid"/>
      </local_variable>
    

  
    <unix:file_test check="all" check_existence="none_exist" comment="Testing group ownership of /var/log/" id="test_file_groupowner_var_log_journal_0" version="1">
      <unix:object object_ref="object_file_groupowner_var_log_journal_0" />
    </unix:file_test>

    <unix:file_object comment="/var/log/" id="object_file_groupowner_var_log_journal_0" version="1">
          <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
        <unix:path>/var/log</unix:path>
          <unix:filename operation="pattern match">.*\.journal[~]?</unix:filename>
      <filter action="exclude">symlink_file_groupowner</filter>
      
      <filter action="exclude">state_file_groupowner_var_log_journal_0_systemd-journal</filter>
      
      <filter action="exclude">state_file_groupowner_var_log_journal_1_root</filter>
      
    </unix:file_object>

    
      <unix:file_state id="state_file_groupowner_var_log_journal_0_systemd-journal" version="1">
        <unix:group_id datatype="int" operation="equals" var_ref="var_file_groupowner_var_log_journal_systemd-journal_gid"></unix:group_id>
      </unix:file_state>
    
      <unix:file_state id="state_file_groupowner_var_log_journal_1_root" version="1">
        <unix:group_id datatype="int" operation="equals" var_ref="var_file_groupowner_var_log_journal_root_gid"></unix:group_id>
      </unix:file_state>
    
  
    <unix:file_state id="symlink_file_groupowner" version="1">
      <unix:type operation="equals">symbolic link</unix:type>
    </unix:file_state>
</def-group>