]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Add an option to restore past broken behavor of the Events manager action
authorMatthew Nicholson <mnicholson@digium.com>
Tue, 13 Apr 2010 16:46:30 +0000 (16:46 +0000)
committerMatthew Nicholson <mnicholson@digium.com>
Tue, 13 Apr 2010 16:46:30 +0000 (16:46 +0000)
Before r238915, certain values for the EventMask parameter of the Events action would result in no response being returned.  This patch adds an option to restore that broken behavior.  Also while fixing this bug I discovered that passing an empty EventMasks parameter would also result in no response being returned, this has been fixed as well while being preserved when the broken behavior is requested.

(closes issue #17023)
Reported by: nblasgen

Review: https://reviewboard.asterisk.org/r/602/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@257070 65c4cc65-6c06-0410-ace0-fbb531ad65f3

configs/manager.conf.sample
main/manager.c

index 1f51b0d8c394ebf64038bafdce828329892c670f..176af1a829e57d7917738594556af682cb626d36 100644 (file)
@@ -40,6 +40,11 @@ bindaddr = 0.0.0.0
 ;
 ;timestampevents = yes
 
+;brokeneventsaction = yes   ; Restore previous behavior that caused the events
+                            ; action to not return a response in certain
+                            ; circumstances.  Defaults to 'no'.
+
+
 ;[mark]
 ;secret = mysecret
 ;deny=0.0.0.0/0.0.0.0
index f3d040f1b4c76ad71b263d5fc2c313e18bdf48f2..bf19199c08b98558ac448bd30df871e7c37aaefe 100644 (file)
@@ -103,6 +103,7 @@ static int asock = -1;
 static int displayconnects = 1;
 static int timestampevents;
 static int httptimeout = 60;
+static int broken_events_action = 0;
 
 static pthread_t t;
 static int block_sockets;
@@ -1432,13 +1433,31 @@ static char mandescr_events[] =
 static int action_events(struct mansession *s, const struct message *m)
 {
        const char *mask = astman_get_header(m, "EventMask");
-       int res;
+       int res, x;
 
        res = set_eventmask(s->session, mask);
+       if (broken_events_action) {
+               /* if this option is set we should not return a response on
+                * error, or when all events are set */
+
+               if (res > 0) {
+                       for (x = 0; x < ARRAY_LEN(perms); x++) {
+                               if (!strcasecmp(perms[x].label, "all") && res == perms[x].num) {
+                                       return 0;
+                               }
+                       }
+                       astman_send_response(s, m, "Events On", NULL);
+               } else if (res == 0)
+                       astman_send_response(s, m, "Events Off", NULL);
+               return 0;
+       }
+
        if (res > 0)
                astman_send_response(s, m, "Events On", NULL);
        else if (res == 0)
                astman_send_response(s, m, "Events Off", NULL);
+       else
+               astman_send_error(s, m, "Invalid event mask");
 
        return 0;
 }
@@ -3067,6 +3086,7 @@ int init_manager(void)
        }
        portno = DEFAULT_MANAGER_PORT;
        displayconnects = 1;
+       broken_events_action = 0;
        cfg = ast_config_load("manager.conf");
        if (!cfg) {
                ast_log(LOG_NOTICE, "Unable to open management configuration manager.conf.  Call management disabled.\n");
@@ -3094,6 +3114,9 @@ int init_manager(void)
        if ((val = ast_variable_retrieve(cfg, "general", "displayconnects")))
                displayconnects = ast_true(val);
 
+       if ((val = ast_variable_retrieve(cfg, "general", "brokeneventsaction")))
+               broken_events_action = ast_true(val);
+
        if ((val = ast_variable_retrieve(cfg, "general", "timestampevents")))
                timestampevents = ast_true(val);