diff options
author | Matthew Jordan <mjordan@digium.com> | 2013-01-02 18:11:59 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2013-01-02 18:11:59 +0000 |
commit | 8fb5bdce9ab9f7f3758545753cbc787653920753 (patch) | |
tree | 65809194af8a4fa757fef26a30a2cc9c3ed02182 /channels/chan_agent.c | |
parent | 1fb06fde957fb466388c764384c2e14698e2dc15 (diff) |
Prevent exhaustion of system resources through exploitation of event cache
Asterisk maintains an internal cache for devices in the event subsystem. The
device state cache holds the state of each device known to Asterisk, such that
consumers of device state information can query for the last known state for
a particular device, even if it is not part of an active call. The concept of
a device in Asterisk can include entities that do not have a physical
representation. One way that this occurred was when anonymous calls are allowed
in Asterisk. A device was automatically created and stored in the cache for
each anonymous call that occurred; this was possible in the SIP and IAX2
channel drivers and through channel drivers that utilized the
res_jabber/res_xmpp resource modules (Gtalk, Jingle, and Motif). These devices
are never removed from the system, allowing anonymous calls to potentially
exhaust a system's resources.
This patch changes the event cache subsystem and device state management to
no longer cache devices that are not associated with a physical entity.
(issue ASTERISK-20175)
Reported by: Russell Bryant, Leif Madsen, Joshua Colp
Tested by: kmoore
patches:
event-cachability-3.diff uploaded by jcolp (license 5000)
........
Merged revisions 378303 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 378320 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 378321 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@378322 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_agent.c')
-rw-r--r-- | channels/chan_agent.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c index 42492f4a2..a9a70d01d 100644 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -618,7 +618,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast) if (p->chan) { ast_channel_internal_bridged_channel_set(p->chan, NULL); p->chan = NULL; - ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "Agent/%s", p->agent); + ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "Agent/%s", p->agent); p->acknowledged = 0; } } else { @@ -875,7 +875,7 @@ static int agent_call(struct ast_channel *ast, const char *dest, int timeout) } else { /* Agent hung-up */ p->chan = NULL; - ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "Agent/%s", p->agent); + ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "Agent/%s", p->agent); } if (!res) { @@ -995,7 +995,7 @@ static int agent_hangup(struct ast_channel *ast) if (!p->loginstart) { p->logincallerid[0] = '\0'; } else { - ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Agent/%s", p->agent); + ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Agent/%s", p->agent); } if (p->abouttograb) { @@ -2143,7 +2143,7 @@ static int login_exec(struct ast_channel *chan, const char *data) } ast_mutex_unlock(&p->lock); AST_LIST_UNLOCK(&agents); - ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Agent/%s", p->agent); + ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Agent/%s", p->agent); while (res >= 0) { ast_mutex_lock(&p->lock); if (p->deferlogoff && p->chan) { @@ -2164,7 +2164,7 @@ static int login_exec(struct ast_channel *chan, const char *data) if (ast_tvdiff_ms(ast_tvnow(), p->lastdisc) > 0) { ast_debug(1, "Wrapup time for %s expired!\n", p->agent); p->lastdisc = ast_tv(0, 0); - ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Agent/%s", p->agent); + ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Agent/%s", p->agent); if (p->ackcall) { check_beep(p, 0); } else { @@ -2235,7 +2235,7 @@ static int login_exec(struct ast_channel *chan, const char *data) ast_queue_log("NONE", ast_channel_uniqueid(chan), agent, "AGENTLOGOFF", "%s|%ld", ast_channel_name(chan), logintime); ast_verb(2, "Agent '%s' logged out\n", p->agent); /* If there is no owner, go ahead and kill it now */ - ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "Agent/%s", p->agent); + ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "Agent/%s", p->agent); if (p->dead && !p->owner) { ast_mutex_destroy(&p->lock); ast_cond_destroy(&p->app_complete_cond); |