dirsrvtests/tickets/ticket47313_test.py | 3
dirsrvtests/tickets/ticket47808_test.py | 212 ++++++++++++++++++++++++++++++++
2 files changed, 215 insertions(+)
New commits:
commit ba9c8b61ec63ce69711ac77da296ea96d2f366dc
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Jun 6 16:00:46 2014 -0700
Ticket 47808 - CI test: add test case for ticket 47808
Bug Description: If be_txn plugin fails in ldbm_back_add, adding entry
is double freed.
Test Description:
It enables attribute uniqueness plugin with sn as a unique attribute
Add an entry 1 with sn = ENTRY_NAME
Add an entry 2 with sn = ENTRY_NAME
If the second add does not crash the server and the following search
found none, the bug is fixed.
https://fedorahosted.org/389/ticket/47808
diff --git a/dirsrvtests/tickets/ticket47313_test.py b/dirsrvtests/tickets/ticket47313_test.py
index f010de9..370dfc6 100644
--- a/dirsrvtests/tickets/ticket47313_test.py
+++ b/dirsrvtests/tickets/ticket47313_test.py
@@ -196,6 +196,9 @@ def test_ticket47313_run(topology):
topology.standalone.delete_s(entry_dn_en_only)
def test_ticket47313_final(topology):
+ mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '0')]
+ topology.standalone.modify_s(DN_CONFIG, mod)
+
topology.standalone.stop(timeout=10)
def run_isolated():
diff --git a/dirsrvtests/tickets/ticket47808_test.py b/dirsrvtests/tickets/ticket47808_test.py
new file mode 100644
index 0000000..4bfb4ce
--- /dev/null
+++ b/dirsrvtests/tickets/ticket47808_test.py
@@ -0,0 +1,212 @@
+import os
+import sys
+import time
+import ldap
+import logging
+import socket
+import time
+import logging
+import pytest
+from lib389 import DirSrv, Entry, tools
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from constants import *
+
+log = logging.getLogger(__name__)
+
+installation_prefix = '/home/nhosoi/install'
+
+ATTRIBUTE_UNIQUENESS_PLUGIN = 'cn=attribute uniqueness,cn=plugins,cn=config'
+ENTRY_NAME = 'test_entry'
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+#(a)pytest.fixture(scope="module")
+def topology(request):
+ '''
+ This fixture is used to standalone topology for the 'module'.
+ At the beginning, It may exists a standalone instance.
+ It may also exists a backup for the standalone instance.
+
+ Principle:
+ If standalone instance exists:
+ restart it
+ If backup of standalone exists:
+ create/rebind to standalone
+
+ restore standalone instance from backup
+ else:
+ Cleanup everything
+ remove instance
+ remove backup
+ Create instance
+ Create backup
+ '''
+ global installation_prefix
+
+ if installation_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation_prefix
+
+ standalone = DirSrv(verbose=True)
+
+ # Args for the standalone instance
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+
+ # Get the status of the backups
+ backup_standalone = standalone.checkBackupFS()
+
+ # Get the status of the instance and restart it if it exists
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ # assuming the instance is already stopped, just wait 5 sec max
+ standalone.stop(timeout=5)
+ standalone.start(timeout=10)
+
+ if backup_standalone:
+ # The backup exist, assuming it is correct
+ # we just re-init the instance with it
+ if not instance_standalone:
+ standalone.create()
+ # Used to retrieve configuration information (dbdir, confdir...)
+ standalone.open()
+
+ # restore standalone instance from backup
+ standalone.stop(timeout=10)
+ standalone.restoreFS(backup_standalone)
+ standalone.start(timeout=10)
+
+ else:
+ # We should be here only in two conditions
+ # - This is the first time a test involve standalone instance
+ # - Something weird happened (instance/backup destroyed)
+ # so we discard everything and recreate all
+
+ # Remove the backup. So even if we have a specific backup file
+ # (e.g backup_standalone) we clear backup that an instance may have created
+ if backup_standalone:
+ standalone.clearBackupFS()
+
+ # Remove the instance
+ if instance_standalone:
+ standalone.delete()
+
+ # Create the instance
+ standalone.create()
+
+ # Used to retrieve configuration information (dbdir, confdir...)
+ standalone.open()
+
+ # Time to create the backups
+ standalone.stop(timeout=10)
+ standalone.backupfile = standalone.backupFS()
+ standalone.start(timeout=10)
+
+ #
+ # Here we have standalone instance up and running
+ # Either coming from a backup recovery
+ # or from a fresh (re)init
+ # Time to return the topology
+ return TopologyStandalone(standalone)
+
+
+def test_ticket47808_run(topology):
+ """
+ It enables attribute uniqueness plugin with sn as a unique attribute
+ Add an entry 1 with sn = ENTRY_NAME
+ Add an entry 2 with sn = ENTRY_NAME
+ If the second add does not crash the server and the following search found none,
+ the bug is fixed.
+ """
+
+ # bind as directory manager
+ topology.standalone.log.info("Bind as %s" % DN_DM)
+ topology.standalone.simple_bind_s(DN_DM, PASSWORD)
+
+ topology.standalone.log.info("\n\n######################### SETUP ATTR UNIQ PLUGIN ######################\n")
+
+ # enable attribute uniqueness plugin
+ mod = [(ldap.MOD_REPLACE, 'nsslapd-pluginEnabled', 'on'), (ldap.MOD_REPLACE, 'nsslapd-pluginarg0', 'sn'), (ldap.MOD_REPLACE, 'nsslapd-pluginarg1', SUFFIX)]
+ topology.standalone.modify_s(ATTRIBUTE_UNIQUENESS_PLUGIN, mod)
+
+ topology.standalone.log.info("\n\n######################### ADD USER 1 ######################\n")
+
+ # Prepare entry 1
+ entry_name = '%s 1' % (ENTRY_NAME)
+ entry_dn_1 = 'cn=%s, %s' % (entry_name, SUFFIX)
+ entry_1 = Entry(entry_dn_1)
+ entry_1.setValues('objectclass', 'top', 'person')
+ entry_1.setValues('sn', ENTRY_NAME)
+ entry_1.setValues('cn', entry_name)
+ topology.standalone.log.info("Try to add Add %s: %r" % (entry_1, entry_1))
+ topology.standalone.add_s(entry_1)
+
+ topology.standalone.log.info("\n\n######################### Restart Server ######################\n")
+ topology.standalone.stop(timeout=10)
+ topology.standalone.start(timeout=10)
+
+ topology.standalone.log.info("\n\n######################### ADD USER 2 ######################\n")
+
+ # Prepare entry 2 having the same sn, which crashes the server
+ entry_name = '%s 2' % (ENTRY_NAME)
+ entry_dn_2 = 'cn=%s, %s' % (entry_name, SUFFIX)
+ entry_2 = Entry(entry_dn_2)
+ entry_2.setValues('objectclass', 'top', 'person')
+ entry_2.setValues('sn', ENTRY_NAME)
+ entry_2.setValues('cn', entry_name)
+ topology.standalone.log.info("Try to add Add %s: %r" % (entry_2, entry_2))
+ try:
+ topology.standalone.add_s(entry_2)
+ except:
+ topology.standalone.log.warn("Adding %s failed" % entry_dn_2)
+ pass
+
+ topology.standalone.log.info("\n\n######################### IS SERVER UP? ######################\n")
+ ents = topology.standalone.search_s(entry_dn_1, ldap.SCOPE_BASE, '(objectclass=*)')
+ assert len(ents) == 1
+ topology.standalone.log.info("Yes, it's up.")
+
+ topology.standalone.log.info("\n\n######################### CHECK USER 2 NOT ADDED ######################\n")
+ topology.standalone.log.info("Try to search %s" % entry_dn_2)
+ try:
+ ents = topology.standalone.search_s(entry_dn_2, ldap.SCOPE_BASE, '(objectclass=*)')
+ except ldap.NO_SUCH_OBJECT:
+ topology.standalone.log.info("Found none")
+
+ topology.standalone.log.info("\n\n######################### DELETE USER 1 ######################\n")
+
+ topology.standalone.log.info("Try to delete %s " % entry_dn_1)
+ topology.standalone.delete_s(entry_dn_1)
+
+def test_ticket47808_final(topology):
+ topology.standalone.stop(timeout=10)
+
+def run_isolated():
+ '''
+ run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..)
+ To run isolated without py.test, you need to
+ - edit this file and comment '@pytest.fixture' line before 'topology' function.
+ - set the installation prefix
+ - run this program
+ '''
+ global installation_prefix
+ installation_prefix = '/home/nhosoi/install'
+
+ topo = topology(True)
+ test_ticket47808_run(topo)
+
+ test_ticket47808_final(topo)
+
+
+if __name__ == '__main__':
+ run_isolated()
+
ldap/servers/slapd/modify.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit ccc61a3a589a47844a7e6eeb13f87e1351637618
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Mon Mar 17 19:34:45 2014 -0700
Ticket 47752 - Don't add unhashed password mod if we don't have an unhashed value
When performing a modify operation to replace the userpassword with a pre-hashed
value, the modify code adds a LDAPMod that replaces the "unhashed#user#password"
attribute with no values. While this doesn't cause any harm inside DS itself, it
is not the correct behavior. We should only add a LDAPMod for the unhashed password
if we actually have an unhashed value available.
https://fedorahosted.org/389/ticket/47752
Reviewed by mreynold(a)redhat.com
diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c
index 34fc326..fb0fdde 100644
--- a/ldap/servers/slapd/modify.c
+++ b/ldap/servers/slapd/modify.c
@@ -975,10 +975,10 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw)
} else {
/* add pseudo password attribute */
valuearray_init_bervalarray_unhashed_only(pw_mod->mod_bvalues, &va);
- if(va){
+ if(va && va[0]){
slapi_mods_add_mod_values(&smods, pw_mod->mod_op, unhashed_pw_attr, va);
- valuearray_free(&va);
}
+ valuearray_free(&va);
}
/* Init new value array for hashed value */
ldap/servers/slapd/add.c | 6 ++----
ldap/servers/slapd/back-ldbm/ldbm_add.c | 4 +++-
2 files changed, 5 insertions(+), 5 deletions(-)
New commits:
commit c6b5630cd094e7a25d3f9c9ca347c4a652417756
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jun 5 12:10:37 2014 -0700
Ticket #47808 - If be_txn plugin fails in ldbm_back_add, adding entry is double freed.
Bug description: Backend add ldbm_back_add frees the entry to be added,
if the add fails in the be_txn plugins. But the frontend releases the
entry when an error is returned from the backend.
Fix desxription: When the entry is freed in the backend, set NULL to
the pblock SLAPI_ADD_ENTRY to tell the frontend not to free the entry.
https://fedorahosted.org/389/ticket/47808
Reviewed by mreynolds(a)redhat.com (Thank you, Mark!!)
(cherry picked from commit d50f99476386b6c464884d2d16a688ecafc7fafc)
(cherry picked from commit 1f3510ad05e07667e0ec16c82baa2d4909675889)
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index fadc56b..875ad22 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -767,10 +767,8 @@ static void op_shared_add (Slapi_PBlock *pb)
}
else
{
- /* restore e so we can free it below */
- if (save_e) {
- e = save_e;
- }
+ /* PR_ASSERT(!save_e); save_e is supposed to be freed in the backend. */
+ e = save_e;
if (rc == SLAPI_FAIL_DISKFULL)
{
operation_out_of_disk_space();
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 0a4557b..2b79be3 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -851,7 +851,7 @@ ldbm_back_add( Slapi_PBlock *pb )
slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, ldap_result_code ? &ldap_result_code : &retval);
}
slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
- LDAPDebug1Arg(LDAP_DEBUG_ANY, "SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN plugin failed: %d",
+ LDAPDebug1Arg(LDAP_DEBUG_ANY, "SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN plugin failed: %d\n",
ldap_result_code ? ldap_result_code : retval);
goto error_return;
}
@@ -1160,6 +1160,8 @@ error_return:
{
if (inst) {
CACHE_REMOVE(&inst->inst_cache, addingentry);
+ /* tell frontend not to free this entry */
+ slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
}
}
else
ldap/servers/slapd/add.c | 6 ++----
ldap/servers/slapd/back-ldbm/ldbm_add.c | 4 +++-
2 files changed, 5 insertions(+), 5 deletions(-)
New commits:
commit 1f3510ad05e07667e0ec16c82baa2d4909675889
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jun 5 12:10:37 2014 -0700
Ticket #47808 - If be_txn plugin fails in ldbm_back_add, adding entry is double freed.
Bug description: Backend add ldbm_back_add frees the entry to be added,
if the add fails in the be_txn plugins. But the frontend releases the
entry when an error is returned from the backend.
Fix desxription: When the entry is freed in the backend, set NULL to
the pblock SLAPI_ADD_ENTRY to tell the frontend not to free the entry.
https://fedorahosted.org/389/ticket/47808
Reviewed by mreynolds(a)redhat.com (Thank you, Mark!!)
(cherry picked from commit d50f99476386b6c464884d2d16a688ecafc7fafc)
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index fadc56b..875ad22 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -767,10 +767,8 @@ static void op_shared_add (Slapi_PBlock *pb)
}
else
{
- /* restore e so we can free it below */
- if (save_e) {
- e = save_e;
- }
+ /* PR_ASSERT(!save_e); save_e is supposed to be freed in the backend. */
+ e = save_e;
if (rc == SLAPI_FAIL_DISKFULL)
{
operation_out_of_disk_space();
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 0a39f71..c99db8d 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -851,7 +851,7 @@ ldbm_back_add( Slapi_PBlock *pb )
slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, ldap_result_code ? &ldap_result_code : &retval);
}
slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
- LDAPDebug1Arg(LDAP_DEBUG_ANY, "SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN plugin failed: %d",
+ LDAPDebug1Arg(LDAP_DEBUG_ANY, "SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN plugin failed: %d\n",
ldap_result_code ? ldap_result_code : retval);
goto error_return;
}
@@ -1160,6 +1160,8 @@ error_return:
{
if (inst) {
CACHE_REMOVE(&inst->inst_cache, addingentry);
+ /* tell frontend not to free this entry */
+ slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
}
}
else
ldap/servers/slapd/add.c | 6 ++----
ldap/servers/slapd/back-ldbm/ldbm_add.c | 4 +++-
2 files changed, 5 insertions(+), 5 deletions(-)
New commits:
commit d50f99476386b6c464884d2d16a688ecafc7fafc
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Jun 5 12:10:37 2014 -0700
Ticket #47808 - If be_txn plugin fails in ldbm_back_add, adding entry is double freed.
Bug description: Backend add ldbm_back_add frees the entry to be added,
if the add fails in the be_txn plugins. But the frontend releases the
entry when an error is returned from the backend.
Fix desxription: When the entry is freed in the backend, set NULL to
the pblock SLAPI_ADD_ENTRY to tell the frontend not to free the entry.
https://fedorahosted.org/389/ticket/47808
Reviewed by mreynolds(a)redhat.com (Thank you, Mark!!)
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index fadc56b..875ad22 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -767,10 +767,8 @@ static void op_shared_add (Slapi_PBlock *pb)
}
else
{
- /* restore e so we can free it below */
- if (save_e) {
- e = save_e;
- }
+ /* PR_ASSERT(!save_e); save_e is supposed to be freed in the backend. */
+ e = save_e;
if (rc == SLAPI_FAIL_DISKFULL)
{
operation_out_of_disk_space();
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 582e06a..5be1cd8 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -853,7 +853,7 @@ ldbm_back_add( Slapi_PBlock *pb )
slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, ldap_result_code ? &ldap_result_code : &retval);
}
slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
- LDAPDebug1Arg(LDAP_DEBUG_ANY, "SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN plugin failed: %d",
+ LDAPDebug1Arg(LDAP_DEBUG_ANY, "SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN plugin failed: %d\n",
ldap_result_code ? ldap_result_code : retval);
goto error_return;
}
@@ -1162,6 +1162,8 @@ error_return:
{
if (inst) {
CACHE_REMOVE(&inst->inst_cache, addingentry);
+ /* tell frontend not to free this entry */
+ slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
}
}
else