[asterisk-commits] may: branch may/ooh323_qsig r397705 - in /team/may/ooh323_qsig: ./ configs/ r...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 27 10:13:15 CDT 2013


Author: may
Date: Tue Aug 27 10:13:12 2013
New Revision: 397705

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397705
Log:
Multiple revisions 394065,394076,394089

........
  r394065 | dlee | 2013-07-11 17:56:26 +0400 (Thu, 11 Jul 2013) | 1 line
  
  Apply defaults to ari.conf's general section
........
  r394076 | dlee | 2013-07-11 18:39:55 +0400 (Thu, 11 Jul 2013) | 11 lines
  
  Change ARI user config to use a type field
  
  When I initially wrote the configuration support for ARI users, I
  determined the section type by a category prefix (i.e., [user-admin]).
  
  This is neither idiomatic Asterisk configuration, nor is it really
  that user friendly. This patch replaces the category prefix with a
  type field in the section, which is much cleaner.
  
  Review: https://reviewboard.asterisk.org/r/2664/
........
  r394089 | dlee | 2013-07-11 19:37:51 +0400 (Thu, 11 Jul 2013) | 12 lines
  
  Correct test_cel cleanup.
  
  When I corrected the CEL test crash in r394037, I didn't quite pay attention
  to how the globals and locals were being shuffled around in the cleanup
  callback. I removed the nulling of the global variables, which caused them
  to be double cleaned.
  
  This patch puts the global nulling code back (since the vars are cleaned up
  by RAII_VARs), and removes the explicit ao2_cleanup() (since they were no-ops,
  because the variables had just been nulled).
........

Merged revisions 394065,394076,394089 from http://svn.asterisk.org/svn/asterisk/trunk

Modified:
    team/may/ooh323_qsig/   (props changed)
    team/may/ooh323_qsig/configs/ari.conf.sample
    team/may/ooh323_qsig/res/res_stasis_http.c
    team/may/ooh323_qsig/res/stasis_http/config.c
    team/may/ooh323_qsig/tests/test_cel.c

Propchange: team/may/ooh323_qsig/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Aug 27 10:13:12 2013
@@ -1,1 +1,1 @@
-/trunk:1-380157,380165-391000,391012,391016-393400,393410-393530,393542-393834,393843-394050
+/trunk:1-380157,380165-391000,391012,391016-393400,393410-393530,393542-393834,393843-394050,394065-394089

Modified: team/may/ooh323_qsig/configs/ari.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/configs/ari.conf.sample?view=diff&rev=397705&r1=397704&r2=397705
==============================================================================
--- team/may/ooh323_qsig/configs/ari.conf.sample (original)
+++ team/may/ooh323_qsig/configs/ari.conf.sample Tue Aug 27 10:13:12 2013
@@ -8,7 +8,8 @@
 ;auth_realm =		; Realm to use for authentication. Defaults to Asterisk
 ;			; REST Interface.
 
-;[user-username]
+;[username]
+;type = user		; Specifies user configuration
 ;read_only = no		; When set to yes, user is only authorized for
 ;			; read-only requests.
 ;

Modified: team/may/ooh323_qsig/res/res_stasis_http.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/res/res_stasis_http.c?view=diff&rev=397705&r1=397704&r2=397705
==============================================================================
--- team/may/ooh323_qsig/res/res_stasis_http.c (original)
+++ team/may/ooh323_qsig/res/res_stasis_http.c Tue Aug 27 10:13:12 2013
@@ -95,6 +95,14 @@
 
 			<configObject name="user">
 				<synopsis>Per-user configuration settings</synopsis>
+				<configOption name="type">
+					<synopsis>Define this configuration section as a user.</synopsis>
+					<description>
+						<enumlist>
+							<enum name="user"><para>Configure this section as a <replaceable>user</replaceable></para></enum>
+						</enumlist>
+					</description>
+				</configOption>
 				<configOption name="read_only">
 					<synopsis>When set to yes, user is only authorized for read-only requests</synopsis>
 				</configOption>

