<def-group>
  <definition class="compliance" id="dconf_gnome_screensaver_lock_enabled" version="2">
    {{{ oval_metadata("Idle activation of the screen lock should be enabled.") }}}
    <criteria operator="OR">
      <extend_definition comment="dconf installed" definition_ref="package_dconf_installed" negate="true" />
      <criteria comment="Enable screensaver lock and prevent user from changing it" operator="AND">
        <extend_definition comment="dconf user profile exists" definition_ref="enable_dconf_user_profile" />
        <criterion comment="screensaver lock is enabled" test_ref="test_screensaver_lock_enabled" />
        <criterion comment="screensaver lock prevent user from changing" test_ref="test_prevent_user_screensaver_lock" />
      </criteria>
    </criteria>
  </definition>

  <ind:textfilecontent54_test check="all" check_existence="all_exist"
  comment="screensaver lock is enabled"
  id="test_screensaver_lock_enabled" version="1">
    <ind:object object_ref="obj_screensaver_lock_enabled" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="obj_screensaver_lock_enabled"
  version="1">
    <ind:path>/etc/dconf/db/local.d/</ind:path>
    <ind:filename operation="pattern match">^.*$</ind:filename>
{{% if product in ['sle12','sle15'] %}}
    <ind:pattern operation="pattern match">^\[org/gnome/desktop/lockdown\]([^\n]*\n+)+?disable-lock-screen=false$</ind:pattern>
{{% else %}}
    <ind:pattern operation="pattern match">^\[org/gnome/desktop/screensaver\]([^\n]*\n+)+?lock-enabled=true$</ind:pattern>
{{% endif %}}
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>

  <ind:textfilecontent54_test check="all" check_existence="all_exist"
  comment="screensaver lock cannot be changed by user"
  id="test_prevent_user_screensaver_lock" version="1">
    <ind:object object_ref="obj_prevent_user_screensaver_lock" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="obj_prevent_user_screensaver_lock"
  version="1">
    <ind:path>/etc/dconf/db/local.d/locks/</ind:path>
    <ind:filename operation="pattern match">^.*$</ind:filename>
{{% if product in ['sle12','sle15'] %}}
    <ind:pattern operation="pattern match">^/org/gnome/desktop/lockdown/disable-lock-screen$</ind:pattern>
{{% else %}}
    <ind:pattern operation="pattern match">^/org/gnome/desktop/screensaver/lock-enabled$</ind:pattern>
{{% endif %}}
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>
</def-group>
