s4-ldif: get rid of the ndr_pull_error message on startup
authorAndrew Tridgell <tridge@samba.org>
Sat, 2 Oct 2010 20:03:40 +0000 (13:03 -0700)
committerAndrew Tridgell <tridge@samba.org>
Sun, 3 Oct 2010 04:11:52 +0000 (21:11 -0700)
detect if the prefixmap blob is text or binary using the first 4 bytes

source4/lib/ldb-samba/ldif_handlers.c

index 1c366104c05286e8e2ba356b78e0b7b20baf25ce..324209b836ee382d51aa81f63ef5bd2bd5a034f5 100644 (file)
@@ -527,17 +527,22 @@ static int ldif_read_prefixMap(struct ldb_context *ldb, void *mem_ctx,
                return -1;
        }
 
-       ndr_err = ndr_pull_struct_blob(in, tmp_ctx, blob,
-                                      (ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
-       if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-               ndr_err = ndr_push_struct_blob(out, mem_ctx,
-                                              blob,
-                                              (ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
-               talloc_free(tmp_ctx);
-               if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-                       return -1;
+       /* use the switch value to detect if this is in the binary
+        * format
+        */
+       if (in->length >= 4 && IVAL(in->data, 0) == PREFIX_MAP_VERSION_DSDB) {
+               ndr_err = ndr_pull_struct_blob(in, tmp_ctx, blob,
+                                              (ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
+               if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+                       ndr_err = ndr_push_struct_blob(out, mem_ctx,
+                                                      blob,
+                                                      (ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
+                       talloc_free(tmp_ctx);
+                       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+                               return -1;
+                       }
+                       return 0;
                }
-               return 0;
        }
 
        /* If this does not parse, then it is probably the text version, and we should try it that way */