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)
(cherry picked from commit e50653fffab5036e2027f99f9d2b2bf70f498e2e)
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)
(cherry picked from commit f5ee5b8babfb7b61db7da3db7ab7c443eda58323)
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)
(cherry picked from commit d4f9c40d6d7f36b31e81c2326036a65229fe470f)
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)
(cherry picked from commit 89b78da25aa79101d6b43529a7486c64feb5eda6)
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)
(cherry picked from commit 1580bcd71cbb60f0e97a36bf83faca6e079cd861)
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)
(cherry picked from commit 6d43552d862234334f94a5768132d71847bfcd20)
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)

Conflicts:
	ldap/servers/slapd/back-ldbm/ldbm_add.c
Ticket #47820 - 1.2.11 branch: coverity errors

Description:
* Deadcode
1. Defect type: UNUSED_VALUE
1. 389-ds-base-1.2.11.15/ldap/servers/slapd/daemon.c:1894:returned_pointer – Pointer "slapdFrontendConfig" returned by "getFrontendConfig()" is never used.
   Solution: removed the line 1894.

* Clang
1. Defect type: CLANG_WARNING
1. 389-ds-base-1.2.11.15/ldap/servers/slapd/valueset.c:1116:20:warning – Array access (via field 'va') results in a null pointer dereference
2. Defect type: CLANG_WARNING
1. 389-ds-base-1.2.11.15/ldap/servers/slapd/valueset.c:1090:26:warning – Array access (via field 'va') results in a null pointer dereference
   Solution: Added the code to check null dereference on vs->va on vs->va

3. Defect type: CLANG_WARNING
1. 389-ds-base-1.2.11.15/ldap/servers/slapd/daemon.c:1896:6:warning – Value stored to 'maxthreads' during its initialization is never read
   Solution: removed the line 1896.

4. Defect type: CLANG_WARNING
1. 389-ds-base-1.2.11.15/ldap/servers/slapd/daemon.c:1894:25:warning – Value stored to 'slapdFrontendConfig' during its initialization is never read
   Solution: Already addressed in Deadcode : 1. Defect type: UNUSED_VALUE

5. Defect type: CLANG_WARNING
1. 389-ds-base-1.2.11.15/ldap/servers/slapd/daemon.c:1091:21:warning – Dereference of null pointer (loaded from variable 'nap')
   Solution: Added the code to check null dereference on nap and *nap.

6. Defect type: CLANG_WARNING
1. 389-ds-base-1.2.11.15/ldap/servers/slapd/back-ldbm/ldbm_search.c:455:25:warning – Value stored to 'virtual_list_view' is never read
   Solution: Porting bug (bz1109952; DS 47780).  Moved the line to the right position.

7. Defect type: CLANG_WARNING
1. 389-ds-base-1.2.11.15/ldap/servers/slapd/back-ldbm/ldbm_add.c:1110:2:warning – Value stored to 'noabort' is never read
   Solution: Removed unnecessary assignment.

Compiler Warnings
12. Defect type: COMPILER_WARNING
2. 389-ds-base-1.2.11.15/ldap/servers/slapd/daemon.c:1896:warning – unused variable 'maxthreads'
   Solution: already addressed 3. Defect type: CLANG_WARNING

13. Defect type: COMPILER_WARNING
1. 389-ds-base-1.2.11.15/ldap/servers/slapd/daemon.c:1895:warning – unused variable 'idletimeout'
   Solution: Removed the unused variable.

14. Defect type: COMPILER_WARNING ¶
1. 389-ds-base-1.2.11.15/ldap/servers/slapd/daemon.c:1894:warning – unused variable 'slapdFrontendConfig'
   Solution: already addressed 1. Defect type: UNUSED_VALUE

15. Defect type: COMPILER_WARNING
2. 389-ds-base-1.2.11.15/ldap/servers/slapd/daemon.c:1788:warning – 'compute_idletimeout' defined but not used
   Solution: removed the unused function.

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

Reviewed by rmeggins@redhat.com (Thanks, Rich!!)
Revert "Ticket #47423 - 7-bit check plugin does not work for userpassword attribute"

This reverts commit 7e7a85f6fb74547f7d2af191db3b4608b39995ab.

This patch should not be in 389-ds-base-1.2.11 branch.
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.2.11
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)
(cherry picked from commit 18bc3e82c3919867f14747343e452019630b60d0)
(cherry picked from commit e260d9fd9e680579677007b6466f4e9ad3323eb6)
Ticket 47821 - deref plugin cannot handle complex acis

Bug Description:  the deref plugin does not return attributes if
			the access depends on rules requireing
			the entry

Fix Description:   do the access check after the entry is retrieved

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

Reviewed by: mark, thanks

Conflicts:
	ldap/servers/plugins/deref/deref.c
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)
(cherry picked from commit 2f3852fea43efde5994b3805d65cf2fc80210d73)
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)
(cherry picked from commit f18411d98a441f26f1ef2246b62e84b72ce39ec4)
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;
Thanks to lkrispen@redhat.com for figuring it out.

Note: This is the cause of Ticket #47830 - usn tombstone entry not properly created
(cherry picked from commit 98cf4246b6e5c8a99a1e9063eca9aad9560185bd)
(cherry picked from commit 8c496b1e3b9d8a23369573423cb0b22bc6ed0e2d)
(cherry picked from commit 51a76a4d565f0e93092e589ee7e3064d5371c54a)
Revert "Ticket #47750 - Creating a glue fails if one above level is a conflict or missing"

This reverts commit 30f1ba8154a4034137c3640007ee35cdb65131dd.
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.2.11
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)
(cherry picked from commit 45dcda2425a865bf529ad0c8423664091392b865)
(cherry picked from commit aead2be2a9cc5392713c7849c18a9bf218beb533)
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)