/*
see if a buffer should be base64 encoded
*/
-int ldb_should_b64_encode(const struct ldb_val *val)
+int ldb_should_b64_encode(struct ldb_context *ldb, const struct ldb_val *val)
{
unsigned int i;
uint8_t *p = val->data;
+ if (ldb->flags & LDB_FLG_SHOW_BINARY) {
+ return 0;
+ }
+
if (val->length == 0) {
return 0;
}
if (ret != LDB_SUCCESS) {
v = msg->elements[i].values[j];
}
- if (ret != LDB_SUCCESS || ldb_should_b64_encode(&v)) {
+ if (ret != LDB_SUCCESS || ldb_should_b64_encode(ldb, &v)) {
ret = fprintf_fn(private_data, "%s:: ",
msg->elements[i].name);
CHECK_RET;
*/
#define LDB_FLG_NOMMAP 8
+/**
+ Flag to tell ldif handlers not to force encoding of binary
+ structures in base64
+*/
+#define LDB_FLG_SHOW_BINARY 16
+
/*
structures for ldb_parse_tree handling code
*/
int check_critical_controls(struct ldb_control **controls);
/* The following definitions come from lib/ldb/common/ldb_ldif.c */
-int ldb_should_b64_encode(const struct ldb_val *val);
+int ldb_should_b64_encode(struct ldb_context *ldb, const struct ldb_val *val);
/* The following definitions come from lib/ldb/common/ldb_match.c */
int ldb_match_msg(struct ldb_context *ldb,
talloc_free(attr_folded);
return NULL;
}
- if (ldb_should_b64_encode(&v)) {
+ if (ldb_should_b64_encode(ldb, &v)) {
char *vstr = ldb_base64_encode(ldb, (char *)v.data, v.length);
if (!vstr) return NULL;
ret = ldb_dn_new_fmt(ldb, ldb, "%s:%s::%s", LTDB_INDEX, attr_folded, vstr);
{ "output", 'O', POPT_ARG_STRING, &options.output, 0, "Output File", "Output" },
{ NULL, 'o', POPT_ARG_STRING, NULL, 'o', "ldb_connect option", "OPTION" },
{ "controls", 0, POPT_ARG_STRING, NULL, 'c', "controls", NULL },
+ { "show-binary", 0, POPT_ARG_NONE, &options.show_binary, 0, "display binary LDIF", NULL },
#if (_SAMBA_BUILD_ >= 4)
POPT_COMMON_SAMBA
POPT_COMMON_CREDENTIALS
flags |= LDB_FLG_NOSYNC;
}
+ if (options.show_binary) {
+ flags |= LDB_FLG_SHOW_BINARY;
+ }
+
#if (_SAMBA_BUILD_ >= 4)
/* Must be after we have processed command line options */
gensec_init(cmdline_lp_ctx);
const char *input;
const char *output;
char **controls;
+ int show_binary;
};
struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const char **argv,