diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-09-08 21:55:56 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2009-09-08 21:56:31 +1000 |
commit | a8e8a3161164ec469d65d7489d2f71fdc288a131 (patch) | |
tree | 49eea1a5686a0eadd161d6d6e46cc660682401e1 /source4 | |
parent | 6d1d33319ced87c9741983302cf42a4841d688de (diff) | |
download | samba-a8e8a3161164ec469d65d7489d2f71fdc288a131.tar.gz samba-a8e8a3161164ec469d65d7489d2f71fdc288a131.tar.bz2 samba-a8e8a3161164ec469d65d7489d2f71fdc288a131.zip |
s4/ldb: allow printing ntSecurityDescriptor in full
print security descriptors in NDR format if --show-binary is
given. This is easier to read than sddl format.
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/ldb-samba/ldif_handlers.c | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/source4/lib/ldb-samba/ldif_handlers.c b/source4/lib/ldb-samba/ldif_handlers.c index 60b6ccd101..6927576ca6 100644 --- a/source4/lib/ldb-samba/ldif_handlers.c +++ b/source4/lib/ldb-samba/ldif_handlers.c @@ -35,6 +35,37 @@ #include "param/param.h" /* + use ndr_print_* to convert a NDR formatted blob to a ldif formatted blob +*/ +static int ldif_write_NDR(struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *in, struct ldb_val *out, + size_t struct_size, + ndr_pull_flags_fn_t pull_fn, + ndr_print_fn_t print_fn) +{ + uint8_t *p; + enum ndr_err_code err; + if (!(ldb_get_flags(ldb) & LDB_FLG_SHOW_BINARY)) { + return ldb_handler_copy(ldb, mem_ctx, in, out); + } + p = talloc_size(mem_ctx, struct_size); + err = ndr_pull_struct_blob(in, mem_ctx, + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), + p, pull_fn); + if (err != NDR_ERR_SUCCESS) { + talloc_free(p); + return ldb_handler_copy(ldb, mem_ctx, in, out); + } + out->data = (uint8_t *)ndr_print_struct_string(mem_ctx, print_fn, "NDR", p); + talloc_free(p); + if (out->data == NULL) { + return ldb_handler_copy(ldb, mem_ctx, in, out); + } + out->length = strlen((char *)out->data); + return 0; +} + +/* convert a ldif formatted objectSid to a NDR formatted blob */ static int ldif_read_objectSid(struct ldb_context *ldb, void *mem_ctx, @@ -315,7 +346,6 @@ static int ldif_read_ntSecurityDescriptor(struct ldb_context *ldb, void *mem_ctx const struct ldb_val *in, struct ldb_val *out) { struct security_descriptor *sd; - enum ndr_err_code ndr_err; sd = talloc(mem_ctx, struct security_descriptor); @@ -355,6 +385,14 @@ static int ldif_write_ntSecurityDescriptor(struct ldb_context *ldb, void *mem_ct struct security_descriptor *sd; enum ndr_err_code ndr_err; + if (ldb_get_flags(ldb) & LDB_FLG_SHOW_BINARY) { + return ldif_write_NDR(ldb, mem_ctx, in, out, + sizeof(struct security_descriptor), + (ndr_pull_flags_fn_t)ndr_pull_security_descriptor, + (ndr_print_fn_t)ndr_print_security_descriptor); + + } + sd = talloc(mem_ctx, struct security_descriptor); if (sd == NULL) { return -1; @@ -675,38 +713,6 @@ static int ldif_comparison_int32(struct ldb_context *ldb, void *mem_ctx, } /* - use ndr_print_* to convert a NDR formatted blob to a ldif formatted blob -*/ -static int ldif_write_NDR(struct ldb_context *ldb, void *mem_ctx, - const struct ldb_val *in, struct ldb_val *out, - size_t struct_size, - ndr_pull_flags_fn_t pull_fn, - ndr_print_fn_t print_fn) -{ - uint8_t *p; - enum ndr_err_code err; - if (!(ldb_get_flags(ldb) & LDB_FLG_SHOW_BINARY)) { - return ldb_handler_copy(ldb, mem_ctx, in, out); - } - p = talloc_size(mem_ctx, struct_size); - err = ndr_pull_struct_blob(in, mem_ctx, - lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), - p, pull_fn); - if (err != NDR_ERR_SUCCESS) { - talloc_free(p); - return ldb_handler_copy(ldb, mem_ctx, in, out); - } - out->data = (uint8_t *)ndr_print_struct_string(mem_ctx, print_fn, "NDR", p); - talloc_free(p); - if (out->data == NULL) { - return ldb_handler_copy(ldb, mem_ctx, in, out); - } - out->length = strlen((char *)out->data); - return 0; -} - - -/* convert a NDR formatted blob to a ldif formatted repsFromTo */ static int ldif_write_repsFromTo(struct ldb_context *ldb, void *mem_ctx, |