svn commit: samba r12231 - in
branches/tmp/samba4_ldap_controls/source/lib/ldb: common
include ldb_sqlite3 ldb_tdb
idra at samba.org
idra at samba.org
Wed Dec 14 12:30:08 GMT 2005
Author: idra
Date: 2005-12-14 12:30:07 +0000 (Wed, 14 Dec 2005)
New Revision: 12231
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12231
Log:
add a new function to check for srtical controls not handled
Modified:
branches/tmp/samba4_ldap_controls/source/lib/ldb/common/ldb_controls.c
branches/tmp/samba4_ldap_controls/source/lib/ldb/include/ldb_private.h
branches/tmp/samba4_ldap_controls/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
branches/tmp/samba4_ldap_controls/source/lib/ldb/ldb_tdb/ldb_tdb.c
Changeset:
Modified: branches/tmp/samba4_ldap_controls/source/lib/ldb/common/ldb_controls.c
===================================================================
--- branches/tmp/samba4_ldap_controls/source/lib/ldb/common/ldb_controls.c 2005-12-14 10:56:43 UTC (rev 12230)
+++ branches/tmp/samba4_ldap_controls/source/lib/ldb/common/ldb_controls.c 2005-12-14 12:30:07 UTC (rev 12231)
@@ -37,6 +37,8 @@
#include "ldb/include/ldb_errors.h"
#include "ldb/include/ldb_private.h"
+/* check if a control with the specified "oid" exist and return it */
+/* returns NULL if not found */
struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid)
{
int i;
@@ -55,6 +57,9 @@
return NULL;
}
+/* saves the current controls list into the "saver" and replace the one in req with a new one excluding
+the "exclude" control */
+/* returns False on error */
BOOL save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver)
{
struct ldb_control **lcs;
@@ -82,3 +87,22 @@
req->controls = lcs;
return True;
}
+
+/* check if there's any control marked as critical in the list */
+/* return True if any, False if none */
+BOOL check_critical_controls(struct ldb_control **controls)
+{
+ int i;
+
+ if (controls == NULL) {
+ return False;
+ }
+
+ for (i = 0; controls[i]; i++) {
+ if (controls[i]->critical) {
+ return True;
+ }
+ }
+
+ return False;
+}
Modified: branches/tmp/samba4_ldap_controls/source/lib/ldb/include/ldb_private.h
===================================================================
--- branches/tmp/samba4_ldap_controls/source/lib/ldb/include/ldb_private.h 2005-12-14 10:56:43 UTC (rev 12230)
+++ branches/tmp/samba4_ldap_controls/source/lib/ldb/include/ldb_private.h 2005-12-14 12:30:07 UTC (rev 12231)
@@ -185,5 +185,6 @@
struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid);
BOOL save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver);
+BOOL check_critical_controls(struct ldb_control **controls);
#endif
Modified: branches/tmp/samba4_ldap_controls/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
===================================================================
--- branches/tmp/samba4_ldap_controls/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c 2005-12-14 10:56:43 UTC (rev 12230)
+++ branches/tmp/samba4_ldap_controls/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c 2005-12-14 12:30:07 UTC (rev 12231)
@@ -1785,14 +1785,8 @@
static int lsqlite3_request(struct ldb_module *module, struct ldb_request *req)
{
/* check for oustanding critical controls and return an error if found */
-
- if (req->controls) {
- int i;
- for (i = 0; req->controls[i]; i++) {
- if (req->controls[i]->critical) {
- return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
- }
- }
+ if (check_critical_controls(req->controls)) {
+ return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
}
switch (req->operation) {
Modified: branches/tmp/samba4_ldap_controls/source/lib/ldb/ldb_tdb/ldb_tdb.c
===================================================================
--- branches/tmp/samba4_ldap_controls/source/lib/ldb/ldb_tdb/ldb_tdb.c 2005-12-14 10:56:43 UTC (rev 12230)
+++ branches/tmp/samba4_ldap_controls/source/lib/ldb/ldb_tdb/ldb_tdb.c 2005-12-14 12:30:07 UTC (rev 12231)
@@ -737,13 +737,8 @@
{
/* check for oustanding critical controls and return an error if found */
- if (req->controls) {
- int i;
- for (i = 0; req->controls[i] != NULL; i++) {
- if (req->controls[i]->critical) {
- return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
- }
- }
+ if (check_critical_controls(req->controls)) {
+ return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
}
switch (req->operation) {
More information about the samba-cvs
mailing list