summaryrefslogtreecommitdiff
path: root/lib/audit_logging
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2018-12-13 13:53:08 +1300
committerAndrew Bartlett <abartlet@samba.org>2018-12-14 10:27:18 +0100
commitedab1318f9138c0d87de7cc7cfa5da8e29c906f8 (patch)
treefebf6c3cb40f389129c168b92e1355cc9ef06b85 /lib/audit_logging
parentf183fd328314d90a92659720adebf034917962ec (diff)
downloadsamba-edab1318f9138c0d87de7cc7cfa5da8e29c906f8.tar.gz
audit_logging: Remove debug log header and JSON Authentication: prefix
Feedback from real-world users is that they really want raw JSON strings in the log. We can not easily remove the leading " " but the other strings above and before the JSON are really annoying to strip back off BUG: https://bugzilla.samba.org/show_bug.cgi?id=13714 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Diffstat (limited to 'lib/audit_logging')
-rw-r--r--lib/audit_logging/audit_logging.c19
-rw-r--r--lib/audit_logging/audit_logging.h3
2 files changed, 13 insertions, 9 deletions
diff --git a/lib/audit_logging/audit_logging.c b/lib/audit_logging/audit_logging.c
index acccb9f7ab9..644f72e09e1 100644
--- a/lib/audit_logging/audit_logging.c
+++ b/lib/audit_logging/audit_logging.c
@@ -105,13 +105,11 @@ const struct json_object json_empty_object = {.valid = false, .root = NULL};
*
* Write the json object to the audit logs as a formatted string
*
- * @param prefix Text to be printed at the start of the log line
* @param message The content of the log line.
* @param debub_class The debug class to log the message with.
* @param debug_level The debug level to log the message with.
*/
-void audit_log_json(const char* prefix,
- struct json_object* message,
+void audit_log_json(struct json_object* message,
int debug_class,
int debug_level)
{
@@ -126,13 +124,20 @@ void audit_log_json(const char* prefix,
ctx = talloc_new(NULL);
s = json_to_string(ctx, message);
if (s == NULL) {
- DBG_ERR("json_to_string for (%s) returned NULL, "
- "JSON audit message could not written\n",
- prefix);
+ DBG_ERR("json_to_string returned NULL, "
+ "JSON audit message could not written\n");
TALLOC_FREE(ctx);
return;
}
- DEBUGC(debug_class, debug_level, ("JSON %s: %s\n", prefix, s));
+ /*
+ * This is very strange, but we call this routine to get a log
+ * output without the header. JSON logs all have timestamps
+ * so this only makes parsing harder.
+ *
+ * We push out the raw JSON blob without a prefix, consumers
+ * can find such lines by the leading {
+ */
+ DEBUGADDC(debug_class, debug_level, ("%s\n", s));
TALLOC_FREE(ctx);
}
diff --git a/lib/audit_logging/audit_logging.h b/lib/audit_logging/audit_logging.h
index 5f095c0df9a..86e9134a86a 100644
--- a/lib/audit_logging/audit_logging.h
+++ b/lib/audit_logging/audit_logging.h
@@ -43,8 +43,7 @@ extern const struct json_object json_empty_object;
#define JSON_ERROR -1
-void audit_log_json(const char *prefix,
- struct json_object *message,
+void audit_log_json(struct json_object *message,
int debug_class,
int debug_level);
void audit_message_send(struct imessaging_context *msg_ctx,