dynsec: Consistent behaviour when setting clientid.

pull/1919/head
Roger A. Light 5 years ago
parent 047c09bd32
commit d8775b7d9c

@ -697,12 +697,16 @@ int dynsec_clients__process_modify(cJSON *j_responses, struct mosquitto *context
} }
if(json_get_string(command, "clientid", &clientid, false) == MOSQ_ERR_SUCCESS){ if(json_get_string(command, "clientid", &clientid, false) == MOSQ_ERR_SUCCESS){
str = mosquitto_strdup(clientid); if(clientid && strlen(clientid) > 0){
if(str == NULL){ str = mosquitto_strdup(clientid);
dynsec__command_reply(j_responses, context, "modifyClient", "Internal error", correlation_data); if(str == NULL){
return MOSQ_ERR_NOMEM; dynsec__command_reply(j_responses, context, "modifyClient", "Internal error", correlation_data);
return MOSQ_ERR_NOMEM;
}
mosquitto_free(client->clientid);
}else{
str = NULL;
} }
mosquitto_free(client->clientid);
client->clientid = str; client->clientid = str;
} }

@ -50,9 +50,9 @@ list_clients_verbose_response = {'responses':[{"command": "listClients", "data":
get_client_command = { "commands": [{ get_client_command = { "commands": [{
"command": "getClient", "username": "user_one"}]} "command": "getClient", "username": "user_one", "correlationData": "42"}]}
get_client_response = {'responses':[{'command': 'getClient', 'data': {'client': {'username': 'user_one', 'clientid': 'cid', get_client_response = {'responses':[{'command': 'getClient', 'data': {'client': {'username': 'user_one', 'clientid': 'cid',
'textname': 'Name', 'textdescription': 'Description', 'groups': [], 'roles': []}}}]} 'textname': 'Name', 'textdescription': 'Description', 'groups': [], 'roles': []}}, "correlationData":"42"}]}
set_client_password_command = {"commands": [{ set_client_password_command = {"commands": [{
"command": "setClientPassword", "username": "user_one", "password": "password"}]} "command": "setClientPassword", "username": "user_one", "password": "password"}]}

@ -80,6 +80,7 @@ create_roles_response = {'responses': [
modify_client_command1 = { "commands": [{ modify_client_command1 = { "commands": [{
"command": "modifyClient", "username": "user_one", "command": "modifyClient", "username": "user_one",
"textname": "Modified name", "textdescription": "Modified description", "textname": "Modified name", "textdescription": "Modified description",
"clientid": "",
"roles":[ "roles":[
{'rolename':'role_one', 'priority':2}, {'rolename':'role_one', 'priority':2},
{'rolename':'role_two'}, {'rolename':'role_two'},
@ -112,7 +113,7 @@ get_client_response1 = {'responses':[{'command': 'getClient', 'data': {'client':
get_client_command2 = { "commands": [{ get_client_command2 = { "commands": [{
"command": "getClient", "username": "user_one"}]} "command": "getClient", "username": "user_one"}]}
get_client_response2 = {'responses':[{'command': 'getClient', 'data': {'client': {'username': 'user_one', 'clientid': 'cid', get_client_response2 = {'responses':[{'command': 'getClient', 'data': {'client': {'username': 'user_one',
'textname': 'Modified name', 'textdescription': 'Modified description', 'textname': 'Modified name', 'textdescription': 'Modified description',
'roles': [ 'roles': [
{'rolename':'role_three', 'priority':10}, {'rolename':'role_three', 'priority':10},
@ -126,7 +127,7 @@ get_client_response2 = {'responses':[{'command': 'getClient', 'data': {'client':
get_client_command3 = { "commands": [{ get_client_command3 = { "commands": [{
"command": "getClient", "username": "user_one"}]} "command": "getClient", "username": "user_one"}]}
get_client_response3 = {'responses':[{'command': 'getClient', 'data': {'client': {'username': 'user_one', 'clientid': 'cid', get_client_response3 = {'responses':[{'command': 'getClient', 'data': {'client': {'username': 'user_one',
'textname': 'Modified name', 'textdescription': 'Modified description', 'textname': 'Modified name', 'textdescription': 'Modified description',
'groups': [], 'groups': [],
'roles': [ 'roles': [

Loading…
Cancel
Save