[asterisk-commits] [svn-commits] russell: trunk r64786 - in /trunk:
configs/manager.conf.sample main/manager.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu May 17 10:12:23 MST 2007
: <asterisk at leapscape.com>
X-pstn-levels: (S:99.90000/99.90000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )
X-pstn-settings: 3 (1.0000:1.0000) s fc lc gt3 gt2 gt1 r p m c
X-pstn-addresses: from <svn-commits at lists.digium.com> [db-null]
Author: russell
Date: Thu May 17 12:12:23 2007
New Revision: 64786
URL: http://svn.digium.com/view/asterisk?view=rev&rev=64786
Log:
Add an option that lets you only allow one connection at a time for each
manager user. (issue #8664, reported and original patch by ssokol, patch
updated by bkruse, and further updated by me)
Modified:
trunk/configs/manager.conf.sample
trunk/main/manager.c
Modified: trunk/configs/manager.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/manager.conf.sample?view=diff&rev=64786&r1=64785&r2=64786
==============================================================================
--- trunk/configs/manager.conf.sample (original)
+++ trunk/configs/manager.conf.sample Thu May 17 12:12:23 2007
@@ -45,6 +45,10 @@
; sslcert=/tmp/asterisk.pem ; path to the certificate.
+;
+;allowmultiplelogin = yes ; IF set to no, rejects manager logins that are already in use.
+; ; The default is yes.
+;
;displayconnects = yes
;
; Add a Unix epoch timestamp to events (not action responses)
Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=64786&r1=64785&r2=64786
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Thu May 17 12:12:23 2007
@@ -111,6 +111,7 @@
static AST_LIST_HEAD_STATIC(all_events, eventqent);
static int displayconnects = 1;
+static int allowmultiplelogin;
static int timestampevents;
static int httptimeout = 60;
static int manager_enabled = 0;
@@ -416,6 +417,21 @@
return ret;
}
+
+static int check_manager_session_inuse(const char *name)
+{
+ struct mansession *session = NULL;
+
+ AST_LIST_LOCK(&sessions);
+ AST_LIST_TRAVERSE(&sessions, session, list) {
+ if (!strcasecmp(session->username, name))
+ break;
+ }
+ AST_LIST_UNLOCK(&sessions);
+
+ return session ? 1 : 0;
+}
+
/*!
* lookup an entry in the list of registered users.
@@ -2266,6 +2282,7 @@
char action[80] = "";
int ret = 0;
struct manager_action *tmp;
+ const char *user = astman_get_header(m, "Username");
ast_copy_string(action, astman_get_header(m, "Action"), sizeof(action));
if (option_debug)
@@ -2282,6 +2299,16 @@
ast_mutex_unlock(&s->__lock);
return 0;
}
+
+ if (!allowmultiplelogin && !s->authenticated && user &&
+ (!strcasecmp(action, "Login") || !strcasecmp(action, "Challenge"))) {
+ if (check_manager_session_inuse(user)) {
+ sleep(1);
+ astman_send_error(s, m, "Login Already In Use");
+ return -1;
+ }
+ }
+
ast_rwlock_rdlock(&actionlock);
for (tmp = first_action ; tmp; tmp = tmp->next) {
if (strcasecmp(action, tmp->action))
@@ -3276,6 +3303,8 @@
ast_log(LOG_WARNING, "Invalid address '%s' specified, using 0.0.0.0\n", val);
memset(&ami_desc.sin.sin_addr, 0, sizeof(ami_desc.sin.sin_addr));
}
+ } else if (!strcasecmp(var->name, "allowmultiplelogin")) {
+ allowmultiplelogin = ast_true(val);
} else if (!strcasecmp(var->name, "displayconnects")) {
displayconnects = ast_true(val);
} else if (!strcasecmp(var->name, "timestampevents")) {
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --
svn-commits mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/svn-commits
More information about the asterisk-commits
mailing list