Ticket #47773 - mem leak in do_bind when there is an error

https://fedorahosted.org/389/ticket/47773
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Do not get the SLAPI_BIND_TARGET_SDN from the pblock and
free it in the clean up code if it was never set in the pblock - just free
the local variable sdn in this case.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
Ticket #47774 mem leak in do_search - rawbase not freed upon certain errors

https://fedorahosted.org/389/ticket/47774
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Free the local rawbase variable if it was not set in the
pblock.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
Ticket #47772 empty modify returns LDAP_INVALID_DN_SYNTAX

https://fedorahosted.org/389/ticket/47772
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: Do not call normalize_mods2bvals if mods is NULL - just allow
the empty modify op to proceed.  Since normalize_mods2bvals only cares about
DN syntax attributes, it is appropriate to return LDAP_INVALID_DN_SYNTAX if
normalize_mods2bvals returns NULL.
Since this fix allows NULL mods to proceed throughout the code, I checked for
all places that SLAPI_MODIFY_MODS was used, to make sure we don't try to
dereference NULL mods, and to make sure the NULL mods were handled correctly
otherwise.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
Ticket 47712 - betxn: retro changelog broken after cancelled transaction

Bug Description:  If a transaction is aborted (eg failing automember) and
			the retrocl is either broken (first txn after enabling rcl)
			or there are gaps in the changenumbers
			The reason that there are gaps in changenumbers is that
			if the txn is undone the entry is removed from the
			RCL database, but the last changnumer was incremented already
			The reason that the RCL seems to be broken is that
			the entry is removed from the database, but is still in
			the entry cache. For the first change the changenumber is
			always recreated and it detects the entry in the entrycache
			and returns "already exists". If the gaps would be avoided
			this would also happen for later failures.
Fix Description:   If the RCL postop function is called with an error set in the
			pblock, set a flag that next time a chnagenumber will be
			assigned it is recreated from the database.
		   It is not possible to remove the CL entry from the entry cache
			from the RCL plugin, cache functions are not available.
			The only solution is to avoid keeing RCL entries in the
			entry cache after their initial creation. Extend the
			operation flags to trigger a removal from cache in
			ldbm_back_add()

https://fedorahosted.org/389/ticket/47712

Reviewed by: richm, thanks
Ticket #47772 empty modify returns LDAP_INVALID_DN_SYNTAX

https://fedorahosted.org/389/ticket/47772
Reviewed by: tbordaz, mreynolds (Thanks!)
Branch: master
Fix Description: tbordaz pointed out a couple of other places where the
pblock modify_mods structure is being referenced directly, and needs to be
checked for NULL.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
fix assertion failure introduced with fix for ticket 47667
Ticket 47782 - Parent numbordinate count can be incorrectly updated if an error occurs

Bug Description:  When adding and deleting entries there is a small chance that the modified
                  parent entry(numbsubordinates) could be replaced in the entry cache, even
                  if the operation fails.

Fix Description:  For deletes we can simply move the cache entry switching to a safe location,
                  but for adds we need to unswitch the parent's entry in the cache.

https://fedorahosted.org/389/ticket/47782

Reviewed by: nhosoi(Thanks!)
Ticket 47761 - Return all attributes in rootdse without explicit request

Bug Description:  a search for the rootdse: -s base -b ""
			only returns the user attributes not the
			operational attributes like "supportedControl"
		 This is correct inLDAPv3, and behaviour was introduced
			with fix for #47634, but for backward compatibility
			the old behaviour should be configurable

Fix Description:   Introduce a multivalued attribute to specify the
			attribites which should be returned without
			specific request

https://fedorahosted.org/389/ticket/47634

Reviewed by: richm, thanks
fix jenkins warning
Ticket #346 - Slow ldapmodify operation time for large quantities of multi-valued attribute values

Description: slapi_entry_add_value is used to add values for sorting,
which did not pass the attribute syntax info and the fallback compare
algorithm was used.  It sometimes different from the attribute syntax
based sorting and failed to find out an attribute.  This patch passes
an attribute syntax info for sorting.

Plus, featuring slapi_berval_cmp for the fallback compare algorithm.
It is closer to the syntax based sorting.

https://fedorahosted.org/389/ticket/346

Reviewed by rmeggins@redhat.com (Thank you, Rich!)
Ticket 47779 - Part of DNA shared configuration is deleted after server restart

