From: Kevin Harwell Date: Tue, 9 Jul 2019 19:42:51 +0000 (-0500) Subject: manager: Log AMI actions X-Git-Tag: 13.29.0-rc1~44^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2eaba485382d860ee55094c6007d8786e0623d6;p=thirdparty%2Fasterisk.git 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 --- diff --git a/main/manager.c b/main/manager.c index 0cd9ed52cf..0efb030fde 100644 --- a/main/manager.c +++ b/main/manager.c @@ -6408,6 +6408,32 @@ static int manager_moduleload(struct mansession *s, const struct message *m) 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: \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. @@ -6438,6 +6464,8 @@ static int process_message(struct mansession *s, const struct message *m) 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);