From: Volker Lendecke Date: Wed, 14 Apr 2021 14:30:16 +0000 (+0200) Subject: dsdb: Slightly tune get_new_descriptor() X-Git-Tag: tevent-0.11.0~1086 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a20c4b183d71b6e965221b59704c57df36ab8b1a;p=thirdparty%2Fsamba.git dsdb: Slightly tune get_new_descriptor() DBG_DEBUG only calls its arguments if required according to the debug level. A simple talloc_new/TALLOC_FREE in the normal case should be much cheaper than the full sddl_encode(). I just stumbled across this code, this is has not shown up in any profiles. I just think it's cleaner this way. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source4/dsdb/samdb/ldb_modules/descriptor.c b/source4/dsdb/samdb/ldb_modules/descriptor.c index daa08c2ebc7..8a4c2c3591f 100644 --- a/source4/dsdb/samdb/ldb_modules/descriptor.c +++ b/source4/dsdb/samdb/ldb_modules/descriptor.c @@ -257,7 +257,6 @@ static DATA_BLOB *get_new_descriptor(struct ldb_module *module, struct auth_session_info *session_info = ldb_get_opaque(ldb, DSDB_SESSION_INFO); const struct dom_sid *domain_sid = samdb_domain_sid(ldb); - char *sddl_sd; struct dom_sid *default_owner; struct dom_sid *default_group; struct security_descriptor *default_descriptor = NULL; @@ -414,8 +413,13 @@ static DATA_BLOB *get_new_descriptor(struct ldb_module *module, final_sd->sacl->revision = SECURITY_ACL_REVISION_ADS; } - sddl_sd = sddl_encode(mem_ctx, final_sd, domain_sid); - DEBUG(10, ("Object %s created with descriptor %s\n\n", ldb_dn_get_linearized(dn), sddl_sd)); + { + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); + DBG_DEBUG("Object %s created with descriptor %s\n\n", + ldb_dn_get_linearized(dn), + sddl_encode(tmp_ctx, final_sd, domain_sid)); + TALLOC_FREE(tmp_ctx); + } linear_sd = talloc(mem_ctx, DATA_BLOB); if (!linear_sd) {