sort: enable custom behaviour on critical control
authorGarming Sam <garming@catalyst.net.nz>
Thu, 10 Mar 2016 02:25:44 +0000 (15:25 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 22 Mar 2016 07:00:31 +0000 (08:00 +0100)
The sort module should simply return unsorted results when a sort is
unsupported but not critical. A similar custom behaviour should be
expected with VLV pagination when it is enabled.

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/modules/sort.c
source4/dsdb/samdb/ldb_modules/rootdse.c

index 19cf60b776b0bfc026e4a026a0eef0dec4c69167..cb6f8df440f2ec07557277d182129cfab47f1ec1 100644 (file)
@@ -309,6 +309,8 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
                }
        }
 
+       control->critical = 0;
+
        /* We are asked to sort on an attribute, and if that attribute is not
           already in the search attributes we need to add it (and later
           remove it on the return journey).
index ff134584644f6801e382f018e82dde34df31ba99..6a1b8ef944fcf5a3ed4f8f7c2c5e44d37165b72a 100644 (file)
@@ -701,11 +701,20 @@ static int rootdse_filter_controls(struct ldb_module *module, struct ldb_request
                        continue;
                }
 
-               /* If the control is DIRSYNC control then we keep the critical
-                * flag as the dirsync module will need to act upon it
+               /*
+                * If the control is DIRSYNC, SORT or VLV then we keep the
+                * critical flag as the modules will need to act upon it.
+                *
+                * These modules have to unset the critical flag after the
+                * request has been seen by the correct module.
                 */
-               if (is_registered && strcmp(req->controls[i]->oid,
-                                       LDB_CONTROL_DIRSYNC_OID)!= 0) {
+               if (is_registered &&
+                   strcmp(req->controls[i]->oid,
+                          LDB_CONTROL_DIRSYNC_OID) != 0 &&
+                   strcmp(req->controls[i]->oid,
+                          LDB_CONTROL_VLV_REQ_OID) != 0 &&
+                   strcmp(req->controls[i]->oid,
+                          LDB_CONTROL_SERVER_SORT_OID) != 0) {
                        req->controls[i]->critical = 0;
                }
        }