Ticket 47729 - Directory Server crashes if shutdown during a replication initialization

Bug Description:  When a shutdown was detected we marked that the total update was done
                  prematurely(prp->stopped).  This allowed the replication plugin to close
                  while the total update was still in progress. Other plugins continued to
                  be shutdown (e.g. ldbm database), while the total update was using shared
                  resources - which lead to a crash.

Fix Description:  Only mark the total update protocol as stopped, after it is finished using
                  shared resources.

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

Reviewed by: nhosoi(Thanks!)
(cherry picked from commit e7f7e9127717c1d432b10493b626fed334cc595f)
Ticket #47735 - e_uniqueid fails to set if an entry is a conflict entry

Bug Description:
When an entry is turned to be a conflict entry, its nsUniqueId has
a mdcsn info as a subtype like this:
 nsUniqueId;mdcsn-5319136f000200010000: c5e0d787-a58f11e3-b7f9dfd1-acc3d5e4
In this case, the attribute type is assigned to the berval "type"
as follows:
 type.bv_val = "nsUniqueId;mdcsn-5319136f000200010000"
 type.bv_len = 37
The subtyped stateinfo is processed in str2entry_state_information_from_type,
which modifies type.bv_val to "nsUniqueId", but type.bv_len remains 37.
str2entry_fast has this logic to set e_uniqueid, where the nsUniqueId
with stateinfo fails to set the value to e_uniqueid.
 if ( type.bv_len == 10 &&
      PL_strncasecmp (type.bv_val, "nsUniqueId", type.bv_len) == 0 ){

Fix Description: This patch resets the length of the type with the
basetype length 10 before the if expression is called for setting
e_uniqueid.

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

Reviewed by rmeggins@redhat.com (Thank you, Rich!!)
(cherry picked from commit 07bd2259cc45c9d5c193b15faaf0d0c60e1b723c)
(cherry picked from commit 6e0ffbe1bdde99cfd71a5617d89482eef4696c7f)
Ticket #47737 - Under heavy stress, failure of turning a tombstone into glue makes the server hung

Description: Turning a tombstone entry to a glue entry is done in a
while loop (create_glue_entry:urp_glue.c) Unless the transformation
is successful (or LDAP_NO_SUCH_OBJECT), it cannot exit from the loop.
But under a stress, there could be a tombstone and a conflict entry
coexist, and do_create_glue_entry keeps returning LDAP_ALREADY_EXISTS.
In such a case, we need to give up creating a glue.

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

Reviewed by rmeggins@redhat.com (Thank you, Rich!)
(cherry picked from commit a84dab5923de59cfda9bd4e78813d0c22bab35ae)
(cherry picked from commit 97fa6d25159bcdbc6701c4696d675683bed34761)
Ticket 47700 - Fix compiler warnings

The original fix for ticket 47700 caused new compiler warnings

Addresses these new warnings:
   warning: deprecated conversion from string constant to 'char*'

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

Reveiwed by: nhosoi(Thanks!)
(cherry picked from commit 9698a97075e04219e103b2693ac5002d33b19486)
Ticket #47739 - directory server is insecurely misinterpreting authzid on a SASL/GSSAPI bind

Description: SASL_CB_PROXY_POLICY callback is not needed since we
don't support the case authid and authzid do not match.  This patch
gets rid of the callback function ids_sasl_proxy_policy.

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

Reviewed by nkinder@redhat.com (Thank you, Nathan!!)
(cherry picked from commit 76acff12a86110d4165f94e2cba13ef5c7ebc38a)
(cherry picked from commit 9bc2b46b7c7ee4c975d04b041f73a5992906b07c)
Revert "Ticket 47700 - Fix compiler warnings"

This reverts commit c0c8da7ae44d0fe6d95453efba96a7783910830a.
bump version to 1.3.1.20
Ticket 47722 - rsearch filter error on any search filter

Bug Description:  A NULL gets incorrectly added to the search filter, which
                  creates an invalid filter.

Fix Description:  Do not add a NULL character to the search filter.

Original fix submitted by nkinder(Thanks!)

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

Reviewed by: nhoosi(Thanks!)
(cherry picked from commit 8afcf90b0d9d6599144bb1666ca79cef9e91b3ef)
Ticket47722 - Fixed filter not correctly identified

Bug Description:  Due to an improper table initialization, fixed filters
                  were not correctly identifed, which lead to incorrect
                  code execution.

Fix Description:  Correct the table initialization.  Also, removed all the
                  fixed buffers for user supplied values.  Also increased
                  the maximum string length to handle a 64bit unsigned integer.

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

Reviewed by: richm(Thanks!)
(cherry picked from commit 2ec0cdb295e145bff60d020708339c77b10a9367)
Ticket #47734 - Change made in resolving ticket #346 fails on Debian SPARC64

Description: The following change is not generic beyond x86 and
x86_64 architecture.  Putting the change into "#if (defined(CPU_x86)
|| defined(CPU_x86_64))".
 commit c0151f78509c35250095da6e2785842337963008
 Trac Ticket #346 - Slow ldapmodify operation time for large
                    quantities of multi-valued attribute values
 3) In slapi_has8thBit, instead of checking the 8th bit one byte
 by one byte, check 4 bytes at one time.

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

