Dynsec: Fix loading of clients with no password.

pull/1886/head
Roger A. Light 5 years ago
parent 4b3c76d97a
commit c5fe1fc36b

@ -108,7 +108,7 @@ void dynsec_clients__cleanup(void)
int dynsec_clients__config_load(cJSON *tree) int dynsec_clients__config_load(cJSON *tree)
{ {
cJSON *j_clients, *j_client, *jtmp, *j_roles, *j_role; cJSON *j_clients, *j_client, *jtmp, *j_roles, *j_role;
cJSON *j_salt, *j_password; cJSON *j_salt, *j_password, *j_iterations;
struct dynsec__client *client; struct dynsec__client *client;
struct dynsec__role *role; struct dynsec__role *role;
unsigned char *buf; unsigned char *buf;
@ -152,15 +152,16 @@ int dynsec_clients__config_load(cJSON *tree)
client->disabled = cJSON_IsTrue(jtmp); client->disabled = cJSON_IsTrue(jtmp);
} }
/* Hash iterations */ /* Salt */
jtmp = cJSON_GetObjectItem(j_client, "iterations"); j_salt = cJSON_GetObjectItem(j_client, "salt");
if(jtmp == NULL || !cJSON_IsNumber(jtmp)){ j_password = cJSON_GetObjectItem(j_client, "password");
// FIXME log j_iterations = cJSON_GetObjectItem(j_client, "iterations");
mosquitto_free(client->username);
mosquitto_free(client); if(j_salt && cJSON_IsString(j_salt)
continue; && j_password && cJSON_IsString(j_password)
} && j_iterations && cJSON_IsNumber(j_iterations)){
iterations = (int)jtmp->valuedouble;
iterations = (int)j_iterations->valuedouble;
if(iterations < 1){ if(iterations < 1){
// FIXME log // FIXME log
mosquitto_free(client->username); mosquitto_free(client->username);
@ -170,13 +171,6 @@ int dynsec_clients__config_load(cJSON *tree)
client->pw.iterations = iterations; client->pw.iterations = iterations;
} }
/* Salt */
j_salt = cJSON_GetObjectItem(j_client, "salt");
j_password = cJSON_GetObjectItem(j_client, "password");
if(j_salt && cJSON_IsString(j_salt)
&& j_password && cJSON_IsString(j_password)){
if(dynsec_auth__base64_decode(j_salt->valuestring, &buf, &buf_len) != MOSQ_ERR_SUCCESS if(dynsec_auth__base64_decode(j_salt->valuestring, &buf, &buf_len) != MOSQ_ERR_SUCCESS
|| buf_len != sizeof(client->pw.salt)){ || buf_len != sizeof(client->pw.salt)){

Loading…
Cancel
Save