[Asterisk-code-review] manager: Log AMI actions (...asterisk[16])

Friendly Automation asteriskteam at digium.com
Fri Jul 19 07:30:12 CDT 2019


Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11564 )

Change subject: manager: Log AMI actions
......................................................................

manager: Log AMI actions

When manager debugging is turned on, this patch makes it so incoming AMI actions
are now also logged.

Change-Id: I8047524510e7ac97d99482b2448f8e368f29cd47
---
M main/manager.c
1 file changed, 28 insertions(+), 0 deletions(-)

Approvals:
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/main/manager.c b/main/manager.c
index f9a991a..df2d638 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -6444,6 +6444,32 @@
 	return 0;
 }
 
+static void log_action(const struct message *m, const char *action)
+{
+	struct ast_str *buf;
+	int x;
+
+	if (!manager_debug) {
+		return;
+	}
+
+	buf = ast_str_create(256);
+	if (!buf) {
+		return;
+	}
+
+	for (x = 0; x < m->hdrcount; ++x) {
+		if (!strncasecmp(m->headers[x], "Secret", 6)) {
+			ast_str_append(&buf, 0, "Secret: <redacted from logging>\n");
+		} else {
+			ast_str_append(&buf, 0, "%s\n", m->headers[x]);
+		}
+	}
+
+	ast_verbose("<--- Examining AMI action: -->\n%s\n", ast_str_buffer(buf));
+	ast_free(buf);
+}
+
 /*
  * Done with the action handlers here, we start with the code in charge
  * of accepting connections and serving them.
@@ -6474,6 +6500,8 @@
 		return 0;
 	}
 
+	log_action(m, action);
+
 	if (ast_shutting_down()) {
 		ast_log(LOG_ERROR, "Unable to process manager action '%s'. Asterisk is shutting down.\n", action);
 		mansession_lock(s);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11564
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I8047524510e7ac97d99482b2448f8e368f29cd47
Gerrit-Change-Number: 11564
Gerrit-PatchSet: 3
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190719/d08d1d75/attachment.html>


More information about the asterisk-code-review mailing list