Blame SOURCES/0034-Issue-4480-Unexpected-info-returned-to-ldap-request-.patch

ef1f48
From 340b81a59cee365e7300e57c1ca5f4866373954c Mon Sep 17 00:00:00 2001
ef1f48
From: tbordaz <tbordaz@redhat.com>
ef1f48
Date: Wed, 16 Dec 2020 16:30:28 +0100
ef1f48
Subject: [PATCH 1/4] Issue 4480 - Unexpected info returned to ldap request
ef1f48
 (#4491)
ef1f48
ef1f48
Bug description:
ef1f48
	If the bind entry does not exist, the bind result info
ef1f48
        reports that 'No such entry'. It should not give any
ef1f48
        information if the target entry exists or not
ef1f48
ef1f48
Fix description:
ef1f48
	Does not return any additional information during a bind
ef1f48
ef1f48
relates: https://github.com/389ds/389-ds-base/issues/4480
ef1f48
ef1f48
Reviewed by: William Brown, Viktor Ashirov, Mark Reynolds (thank you all)
ef1f48
ef1f48
Platforms tested:  F31
ef1f48
---
ef1f48
 dirsrvtests/tests/suites/basic/basic_test.py | 30 ++++++++++++++++++++
ef1f48
 ldap/servers/slapd/back-ldbm/ldbm_config.c   |  2 +-
ef1f48
 ldap/servers/slapd/result.c                  |  2 +-
ef1f48
 3 files changed, 32 insertions(+), 2 deletions(-)
ef1f48
ef1f48
diff --git a/dirsrvtests/tests/suites/basic/basic_test.py b/dirsrvtests/tests/suites/basic/basic_test.py
ef1f48
index 120207321..e9afa1e7e 100644
ef1f48
--- a/dirsrvtests/tests/suites/basic/basic_test.py
ef1f48
+++ b/dirsrvtests/tests/suites/basic/basic_test.py
ef1f48
@@ -1400,6 +1400,36 @@ def test_dscreate_multiple_dashes_name(dscreate_long_instance):
ef1f48
     assert not dscreate_long_instance.exists()
ef1f48
 
ef1f48
 
ef1f48
+def test_bind_invalid_entry(topology_st):
ef1f48
+    """Test the failing bind does not return information about the entry
ef1f48
+
ef1f48
+    :id: 5cd9b083-eea6-426b-84ca-83c26fc49a6f
ef1f48
+
ef1f48
+    :setup: Standalone instance
ef1f48
+
ef1f48
+    :steps:
ef1f48
+    1: bind as non existing entry
ef1f48
+    2: check that bind info does not report 'No such entry'
ef1f48
+
ef1f48
+    :expectedresults:
ef1f48
+    1: pass
ef1f48
+    2: pass
ef1f48
+    """
ef1f48
+
ef1f48
+    topology_st.standalone.restart()
ef1f48
+    INVALID_ENTRY="cn=foooo,%s" % DEFAULT_SUFFIX
ef1f48
+    try:
ef1f48
+        topology_st.standalone.simple_bind_s(INVALID_ENTRY, PASSWORD)
ef1f48
+    except ldap.LDAPError as e:
ef1f48
+        log.info('test_bind_invalid_entry: Failed to bind as %s (expected)' % INVALID_ENTRY)
ef1f48
+        log.info('exception description: ' + e.args[0]['desc'])
ef1f48
+        if 'info' in e.args[0]:
ef1f48
+            log.info('exception info: ' + e.args[0]['info'])
ef1f48
+        assert e.args[0]['desc'] == 'Invalid credentials'
ef1f48
+        assert 'info' not in e.args[0]
ef1f48
+        pass
ef1f48
+
ef1f48
+    log.info('test_bind_invalid_entry: PASSED')
ef1f48
 
ef1f48
 if __name__ == '__main__':
ef1f48
     # Run isolated
ef1f48
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c
ef1f48
index 88c186359..dee5fc088 100644
ef1f48
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
ef1f48
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
ef1f48
@@ -1266,7 +1266,7 @@ ldbm_config_search_entry_callback(Slapi_PBlock *pb __attribute__((unused)),
ef1f48
             if (attrs) {
ef1f48
                 for (size_t i = 0; attrs[i]; i++) {
ef1f48
                     if (ldbm_config_moved_attr(attrs[i])) {
ef1f48
-                        slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, "at least one required attribute has been moved to the BDB scecific configuration entry");
ef1f48
+                        slapi_pblock_set(pb, SLAPI_RESULT_TEXT, "at least one required attribute has been moved to the BDB scecific configuration entry");
ef1f48
                         break;
ef1f48
                     }
ef1f48
                 }
ef1f48
diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
ef1f48
index 61efb6f8d..40c5dcc57 100644
ef1f48
--- a/ldap/servers/slapd/result.c
ef1f48
+++ b/ldap/servers/slapd/result.c
ef1f48
@@ -355,7 +355,7 @@ send_ldap_result_ext(
ef1f48
     if (text) {
ef1f48
         pbtext = text;
ef1f48
     } else {
ef1f48
-        slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &pbtext);
ef1f48
+        slapi_pblock_get(pb, SLAPI_RESULT_TEXT, &pbtext);
ef1f48
     }
ef1f48
 
ef1f48
     if (operation == NULL) {
ef1f48
-- 
ef1f48
2.26.2
ef1f48