|
|
f92ce9 |
From 09f106acd0ad639965fdc1b97fd1718ce4eec355 Mon Sep 17 00:00:00 2001
|
|
|
f92ce9 |
From: Ludwig Krispenz <lkrispen@redhat.com>
|
|
|
f92ce9 |
Date: Wed, 10 Sep 2014 13:22:06 +0200
|
|
|
f92ce9 |
Subject: [PATCH 3/7] fix for 47885 did not always return a response control
|
|
|
f92ce9 |
|
|
|
f92ce9 |
reviewd by rich, thanks
|
|
|
f92ce9 |
|
|
|
f92ce9 |
(cherry picked from commit 55e317f2a5d8fc488e7eeee6f2b4155298a45d25)
|
|
|
f92ce9 |
---
|
|
|
f92ce9 |
ldap/servers/plugins/deref/deref.c | 30 ++++++++++++------------------
|
|
|
f92ce9 |
1 file changed, 12 insertions(+), 18 deletions(-)
|
|
|
f92ce9 |
|
|
|
f92ce9 |
diff --git a/ldap/servers/plugins/deref/deref.c b/ldap/servers/plugins/deref/deref.c
|
|
|
f92ce9 |
index 96d42e6..1bab0ab 100644
|
|
|
f92ce9 |
--- a/ldap/servers/plugins/deref/deref.c
|
|
|
f92ce9 |
+++ b/ldap/servers/plugins/deref/deref.c
|
|
|
f92ce9 |
@@ -591,14 +591,13 @@ deref_values_free(Slapi_ValueSet** results, char** actual_type_name, int buffer_
|
|
|
f92ce9 |
slapi_vattr_values_free(results, actual_type_name, buffer_flags);
|
|
|
f92ce9 |
}
|
|
|
f92ce9 |
|
|
|
f92ce9 |
-static int
|
|
|
f92ce9 |
+static void
|
|
|
f92ce9 |
deref_do_deref_attr(Slapi_PBlock *pb, BerElement *ctrlber, const char *derefdn, const char *derefattr, const char **attrs)
|
|
|
f92ce9 |
{
|
|
|
f92ce9 |
char **retattrs = NULL;
|
|
|
f92ce9 |
Slapi_PBlock *derefpb = NULL;
|
|
|
f92ce9 |
Slapi_Entry **entries = NULL;
|
|
|
f92ce9 |
int rc;
|
|
|
f92ce9 |
- int needcontrol = 0;
|
|
|
f92ce9 |
|
|
|
f92ce9 |
/* If the access check on the attributes is done without retrieveing the entry
|
|
|
f92ce9 |
* it cannot handle acis which need teh entry, eg to apply a targetfilter rule
|
|
|
f92ce9 |
@@ -628,7 +627,6 @@ deref_do_deref_attr(Slapi_PBlock *pb, BerElement *ctrlber, const char *derefdn,
|
|
|
f92ce9 |
"The client does not have permission to read the requested "
|
|
|
f92ce9 |
"attributes in entry %s\n", derefdn);
|
|
|
f92ce9 |
} else {
|
|
|
f92ce9 |
- needcontrol = 1;
|
|
|
f92ce9 |
ber_printf(ctrlber, "{ss", derefattr, derefdn); /* begin DerefRes + derefAttr + derefVal */
|
|
|
f92ce9 |
for (ii = 0; retattrs[ii]; ++ii) {
|
|
|
f92ce9 |
Slapi_Value *sv;
|
|
|
f92ce9 |
@@ -704,7 +702,6 @@ deref_do_deref_attr(Slapi_PBlock *pb, BerElement *ctrlber, const char *derefdn,
|
|
|
f92ce9 |
slapi_pblock_destroy(derefpb);
|
|
|
f92ce9 |
slapi_ch_free((void **)&retattrs); /* retattrs does not own the strings */
|
|
|
f92ce9 |
|
|
|
f92ce9 |
- return needcontrol;
|
|
|
f92ce9 |
}
|
|
|
f92ce9 |
|
|
|
f92ce9 |
static int
|
|
|
f92ce9 |
@@ -718,7 +715,6 @@ deref_pre_entry(Slapi_PBlock *pb)
|
|
|
f92ce9 |
LDAPControl *ctrl = NULL;
|
|
|
f92ce9 |
const LDAPControl **searchctrls = NULL;
|
|
|
f92ce9 |
LDAPControl **newsearchctrls = NULL;
|
|
|
f92ce9 |
- int needcontrol = 0;
|
|
|
f92ce9 |
|
|
|
f92ce9 |
if (!speclist) {
|
|
|
f92ce9 |
return 0; /* nothing to do */
|
|
|
f92ce9 |
@@ -762,25 +758,23 @@ deref_pre_entry(Slapi_PBlock *pb)
|
|
|
f92ce9 |
for (; results && sv; idx = slapi_valueset_next_value(results, idx, &sv)) {
|
|
|
f92ce9 |
const char *derefdn = slapi_value_get_string(sv);
|
|
|
f92ce9 |
|
|
|
f92ce9 |
- needcontrol += deref_do_deref_attr(pb, ctrlber, derefdn, spec->derefattr, (const char **)spec->attrs);
|
|
|
f92ce9 |
+ deref_do_deref_attr(pb, ctrlber, derefdn, spec->derefattr, (const char **)spec->attrs);
|
|
|
f92ce9 |
}
|
|
|
f92ce9 |
deref_values_free(&results, &actual_type_name, buffer_flags);
|
|
|
f92ce9 |
}
|
|
|
f92ce9 |
|
|
|
f92ce9 |
ber_printf(ctrlber, "}"); /* end control val */
|
|
|
f92ce9 |
|
|
|
f92ce9 |
- if (needcontrol) {
|
|
|
f92ce9 |
- slapi_build_control(LDAP_CONTROL_X_DEREF, ctrlber, 0, &ctrl);
|
|
|
f92ce9 |
- /* get the list of controls */
|
|
|
f92ce9 |
- slapi_pblock_get(pb, SLAPI_SEARCH_CTRLS, &searchctrls);
|
|
|
f92ce9 |
- /* dup them */
|
|
|
f92ce9 |
- slapi_add_controls(&newsearchctrls, (LDAPControl **)searchctrls, 1);
|
|
|
f92ce9 |
- /* add our control */
|
|
|
f92ce9 |
- slapi_add_control_ext(&newsearchctrls, ctrl, 0);
|
|
|
f92ce9 |
- ctrl = NULL; /* newsearchctrls owns it now */
|
|
|
f92ce9 |
- /* set the controls in the pblock */
|
|
|
f92ce9 |
- slapi_pblock_set(pb, SLAPI_SEARCH_CTRLS, newsearchctrls);
|
|
|
f92ce9 |
- }
|
|
|
f92ce9 |
+ slapi_build_control(LDAP_CONTROL_X_DEREF, ctrlber, 0, &ctrl);
|
|
|
f92ce9 |
+ /* get the list of controls */
|
|
|
f92ce9 |
+ slapi_pblock_get(pb, SLAPI_SEARCH_CTRLS, &searchctrls);
|
|
|
f92ce9 |
+ /* dup them */
|
|
|
f92ce9 |
+ slapi_add_controls(&newsearchctrls, (LDAPControl **)searchctrls, 1);
|
|
|
f92ce9 |
+ /* add our control */
|
|
|
f92ce9 |
+ slapi_add_control_ext(&newsearchctrls, ctrl, 0);
|
|
|
f92ce9 |
+ ctrl = NULL; /* newsearchctrls owns it now */
|
|
|
f92ce9 |
+ /* set the controls in the pblock */
|
|
|
f92ce9 |
+ slapi_pblock_set(pb, SLAPI_SEARCH_CTRLS, newsearchctrls);
|
|
|
f92ce9 |
ber_free(ctrlber, 1);
|
|
|
f92ce9 |
|
|
|
f92ce9 |
return 0;
|
|
|
f92ce9 |
--
|
|
|
f92ce9 |
1.9.3
|
|
|
f92ce9 |
|