aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-03 18:23:32 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-03 18:23:32 +0000
commitd13fe2eb1519175fb7d8a884c6bd899180804186 (patch)
tree9fdee22487fbeb0b0eb9b0dbf62882f5d165194e
parent6fb5bda2e3df09a0bfa64659e631a4dc42c4dda9 (diff)
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: http://svn.digium.com/svn/asterisk/branches/1.4@120061 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/manager.c67
1 files changed, 66 insertions, 1 deletions
diff --git a/main/manager.c b/main/manager.c
index 6068bf2ef..2dc76645a 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -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;