diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-08-16 15:31:18 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-08-16 15:31:18 +0000 |
commit | c4b25be3efc9c553091a52f00d362a55e64c363b (patch) | |
tree | b90af6c36115564bddd0641185f856432366aa3f | |
parent | b7fbd14cece6a0345918a946fdba5bdc3268e539 (diff) |
Verify extension is correct
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1350 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-x | channels/chan_agent.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c index aeb867784..6128965bc 100755 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -983,12 +983,35 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode) if (!p->chan) { if (callbackmode) { char tmpchan[256] = ""; + int pos = 0; /* Retrieve login chan */ - if (exten) { - strncpy(tmpchan, exten, sizeof(tmpchan) - 1); - res = 0; - } else - res = ast_app_getdata(chan, "agent-newlocation", tmpchan, sizeof(tmpchan) - 1, 0); + for (;;) { + if (exten) { + strncpy(tmpchan, exten, sizeof(tmpchan) - 1); + res = 0; + } else + res = ast_app_getdata(chan, "agent-newlocation", tmpchan+pos, sizeof(tmpchan) - 2, 0); + if (!strlen(tmpchan) || ast_exists_extension(chan, context && strlen(context) ? context : "default", tmpchan, + 1, NULL)) + break; + if (exten) { + ast_log(LOG_WARNING, "Extension '%s' is not valid for automatic login of agent '%s'\n", exten, p->agent); + exten = NULL; + pos = 0; + } else { + res = ast_streamfile(chan, "invalid", chan->language); + if (!res) + res = ast_waitstream(chan, AST_DIGIT_ANY); + if (res > 0) { + tmpchan[0] = res; + tmpchan[1] = '\0'; + pos = 1; + } else { + tmpchan[0] = '\0'; + pos = 0; + } + } + } if (!res) { if (context && strlen(context) && strlen(tmpchan)) snprintf(p->loginchan, sizeof(p->loginchan), "%s@%s", tmpchan, context); |