Branch '389-ds-base-1.3.1' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/add.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
New commits:
commit 4eb33f330c5f29c701c78faba5720f610f871c2a
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Sep 22 13:41:06 2015 -0400
Ticket 48284 - free entry when internal add fails
Bug Description: The entry passed to an internal add operaton is expected
to be consumed, but it is not freed during an internal
add when setting slapi_add_internal_pb() returns an error.
Fix Description: Free the entry in slapi_add_internal_pb() when the operation
is not allowed.
https://fedorahosted.org/389/ticket/48284
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 622be8bfbc942fe100b8880df72db26e99e1c954)
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index 4fb6540..f1af759 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -348,6 +348,12 @@ int slapi_add_internal_pb (Slapi_PBlock *pb)
if (!allow_operation (pb))
{
+ /* free the entry as it's expected to be consumed */
+ Slapi_Entry *e;
+ slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e);
+ slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
+ slapi_entry_free(e);
+
slapi_send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL,
"This plugin is not configured to access operation target data", 0, NULL );
return 0;
@@ -759,8 +765,8 @@ static void op_shared_add (Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &pse);
do_ps_service(pse, NULL, LDAP_CHANGETYPE_ADD, 0);
/*
- * If be_add succeeded, then e is consumed except the resurect case.
- * If it is resurect, the corresponding tombstone entry is resurected
+ * If be_add succeeded, then e is consumed except the resurrect case.
+ * If it is resurrect, the corresponding tombstone entry is resurrected
* and put into the cache.
* Otherwise, we set e to NULL to prevent freeing it ourselves.
*/
8 years, 7 months
Branch '389-ds-base-1.3.2' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/add.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
New commits:
commit 8449e3bf183ebe37c06325f14f8bc963da563fcc
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Sep 22 13:41:06 2015 -0400
Ticket 48284 - free entry when internal add fails
Bug Description: The entry passed to an internal add operaton is expected
to be consumed, but it is not freed during an internal
add when setting slapi_add_internal_pb() returns an error.
Fix Description: Free the entry in slapi_add_internal_pb() when the operation
is not allowed.
https://fedorahosted.org/389/ticket/48284
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 622be8bfbc942fe100b8880df72db26e99e1c954)
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index 243ef63..1682a60 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -348,6 +348,12 @@ int slapi_add_internal_pb (Slapi_PBlock *pb)
if (!allow_operation (pb))
{
+ /* free the entry as it's expected to be consumed */
+ Slapi_Entry *e;
+ slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e);
+ slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
+ slapi_entry_free(e);
+
slapi_send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL,
"This plugin is not configured to access operation target data", 0, NULL );
return 0;
@@ -759,8 +765,8 @@ static void op_shared_add (Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &pse);
do_ps_service(pse, NULL, LDAP_CHANGETYPE_ADD, 0);
/*
- * If be_add succeeded, then e is consumed except the resurect case.
- * If it is resurect, the corresponding tombstone entry is resurected
+ * If be_add succeeded, then e is consumed except the resurrect case.
+ * If it is resurrect, the corresponding tombstone entry is resurrected
* and put into the cache.
* Otherwise, we set e to NULL to prevent freeing it ourselves.
*/
8 years, 7 months
Branch '389-ds-base-1.3.3' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/add.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
New commits:
commit 61f3a05fde969df172c3e3d17dd9fc423998ff26
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Sep 22 13:41:06 2015 -0400
Ticket 48284 - free entry when internal add fails
Bug Description: The entry passed to an internal add operaton is expected
to be consumed, but it is not freed during an internal
add when setting slapi_add_internal_pb() returns an error.
Fix Description: Free the entry in slapi_add_internal_pb() when the operation
is not allowed.
https://fedorahosted.org/389/ticket/48284
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 622be8bfbc942fe100b8880df72db26e99e1c954)
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index 12b97e8..8f72e28 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -348,6 +348,12 @@ int slapi_add_internal_pb (Slapi_PBlock *pb)
if (!allow_operation (pb))
{
+ /* free the entry as it's expected to be consumed */
+ Slapi_Entry *e;
+ slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e);
+ slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
+ slapi_entry_free(e);
+
slapi_send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL,
"This plugin is not configured to access operation target data", 0, NULL );
return 0;
@@ -759,8 +765,8 @@ static void op_shared_add (Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &pse);
do_ps_service(pse, NULL, LDAP_CHANGETYPE_ADD, 0);
/*
- * If be_add succeeded, then e is consumed except the resurect case.
- * If it is resurect, the corresponding tombstone entry is resurected
+ * If be_add succeeded, then e is consumed except the resurrect case.
+ * If it is resurrect, the corresponding tombstone entry is resurrected
* and put into the cache.
* Otherwise, we set e to NULL to prevent freeing it ourselves.
*/
8 years, 7 months
Branch '389-ds-base-1.3.4' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/add.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
New commits:
commit 99dbfb7601daea80f80d1ea9d29766d76555e01a
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Sep 22 13:41:06 2015 -0400
Ticket 48284 - free entry when internal add fails
Bug Description: The entry passed to an internal add operaton is expected
to be consumed, but it is not freed during an internal
add when setting slapi_add_internal_pb() returns an error.
Fix Description: Free the entry in slapi_add_internal_pb() when the operation
is not allowed.
https://fedorahosted.org/389/ticket/48284
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 622be8bfbc942fe100b8880df72db26e99e1c954)
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index 5eb2042..31012a2 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -316,6 +316,12 @@ int slapi_add_internal_pb (Slapi_PBlock *pb)
if (!allow_operation (pb))
{
+ /* free the entry as it's expected to be consumed */
+ Slapi_Entry *e;
+ slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e);
+ slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
+ slapi_entry_free(e);
+
slapi_send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL,
"This plugin is not configured to access operation target data", 0, NULL );
return 0;
@@ -727,8 +733,8 @@ static void op_shared_add (Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &pse);
do_ps_service(pse, NULL, LDAP_CHANGETYPE_ADD, 0);
/*
- * If be_add succeeded, then e is consumed except the resurect case.
- * If it is resurect, the corresponding tombstone entry is resurected
+ * If be_add succeeded, then e is consumed except the resurrect case.
+ * If it is resurrect, the corresponding tombstone entry is resurrected
* and put into the cache.
* Otherwise, we set e to NULL to prevent freeing it ourselves.
*/
8 years, 7 months
ldap/servers
by Mark Reynolds
ldap/servers/slapd/add.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
New commits:
commit 622be8bfbc942fe100b8880df72db26e99e1c954
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Sep 22 13:41:06 2015 -0400
Ticket 48284 - free entry when internal add fails
Bug Description: The entry passed to an internal add operaton is expected
to be consumed, but it is not freed during an internal
add when setting slapi_add_internal_pb() returns an error.
Fix Description: Free the entry in slapi_add_internal_pb() when the operation
is not allowed.
https://fedorahosted.org/389/ticket/48284
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index 5eb2042..31012a2 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -316,6 +316,12 @@ int slapi_add_internal_pb (Slapi_PBlock *pb)
if (!allow_operation (pb))
{
+ /* free the entry as it's expected to be consumed */
+ Slapi_Entry *e;
+ slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e);
+ slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
+ slapi_entry_free(e);
+
slapi_send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL,
"This plugin is not configured to access operation target data", 0, NULL );
return 0;
@@ -727,8 +733,8 @@ static void op_shared_add (Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &pse);
do_ps_service(pse, NULL, LDAP_CHANGETYPE_ADD, 0);
/*
- * If be_add succeeded, then e is consumed except the resurect case.
- * If it is resurect, the corresponding tombstone entry is resurected
+ * If be_add succeeded, then e is consumed except the resurrect case.
+ * If it is resurrect, the corresponding tombstone entry is resurrected
* and put into the cache.
* Otherwise, we set e to NULL to prevent freeing it ourselves.
*/
8 years, 7 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/replication/repl5_replica.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
New commits:
commit 3896e68cd2ee56df7bcc95add500fee56733d62c
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Sep 22 09:49:12 2015 -0400
Ticket 48266 - Online init crashes consumer
Bug Description: When trying to create the 'replica keep alive' entry
on a consumer during an online init, the entry gets freed
in op_shared_add(), and then freed again in
replica_subentry_create() which leads to a crash.
Fix Description: Do not free the "keep alive" entry if a referral is
returned when trying to create the keep-alive entry.
https://fedorahosted.org/389/ticket/48266
Reviewed by: tbordaz(Thanks!)
(cherry picked from commit 5538bac519c5363bb456e98d615c9366dedd57d8)
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index a53e685..cb3fdb5 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -443,7 +443,9 @@ replica_subentry_create(Slapi_DN *repl_root, ReplicaId rid)
repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0 /* flags */);
slapi_add_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &return_value);
- if (return_value != LDAP_SUCCESS && return_value != LDAP_ALREADY_EXISTS)
+ if (return_value != LDAP_SUCCESS &&
+ return_value != LDAP_ALREADY_EXISTS &&
+ return_value != LDAP_REFERRAL /* CONSUMER */)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Warning: unable to "
"create replication keep alive entry %s: %s\n", slapi_entry_get_dn_const(e),
8 years, 7 months
Branch '389-ds-base-1.3.3' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/replication/repl5_replica.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
New commits:
commit c28b52f6fa4b6423df3fa03338769ad6d1ad54f7
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Sep 22 09:49:12 2015 -0400
Ticket 48266 - Online init crashes consumer
Bug Description: When trying to create the 'replica keep alive' entry
on a consumer during an online init, the entry gets freed
in op_shared_add(), and then freed again in
replica_subentry_create() which leads to a crash.
Fix Description: Do not free the "keep alive" entry if a referral is
returned when trying to create the keep-alive entry.
https://fedorahosted.org/389/ticket/48266
Reviewed by: tbordaz(Thanks!)
(cherry picked from commit 5538bac519c5363bb456e98d615c9366dedd57d8)
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index c19365e..a0c1011 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -477,7 +477,9 @@ replica_subentry_create(Slapi_DN *repl_root, ReplicaId rid)
repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0 /* flags */);
slapi_add_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &return_value);
- if (return_value != LDAP_SUCCESS && return_value != LDAP_ALREADY_EXISTS)
+ if (return_value != LDAP_SUCCESS &&
+ return_value != LDAP_ALREADY_EXISTS &&
+ return_value != LDAP_REFERRAL /* CONSUMER */)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Warning: unable to "
"create replication keep alive entry %s: %s\n", slapi_entry_get_dn_const(e),
8 years, 7 months
Branch '389-ds-base-1.3.4' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/replication/repl5_replica.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
New commits:
commit 1c127b40c1c7298839562326babbf2cba65cce1b
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Sep 22 09:49:12 2015 -0400
Ticket 48266 - Online init crashes consumer
Bug Description: When trying to create the 'replica keep alive' entry
on a consumer during an online init, the entry gets freed
in op_shared_add(), and then freed again in
replica_subentry_create() which leads to a crash.
Fix Description: Do not free the "keep alive" entry if a referral is
returned when trying to create the keep-alive entry.
https://fedorahosted.org/389/ticket/48266
Reviewed by: tbordaz(Thanks!)
(cherry picked from commit 5538bac519c5363bb456e98d615c9366dedd57d8)
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 6ac28c1..708008c 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -448,7 +448,9 @@ replica_subentry_create(Slapi_DN *repl_root, ReplicaId rid)
repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0 /* flags */);
slapi_add_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &return_value);
- if (return_value != LDAP_SUCCESS && return_value != LDAP_ALREADY_EXISTS)
+ if (return_value != LDAP_SUCCESS &&
+ return_value != LDAP_ALREADY_EXISTS &&
+ return_value != LDAP_REFERRAL /* CONSUMER */)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Warning: unable to "
"create replication keep alive entry %s: %s\n", slapi_entry_get_dn_const(e),
8 years, 7 months
ldap/servers
by Mark Reynolds
ldap/servers/plugins/replication/repl5_replica.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
New commits:
commit 5538bac519c5363bb456e98d615c9366dedd57d8
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Sep 22 09:49:12 2015 -0400
Ticket 48266 - Online init crashes consumer
Bug Description: When trying to create the 'replica keep alive' entry
on a consumer during an online init, the entry gets freed
in op_shared_add(), and then freed again in
replica_subentry_create() which leads to a crash.
Fix Description: Do not free the "keep alive" entry if a referral is
returned when trying to create the keep-alive entry.
https://fedorahosted.org/389/ticket/48266
Reviewed by: tbordaz(Thanks!)
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 6ac28c1..708008c 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -448,7 +448,9 @@ replica_subentry_create(Slapi_DN *repl_root, ReplicaId rid)
repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0 /* flags */);
slapi_add_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &return_value);
- if (return_value != LDAP_SUCCESS && return_value != LDAP_ALREADY_EXISTS)
+ if (return_value != LDAP_SUCCESS &&
+ return_value != LDAP_ALREADY_EXISTS &&
+ return_value != LDAP_REFERRAL /* CONSUMER */)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Warning: unable to "
"create replication keep alive entry %s: %s\n", slapi_entry_get_dn_const(e),
8 years, 7 months
Branch '389-ds-base-1.3.4' - 2 commits - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/bind.c | 58 +++++++++++++++++++++++++++++++-------
ldap/servers/slapd/mapping_tree.c | 19 ++++++++++++
ldap/servers/slapd/slapi-plugin.h | 1
3 files changed, 68 insertions(+), 10 deletions(-)
New commits:
commit a215c006e0900caaa555def9e047e295844d8652
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Sep 18 15:19:51 2015 -0700
Ticket #48188 - segfault in ns-slapd due to accessing Slapi_DN freed in pre bind plug-in
Description: Additional fixes based upon the comments by rmeggins(a)redhat.com
(Thank you, Rich!!).
https://fedorahosted.org/389/ticket/48188?replyto=24#comment:24
1. Implemented the case 2)
If the plugin changes the SLAPI_BIND_TARGET_SDN *value*,
we need to select a different backend. It is possible
(but not very useful) for the plugin to change the pointer,
but use the same value.
2. Added an api slapi_be_select_exact which returns NULL if
there is no matching backend.
https://fedorahosted.org/389/ticket/48188
Reviewed by rmeggins(a)redhat.com (Thank you!)
(cherry picked from commit 8212a8913b748cd1f5e986a754c37ef41db8272a)
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index 4ec276a..474b508 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -107,6 +107,7 @@ do_bind( Slapi_PBlock *pb )
int auto_bind = 0;
int minssf = 0;
int minssf_exclude_rootdse = 0;
+ Slapi_DN *original_sdn = NULL;
LDAPDebug( LDAP_DEBUG_TRACE, "do_bind\n", 0, 0, 0 );
@@ -660,10 +661,9 @@ do_bind( Slapi_PBlock *pb )
goto free_and_return;
}
- if (referral)
- {
- send_referrals_from_entry(pb,referral);
- slapi_entry_free(referral);
+ if (referral) {
+ send_referrals_from_entry(pb,referral);
+ slapi_entry_free(referral);
goto free_and_return;
}
@@ -671,29 +671,50 @@ do_bind( Slapi_PBlock *pb )
/* not root dn - pass to the backend */
if ( be->be_bind != NULL ) {
-
+ original_sdn = slapi_sdn_dup(sdn);
/*
* call the pre-bind plugins. if they succeed, call
* the backend bind function. then call the post-bind
* plugins.
*/
if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_BIND_FN ) == 0 ) {
+ int sdn_updated = 0;
rc = 0;
/* Check if a pre_bind plugin mapped the DN to another backend */
Slapi_DN *pb_sdn;
slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &pb_sdn);
- if (pb_sdn != sdn) {
+ if (!pb_sdn) {
+ PR_snprintf(errorbuf, sizeof(errorbuf), "Pre-bind plug-in set NULL dn\n");
+ send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, errorbuf, 0, NULL);
+ goto free_and_return;
+ } else if ((pb_sdn != sdn) || (sdn_updated = slapi_sdn_compare(original_sdn, pb_sdn))) {
/*
* Slapi_DN set in pblock was changed by a pre bind plug-in.
* It is a plug-in's responsibility to free the original Slapi_DN.
*/
sdn = pb_sdn;
dn = slapi_sdn_get_dn(sdn);
-
- slapi_be_Unlock(be);
- be = slapi_be_select(sdn);
- slapi_be_Rlock(be);
+ if (!dn) {
+ PR_snprintf(errorbuf, sizeof(errorbuf), "Pre-bind plug-in set corrupted dn\n");
+ send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, errorbuf, 0, NULL);
+ goto free_and_return;
+ }
+ if (!sdn_updated) { /* pb_sdn != sdn; need to compare the dn's. */
+ sdn_updated = slapi_sdn_compare(original_sdn, sdn);
+ }
+ if (sdn_updated) { /* call slapi_be_select only when the DN is updated. */
+ slapi_be_Unlock(be);
+ be = slapi_be_select_exact(sdn);
+ if (be) {
+ slapi_be_Rlock(be);
+ slapi_pblock_set( pb, SLAPI_BACKEND, be );
+ } else {
+ PR_snprintf(errorbuf, sizeof(errorbuf), "No matching backend for %s\n", dn);
+ send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, errorbuf, 0, NULL);
+ goto free_and_return;
+ }
+ }
}
/*
@@ -845,10 +866,12 @@ account_locked:
}
free_and_return:;
- if (be)
+ slapi_sdn_free(&original_sdn);
+ if (be) {
slapi_be_Unlock(be);
+ }
if (bind_sdn_in_pb) {
- slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &sdn);
+ slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &sdn);
}
slapi_sdn_free(&sdn);
slapi_ch_free_string( &saslmech );
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index 165eba1..20c2cc3 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -3095,6 +3095,25 @@ slapi_be_select( const Slapi_DN *sdn ) /* JCM - The name of this should change??
return be;
}
+Slapi_Backend *
+slapi_be_select_exact(const Slapi_DN *sdn)
+{
+ Slapi_Backend *be = NULL;
+ mapping_tree_node *node = NULL;
+
+ if (!sdn) {
+ LDAPDebug0Args(LDAP_DEBUG_ANY, "slapi_be_select_exact: Empty Slapi_DN is given.\n");
+ return NULL;
+ }
+ node = slapi_get_mapping_tree_node_by_dn(sdn);
+
+ if (node && node->mtn_be) {
+ be = node->mtn_be[0];
+ }
+
+ return be;
+}
+
/* Check if the dn targets an internal reserved backends */
int
slapi_on_internal_backends(const Slapi_DN *sdn)
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 4134c1b..72f3920 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -6339,6 +6339,7 @@ Slapi_Backend *slapi_be_new( const char *type, const char *name,
int isprivate, int logchanges );
void slapi_be_free(Slapi_Backend **be);
Slapi_Backend *slapi_be_select( const Slapi_DN *sdn );
+Slapi_Backend *slapi_be_select_exact(const Slapi_DN *sdn);
Slapi_Backend *slapi_be_select_by_instance_name( const char *name );
int slapi_be_exist(const Slapi_DN *sdn);
void slapi_be_delete_onexit(Slapi_Backend *be);
commit 6871f4f6d14198563f7f3cb0646a00faa28d35ea
Author: Simo Sorce <simo(a)redhat.com>
Date: Fri Sep 18 11:13:43 2015 -0700
Ticket #48188 - segfault in ns-slapd due to accessing Slapi_DN freed in pre bind plug-in
This patch is based upon the patch provided by Simo Sorce <simo(a)redhat.com> for
Ticket #48272 - Allow PRE_BIND plugins to mangle DNs
Description:
Allow a pre_bind plugin to map a DN to another
This is useful for plugins that deal with virtual trees or non-standard
clients binding with values that are not proper DNs and similar situations.
Signed-off-by: Simo Sorce <simo(a)redhat.com>
2 changes are made to the original patch:
1. removed "slapi_sdn_free(&sdn)" with this comment:
* It is a plug-in's responsibility to free the original Slapi_DN.
Note: slapi-nis already freed the original sdn.
2. reset dn from the new sdn.
dn = slapi_sdn_get_dn(sdn);
https://fedorahosted.org/389/ticket/48188
Reviewed by rmeggins(a)redhat.com and lkrispen(a)redhat.com.
(cherry picked from commit 40e0d0f80d6fd1271431e105580293747c43c327)
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index 1bd604f..4ec276a 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -669,7 +669,7 @@ do_bind( Slapi_PBlock *pb )
slapi_pblock_set( pb, SLAPI_BACKEND, be );
- /* not root dn - pass to the backend */
+ /* not root dn - pass to the backend */
if ( be->be_bind != NULL ) {
/*
@@ -677,10 +677,25 @@ do_bind( Slapi_PBlock *pb )
* the backend bind function. then call the post-bind
* plugins.
*/
- if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_BIND_FN )
- == 0 ) {
+ if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_BIND_FN ) == 0 ) {
rc = 0;
+ /* Check if a pre_bind plugin mapped the DN to another backend */
+ Slapi_DN *pb_sdn;
+ slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &pb_sdn);
+ if (pb_sdn != sdn) {
+ /*
+ * Slapi_DN set in pblock was changed by a pre bind plug-in.
+ * It is a plug-in's responsibility to free the original Slapi_DN.
+ */
+ sdn = pb_sdn;
+ dn = slapi_sdn_get_dn(sdn);
+
+ slapi_be_Unlock(be);
+ be = slapi_be_select(sdn);
+ slapi_be_Rlock(be);
+ }
+
/*
* Is this account locked ?
* could be locked through the account inactivation
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 7 months