[svn-commits] dlee: branch dlee/ari-authn r392901 - /team/dlee/ari-authn/res/stasis_http/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jun 25 15:37:53 CDT 2013


Author: dlee
Date: Tue Jun 25 15:37:51 2013
New Revision: 392901

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392901
Log:
Print errors if password config is missing

Modified:
    team/dlee/ari-authn/res/stasis_http/config.c

Modified: team/dlee/ari-authn/res/stasis_http/config.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-authn/res/stasis_http/config.c?view=diff&rev=392901&r1=392900&r2=392901
==============================================================================
--- team/dlee/ari-authn/res/stasis_http/config.c (original)
+++ team/dlee/ari-authn/res/stasis_http/config.c Tue Jun 25 15:37:51 2013
@@ -275,6 +275,45 @@
 	return user;
 }
 
+static int check_passwords_cb(void *obj, void *arg, int flags)
+{
+	struct ari_conf_user *user = obj;
+
+	if (ast_strlen_zero(user->password)) {
+		ast_log(LOG_ERROR, "User '%s' missing password\n",
+			user->username);
+	}
+
+	return 0;
+}
+
+static int process_config(int reload)
+{
+	RAII_VAR(struct ari_conf *, conf, NULL, ao2_cleanup);
+
+	switch (aco_process_config(&cfg_info, reload)) {
+	case ACO_PROCESS_ERROR:
+		return -1;
+	case ACO_PROCESS_OK:
+	case ACO_PROCESS_UNCHANGED:
+		break;
+	}
+
+	conf = ari_config_get();
+	if (!conf) {
+		ast_assert(0); /* We just configured; it should be there */
+		return -1;
+	}
+
+	if (ao2_container_count(conf->users) == 0) {
+		ast_log(LOG_ERROR, "No configured users for ARI\n");
+	}
+
+	ao2_callback(conf->users, OBJ_NODATA, check_passwords_cb, NULL);
+
+	return 0;
+}
+
 int ari_config_init(void)
 {
 	if (aco_info_init(&cfg_info)) {
@@ -300,25 +339,12 @@
 	aco_option_register_custom(&cfg_info, "password_format", ACO_EXACT,
 		user, "plain",  password_format_handler, 0);
 
-	if (aco_process_config(&cfg_info, 0)) {
-		aco_info_destroy(&cfg_info);
-		return -1;
-	}
-
-	return 0;
+	return process_config(0);
 }
 
 int ari_config_reload(void)
 {
-	switch (aco_process_config(&cfg_info, 1)) {
-	case ACO_PROCESS_OK:
-	case ACO_PROCESS_UNCHANGED:
-		return 0;
-	case ACO_PROCESS_ERROR:
-		return -1;
-	}
-
-	return -1;
+	return process_config(1);
 }
 
 void ari_config_destroy(void)




More information about the svn-commits mailing list