<def-group>
  <definition class="compliance" id="file_owner_var_log_waagent" version="1">
  
    <metadata>
        <title>Verify User Who Owns /var/log/waagent.log File</title>
        
    <affected family="unix">
    <platform>Ubuntu 22.04</platform>
    </affected>
        <description>This test makes sure that /var/log/ is owned by syslog or root.</description>
    </metadata>
     <criteria>
   
     <criterion comment="Check file ownership of /var/log/" test_ref="test_file_owner_var_log_waagent_0" />
   
  
    </criteria>
  </definition>
  <unix:password_object id="object_file_owner_var_log_waagent_syslog_uid" version="1">
    <unix:username operation="pattern match">syslog</unix:username>
  </unix:password_object>
  <local_variable id="var_file_owner_var_log_waagent_syslog_uid" comment="Retrieve the uid of syslog" datatype="int" version="1">
    <object_component item_field="user_id" object_ref="object_file_owner_var_log_waagent_syslog_uid" />
  </local_variable>
  <unix:password_object id="object_file_owner_var_log_waagent_root_uid" version="1">
    <unix:username operation="pattern match">root</unix:username>
  </unix:password_object>
  <local_variable id="var_file_owner_var_log_waagent_root_uid" comment="Retrieve the uid of root" datatype="int" version="1">
    <object_component item_field="user_id" object_ref="object_file_owner_var_log_waagent_root_uid" />
  </local_variable>

  
  <unix:file_test check="all" check_existence="none_exist" comment="Testing user ownership of /var/log/" id="test_file_owner_var_log_waagent_0" version="1">
    <unix:object object_ref="object_file_owner_var_log_waagent_0" />
  </unix:file_test>

  <unix:file_object comment="/var/log/" id="object_file_owner_var_log_waagent_0" version="1">
      <unix:path>/var/log</unix:path>
      <unix:filename operation="pattern match">.*waagent.log.*</unix:filename>
    <filter action="exclude">symlink_file_owner</filter>
    
      <filter action="exclude">state_file_owner_var_log_waagent_0_syslog</filter>
    
      <filter action="exclude">state_file_owner_var_log_waagent_1_root</filter>
    
  </unix:file_object>
  
    <unix:file_state id="state_file_owner_var_log_waagent_0_syslog" version="1">
      <unix:user_id datatype="int" operation="equals" var_ref="var_file_owner_var_log_waagent_syslog_uid"></unix:user_id>
    </unix:file_state>
  
    <unix:file_state id="state_file_owner_var_log_waagent_1_root" version="1">
      <unix:user_id datatype="int" operation="equals" var_ref="var_file_owner_var_log_waagent_root_uid"></unix:user_id>
    </unix:file_state>
  
  
  <unix:file_state id="symlink_file_owner" version="1">
    <unix:type operation="equals">symbolic link</unix:type>
  </unix:file_state>
</def-group>