Ticket 47750 - Fix incomplete backport to 1.3.1/1.2.11

Description:  An incomplete backport of 47750 to 1.3.1 and 1.2.11 caused
              a memory leak.

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

Reviewed by: rmeggins(Thanks!)
Ticket 47900 - Adding an entry with an invalid password as rootDN is incorrectly rejected

Bug Description:  Root DN and password administrators should bypass all password
                  restrictions and syntax checks, but on ADD operations the password
                  checks were still be applied to root/password admins.

Fix Description:  Do not check the password syntax if the bind DN is a rootDN/password admin.

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

Reviewed by: nhosoi(Thanks!)

(cherry picked from commit 50820f80c2da853c29962485b5e9806e68d5aece)
Ticket #47834 - Tombstone_to_glue: if parents are also converted to glue, the target entry's DN must be adjusted.

Bug description: tombstone_to_glue resolves parents recursively if
they are also a tombstone entry, which may change the DN of the
target entry, but the DN change was not adjusted.

Fix description: Added a new argument newparentdn to tombstone_to_
glue_resolve_parent to return the new parent DN if it has been updated.
If a new parent DN is returned, set it to the target DN.

This patch also adds a cache debugging function: check_entry_cache,
which is disabled by default (in #ifdef CACHE_DEBUG)

Note: this bug is a left over of ticket #47750.

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

Reviewed by rmeggins@redhat.com (Thank you, Rich!!)
(cherry picked from commit 708a56b8d524131362e2d71b7fbc2eb257075e14)

(cherry picked from commit 513788ce60ef4f3742bfdb5442a92887735367c9)
Ticket #47834 - Tombstone_to_glue: if parents are also converted to glue, the target entry's DN must be adjusted.

Bug Description: Test case to verify the problem crashed the server.

Fix Description:
1. Clean up entry cache related code
1-1. Changing cache log reentrant to avoid self deadlock.
1-2. Introducing cache_is_in_cache to get rid of local variables in
     ldap_back_{add,delete,modify,modrdn}.
2. ldap_back_{add,delete,modify,modrdn}
2-1. As described in 1-2, removed [a-z]*_in_cache local variables.
2-2. In the deadlock retry loop, entries were duplicated by backentry_
     dup after CACHE_REMOVE'd and CACHE_RETURN'ed.  At the moment, the
     entry could be already freed.  Changed to create a duplicated
	 entry before calling CACHE_REMOVE and CACHE_RETURN.
3. _cl5NewDBFile (replication/cl5_api.c): When a leftover semaphore is
   found, _cl5NewDBFile removes it and creates it, but it rarely fails
   to delete and it causes the server restart fail.  Adding a message
   to remove such a leftover semaphore by ipcrm.

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

Reviewed by mreynolds@redhat.com (Thank you, Mark!!)
(cherry picked from commit 6333936da2c4287e96b36fecc24a4c62da5a8ea2)
(cherry picked from commit d9c8b1fe47e8ce708fa3cbeddbefa1916f1bf669)
Ticket #47748 - Simultaneous adding a user and binding as the user could fail in the password policy check

Description: commit 4fc53e1a63222d0ff67c30a59f2cff4b535f90a8 fix for
Ticket #47748 introduced a bug: "Simple bind hangs after enabling
password policy".

In do_bind, slapi_check_account_lock and need_new_pw overwrote the
return code from backend bind which is used later. This patch fixes
it not to override the return code.

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

Reviewed by mreynolds@redhat.com (Thank you, Mark!!)

(cherry picked from commit 4f11606b02419c8ccdb319b8040e683af9109d1b)
(cherry picked from commit 8c82941c0f2b0b5d7fa698a1ca3e4f26245cf85a)
(cherry picked from commit 5b6d60ec4d3d93d1d69f6a071ce135a06f4c8cfd)
Ticket #47750 - Creating a glue fails if one above level is a conflict or missing

Description: Poring changes made to 1.2.11 branch to newer versions.
1) Enabiling cache lock in cache_is_in_cache and cache_has_otherref.
2) Removing unused field new_entry_in_cache from "struct _modify_context".

(cherry picked from commit 5ae13072330e9a769a5949b2e8a91085b38ac4e1)
(cherry picked from commit ef766784ed7d09aa81e82316b621e8490a368dc6)
(cherry picked from commit 6ca4422d1a585c30b92045cff4d38f1c7edf72c7)
Ticket 47900 - Server fails to start if password admin is set

Bug Description:  The server will crash at startup if the password admin is set.

Fix Description:  When creating a password policy for the pblock, which we do
                  for add and modifiy operations, make sure the server is fully
                  up and running before searching backends for password admins.

                  Also, allow passwordAdminDN to be deleted from the cn=config.

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

Reviewed by: nhosoi(Thanks!)

(cherry picked from commit 4711de687174d6e5dd7b2c04782b62dc1cb90a6e)
Ticket 47918 - result of dna_dn_is_shared_config is incorrectly used

Bug Description:  dna_load_shared_servers() is called for all entries,
                  except the config entries

Fix Description:   revert the logic of the result of dna_dn_is_shared_config()

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

Reviewed by: Mark, Thanks