|
|
|
@ -341,7 +341,7 @@ void config__cleanup(struct mosquitto__config *config)
|
|
|
|
|
#ifdef WITH_TLS
|
|
|
|
|
mosquitto__free(config->bridges[i].tls_version);
|
|
|
|
|
mosquitto__free(config->bridges[i].tls_cafile);
|
|
|
|
|
#ifdef WITH_TLS_PSK
|
|
|
|
|
#ifdef FINAL_WITH_TLS_PSK
|
|
|
|
|
mosquitto__free(config->bridges[i].tls_psk_identity);
|
|
|
|
|
mosquitto__free(config->bridges[i].tls_psk);
|
|
|
|
|
#endif
|
|
|
|
@ -446,6 +446,7 @@ int config__parse_args(struct mosquitto_db *db, struct mosquitto__config *config
|
|
|
|
|
|| config->default_listener.max_connections != -1
|
|
|
|
|
|| config->default_listener.mount_point
|
|
|
|
|
|| config->default_listener.protocol != mp_mqtt
|
|
|
|
|
|| config->default_listener.socket_domain
|
|
|
|
|
|| config->default_listener.security_options.password_file
|
|
|
|
|
|| config->default_listener.security_options.psk_file
|
|
|
|
|
|| config->default_listener.security_options.auth_plugin_config_count
|
|
|
|
@ -476,6 +477,7 @@ int config__parse_args(struct mosquitto_db *db, struct mosquitto__config *config
|
|
|
|
|
}
|
|
|
|
|
config->listeners[config->listener_count-1].max_connections = config->default_listener.max_connections;
|
|
|
|
|
config->listeners[config->listener_count-1].protocol = config->default_listener.protocol;
|
|
|
|
|
config->listeners[config->listener_count-1].socket_domain = config->default_listener.socket_domain;
|
|
|
|
|
config->listeners[config->listener_count-1].client_count = 0;
|
|
|
|
|
config->listeners[config->listener_count-1].socks = NULL;
|
|
|
|
|
config->listeners[config->listener_count-1].sock_count = 0;
|
|
|
|
@ -495,6 +497,7 @@ int config__parse_args(struct mosquitto_db *db, struct mosquitto__config *config
|
|
|
|
|
config->listeners[config->listener_count-1].use_identity_as_username = config->default_listener.use_identity_as_username;
|
|
|
|
|
config->listeners[config->listener_count-1].use_subject_as_username = config->default_listener.use_subject_as_username;
|
|
|
|
|
#endif
|
|
|
|
|
config->listeners[config->listener_count-1].security_options.acl_file = config->default_listener.security_options.acl_file;
|
|
|
|
|
config->listeners[config->listener_count-1].security_options.password_file = config->default_listener.security_options.password_file;
|
|
|
|
|
config->listeners[config->listener_count-1].security_options.psk_file = config->default_listener.security_options.psk_file;
|
|
|
|
|
config->listeners[config->listener_count-1].security_options.auth_plugin_configs = config->default_listener.security_options.auth_plugin_configs;
|
|
|
|
@ -684,7 +687,7 @@ int config__read(struct mosquitto_db *db, struct mosquitto__config *config, bool
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
|
}
|
|
|
|
|
#ifdef WITH_TLS_PSK
|
|
|
|
|
#ifdef FINAL_WITH_TLS_PSK
|
|
|
|
|
if(config->bridges[i].tls_psk && !config->bridges[i].tls_psk_identity){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration: missing bridge_identity.\n");
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
@ -816,6 +819,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
|
|
|
|
conf__set_cur_security_options(config, cur_listener, &cur_security_options);
|
|
|
|
|
if(conf__parse_bool(&token, "allow_zero_length_clientid", &cur_security_options->allow_zero_length_clientid, saveptr)) return MOSQ_ERR_INVAL;
|
|
|
|
|
}else if(!strncmp(token, "auth_opt_", 9)){
|
|
|
|
|
if(reload) continue; // Auth plugin not currently valid for reloading.
|
|
|
|
|
if(!cur_auth_plugin_config){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: An auth_opt_ option exists in the config file without an auth_plugin.");
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
@ -917,7 +921,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
|
}
|
|
|
|
|
#ifdef WITH_TLS_PSK
|
|
|
|
|
#ifdef FINAL_WITH_TLS_PSK
|
|
|
|
|
if(cur_bridge->tls_psk_identity || cur_bridge->tls_psk){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Cannot use both certificate and psk encryption in a single bridge.");
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
@ -934,7 +938,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
|
}
|
|
|
|
|
#ifdef WITH_TLS_PSK
|
|
|
|
|
#ifdef FINAL_WITH_TLS_PSK
|
|
|
|
|
if(cur_bridge->tls_psk_identity || cur_bridge->tls_psk){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Cannot use both certificate and psk encryption in a single bridge.");
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
@ -951,7 +955,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
|
}
|
|
|
|
|
#ifdef WITH_TLS_PSK
|
|
|
|
|
#ifdef FINAL_WITH_TLS_PSK
|
|
|
|
|
if(cur_bridge->tls_psk_identity || cur_bridge->tls_psk){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Cannot use both certificate and psk encryption in a single bridge.");
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
@ -962,7 +966,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge and/or TLS support not available.");
|
|
|
|
|
#endif
|
|
|
|
|
}else if(!strcmp(token, "bridge_identity")){
|
|
|
|
|
#if defined(WITH_BRIDGE) && defined(WITH_TLS_PSK)
|
|
|
|
|
#if defined(WITH_BRIDGE) && defined(FINAL_WITH_TLS_PSK)
|
|
|
|
|
if(reload) continue; // FIXME
|
|
|
|
|
if(!cur_bridge){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
|
|
|
|
@ -997,7 +1001,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
|
}
|
|
|
|
|
#ifdef WITH_TLS_PSK
|
|
|
|
|
#ifdef FINAL_WITH_TLS_PSK
|
|
|
|
|
if(cur_bridge->tls_psk_identity || cur_bridge->tls_psk){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Cannot use both certificate and psk encryption in a single bridge.");
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
@ -1032,7 +1036,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
|
|
|
|
|
#endif
|
|
|
|
|
}else if(!strcmp(token, "bridge_psk")){
|
|
|
|
|
#if defined(WITH_BRIDGE) && defined(WITH_TLS_PSK)
|
|
|
|
|
#if defined(WITH_BRIDGE) && defined(FINAL_WITH_TLS_PSK)
|
|
|
|
|
if(reload) continue; // FIXME
|
|
|
|
|
if(!cur_bridge){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
|
|
|
|
@ -1688,7 +1692,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty protocol value in configuration.");
|
|
|
|
|
}
|
|
|
|
|
}else if(!strcmp(token, "psk_file")){
|
|
|
|
|
#ifdef WITH_TLS_PSK
|
|
|
|
|
#ifdef FINAL_WITH_TLS_PSK
|
|
|
|
|
conf__set_cur_security_options(config, cur_listener, &cur_security_options);
|
|
|
|
|
if(reload){
|
|
|
|
|
mosquitto__free(cur_security_options->psk_file);
|
|
|
|
@ -1699,7 +1703,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS/TLS-PSK support not available.");
|
|
|
|
|
#endif
|
|
|
|
|
}else if(!strcmp(token, "psk_hint")){
|
|
|
|
|
#ifdef WITH_TLS_PSK
|
|
|
|
|
#ifdef FINAL_WITH_TLS_PSK
|
|
|
|
|
if(reload) continue; // Listeners not valid for reloading.
|
|
|
|
|
if(conf__parse_string(&token, "psk_hint", &cur_listener->psk_hint, saveptr)) return MOSQ_ERR_INVAL;
|
|
|
|
|
#else
|
|
|
|
@ -1773,6 +1777,22 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
|
|
|
|
#else
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
|
|
|
|
|
#endif
|
|
|
|
|
}else if(!strcmp(token, "socket_domain")){
|
|
|
|
|
if(reload) continue; // Listeners not valid for reloading.
|
|
|
|
|
token = strtok_r(NULL, " ", &saveptr);
|
|
|
|
|
if(token){
|
|
|
|
|
if(!strcmp(token, "ipv4")){
|
|
|
|
|
cur_listener->socket_domain = AF_INET;
|
|
|
|
|
}else if(!strcmp(token, "ipv6")){
|
|
|
|
|
cur_listener->socket_domain = AF_INET6;
|
|
|
|
|
}else{
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid socket_domain value \"%s\" in configuration.", token);
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty socket_domain value in configuration.");
|
|
|
|
|
return MOSQ_ERR_INVAL;
|
|
|
|
|
}
|
|
|
|
|
}else if(!strcmp(token, "store_clean_interval")){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: store_clean_interval is no longer needed.");
|
|
|
|
|
}else if(!strcmp(token, "sys_interval")){
|
|
|
|
|