Modified: team/may/ooh323_qsig/res/stasis_http/config.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/res/stasis_http/config.c?view=diff&rev=397705&r1=397704&r2=397705
==============================================================================
--- team/may/ooh323_qsig/res/stasis_http/config.c (original)
+++ team/may/ooh323_qsig/res/stasis_http/config.c Tue Aug 27 10:13:12 2013
@@ -89,16 +89,8 @@
 static void *user_alloc(const char *cat)
 {
 	RAII_VAR(struct ari_conf_user *, user, NULL, ao2_cleanup);
-	const char *username;
 
 	if (!cat) {
-		return NULL;
-	}
-
-	username = strchr(cat, '-') + 1;
-
-	if (!username) {
-		ast_log(LOG_ERROR, "Invalid user category '%s'\n", cat);
 		return NULL;
 	}
 
@@ -110,7 +102,7 @@
 		return NULL;
 	}
 
-	user->username = ast_strdup(username);
+	user->username = ast_strdup(cat);
 	if (!user->username) {
 		return NULL;
 	}
@@ -141,21 +133,20 @@
 /*! \brief \ref aco_type item_find function */
 static void *user_find(struct ao2_container *tmp_container, const char *cat)
 {
-	const char *username;
-
 	if (!cat) {
 		return NULL;
 	}
 
-	username = strchr(cat, '-') + 1;
-	return ao2_find(tmp_container, username, OBJ_KEY);
+	return ao2_find(tmp_container, cat, OBJ_KEY);
 }
 
 static struct aco_type user_option = {
 	.type = ACO_ITEM,
 	.name = "user",
-	.category_match = ACO_WHITELIST,
-	.category = "^user-.+$",
+	.category_match = ACO_BLACKLIST,
+	.category = "^general$",
+	.matchfield = "type",
+	.matchvalue = "user",
 	.item_alloc = user_alloc,
 	.item_find = user_find,
 	.item_offset = offsetof(struct ari_conf, users),
@@ -187,6 +178,7 @@
 	if (!cfg->general) {
 		return NULL;
 	}
+	aco_set_defaults(&general_option, "general", cfg->general);
 
 	cfg->users = ao2_container_alloc_rbtree(AO2_ALLOC_OPT_LOCK_NOLOCK,
 		AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, user_sort_cmp, NULL);
@@ -317,6 +309,8 @@
 		FLDSET(struct ari_conf_general, auth_realm),
 		ARI_AUTH_REALM_LEN);
 
+	aco_option_register(&cfg_info, "type", ACO_EXACT, user, NULL,
+		OPT_NOOP_T, 0, 0);
 	aco_option_register(&cfg_info, "read_only", ACO_EXACT, user,
 		"no", OPT_BOOL_T, 1,
 		FLDSET(struct ari_conf_user, read_only));

Modified: team/may/ooh323_qsig/tests/test_cel.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_qsig/tests/test_cel.c?view=diff&rev=397705&r1=397704&r2=397705
==============================================================================
--- team/may/ooh323_qsig/tests/test_cel.c (original)
+++ team/may/ooh323_qsig/tests/test_cel.c Tue Aug 27 10:13:12 2013
@@ -1335,6 +1335,10 @@
 	ast_event_unsubscribe(event_sub);
 	event_sub = NULL;
 
+	/* cleaned up by RAII_VAR's */
+	cel_expected_events = NULL;
+	cel_received_events = NULL;
+
 	/* check events */
 	ast_test_validate(test, !check_events(local_expected, local_received));
 
@@ -1343,11 +1347,7 @@
 	ao2_cleanup(saved_config);
 	saved_config = NULL;
 
-	/* get rid of events */
-	ao2_cleanup(cel_received_events);
-	cel_received_events = NULL;
-	ao2_cleanup(cel_expected_events);
-	cel_expected_events = NULL;
+	/* clean up the locks */
 	ast_mutex_destroy(&sync_lock);
 	ast_cond_destroy(&sync_out);
 	return 0;




More information about the asterisk-commits mailing list