Ticket #47809 - find a way to remove replication plugin errors messages "changelog iteration code returned a dummy entry with csn %s, skipping ..."

Description:
1) Can't locate CSN %s in the changelog (DB rc=%d).
   Print the message once per one missing CSN.
2) changelog iteration code returned a dummy entry with csn %s, skipping ...
   Downgrade the log level to replication log level (SLAPI_LOG_REPL).

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

Reviewed by rmeggins@redhat.com (Thanks, Rich!)
(cherry picked from commit 6a1b10db6d41be9e3aadf6f7cbb18aaf4d00e87b)
(cherry picked from commit ddca54d9d8e8d7f3f8b1cd431cbf6381361f323e)
Ticket #47423 - 7-bit check plugin does not work for userpassword attribute

Bug description: 7-bit check plugin fails to validate userpassword
attribute

Fix description: This patch corrects the validation code for userpassword
attribute. It fetches the unhashed userpassword from the extension
instead of the entry attribute value

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

Reviewed by nhosoi.
(cherry picked from commit d804aaf7ee15841ac1aeaf831879fe56da23931d)
Ticket 47426 - move compute_idletimeout out of handle_pr_read_ready

Description:  Instead of calculating the idletimeout everytime new data is received,
              set the anonymous reslimit idletimeout and handle in the connection struct when the
              connection first comes in.  Then update idletimeout after each bind.

              I removed compute_idletimeout() because bind_credentials_set_nolock()
              basically does the same thing, so it was just extended to update
              the idletimeout.

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

Reviewed by: richm(Thanks!)
(cherry picked from commit ed83a783887b0f9c54781bac64c7b26f0402640a)
Ticket47426 - Coverity issue with last commit(move compute_idletimeout out of handle_pr_read_ready)

I had added a NULL check trying to avoid a coverity error, but pb->pb_conn can not be
NULL when it gets to this code.  Removed NULL check.

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

Reviewed by: ?
(cherry picked from commit a4daf1a0a65f796878b40b8ebc572082a1101f3b)
Ticket 47331 - Self entry access ACI not working properly

Bug Description:

	There are two issues in that bug.

	The first one is that for a given entry, the rights related to an attribute are evaluated and cached. Reusing this evaluation for a different entry is erronous.

	The second one is that for each deny/allow aci, the results of the evaluation of the aci is cached. These results
	are reset for aci type that are entry related.  The parsing of the rule self entry access miss the setting
	of ACI_USERDN_SELFRULE.
	This flag allows to reset (in result cache) a result obtained on a previous entry. The consequence is that
	a previous result was erronously reused.

Fix Description:

	The fix for the first issue, is to prevent acl__match_handlesFromCache to reuse already evaluated attributes.
	A new flag make acl__match_handlesFromCache to return if the evaluation is entry related.

	The second fix is to set ACI_USERDN_SELFRULE, when we have a rule like 'userdn = ldap:///self'

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

Reviewed by: Noriko Hosoi, Ludwig Krispenz

Platforms tested: fedora 17

Flag Day: no

Doc impact: no
(cherry picked from commit 79346deb255ca8d7889d7590534d308d4e3a78da)
Ticket 47331 - Self entry access ACI not working properly

Description: Additional change to
  commit 79346deb255ca8d7889d7590534d308d4e3a78da
which added a macro ACLPB_CACHE_RESULT_PER_ENTRY_SKIP, but
ACLPB_STATE_ALL was not updated to cover the bit.
This patch updates ACLPB_STATE_ALL to support the new bit.
(cherry picked from commit 86fea4b326b28912cd0d8de0d0cb3a2f8dea423e)
Ticket 47815 - Add operations rejected by betxn plugins remain in cache

Bug Description:  When an add operation is rejected by a betxn post plugin
                  the "adding" entry is removed the cache(previously added
                  tentatively), it gets re-added back to the entry cache
                  when we call betxn post plugins just before the abort.

Fix Description:  Remove the entry from the cache when the 2nd run of
                  the betxn postop plugins fails(just before we abort
                  the transaction).

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

valgrind: passed
jenkins: passed

Reviewed by: nhosoi(Thanks!)

(cherry picked from commit fe81bda5f2f2cef647cedadf9ba442f8b7851973)
Ticket 47817 - The error result text message should be obtained just prior to sending result

Bug Description:  We do not get pblock result message after the betxn postop plugins
                  are called.  If a betxn plugin modified the ldap result message, then
                  when the backend returns the results it does an invalid read on the
                  old pointer of the old result message.

Fix Description:  Get the result message after we call the betxn postop plugins.

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

jenkins: passed

Reviewed by: nhosoi(Thanks!)

(cherry picked from commit 68e766891d1067b2b86bd48bfa16d0837fa5a737)
Ticket #47831 - server restart wipes out index config if there is a default index

https://fedorahosted.org/389/ticket/47831
Reviewed by: nhosoi (Thanks!)
Branch: 389-ds-base-1.3.1
Fix Description: In ldbm_instance_index_config_enable_index(), only call
the function ldbm_index_parse_entry() if the index does not exist.  Instead,
get the name of the index from the "cn" attribute of the entry, and use
ainfo_get() to get the index.  If this returns NULL, then call
ldbm_index_parse_entry() to create and parse the index.
Platforms tested: Fedora 20
Flag Day: no
Doc impact: no

