MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / cib_remote_msg

Function cib_remote_msg

cib/remote.c:409–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407}
408
409int
410cib_remote_msg(gpointer data)
411{
412 const char *value = NULL;
413 xmlNode *command = NULL;
414 cib_client_t *client = data;
415
416 crm_trace("%s callback", client->encrypted ? "secure" : "clear-text");
417
418 command = crm_recv_remote_msg(client->session, client->encrypted);
419 if (command == NULL) {
420 return -1;
421 }
422
423 value = crm_element_name(command);
424 if (safe_str_neq(value, "cib_command")) {
425 crm_log_xml_trace(command, "Bad command: ");
426 goto bail;
427 }
428
429 if (client->name == NULL) {
430 value = crm_element_value(command, F_CLIENTNAME);
431 if (value == NULL) {
432 client->name = strdup(client->id);
433 } else {
434 client->name = strdup(value);
435 }
436 }
437
438 if (client->callback_id == NULL) {
439 value = crm_element_value(command, F_CIB_CALLBACK_TOKEN);
440 if (value != NULL) {
441 client->callback_id = strdup(value);
442 crm_trace("Callback channel for %s is %s", client->id, client->callback_id);
443
444 } else {
445 client->callback_id = strdup(client->id);
446 }
447 }
448
449 /* unset dangerous options */
450 xml_remove_prop(command, F_ORIG);
451 xml_remove_prop(command, F_CIB_HOST);
452 xml_remove_prop(command, F_CIB_GLOBAL_UPDATE);
453
454 crm_xml_add(command, F_TYPE, T_CIB);
455 crm_xml_add(command, F_CIB_CLIENTID, client->id);
456 crm_xml_add(command, F_CIB_CLIENTNAME, client->name);
457#if ENABLE_ACL
458 crm_xml_add(command, F_CIB_USER, client->user);
459#endif
460
461 if (crm_element_value(command, F_CIB_CALLID) == NULL) {
462 char *call_uuid = crm_generate_uuid();
463
464 /* fix the command */
465 crm_xml_add(command, F_CIB_CALLID, call_uuid);
466 free(call_uuid);

Callers

nothing calls this directly

Calls 9

crm_recv_remote_msgFunction · 0.85
safe_str_neqFunction · 0.85
crm_element_valueFunction · 0.85
xml_remove_propFunction · 0.85
crm_xml_addFunction · 0.85
crm_generate_uuidFunction · 0.85
crm_xml_add_intFunction · 0.85
free_xmlFunction · 0.85

Tested by

no test coverage detected