When listing the manager users, managers in users.conf are not shown, even

though they are allowed to connect.
(closes issue #12594)
 Reported by: bkruse
 Patches: 
       12594-managerusers-2.diff uploaded by qwell (license 4)
 Tested by: bkruse


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@120061 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2008-06-03 18:23:32 +00:00
parent 088ac37bfc
commit 98b11ad0ee

View File

@@ -2877,7 +2877,7 @@ static int webregged = 0;
int init_manager(void)
{
struct ast_config *cfg = NULL;
struct ast_config *cfg = NULL, *ucfg = NULL;
const char *val;
char *cat = NULL;
int oldportno = portno;
@@ -2975,6 +2975,71 @@ int init_manager(void)
AST_LIST_LOCK(&users);
if ((ucfg = ast_config_load("users.conf"))) {
while ((cat = ast_category_browse(ucfg, cat))) {
int hasmanager = 0;
struct ast_variable *var = NULL;
if (!strcasecmp(cat, "general")) {
continue;
}
if (!(hasmanager = ast_true(ast_variable_retrieve(ucfg, cat, "hasmanager")))) {
continue;
}
/* Look for an existing entry, if none found - create one and add it to the list */
if (!(user = ast_get_manager_by_name_locked(cat))) {
if (!(user = ast_calloc(1, sizeof(*user)))) {
break;
}
/* Copy name over */
ast_copy_string(user->username, cat, sizeof(user->username));
/* Insert into list */
AST_LIST_INSERT_TAIL(&users, user, list);
}
/* Make sure we keep this user and don't destroy it during cleanup */
user->keep = 1;
for (var = ast_variable_browse(ucfg, cat); var; var = var->next) {
if (!strcasecmp(var->name, "secret")) {
if (user->secret) {
free(user->secret);
}
user->secret = ast_strdup(var->value);
} else if (!strcasecmp(var->name, "deny") ) {
if (user->deny) {
free(user->deny);
}
user->deny = ast_strdup(var->value);
} else if (!strcasecmp(var->name, "permit") ) {
if (user->permit) {
free(user->permit);
}
user->permit = ast_strdup(var->value);
} else if (!strcasecmp(var->name, "read") ) {
if (user->read) {
free(user->read);
}
user->read = ast_strdup(var->value);
} else if (!strcasecmp(var->name, "write") ) {
if (user->write) {
free(user->write);
}
user->write = ast_strdup(var->value);
} else if (!strcasecmp(var->name, "displayconnects") ) {
user->displayconnects = ast_true(var->value);
} else if (!strcasecmp(var->name, "hasmanager")) {
/* already handled */
} else {
ast_log(LOG_DEBUG, "%s is an unknown option (to the manager module).\n", var->name);
}
}
}
ast_config_destroy(ucfg);
}
while ((cat = ast_category_browse(cfg, cat))) {
struct ast_variable *var = NULL;