(cherry picked from commit 5c5c9603946ecb89fb17df665a95aa3ce75e01de)
(cherry picked from commit 111e11ad2b8ef1f3a1827e0aa833512189424a8b)
Ticket #47750 - Creating a glue fails if one above level is a conflict or missing

Bug description: https://fedorahosted.org/389/ticket/47750#comment:16

Fix description: The logic in slapi_is_special_rdn to check if the
RDN is a tombstone or not had a problem.  Even if the first part of
RDN is not nsuniqueid=<UNIQUE_ID>, it was returning true.  In this
patch, code to check the case is added and it returns false if the
first part of RDN is not  nsuniqueid=<UNIQUE_ID>.

Reviewed by mreynolds@redhat.com and rmeggins@redhat.com (Thank you,
Mark and Rich!!)
(cherry picked from commit 286559dac7a968faa0102f0165ba56892795b269)
(cherry picked from commit 36b883082265a2a5b2c818c0f7ce93e97ee55672)
Ticket #47750 - Creating a glue fails if one above level is a conflict or missing

Description: This commit accidentally removed the code to decrementing
the reference count for the backend instance.
  Commit: 160cb3f686e433c01532d28770b2977ec957e73e
  Ticket #47750 - Creating a glue fails if one above level is a conflict or missing;
Thanks to mreynolds@redhat.com for finding this out.
(cherry picked from commit 788a48fa98bb33a6601d7a198aa63b46d12ad78d)
(cherry picked from commit dfbc46a8574fdb5a2aef5a2ce1ea48400ba263aa)
Ticket #47763 - winsync plugin modify is broken

Description: Thanks to Carsten Grzemba for the patch.  Made minimum
changes such as replacing the direct access to the bv_len in Slapi_Value
with slapi_value_get_length.

Note: Regarding attr_compare_equal, since there is no strong reason
to switch to this new attr_compare_equal, we continue using the original
code.  The newly provided code is in "#if 0".

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

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

(cherry picked from commit b6b7199470671315d693ddec8db7c4ffbc4a1ee8)
(cherry picked from commit 7666910670755bab0453d146ff87014833c58c4e)
Ticket #47750 - Creating a glue fails if one above level is a conflict or missing

Description: This commit accidentally removed the code to add entry
back to cache if it was replaced:
  Commit: 160cb3f686e433c01532d28770b2977ec957e73e
  Ticket #47750 - Creating a glue fails if one above level is a conflict or missing;

Note: This is the cause of Ticket #47830 - usn tombstone entry not properly created
(cherry picked from commit 98cf4246b6e5c8a99a1e9063eca9aad9560185bd)
(cherry picked from commit 8c496b1e3b9d8a23369573423cb0b22bc6ed0e2d)
Ticket 47779 - Potential deadlock after startup if a dna configuration change is made

Bug Description:  DNA delays the shared server configuration creation
                  until 30 seconds after startup to allow other plugins
                  to start (replication and retro cl).  This delayed config
                  event starts a transaction while holding the read lock
                  which can lead to a deadlock.

Fix Description:  Make a one time copy of the shared server config for
                  the config update event so we don't need to hold any
                  locks while starting the backend transaction.

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

valgrind: passed
jenkins: passed

Reviewed by: rmeggins(Thanks!)

(cherry picked from commit badd35439b8ec5e7ccac070e5c8ef66565f75866)
(cherry picked from commit a696931de75249e65e8e72af0f55f30f4f4b6138)
Ticket 47781 - Server deadlock if online import started while
 server is under load

Bug Description:  Online import of ldif containing repl data deadlocks server.

Fix Description:  Replace the replica lock(PRLock) with a PRMonitor reentrant lock.

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

jenkins: passed

Reviewed by: nhosoi(Thanks!)

(cherry picked from commit 0e11f7182a3b8f42f90ec8335936965b88a11336)
(cherry picked from commit 5b46542a71b1fe2cab03aa44f6f84d579f5a9683)
Ticket #47692 single valued attribute replicated ADD does not work

https://fedorahosted.org/389/ticket/47692
Reviewed by: nhosoi (Thanks!)
Branch: 389-ds-base-1.3.1
Fix Description: Previous fix was incomplete - needed to move the
deleted attribute to the present attribute list.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no

(cherry picked from commit 4b54366593e50d71239588343f532eab39ef56e0)
(cherry picked from commit 60d8bf9f77c298197e4c8ecee585f8a2e6c0457c)
Ticket 47858 - Internal searches using OP_FLAG_REVERSE_CANDIDATE_ORDER can crash the server

Bug Description:  If an internal search uses OP_FLAG_REVERSE_CANDIDATE_ORDER, and
                  the search fails tro find any candidates the server will crash.

Fix Description:  Make sure we do not dereference a NULL sr_candidates pointer in
                  ldbm_search().

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

Reviewed by: rmeggins(Thanks!)

(cherry picked from commit e6cee31aa2beb6496df86490776f1f93d3a8348b)
(cherry picked from commit da318fa5f147e229069b13c0479fdf81ccc28213)