Reviewed by rmeggins@redhat.com (Thank you, Rich!!)
(cherry picked from commit 1e00913312e165ead2f3a25b6d70f7839115007e)
(cherry picked from commit ba9248d02447dc693114961d9296ecb742a75add)
Ticket 47740 - Coverity Fixes (Mark - part 1)

Fixed these issues:

12510 - resource leak in lib/libutil/certmap.c
12509 - resource leak in ldap/servers/plugins/chainingdb/cb_bind.c
12508 - resource leak in ldap/servers/plugins/replication/repl5_replica_config.c
12507 - resource leak in ldap/servers/plugins/replication/repl5_replica_config.c
12506 - resource leak in ldap/servers/plugins/chainingdb/cb_config.c
12505 - resource leak in ldap/servers/plugins/posix-winsync/posix-winsync.c
12500 - resource leak in ldap/servers/plugins/chainingdb/cb_instance.c

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

Reviewed by: nhosoi(Thanks!)
(cherry picked from commit d3ed247b7ed59eac8776ea9e73ee21ec8bcd2011)
Ticket 47538 - RFE: repl-monitor.pl plain text output, cmdline config options

RFE Description:  Request option to print report in plain text(instead of HTML), and
                  be able to add the configfuration file directives as command line
                  options.

Fix Description:  Add a new option "-s" for displaying plain text report.

                  Added new options for the config file directives:

                      -c "connection value"
                      -a "alias value"
                      -k "color value"

                  Added a new option (-W, --prompt) to prompt for passwords.

                  Added "long names" to the commandline options.
                  Updated to use:  GetOpts::Long, strict, warnings

                  Cleaned up some HTML code/colors, and indentation.

                  Update man page.

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

Reviewed by: nhosoi, nkinder, and rmeggins(Thanks!!!)
(cherry picked from commit 76abd736d3bf763cc0e7bc1987fe76c27159db6f)
Ticket 47640 - Fix coverity issues - part 3

12504 - resource leak - /ldap/servers/slapd/back-ldbm/import-threads.c
12499 - resource leak - /ldap/servers/slapd/passwd_extop.c
12497 - resource leak - /ldap/servers/slapd/mapping_tree.c
12496 - resource leak - /ldap/servers/slapd/mapping_tree.c
12495 - resource leak - /ldap/servers/plugins/replication/legacy_consumer.c
12493 - resource leak - /ldap/servers/slapd/tools/rsearch/sdattable.c
12492 - resource leak - /ldap/servers/slapd/tools/pwenc.c
12491 - resource leak - /ldap/servers/slapd/tools/mmldif.c

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

Reviewed by: rmeggins(Thanks!)
Ticket 47740 - Fix coverity erorrs - Part 4

12498 - resource leak - /ldap/servers/plugins/chainingdn/cb_instance.c
12490 - resource leak - /ldap/servers/plugins/chainingdn/cb_controls.c
12489 - resource leak - /ldap/servers/plugins/replication/repl5_replica_config.c
12488 - resource leak - /ldap/servers/slapd/main.c
12485 - resource leak - /ldap/servers/plugins/replication/repl5_replica_config.c
12484 - resource leak - /ldap/servers/plugins/replication/repl5_replica_config.c
12483 - resource leak - /ldap/servers/slapd/back-ldbm/upgrade.c
12482 - resource leak - /ldap/servers/plugins/replication/repl5_replica.c
12481 - resource leak - /ldap/servers/plugins/acl/aclplugin.c
12476 - resource leak - /ldap/servers/slapd/back-ldbm/upgrade.c
12475 - resource leak - /ldap/servers/slapd/back-ldbm/upgrade.c

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

Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 48c1f2afb047de272603c87e6b592dd681eb8d9d)