1
0
mirror of https://github.com/eclipse/mosquitto.git synced 2025-05-09 01:01:11 +08:00

Per listener allow_zero_length_clientid.

This commit is contained in:
Roger A. Light 2018-03-18 21:23:50 +00:00
parent 7271893966
commit 26bc3206cd
5 changed files with 14 additions and 5 deletions

View File

@ -488,6 +488,8 @@
options are affected:</para>
<para><option>password_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_opt_*</option>,
<option>auto_id_prefix</option>.</para>

View File

@ -142,7 +142,7 @@
# affected:
#
# 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
# setting behaviour from previous versions of mosquitto.

View File

@ -152,7 +152,7 @@ static void config__init_reload(struct mosquitto__config *config)
config->acl_file = NULL;
config->security_options.allow_anonymous = -1;
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_len = 0;
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")){
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")){
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)){
if(!cur_auth_plugin){
log__printf(NULL, MOSQ_LOG_ERR, "Error: An auth_opt_ option exists in the config file without an auth_plugin.");

View File

@ -240,7 +240,13 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context)
mosquitto__free(client_id);
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);
rc = MOSQ_ERR_PROTOCOL;
goto handle_connect_error;

View File

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