[svn-commits] russell: branch 1.4 r51233 - /branches/1.4/main/manager.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Jan 18 10:18:44 MST 2007


Author: russell
Date: Thu Jan 18 11:18:43 2007
New Revision: 51233

URL: http://svn.digium.com/view/asterisk?view=rev&rev=51233
Log:
Make the "hasmanager" option in users.conf actually have an effect.
(issue #8740, LnxPrgr3)

Modified:
    branches/1.4/main/manager.c

Modified: branches/1.4/main/manager.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/manager.c?view=diff&rev=51233&r1=51232&r2=51233
==============================================================================
--- branches/1.4/main/manager.c (original)
+++ branches/1.4/main/manager.c Thu Jan 18 11:18:43 2007
@@ -953,6 +953,40 @@
 		ast_copy_string(s->username, cat, sizeof(s->username));
 		s->readperm = get_perm(ast_variable_retrieve(cfg, cat, "read"));
 		s->writeperm = get_perm(ast_variable_retrieve(cfg, cat, "write"));
+		ast_config_destroy(cfg);
+		if (events)
+			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);



More information about the svn-commits mailing list