diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-01-18 17:18:43 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-01-18 17:18:43 +0000 |
commit | 62c05f48bd7904a50d7f8c8c7c68d36e2395606c (patch) | |
tree | e542f2688de089d2c59e36ba7a48760265feaf50 /main/manager.c | |
parent | 3dd9cfc45091433d65daa6e63aa4764669ea5fdd (diff) |
Make the "hasmanager" option in users.conf actually have an effect.
(issue #8740, LnxPrgr3)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@51233 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/manager.c')
-rw-r--r-- | main/manager.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/main/manager.c b/main/manager.c index 79ca6e942..e319962a6 100644 --- a/main/manager.c +++ b/main/manager.c @@ -958,6 +958,40 @@ static int authenticate(struct mansession *s, const struct message *m) set_eventmask(s, events); return 0; } + ast_config_destroy(cfg); + cfg = ast_config_load("users.conf"); + if (!cfg) + return -1; + cat = ast_category_browse(cfg, NULL); + while (cat) { + struct ast_variable *v; + const char *password = NULL; + int hasmanager = 0; + if (strcasecmp(cat, user) || !strcasecmp(cat, "general")) { + cat = ast_category_browse(cfg, cat); + continue; + } + for (v = ast_variable_browse(cfg, cat); v; v = v->next) { + if (!strcasecmp(v->name, "secret")) + password = v->value; + else if (!strcasecmp(v->name, "hasmanager")) + hasmanager = ast_true(v->value); + } + if (!hasmanager) + break; + if (!password || strcmp(password, pass)) { + ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", ast_inet_ntoa(s->sin.sin_addr), user); + ast_config_destroy(cfg); + return -1; + } + ast_copy_string(s->username, cat, sizeof(s->username)); + s->readperm = -1; + s->writeperm = -1; + ast_config_destroy(cfg); + if (events) + set_eventmask(s, events); + return 0; + } 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; |