Per listener allow_zero_length_clientid.

pull/746/merge
Roger A. Light 8 years ago
parent 7271893966
commit 26bc3206cd

@ -488,6 +488,8 @@
options are affected:</para> options are affected:</para>
<para><option>password_file</option>, <para><option>password_file</option>,
<option>acl_file</option>, <option>psk_file</option>, <option>acl_file</option>, <option>psk_file</option>,
<option>allow_anonymous</option>,
<option>allow_zero_length_clientid</option>,
<option>auth_plugin</option>, <option>auth_plugin</option>,
<option>auth_opt_*</option>, <option>auth_opt_*</option>,
<option>auto_id_prefix</option>.</para> <option>auto_id_prefix</option>.</para>

@ -142,7 +142,7 @@
# affected: # affected:
# #
# password_file acl_file psk_file auth_plugin auth_opt_* allow_anonymous # password_file acl_file psk_file auth_plugin auth_opt_* allow_anonymous
# auto_id_prefix # auto_id_prefix allow_zero_length_clientid
# #
# The default behaviour is for this to be set to false, which maintains the # The default behaviour is for this to be set to false, which maintains the
# setting behaviour from previous versions of mosquitto. # setting behaviour from previous versions of mosquitto.

@ -152,7 +152,7 @@ static void config__init_reload(struct mosquitto__config *config)
config->acl_file = NULL; config->acl_file = NULL;
config->security_options.allow_anonymous = -1; config->security_options.allow_anonymous = -1;
config->allow_duplicate_messages = false; config->allow_duplicate_messages = false;
config->allow_zero_length_clientid = true; config->security_options.allow_zero_length_clientid = true;
config->security_options.auto_id_prefix = NULL; config->security_options.auto_id_prefix = NULL;
config->security_options.auto_id_prefix_len = 0; config->security_options.auto_id_prefix_len = 0;
config->autosave_interval = 1800; config->autosave_interval = 1800;
@ -714,7 +714,8 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, const
}else if(!strcmp(token, "allow_duplicate_messages")){ }else if(!strcmp(token, "allow_duplicate_messages")){
if(conf__parse_bool(&token, "allow_duplicate_messages", &config->allow_duplicate_messages, saveptr)) return MOSQ_ERR_INVAL; if(conf__parse_bool(&token, "allow_duplicate_messages", &config->allow_duplicate_messages, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "allow_zero_length_clientid")){ }else if(!strcmp(token, "allow_zero_length_clientid")){
if(conf__parse_bool(&token, "allow_zero_length_clientid", &config->allow_zero_length_clientid, saveptr)) return MOSQ_ERR_INVAL; 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)){ }else if(!strncmp(token, "auth_opt_", 9)){
if(!cur_auth_plugin){ if(!cur_auth_plugin){
log__printf(NULL, MOSQ_LOG_ERR, "Error: An auth_opt_ option exists in the config file without an auth_plugin."); log__printf(NULL, MOSQ_LOG_ERR, "Error: An auth_opt_ option exists in the config file without an auth_plugin.");

@ -240,7 +240,13 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context)
mosquitto__free(client_id); mosquitto__free(client_id);
client_id = NULL; client_id = NULL;
if(clean_session == 0 || db->config->allow_zero_length_clientid == false){ bool allow_zero_length_clientid;
if(db->config->per_listener_settings){
allow_zero_length_clientid = context->listener->security_options.allow_zero_length_clientid;
}else{
allow_zero_length_clientid = db->config->security_options.allow_zero_length_clientid;
}
if(clean_session == 0 || allow_zero_length_clientid == false){
send__connack(context, 0, CONNACK_REFUSED_IDENTIFIER_REJECTED); send__connack(context, 0, CONNACK_REFUSED_IDENTIFIER_REJECTED);
rc = MOSQ_ERR_PROTOCOL; rc = MOSQ_ERR_PROTOCOL;
goto handle_connect_error; goto handle_connect_error;

@ -156,6 +156,7 @@ struct mosquitto__security_options {
struct mosquitto__auth_plugin_config *auth_plugins; struct mosquitto__auth_plugin_config *auth_plugins;
int auth_plugin_count; int auth_plugin_count;
char allow_anonymous; char allow_anonymous;
bool allow_zero_length_clientid;
char *auto_id_prefix; char *auto_id_prefix;
int auto_id_prefix_len; int auto_id_prefix_len;
}; };
@ -199,7 +200,6 @@ struct mosquitto__config {
char *config_file; char *config_file;
char *acl_file; char *acl_file;
bool allow_duplicate_messages; bool allow_duplicate_messages;
bool allow_zero_length_clientid;
int autosave_interval; int autosave_interval;
bool autosave_on_changes; bool autosave_on_changes;
char *clientid_prefixes; char *clientid_prefixes;

Loading…
Cancel
Save