From: Andrew Tridgell Date: Thu, 6 Oct 2011 03:19:24 +0000 (+1100) Subject: ldb: support raw OIDs in control string parsing X-Git-Tag: ldb-1.1.3~68 X-Git-Url: http://git.samba.org/samba.git/?p=nivanova%2Fsamba-autobuild%2F.git;a=commitdiff_plain;h=ea41860d32d38448e08cefd79d30ee1150317a9e ldb: support raw OIDs in control string parsing this makes it possible to use a raw OID string on the command line or in python scripts Pair-Programmed-With: Andrew Bartlett --- diff --git a/lib/ldb/common/ldb_controls.c b/lib/ldb/common/ldb_controls.c index d7a3143932d..42fabfc1856 100644 --- a/lib/ldb/common/ldb_controls.c +++ b/lib/ldb/common/ldb_controls.c @@ -1018,9 +1018,27 @@ struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLO return ctrl; } + + /* support a raw OID */ + if (isdigit(control_strings[0])) { + const char *p = strchr(control_strings, ':'); + if (p == NULL) { + goto failed; + } + if (strspn(control_strings, "0123456789.") != (p-control_strings)) { + goto failed; + } + ctrl->oid = talloc_strndup(ctrl, control_strings, p-control_strings); + ctrl->critical = (p[1]=='1'?1:0); + ctrl->data = NULL; + return ctrl; + } + /* * When no matching control has been found. */ +failed: + talloc_free(ctrl); return NULL; } diff --git a/lib/ldb/include/ldb_private.h b/lib/ldb/include/ldb_private.h index cafc020e291..db2457d6df0 100644 --- a/lib/ldb/include/ldb_private.h +++ b/lib/ldb/include/ldb_private.h @@ -40,6 +40,7 @@ #include "replace.h" #include "system/filesys.h" #include "system/time.h" +#include "system/locale.h" #include "ldb.h" #include "ldb_module.h"