Bug Description:  After a configuration change, like updating dnaNextVal,
                  the shared config entries are always rebuilt, but they do
                  preserve some of the configuration attributes like dnaRemoteBindMethod.

Fix Description:  Maintain a global linked list of all the shared config entries,
                  so when we go to rebuild the shared config entry we can restore
                  the dnaRemote attributes.

https://fedorahosted.org/389/ticket/47779

Reviewed by: nhosoi(Thanks!)
Ticket 47771 - Move parentsdn initialization to avoid crash

Bug Description:  It's possible to call slapi_sdn_done() before parentsdn is
                  initialized - which will crash the server.

Fix Description:  Initialize parentsdn at the top of the function.

https://fedorahosted.org/389/ticket/47771

Reviewed by: nhosoi(Thanks!)
Ticket 47721 - Schema Replication Issue

Bug Description:
	During a replication session, a supplier may send its schema in order to overwrite a consumer schema.
	Since https://fedorahosted.org/389/ticket/47490, a replica acting as a consumer rejects the schema
	if it evaluates that its own schema is a superset of the received schema. Also with 47490, a replica
	acting as a supplier will not send its schema if it evaluates that the consumer schema is a superset
	of its own schema.
	This creates an issue if the schema on both side contains definitions that the other side ignore, or
	that extend the other side definition. In that case each side will keep its own schema.

Fix Description:
	http://directory.fedoraproject.org/wiki/Replication_of_custom_schema_(ticket_47721)
	When acting as a consumer, it may receive a schema during a replication session.
	It then evaluates each definition (objectclasses/attritetypes) and if a definition
	is new or extend a current definition, then it add the definitions in its schema (in 99user.ldif)

	When acting as a supplier, it looks up the consumer schema. Whether it decides to send
	its own schema or not, it first evaluates each definition (objectclasses/attritetypes) and
	if a definition is new or extend a current definition, then it add the definitions in its schema (in 99user.ldif)

https://fedorahosted.org/389/ticket/47721

Reviewed by: Rich Megginson (Big thanks Rich for the review)

Platforms tested:
	for 389-DS CI tests: F17, F19 (jenkins)
	for Dogtag: manual test case master/clone - F19 (10.0.7) / F20 (10.1.1)
	for IPA: F20 3.3.5 manual test case and unit tests

Flag Day: no
Ticket 47721 - Schema Replication Issue (follow up + cleanup)

Fix Description:
	Fix test cases 47490
	Fix test cases 47553 (py.test fixture commented)
	Fix test cases 47619 (task timeout not yet in lib389)
	Forget to change (char *) into (const char *)

https://fedorahosted.org/389/ticket/47721

Reviewed by: Rich Megginson

Platforms tested: F19
Flag Day: no

Doc impact: no
Ticket 47721 - Schema Replication Issue (follow up)

Fix Description:
	Forget to change (char *) into (const char *)

https://fedorahosted.org/389/ticket/47721

Reviewed by: Rich Megginson

Platforms tested: F19
Flag Day: no

Doc impact: no
Ticket 477779 - Need to lock server list when removing list

Description:  Need to hold the write lock when deleting the server list.
              There is no need to lock the list in the close function,
              as all active threads should be stopped.  In 1.3.3, the
              dynamic plugin feature will also safely handle the plugin
              shutdown.

https://fedorahosted.org/389/ticket/47779

Reviewed by: tbordaz(Thanks!)
Ticket 47792 - code cleanup

https://fedorahosted.org/389/ticket/47792

Reviewed by: rmeggins(Thanks!)
Ticket #47707 - 389 DS Server crashes and dies while handles paged searches from clients

Bug Description: If a simple paged search request was sent to the server
and the request was abandoned, the paged result slot in the connection
table was not properly released by setting NULL to pr_current_be.  Since
the slot did not look available for the next request even though it was,
the next request failed to get the valid slot number, and the initial slot
number -1 failed to be replaced with the real slot number.  Until the fix
for "Ticket #47623 fix memleak caused by 47347" was made, it overrode the
allocated array's [-1] location, which usually stores the meta data of the
allocated memory.  That crashed the server in the next realloc since the
corrupted memory was passed to the function.

Fix Description: This patch cleans up the abandoned/cleaned up slot for
reuse.  Also, more check not to break the meta data is added.

Special thanks to German Parente (gparente@redhat.com) for providing the
reproducer and analysing the crash.

https://fedorahosted.org/389/ticket/47707

Reviewed by rmeggins@redhat.com (Thanks, Rich!)