diff options
author | Mark Michelson <mmichelson@digium.com> | 2015-04-28 17:00:37 -0500 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2015-04-30 10:43:51 -0500 |
commit | 11ffcf662f6b19eb0e9d5f8914d379ebef0177c4 (patch) | |
tree | a2727599061f560cce4900094e4854364c9c7add /channels/chan_mgcp.c | |
parent | 57cbb4bc8dda4cf4939f029e60290e3335a82c05 (diff) |
Restrict functionality when ACLs are misconfigured.
This patch has two main purposes:
1) Improve warning messages when ACLs are configured improperly.
2) Prevent misconfigured ACLs from allowing potentially unwanted
traffic.
To acomplish point (2) in most cases, whatever configuration object that
the ACL belonged to was not allowed to load.
The one exception is res_pjsip_acl. In that case, ACLs are their own
configuration object. Furthermore, the module loading code has no
indication that a ACL configuration had a failure. So the tactic taken
here is to create an ACL that just blocks everything.
ASTERISK-24969
Reported by Corey Farrell
Change-Id: I2ebcb6959cefad03cea4d81401be946203fcacae
Diffstat (limited to 'channels/chan_mgcp.c')
-rw-r--r-- | channels/chan_mgcp.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 602d38d01..37935be4b 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -4104,7 +4104,19 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v) ast_sockaddr_to_sin(&tmp, &gw->defaddr); } else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny")) { - gw->ha = ast_append_ha(v->name, v->value, gw->ha, NULL); + int acl_error = 0; + gw->ha = ast_append_ha(v->name, v->value, gw->ha, &acl_error); + if (acl_error) { + ast_log(LOG_ERROR, "Invalid ACL '%s' specified for MGCP gateway '%s' on line %d. Not creating.\n", + v->value, cat, v->lineno); + if (!gw_reload) { + ast_mutex_destroy(&gw->msgs_lock); + ast_free(gw); + } else { + gw->delme = 1; + } + return NULL; + } } else if (!strcasecmp(v->name, "port")) { gw->addr.sin_port = htons(atoi(v->value)); } else if (!strcasecmp(v->name, "context")) { |