Pārlūkot izejas kodu

Ticket #47664 - Page control does not work if effective rights control is specified

Bug Description: If an effective rights control and a simple paged
results control were specified in one search request, the simple
paged results control was ignored.

Fix Description: In the search iteration code, handling the simple
paged results was not fully implemented.  This patch adds it.

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

Reviewed by [email protected] (Thank you, Mark!!)
Noriko Hosoi 11 gadi atpakaļ
vecāks
revīzija
f646bd326a
1 mainītis faili ar 22 papildinājumiem un 11 dzēšanām
  1. 22 11
      ldap/servers/slapd/opshared.c

+ 22 - 11
ldap/servers/slapd/opshared.c

@@ -1302,16 +1302,26 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result,
         slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_ENTRY, &e);
 
         /* Check for possible get_effective_rights control */
-        if ( operation->o_flags & OP_FLAG_GET_EFFECTIVE_RIGHTS )
-        {
+        if (e) {
+          if (operation->o_flags & OP_FLAG_GET_EFFECTIVE_RIGHTS) {
             char *errbuf = NULL;
             char **gerattrs = NULL;
             char **gerattrsdup = NULL;
             char **gap = NULL;
             char *gapnext = NULL;
 
-            slapi_pblock_get( pb, SLAPI_SEARCH_GERATTRS, &gerattrs );
+            if (PAGEDRESULTS_PAGE_END == pr_stat)
+            {
+                /* 
+                 * read ahead -- there is at least more entry.
+                 * undo it and return the PAGE_END
+                 */
+                be->be_prev_search_results(pb);
+                done = 1;
+                continue;
+            }
 
+            slapi_pblock_get( pb, SLAPI_SEARCH_GERATTRS, &gerattrs );
             gerattrsdup = cool_charray_dup(gerattrs);
             gap = gerattrsdup;
             do
@@ -1414,15 +1424,15 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result,
             while (gap && ++gap && *gap);
             slapi_pblock_set( pb, SLAPI_SEARCH_GERATTRS, gerattrs );
             cool_charray_free(gerattrsdup);
-            if (NULL == e)
-            {
-                /* no more entries */
-                done = 1;
-                pr_stat = PAGEDRESULTS_SEARCH_END;
+            if (pagesize == *pnentries)
+            { 
+                /* PAGED RESULTS: reached the pagesize */
+                /* We don't set "done = 1" here.
+                 * We read ahead next entry to check whether there is
+                 * more entries to return or not. */
+                pr_stat = PAGEDRESULTS_PAGE_END;
             }
-        }
-        else if (e)
-        {
+          } else { /* not GET_EFFECTIVE_RIGHTS */
             if (PAGEDRESULTS_PAGE_END == pr_stat)
             {
                 /* 
@@ -1469,6 +1479,7 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result,
                  * more entries to return or not. */
                 pr_stat = PAGEDRESULTS_PAGE_END;
             }
+          }
         }
         else
         {