mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 08:40:16 +00:00
Fix trunk version of manager support for users.conf. Now it actually pays
attention to the "hasmanager" option. (Thanks to Anthony L. for pointing out that this was broken!) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@51247 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -887,15 +887,8 @@ static int authenticate(struct mansession *s, const struct message *m)
|
|||||||
return -1;
|
return -1;
|
||||||
while ( (cat = ast_category_browse(cfg, cat)) ) {
|
while ( (cat = ast_category_browse(cfg, cat)) ) {
|
||||||
/* "general" is not a valid user */
|
/* "general" is not a valid user */
|
||||||
if (!strcasecmp(cat, user) && strcasecmp(cat, "general"))
|
if (strcasecmp(cat, user) || !strcasecmp(cat, "general"))
|
||||||
break;
|
continue;
|
||||||
}
|
|
||||||
if (!cat) {
|
|
||||||
ast_log(LOG_NOTICE, "%s tried to authenticate with nonexistent user '%s'\n", ast_inet_ntoa(s->sin.sin_addr), user);
|
|
||||||
ast_config_destroy(cfg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* collect parameters for the user's entry */
|
/* collect parameters for the user's entry */
|
||||||
for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
|
for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
|
||||||
if (!strcasecmp(v->name, "secret"))
|
if (!strcasecmp(v->name, "secret"))
|
||||||
@@ -916,11 +909,15 @@ static int authenticate(struct mansession *s, const struct message *m)
|
|||||||
s->writetimeout = val;
|
s->writetimeout = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ast_config_destroy(cfg);
|
ast_config_destroy(cfg);
|
||||||
|
if (!cat) {
|
||||||
|
/* Didn't find the user in manager.conf, check users.conf */
|
||||||
|
int hasmanager = 0;
|
||||||
cfg = ast_config_load("users.conf");
|
cfg = ast_config_load("users.conf");
|
||||||
if (!cfg)
|
if (!cfg)
|
||||||
return -1;
|
return -1;
|
||||||
cat = NULL;
|
|
||||||
while ( (cat = ast_category_browse(cfg, cat)) ) {
|
while ( (cat = ast_category_browse(cfg, cat)) ) {
|
||||||
if (!strcasecmp(cat, user) && strcasecmp(cat, "general"))
|
if (!strcasecmp(cat, user) && strcasecmp(cat, "general"))
|
||||||
break;
|
break;
|
||||||
@@ -948,9 +945,17 @@ static int authenticate(struct mansession *s, const struct message *m)
|
|||||||
ast_log(LOG_WARNING, "Invalid writetimeout value '%s' at line %d\n", v->value, v->lineno);
|
ast_log(LOG_WARNING, "Invalid writetimeout value '%s' at line %d\n", v->value, v->lineno);
|
||||||
else
|
else
|
||||||
s->writetimeout = val;
|
s->writetimeout = val;
|
||||||
|
} else if (!strcasecmp(v->name, "hasmanager")) {
|
||||||
|
hasmanager = ast_true(v->value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast_config_destroy(cfg);
|
ast_config_destroy(cfg);
|
||||||
|
if (!hasmanager) {
|
||||||
|
ast_log(LOG_NOTICE, "%s tried to authenticate with nonexistent user '%s'\n", ast_inet_ntoa(s->sin.sin_addr), user);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ha) {
|
if (ha) {
|
||||||
|
|||||||
Reference in New Issue
Block a user