[svn-commits] mmichelson: branch mmichelson/lock_backtraces r118169 - in /team/mmichelson/l...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri May 23 17:07:08 CDT 2008


Author: mmichelson
Date: Fri May 23 17:07:07 2008
New Revision: 118169

URL: http://svn.digium.com/view/asterisk?view=rev&rev=118169
Log:
Updating before merge with trunk


Modified:
    team/mmichelson/lock_backtraces/   (props changed)
    team/mmichelson/lock_backtraces/apps/app_voicemail.c
    team/mmichelson/lock_backtraces/channels/chan_zap.c
    team/mmichelson/lock_backtraces/include/asterisk/manager.h
    team/mmichelson/lock_backtraces/main/http.c
    team/mmichelson/lock_backtraces/main/manager.c

Propchange: team/mmichelson/lock_backtraces/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/mmichelson/lock_backtraces/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri May 23 17:07:07 2008
@@ -1,1 +1,1 @@
-/trunk:1-118138
+/trunk:1-118168

Modified: team/mmichelson/lock_backtraces/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/lock_backtraces/apps/app_voicemail.c?view=diff&rev=118169&r1=118168&r2=118169
==============================================================================
--- team/mmichelson/lock_backtraces/apps/app_voicemail.c (original)
+++ team/mmichelson/lock_backtraces/apps/app_voicemail.c Fri May 23 17:07:07 2008
@@ -9166,6 +9166,8 @@
 	AST_RWLIST_WRLOCK(&mwi_subs);
 	AST_RWLIST_INSERT_TAIL(&mwi_subs, mwi_sub, entry);
 	AST_RWLIST_UNLOCK(&mwi_subs);
+	ast_free((void *) p->mailbox);
+	ast_free((void *) p->context);
 	ast_free(p);	
 	return 0;
 }
@@ -9200,8 +9202,8 @@
 		ast_log(LOG_ERROR, "could not allocate a mwi_sub_task\n");
 		return;
 	}
-	mwist->mailbox = ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX);
-	mwist->context = ast_event_get_ie_str(event, AST_EVENT_IE_CONTEXT);
+	mwist->mailbox = ast_strdup(ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX));
+	mwist->context = ast_strdup(ast_event_get_ie_str(event, AST_EVENT_IE_CONTEXT));
 	mwist->uniqueid = ast_event_get_ie_uint(event, AST_EVENT_IE_UNIQUEID);
 	
 	if (ast_taskprocessor_push(mwi_subscription_tps, handle_subscribe, mwist) < 0) {

Modified: team/mmichelson/lock_backtraces/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/lock_backtraces/channels/chan_zap.c?view=diff&rev=118169&r1=118168&r2=118169
==============================================================================
--- team/mmichelson/lock_backtraces/channels/chan_zap.c (original)
+++ team/mmichelson/lock_backtraces/channels/chan_zap.c Fri May 23 17:07:07 2008
@@ -8213,13 +8213,13 @@
 			}
 #endif
 #ifdef HAVE_PRI
