|
|
|
@ -1918,42 +1918,41 @@ static int process_message(struct mansession *s, struct message *m)
|
|
|
|
|
astman_send_error(s, m, "Missing action in request");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if (!ast_strlen_zero(id)) {
|
|
|
|
|
if (!ast_strlen_zero(id))
|
|
|
|
|
snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
|
|
|
|
|
}
|
|
|
|
|
if (!strcasecmp(action, "Challenge")) {
|
|
|
|
|
char *authtype = astman_get_header(m, "AuthType");
|
|
|
|
|
|
|
|
|
|
if (!strcasecmp(authtype, "MD5")) {
|
|
|
|
|
if (ast_strlen_zero(s->challenge))
|
|
|
|
|
snprintf(s->challenge, sizeof(s->challenge), "%ld", ast_random());
|
|
|
|
|
ast_mutex_lock(&s->__lock);
|
|
|
|
|
astman_append(s, "Response: Success\r\n"
|
|
|
|
|
"%s"
|
|
|
|
|
"Challenge: %s\r\n\r\n",
|
|
|
|
|
idText, s->challenge);
|
|
|
|
|
ast_mutex_unlock(&s->__lock);
|
|
|
|
|
} else {
|
|
|
|
|
astman_send_error(s, m, "Must specify AuthType");
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
} else if (!strcasecmp(action, "Login")) {
|
|
|
|
|
if (authenticate(s, m)) {
|
|
|
|
|
sleep(1);
|
|
|
|
|
astman_send_error(s, m, "Authentication failed");
|
|
|
|
|
return -1;
|
|
|
|
|
} else {
|
|
|
|
|
s->authenticated = 1;
|
|
|
|
|
if (option_verbose > 1) {
|
|
|
|
|
if (displayconnects) {
|
|
|
|
|
ast_verbose(VERBOSE_PREFIX_2 "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ast_log(LOG_EVENT, "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
|
|
|
|
|
astman_send_ack(s, m, "Authentication accepted");
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (!strcasecmp(action, "Challenge")) {
|
|
|
|
|
char *authtype = astman_get_header(m, "AuthType");
|
|
|
|
|
|
|
|
|
|
if (!strcasecmp(authtype, "MD5")) {
|
|
|
|
|
if (ast_strlen_zero(s->challenge))
|
|
|
|
|
snprintf(s->challenge, sizeof(s->challenge), "%ld", ast_random());
|
|
|
|
|
ast_mutex_lock(&s->__lock);
|
|
|
|
|
astman_append(s, "Response: Success\r\n"
|
|
|
|
|
"%s"
|
|
|
|
|
"Challenge: %s\r\n\r\n",
|
|
|
|
|
idText, s->challenge);
|
|
|
|
|
ast_mutex_unlock(&s->__lock);
|
|
|
|
|
} else {
|
|
|
|
|
astman_send_error(s, m, "Must specify AuthType");
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
} else if (!strcasecmp(action, "Login")) {
|
|
|
|
|
if (authenticate(s, m)) {
|
|
|
|
|
sleep(1);
|
|
|
|
|
astman_send_error(s, m, "Authentication failed");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
s->authenticated = 1;
|
|
|
|
|
if (option_verbose > 1) {
|
|
|
|
|
if (displayconnects) {
|
|
|
|
|
ast_verbose(VERBOSE_PREFIX_2 "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ast_log(LOG_EVENT, "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
|
|
|
|
|
astman_send_ack(s, m, "Authentication accepted");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
struct manager_action *tmp;
|
|
|
|
|
ast_mutex_lock(&s->__lock);
|
|
|
|
|