From: Andrew Bartlett Date: Wed, 6 Sep 2017 04:24:35 +0000 (+1200) Subject: repl_meta_data: Show failing replicated entry in error code X-Git-Tag: ldb-1.3.0~234 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;ds=sidebyside;h=24600e8e911cd8bec678282a29a7c5a8aefb9879;p=samba.git repl_meta_data: Show failing replicated entry in error code This re-work of our LDIF printing avoids some of the privacy issue from printing the full LDIF at level 4, while showing the entry that actually fails. Instead, with e3988f8f74f4a11e8f26a548e0a33d20f4e863f7 we now print the DN only at level 4, then the full message at 8. With this patch on failure, we print the redacted failing message at 5. While all of the DRS replication data is potentially sensitive the passwords are most sensitive, and are now not printed unencrypted. This discourages users from sending the full failing trace, as the last entry is much more likely the issue. Signed-off-by: Andrew Bartlett Reviewed-by: Garming Sam --- diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 8f123de7dbe..d2c2084acb1 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -563,9 +563,41 @@ static int replmd_op_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->error != LDB_SUCCESS) { - DEBUG(5,("%s failure. Error is: %s\n", __FUNCTION__, ldb_strerror(ares->error))); + struct GUID_txt_buf guid_txt; + struct ldb_message *msg = NULL; + char *s = NULL; + + if (ac->apply_mode == false) { + DBG_NOTICE("Originating update failure. Error is: %s\n", + ldb_strerror(ares->error)); + return ldb_module_done(ac->req, controls, + ares->response, ares->error); + } + + msg = ac->objs->objects[ac->index_current].msg; + /* + * Set at DBG_NOTICE as once these start to happe, they + * will happen a lot until resolved, due to repeated + * replication. The caller will probably print the + * ldb error string anyway. + */ + DBG_NOTICE("DRS replication apply failure for %s. Error is: %s\n", + ldb_dn_get_linearized(msg->dn), + ldb_strerror(ares->error)); + + s = ldb_ldif_message_redacted_string(ldb_module_get_ctx(ac->module), + ac, + LDB_CHANGETYPE_ADD, + msg); + + DBG_INFO("Failing DRS %s replication message was %s:\n%s\n", + ac->search_msg == NULL ? "ADD" : "MODIFY", + GUID_buf_string(&ac->objs->objects[ac->index_current].object_guid, + &guid_txt), + s); + talloc_free(s); return ldb_module_done(ac->req, controls, - ares->response, ares->error); + ares->response, ares->error); } if (ares->type != LDB_REPLY_DONE) {