-			if ((conf->chan.sig == SIG_PRI) || (conf->chan.sig == SIG_BRI) || (conf->chan.sig == SIG_BRI_PTMP) || (conf->chan.sig == SIG_GR303FXOKS) || (conf->chan.sig == SIG_GR303FXSKS)) {
+			if ((chan_sig == SIG_PRI) || (chan_sig == SIG_BRI) || (chan_sig == SIG_BRI_PTMP) || (chan_sig == SIG_GR303FXOKS) || (chan_sig == SIG_GR303FXSKS)) {
 				int offset;
 				int myswitchtype;
 				int matchesdchan;
 				int x,y;
 				offset = 0;
-				if (((conf->chan.sig == SIG_PRI) || (conf->chan.sig == SIG_BRI) || (conf->chan.sig == SIG_BRI_PTMP)) 
+				if (((chan_sig == SIG_PRI) || (chan_sig == SIG_BRI) || (chan_sig == SIG_BRI_PTMP)) 
 						&& ioctl(tmp->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &offset)) {
 					ast_log(LOG_ERROR, "Unable to set clear mode on clear channel %d of span %d: %s\n", channel, p.spanno, strerror(errno));
 					destroy_zt_pvt(&tmp);
@@ -8244,9 +8244,9 @@
 						destroy_zt_pvt(&tmp);
 						return NULL;
 					}
-					if ((conf->chan.sig == SIG_PRI) ||
-							(conf->chan.sig == SIG_BRI) ||
-							(conf->chan.sig == SIG_BRI_PTMP))
+					if ((chan_sig == SIG_PRI) ||
+							(chan_sig == SIG_BRI) ||
+							(chan_sig == SIG_BRI_PTMP))
 						myswitchtype = conf->pri.switchtype;
 					else
 						myswitchtype = PRI_SWITCH_GR303_TMC;

Modified: team/mmichelson/lock_backtraces/include/asterisk/manager.h
URL: http://svn.digium.com/view/asterisk/team/mmichelson/lock_backtraces/include/asterisk/manager.h?view=diff&rev=118169&r1=118168&r2=118169
==============================================================================
--- team/mmichelson/lock_backtraces/include/asterisk/manager.h (original)
+++ team/mmichelson/lock_backtraces/include/asterisk/manager.h Fri May 23 17:07:07 2008
@@ -203,6 +203,9 @@
 
 void __attribute__ ((format (printf, 2, 3))) astman_append(struct mansession *s, const char *fmt, ...);
 
+/*! \brief Determinie if a manager session ident is authenticated */
+int astman_is_authed(uint32_t ident);
+
 /*! \brief Called by Asterisk initialization */
 int init_manager(void);
 

Modified: team/mmichelson/lock_backtraces/main/http.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/lock_backtraces/main/http.c?view=diff&rev=118169&r1=118168&r2=118169
==============================================================================
--- team/mmichelson/lock_backtraces/main/http.c (original)
+++ team/mmichelson/lock_backtraces/main/http.c Fri May 23 17:07:07 2008
@@ -131,6 +131,18 @@
 	return wkspace;
 }
 
+static uint32_t manid_from_vars(struct ast_variable *sid) {
+	uint32_t mngid;
+
+	while (sid && strcmp(sid->name, "mansession_id"))
+		sid = sid->next;
+	
+	if (!sid || sscanf(sid->value, "%x", &mngid) != 1)
+		return 0;
+	
+	return mngid;
+}
+
 static struct ast_str *static_callback(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *vars, struct ast_variable *headers, int *status, char **title, int *contentlength)
 {
 	char *path;
@@ -178,9 +190,13 @@
 
 	if (S_ISDIR(st.st_mode)) {
 		goto out404;
-	}
+	}	
 
 	if ((fd = open(path, O_RDONLY)) < 0) {
+		goto out403;
+	}
+
+	if (strstr(path, "/private/") && !astman_is_authed(manid_from_vars(vars))) {
 		goto out403;
 	}
 
@@ -514,7 +530,11 @@
 		}
 	}
 
-	if (urih) {
+	if (method == AST_HTTP_POST && !astman_is_authed(manid_from_vars(vars))) {
+		out = ast_http_error((*status = 403),
+			      (*title = ast_strdup("Access Denied")),
+			      NULL, "Sorry, I cannot let you do that, Dave.");
+	} else if (urih) {
 		*static_content = urih->static_content;
 		out = urih->callback(ser, urih, uri, method, vars, headers, status, title, contentlength);
 		AST_RWLIST_UNLOCK(&uris);

Modified: team/mmichelson/lock_backtraces/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/lock_backtraces/main/manager.c?view=diff&rev=118169&r1=118168&r2=118169
==============================================================================
--- team/mmichelson/lock_backtraces/main/manager.c (original)
+++ team/mmichelson/lock_backtraces/main/manager.c Fri May 23 17:07:07 2008
@@ -3292,7 +3292,7 @@
  * the value of the mansession_id cookie (0 is not valid and means
  * a session on the AMI socket).
  */
-static struct mansession *find_session(uint32_t ident)
+static struct mansession *find_session(uint32_t ident, int incinuse)
 {
 	struct mansession *s;
 
@@ -3303,7 +3303,7 @@
 	AST_LIST_TRAVERSE(&sessions, s, list) {
 		ast_mutex_lock(&s->__lock);
 		if (s->managerid == ident && !s->needdestroy) {
-			ast_atomic_fetchadd_int(&s->inuse, 1);
+			ast_atomic_fetchadd_int(&s->inuse, incinuse ? 1 : 0);
 			break;
 		}
 		ast_mutex_unlock(&s->__lock);
@@ -3311,6 +3311,21 @@
 	AST_LIST_UNLOCK(&sessions);
 
 	return s;
+}
+
+int astman_is_authed(uint32_t ident) 
+{
+	int authed;
+	struct mansession *s;
+
+	if (!(s = find_session(ident, 0)))
+		return 0;
+
+	authed = (s->authenticated != 0);
+
+	ast_mutex_unlock(&s->__lock);
+
+	return authed;
 }
 
 int astman_verify_session_readpermissions(uint32_t ident, int perm)
@@ -3603,7 +3618,7 @@
 		}
 	}
 
-	if (!(s = find_session(ident))) {
+	if (!(s = find_session(ident, 1))) {
 		/* Create new session.
 		 * While it is not in the list we don't need any locking
 		 */




More information about the svn-commits mailing list