@ -482,6 +482,7 @@ void dynsec__config_save(void)
int mosquitto_plugin_init ( mosquitto_plugin_id_t * identifier , void * * user_data , struct mosquitto_opt * options , int option_count )
{
int i ;
int rc ;
UNUSED ( user_data ) ;
@ -502,11 +503,46 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
plg_id = identifier ;
dynsec__config_load ( ) ;
mosquitto_callback_register ( plg_id , MOSQ_EVT_CONTROL , dynsec_control_callback , " $CONTROL/dynamic-security/v1 " , NULL ) ;
mosquitto_callback_register ( plg_id , MOSQ_EVT_BASIC_AUTH , dynsec_auth__basic_auth_callback , NULL , NULL ) ;
mosquitto_callback_register ( plg_id , MOSQ_EVT_ACL_CHECK , dynsec__acl_check_callback , NULL , NULL ) ;
rc = mosquitto_callback_register ( plg_id , MOSQ_EVT_CONTROL , dynsec_control_callback , " $CONTROL/dynamic-security/v1 " , NULL ) ;
if ( rc = = MOSQ_ERR_ALREADY_EXISTS ) {
mosquitto_log_printf ( MOSQ_LOG_ERR , " Error: Dynamic security plugin can currently only be loaded once. " ) ;
mosquitto_log_printf ( MOSQ_LOG_ERR , " Note that this was previously incorrectly allowed but could cause problems with duplicate entries in the config. " ) ;
goto error ;
} else if ( rc = = MOSQ_ERR_NOMEM ) {
mosquitto_log_printf ( MOSQ_LOG_ERR , " Error: Out of memory. " ) ;
goto error ;
} else if ( rc ! = MOSQ_ERR_SUCCESS ) {
goto error ;
}
rc = mosquitto_callback_register ( plg_id , MOSQ_EVT_BASIC_AUTH , dynsec_auth__basic_auth_callback , NULL , NULL ) ;
if ( rc = = MOSQ_ERR_ALREADY_EXISTS ) {
mosquitto_log_printf ( MOSQ_LOG_ERR , " Error: Dynamic security plugin can only be loaded once. " ) ;
goto error ;
} else if ( rc = = MOSQ_ERR_NOMEM ) {
mosquitto_log_printf ( MOSQ_LOG_ERR , " Error: Out of memory. " ) ;
goto error ;
} else if ( rc ! = MOSQ_ERR_SUCCESS ) {
goto error ;
}
rc = mosquitto_callback_register ( plg_id , MOSQ_EVT_ACL_CHECK , dynsec__acl_check_callback , NULL , NULL ) ;
if ( rc = = MOSQ_ERR_ALREADY_EXISTS ) {
mosquitto_log_printf ( MOSQ_LOG_ERR , " Error: Dynamic security plugin can only be loaded once. " ) ;
goto error ;
} else if ( rc = = MOSQ_ERR_NOMEM ) {
mosquitto_log_printf ( MOSQ_LOG_ERR , " Error: Out of memory. " ) ;
goto error ;
} else if ( rc ! = MOSQ_ERR_SUCCESS ) {
goto error ;
}
return MOSQ_ERR_SUCCESS ;
error :
mosquitto_free ( config_file ) ;
config_file = NULL ;
return rc ;
}
int mosquitto_plugin_cleanup ( void * user_data , struct mosquitto_opt * options , int option_count )