|
|
d4a1c3 |
From 2310b48089755fb5b8e3dedf12e8a786b9819c19 Mon Sep 17 00:00:00 2001
|
|
|
d4a1c3 |
From: tbordaz <tbordaz@redhat.com>
|
|
|
d4a1c3 |
Date: Thu, 18 Aug 2022 11:17:30 +0200
|
|
|
d4a1c3 |
Subject: [PATCH] Issue 5418 - Sync_repl may crash while managing invalid
|
|
|
d4a1c3 |
cookie (#5420)
|
|
|
d4a1c3 |
|
|
|
d4a1c3 |
Bug description:
|
|
|
d4a1c3 |
If the servers receives an invalid cookie without separator '#',
|
|
|
d4a1c3 |
it parses it into an empty cookie (Sync_Cookie) instead of a NULL
|
|
|
d4a1c3 |
cookie (failure).
|
|
|
d4a1c3 |
Later it sigsegv when using the empty cookie.
|
|
|
d4a1c3 |
|
|
|
d4a1c3 |
Fix description:
|
|
|
d4a1c3 |
If the parsing fails return NULL
|
|
|
d4a1c3 |
|
|
|
d4a1c3 |
relates: #5418
|
|
|
d4a1c3 |
|
|
|
d4a1c3 |
Reviewed by: Viktor Ashirov, Mark Reynolds, William Brown, Simon
|
|
|
d4a1c3 |
Pichugin (thanks !)
|
|
|
d4a1c3 |
---
|
|
|
d4a1c3 |
.../suites/syncrepl_plugin/basic_test.py | 76 +++++++++++++++++++
|
|
|
d4a1c3 |
1 file changed, 76 insertions(+)
|
|
|
d4a1c3 |
|
|
|
d4a1c3 |
diff --git a/dirsrvtests/tests/suites/syncrepl_plugin/basic_test.py b/dirsrvtests/tests/suites/syncrepl_plugin/basic_test.py
|
|
|
d4a1c3 |
index 533460e8f..375517693 100644
|
|
|
d4a1c3 |
--- a/dirsrvtests/tests/suites/syncrepl_plugin/basic_test.py
|
|
|
d4a1c3 |
+++ b/dirsrvtests/tests/suites/syncrepl_plugin/basic_test.py
|
|
|
d4a1c3 |
@@ -594,3 +594,79 @@ def test_sync_repl_cenotaph(topo_m2, request):
|
|
|
d4a1c3 |
pass
|
|
|
d4a1c3 |
|
|
|
d4a1c3 |
request.addfinalizer(fin)
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+def test_sync_repl_invalid_cookie(topology, request):
|
|
|
d4a1c3 |
+ """Test sync_repl with invalid cookie
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ :id: 8fa4a8f8-acf4-42a5-90f1-6ba1d8080e46
|
|
|
d4a1c3 |
+ :setup: install a standalone instance
|
|
|
d4a1c3 |
+ :steps:
|
|
|
d4a1c3 |
+ 1. reset instance to standard (no retroCL, no sync_repl, no dynamic plugin)
|
|
|
d4a1c3 |
+ 2. Enable retroCL/content_sync
|
|
|
d4a1c3 |
+ 3. Establish a sync_repl connection
|
|
|
d4a1c3 |
+ 4. Tests servers results to search with invalid cookie
|
|
|
d4a1c3 |
+ 5. Add/delete an user entry to check the server is up and running
|
|
|
d4a1c3 |
+ :expectedresults:
|
|
|
d4a1c3 |
+ 1. Should succeeds
|
|
|
d4a1c3 |
+ 2. Should succeeds
|
|
|
d4a1c3 |
+ 3. Should succeeds
|
|
|
d4a1c3 |
+ 4. Should succeeds
|
|
|
d4a1c3 |
+ 5. Should succeeds
|
|
|
d4a1c3 |
+ """
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ # Reset the instance in a default config
|
|
|
d4a1c3 |
+ # Disable content sync plugin
|
|
|
d4a1c3 |
+ topology.standalone.restart()
|
|
|
d4a1c3 |
+ topology.standalone.plugins.disable(name=PLUGIN_REPL_SYNC)
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ # Disable retro changelog
|
|
|
d4a1c3 |
+ topology.standalone.plugins.disable(name=PLUGIN_RETRO_CHANGELOG)
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ # Disable dynamic plugins
|
|
|
d4a1c3 |
+ topology.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', b'off')])
|
|
|
d4a1c3 |
+ topology.standalone.restart()
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ # Enable retro changelog
|
|
|
d4a1c3 |
+ topology.standalone.plugins.enable(name=PLUGIN_RETRO_CHANGELOG)
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ # Enbale content sync plugin
|
|
|
d4a1c3 |
+ topology.standalone.plugins.enable(name=PLUGIN_REPL_SYNC)
|
|
|
d4a1c3 |
+ topology.standalone.restart()
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ # Setup the syncer
|
|
|
d4a1c3 |
+ sync = ISyncRepl(topology.standalone)
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ # Test invalid cookies
|
|
|
d4a1c3 |
+ cookies = ('#', '##', 'a#a#a', 'a#a#1', 'foo')
|
|
|
d4a1c3 |
+ for invalid_cookie in cookies:
|
|
|
d4a1c3 |
+ log.info('Testing cookie: %s' % invalid_cookie)
|
|
|
d4a1c3 |
+ try:
|
|
|
d4a1c3 |
+ ldap_search = sync.syncrepl_search(base=DEFAULT_SUFFIX,
|
|
|
d4a1c3 |
+ scope=ldap.SCOPE_SUBTREE,
|
|
|
d4a1c3 |
+ attrlist=['objectclass', 'cn', 'homedirectory', 'sn','uid'],
|
|
|
d4a1c3 |
+ filterstr='(|(objectClass=groupofnames)(objectClass=person))',
|
|
|
d4a1c3 |
+ mode='refreshOnly',
|
|
|
d4a1c3 |
+ cookie=invalid_cookie)
|
|
|
d4a1c3 |
+ poll_result = sync.syncrepl_poll(all=1)
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ log.fatal('Invalid cookie accepted!')
|
|
|
d4a1c3 |
+ assert False
|
|
|
d4a1c3 |
+ except Exception as e:
|
|
|
d4a1c3 |
+ log.info('Invalid cookie correctly rejected: {}'.format(e.args[0]['info']))
|
|
|
d4a1c3 |
+ pass
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ # check that the server is still up and running
|
|
|
d4a1c3 |
+ users = UserAccounts(topology.standalone, DEFAULT_SUFFIX)
|
|
|
d4a1c3 |
+ user = users.create_test_user(uid=1000)
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ # Success
|
|
|
d4a1c3 |
+ log.info('Test complete')
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ def fin():
|
|
|
d4a1c3 |
+ topology.standalone.restart()
|
|
|
d4a1c3 |
+ try:
|
|
|
d4a1c3 |
+ user.delete()
|
|
|
d4a1c3 |
+ except:
|
|
|
d4a1c3 |
+ pass
|
|
|
d4a1c3 |
+
|
|
|
d4a1c3 |
+ request.addfinalizer(fin)
|
|
|
d4a1c3 |
--
|
|
|
d4a1c3 |
2.37.3
|
|
|
d4a1c3 |
|