Fix MQTT v5 clients not being able to specify a password without a username.

Thanks to Erik Moqvist.

Closes #1274.
pull/1313/head
Roger A. Light 6 years ago
parent 3e858c19c1
commit 31f448f35a

@ -1081,8 +1081,8 @@ int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg)
}
cfg->will_props = NULL;
if(cfg->username && mosquitto_username_pw_set(mosq, cfg->username, cfg->password)){
err_printf(cfg, "Error: Problem setting username and password.\n");
if((cfg->username || cfg->password) && mosquitto_username_pw_set(mosq, cfg->username, cfg->password)){
err_printf(cfg, "Error: Problem setting username and/or password.\n");
mosquitto_lib_cleanup();
return 1;
}

Loading…
Cancel
Save