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

Joshua Colp asteriskteam at digium.com
Fri Jul 19 07:42:07 CDT 2019


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11540 )

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
  Joshua Colp: Approved for Submit



diff --git a/main/manager.c b/main/manager.c
index b5388c2..69cbe37 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -6439,6 +6439,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.
@@ -6469,6 +6495,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/+/11540
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I8047524510e7ac97d99482b2448f8e368f29cd47
Gerrit-Change-Number: 11540
Gerrit-PatchSet: 5
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-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190719/3d108436/attachment-0001.html>


More information about the asterisk-code-review mailing list