ldb: support raw OIDs in control string parsing
authorAndrew Tridgell <tridge@samba.org>
Thu, 6 Oct 2011 03:19:24 +0000 (14:19 +1100)
committerAndrew Tridgell <tridge@samba.org>
Thu, 6 Oct 2011 03:34:21 +0000 (14:34 +1100)
this makes it possible to use a raw OID string on the command line or
in python scripts

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

lib/ldb/common/ldb_controls.c
lib/ldb/include/ldb_private.h

index d7a3143932de516a662fa79c3be804c09e4c7ab1..42fabfc1856f4f043b45c064a72979f9daf1fa09 100644 (file)
@@ -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;
 }
 
index cafc020e29137dcd9907256315a02b077ec0126c..db2457d6df027c99890b70ecd1eaab9035d2d311 100644 (file)
@@ -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"