29 #include <sys/types.h> 44 #ifdef HAVE_GNUTLS_GNUTLS_H 46 # include <gnutls/gnutls.h> 49 #include <sys/socket.h> 50 #include <netinet/in.h> 51 #include <netinet/ip.h> 52 #include <arpa/inet.h> 55 #define MAX_TLS_RECV_WAIT 10000 59 static int lrmd_api_disconnect(
lrmd_t * lrmd);
60 static int lrmd_api_is_connected(
lrmd_t * lrmd);
64 static void lrmd_internal_proxy_dispatch(
lrmd_t *lrmd, xmlNode *msg);
67 #ifdef HAVE_GNUTLS_GNUTLS_H 68 # define LRMD_CLIENT_HANDSHAKE_TIMEOUT 5000 69 gnutls_psk_client_credentials_t psk_cred_s;
70 int lrmd_tls_set_key(gnutls_datum_t * key);
71 static void lrmd_tls_disconnect(
lrmd_t * lrmd);
72 static int global_remote_msg_id = 0;
74 static void lrmd_tls_connection_destroy(gpointer userdata);
77 typedef struct lrmd_private_s {
88 char *remote_nodename;
89 #ifdef HAVE_GNUTLS_GNUTLS_H 92 gnutls_psk_client_credentials_t psk_cred_c;
102 int expected_late_replies;
103 GList *pending_notify;
110 void (*proxy_callback)(
lrmd_t *lrmd,
void *userdata, xmlNode *msg);
111 void *proxy_callback_userdata;
116 lrmd_list_add(
lrmd_list_t * head,
const char *value)
121 p->
val = strdup(value);
124 while (end && end->
next) {
143 char *val = (
char *)head->
val;
158 p->
key = strdup(key);
159 p->
value = strdup(value);
162 while (end && end->
next) {
201 copy->
rsc_id =
event->rsc_id ? strdup(event->
rsc_id) : NULL;
204 copy->
output =
event->output ? strdup(event->
output) : NULL;
220 free((
char *)event->
rsc_id);
223 free((
char *)event->
output);
227 g_hash_table_destroy(event->
params);
233 lrmd_dispatch_internal(
lrmd_t * lrmd, xmlNode * msg)
240 if (proxy_session != NULL) {
242 lrmd_internal_proxy_dispatch(lrmd, msg);
244 }
else if (!native->callback) {
246 crm_trace(
"notify event received but client has not set callback");
250 event.remote_nodename = native->remote_nodename;
287 crm_trace(
"op %s notify event received", type);
288 native->callback(&event);
291 g_hash_table_destroy(event.params);
297 lrmd_ipc_dispatch(
const char *buffer, ssize_t length, gpointer userdata)
304 if (!native->callback) {
310 rc = lrmd_dispatch_internal(lrmd, msg);
315 #ifdef HAVE_GNUTLS_GNUTLS_H 317 lrmd_free_xml(gpointer userdata)
323 lrmd_tls_connected(
lrmd_t * lrmd)
327 if (native->remote->tls_session) {
335 lrmd_tls_dispatch(gpointer userdata)
341 int disconnected = 0;
343 if (lrmd_tls_connected(lrmd) == FALSE) {
344 crm_trace(
"tls dispatch triggered after disconnect");
352 if (native->pending_notify) {
355 crm_trace(
"Processing pending notifies");
356 for (iter = native->pending_notify; iter; iter = iter->next) {
357 lrmd_dispatch_internal(lrmd, iter->data);
359 g_list_free_full(native->pending_notify, lrmd_free_xml);
360 native->pending_notify = NULL;
377 lrmd_dispatch_internal(lrmd, xml);
379 if (native->expected_late_replies > 0) {
380 native->expected_late_replies--;
385 crm_err(
"Got outdated reply %d", reply_id);
393 crm_info(
"Server disconnected while reading remote server msg.");
394 lrmd_tls_disconnect(lrmd);
407 switch (native->type) {
411 #ifdef HAVE_GNUTLS_GNUTLS_H 413 if (native->pending_notify) {
420 crm_err(
"Unsupported connection type: %d", native->type);
435 switch (private->type) {
441 lrmd_ipc_dispatch(msg, strlen(msg), lrmd);
445 #ifdef HAVE_GNUTLS_GNUTLS_H 447 lrmd_tls_dispatch(lrmd);
451 crm_err(
"Unsupported connection type: %d", private->type);
454 if (lrmd_api_is_connected(lrmd) == FALSE) {
463 lrmd_create_op(
const char *token,
const char *op, xmlNode *
data,
int timeout,
482 crm_trace(
"Created lrmd %s command with call options %.8lx (%d)",
483 op, (
long)options, options);
488 lrmd_ipc_connection_destroy(gpointer userdata)
493 crm_info(
"IPC connection destroyed");
497 native->source = NULL;
499 if (native->callback) {
502 event.remote_nodename = native->remote_nodename;
503 native->callback(&event);
507 #ifdef HAVE_GNUTLS_GNUTLS_H 509 lrmd_tls_connection_destroy(gpointer userdata)
514 crm_info(
"TLS connection destroyed");
516 if (native->remote->tls_session) {
517 gnutls_bye(*native->remote->tls_session, GNUTLS_SHUT_RDWR);
518 gnutls_deinit(*native->remote->tls_session);
519 gnutls_free(native->remote->tls_session);
521 if (native->psk_cred_c) {
522 gnutls_psk_free_client_credentials(native->psk_cred_c);
527 if (native->process_notify) {
529 native->process_notify = NULL;
531 if (native->pending_notify) {
532 g_list_free_full(native->pending_notify, lrmd_free_xml);
533 native->pending_notify = NULL;
536 free(native->remote->buffer);
537 native->remote->buffer = NULL;
540 native->psk_cred_c = NULL;
541 native->remote->tls_session = NULL;
544 if (native->callback) {
548 native->callback(&event);
562 lrmd_tls_recv_reply(
lrmd_t * lrmd,
int total_timeout,
int expected_reply_id,
int *disconnected)
566 time_t start = time(NULL);
567 const char *msg_type = NULL;
569 int remaining_timeout = 0;
582 if (remaining_timeout) {
583 remaining_timeout = total_timeout - ((time(NULL) - start) * 1000);
585 remaining_timeout = total_timeout;
587 if (remaining_timeout <= 0) {
588 crm_err(
"Never received the expected reply during the timeout period, disconnecting.");
589 *disconnected = TRUE;
596 crm_err(
"Unable to receive expected reply, disconnecting.");
597 *disconnected = TRUE;
599 }
else if (*disconnected) {
610 crm_err(
"Empty msg type received while waiting for reply");
616 native->pending_notify = g_list_append(native->pending_notify, xml);
617 if (native->process_notify) {
624 crm_err(
"Expected a reply, got %s", msg_type);
627 }
else if (reply_id != expected_reply_id) {
628 if (native->expected_late_replies > 0) {
629 native->expected_late_replies--;
631 crm_err(
"Got outdated reply, expected id %d got id %d", expected_reply_id, reply_id);
638 if (native->remote->buffer && native->process_notify) {
646 lrmd_tls_send(
lrmd_t * lrmd, xmlNode * msg)
651 global_remote_msg_id++;
652 if (global_remote_msg_id <= 0) {
653 global_remote_msg_id = 1;
656 rc = lrmd_tls_send_msg(native->remote, msg, global_remote_msg_id,
"request");
658 crm_err(
"Remote lrmd send failed, disconnecting");
659 lrmd_tls_disconnect(lrmd);
666 lrmd_tls_send_recv(
lrmd_t * lrmd, xmlNode * msg,
int timeout, xmlNode ** reply)
669 int disconnected = 0;
672 if (lrmd_tls_connected(lrmd) == FALSE) {
676 rc = lrmd_tls_send(lrmd, msg);
681 xml = lrmd_tls_recv_reply(lrmd, timeout, global_remote_msg_id, &disconnected);
684 crm_err(
"Remote lrmd server disconnected while waiting for reply with id %d. ",
685 global_remote_msg_id);
686 lrmd_tls_disconnect(lrmd);
689 crm_err(
"Remote lrmd never received reply for request id %d. timeout: %dms ",
690 global_remote_msg_id, timeout);
705 lrmd_send_xml(
lrmd_t * lrmd, xmlNode * msg,
int timeout, xmlNode ** reply)
710 switch (native->type) {
714 #ifdef HAVE_GNUTLS_GNUTLS_H 716 rc = lrmd_tls_send_recv(lrmd, msg, timeout, reply);
720 crm_err(
"Unsupported connection type: %d", native->type);
727 lrmd_send_xml_no_reply(
lrmd_t * lrmd, xmlNode * msg)
732 switch (native->type) {
736 #ifdef HAVE_GNUTLS_GNUTLS_H 738 rc = lrmd_tls_send(lrmd, msg);
743 native->expected_late_replies++;
748 crm_err(
"Unsupported connection type: %d", native->type);
755 lrmd_api_is_connected(
lrmd_t * lrmd)
759 switch (native->type) {
763 #ifdef HAVE_GNUTLS_GNUTLS_H 765 return lrmd_tls_connected(lrmd);
769 crm_err(
"Unsupported connection type: %d", native->type);
792 lrmd_send_command(
lrmd_t *lrmd,
const char *op, xmlNode *data,
793 xmlNode **output_data,
int timeout,
798 xmlNode *op_msg = NULL;
799 xmlNode *op_reply = NULL;
801 if (!lrmd_api_is_connected(lrmd)) {
806 crm_err(
"No operation specified");
814 op_msg = lrmd_create_op(native->token, op, data, timeout, options);
816 if (op_msg == NULL) {
821 rc = lrmd_send_xml(lrmd, op_msg, timeout, &op_reply);
823 rc = lrmd_send_xml_no_reply(lrmd, op_msg);
828 crm_perror(LOG_ERR,
"Couldn't perform %s operation (timeout=%d): %d", op, timeout, rc);
832 }
else if(op_reply == NULL) {
847 *output_data = op_reply;
852 if (lrmd_api_is_connected(lrmd) == FALSE) {
862 lrmd_api_poke_connection(
lrmd_t * lrmd)
885 value = g_hash_table_lookup(hash,
"stonith-watchdog-timeout");
895 lrmd_handshake(
lrmd_t * lrmd,
const char *name)
899 xmlNode *reply = NULL;
908 if (native->proxy_callback) {
912 rc = lrmd_send_xml(lrmd, hello, -1, &reply);
915 crm_perror(LOG_DEBUG,
"Couldn't complete registration with the lrmd API: %d", rc);
917 }
else if (reply == NULL) {
918 crm_err(
"Did not receive registration reply");
928 crm_err(
"LRMD protocol mismatch client version %s, server version %s",
933 crm_err(
"Invalid registration message: %s", msg_type);
936 }
else if (tmp_ticket == NULL) {
937 crm_err(
"No registration token provided");
941 crm_trace(
"Obtained registration token: %s", tmp_ticket);
942 native->token = strdup(tmp_ticket);
943 native->peer_version = strdup(version?version:
"1.0");
952 lrmd_api_disconnect(lrmd);
958 lrmd_ipc_connect(
lrmd_t * lrmd,
int *fd)
965 .destroy = lrmd_ipc_connection_destroy
975 }
else if (native->ipc) {
976 crm_perror(LOG_ERR,
"Connection to local resource manager failed");
984 if (native->ipc == NULL) {
985 crm_debug(
"Could not connect to the LRMD API");
992 #ifdef HAVE_GNUTLS_GNUTLS_H 994 copy_gnutls_datum(gnutls_datum_t *dest, gnutls_datum_t *source)
996 dest->data = gnutls_malloc(source->size);
998 memcpy(dest->data, source->data, source->size);
999 dest->size = source->size;
1003 clear_gnutls_datum(gnutls_datum_t *datum)
1005 gnutls_free(datum->data);
1010 #define KEY_READ_LEN 256 1013 set_key(gnutls_datum_t * key,
const char *location)
1016 size_t buf_len = KEY_READ_LEN;
1017 static gnutls_datum_t key_cache = { 0, };
1018 static time_t key_cache_updated = 0;
1020 if (location == NULL) {
1024 if (key_cache.data != NULL) {
1025 if ((time(NULL) - key_cache_updated) < 60) {
1026 copy_gnutls_datum(key, &key_cache);
1027 crm_debug(
"Using cached Pacemaker Remote key");
1030 clear_gnutls_datum(&key_cache);
1031 key_cache_updated = 0;
1032 crm_debug(
"Cleared Pacemaker Remote key cache");
1036 stream = fopen(location,
"r");
1041 key->data = gnutls_malloc(buf_len);
1043 while (!feof(stream)) {
1044 int next = fgetc(stream);
1047 if (!feof(stream)) {
1048 crm_err(
"Error reading Pacemaker Remote key; copy in memory may be corrupted");
1052 if (key->size == buf_len) {
1053 buf_len = key->size + KEY_READ_LEN;
1054 key->data = gnutls_realloc(key->data, buf_len);
1057 key->data[key->size++] = (
unsigned char) next;
1061 if (key->size == 0) {
1062 clear_gnutls_datum(key);
1066 if (key_cache.data == NULL) {
1067 copy_gnutls_datum(&key_cache, key);
1068 key_cache_updated = time(NULL);
1069 crm_debug(
"Cached Pacemaker Remote key");
1076 lrmd_tls_set_key(gnutls_datum_t * key)
1078 const char *specific_location = getenv(
"PCMK_authkey_location");
1080 if (set_key(key, specific_location) == 0) {
1081 crm_debug(
"Using custom authkey location %s", specific_location);
1084 }
else if (specific_location) {
1085 crm_err(
"No valid lrmd remote key found at %s, trying default location", specific_location);
1098 lrmd_gnutls_global_init(
void)
1100 static int gnutls_init = 0;
1103 crm_gnutls_global_init();
1110 report_async_connection_result(
lrmd_t * lrmd,
int rc)
1114 if (native->callback) {
1117 event.remote_nodename = native->remote_nodename;
1118 event.connection_rc = rc;
1119 native->callback(&event);
1123 #ifdef HAVE_GNUTLS_GNUTLS_H 1125 lrmd_tcp_connect_cb(
void *userdata,
int sock)
1132 .destroy = lrmd_tls_connection_destroy,
1135 gnutls_datum_t psk_key = { NULL, 0 };
1137 native->async_timer = 0;
1140 lrmd_tls_connection_destroy(lrmd);
1141 crm_info(
"Could not connect to remote LRMD at %s:%d",
1142 native->server, native->port);
1143 report_async_connection_result(lrmd, rc);
1151 native->sock = sock;
1153 rc = lrmd_tls_set_key(&psk_key);
1155 crm_warn(
"Could not set key for remote LRMD at %s:%d " CRM_XS " rc=%d",
1156 native->server, native->port, rc);
1157 lrmd_tls_connection_destroy(lrmd);
1158 report_async_connection_result(lrmd, rc);
1162 gnutls_psk_allocate_client_credentials(&native->psk_cred_c);
1164 gnutls_free(psk_key.data);
1169 crm_warn(
"Disconnecting after TLS handshake with remote LRMD %s:%d failed",
1170 native->server, native->port);
1171 gnutls_deinit(*native->remote->tls_session);
1172 gnutls_free(native->remote->tls_session);
1173 native->remote->tls_session = NULL;
1174 lrmd_tls_connection_destroy(lrmd);
1179 crm_info(
"TLS connection to remote LRMD %s:%d succeeded",
1180 native->server, native->port);
1186 mainloop_add_fd(name, G_PRIORITY_HIGH, native->sock, lrmd, &lrmd_tls_callbacks);
1188 rc = lrmd_handshake(lrmd, name);
1191 report_async_connection_result(lrmd, rc);
1196 lrmd_tls_connect_async(
lrmd_t * lrmd,
int timeout )
1202 lrmd_gnutls_global_init();
1204 &timer_id, lrmd, lrmd_tcp_connect_cb);
1208 native->sock = sock;
1209 native->async_timer = timer_id;
1214 lrmd_tls_connect(
lrmd_t * lrmd,
int *fd)
1218 .destroy = lrmd_tls_connection_destroy,
1224 gnutls_datum_t psk_key = { NULL, 0 };
1226 lrmd_gnutls_global_init();
1230 crm_warn(
"Could not establish remote lrmd connection to %s", native->server);
1231 lrmd_tls_connection_destroy(lrmd);
1235 native->sock = sock;
1237 rc = lrmd_tls_set_key(&psk_key);
1239 lrmd_tls_connection_destroy(lrmd);
1243 gnutls_psk_allocate_client_credentials(&native->psk_cred_c);
1245 gnutls_free(psk_key.data);
1250 crm_err(
"Session creation for %s:%d failed", native->server, native->port);
1251 gnutls_deinit(*native->remote->tls_session);
1252 gnutls_free(native->remote->tls_session);
1253 native->remote->tls_session = NULL;
1254 lrmd_tls_connection_destroy(lrmd);
1258 crm_info(
"Remote lrmd client TLS connection established with server %s:%d", native->server,
1265 native->server, native->port);
1269 mainloop_add_fd(name, G_PRIORITY_HIGH, native->sock, lrmd, &lrmd_tls_callbacks);
1277 lrmd_api_connect(
lrmd_t * lrmd,
const char *name,
int *fd)
1282 switch (native->type) {
1284 rc = lrmd_ipc_connect(lrmd, fd);
1286 #ifdef HAVE_GNUTLS_GNUTLS_H 1287 case CRM_CLIENT_TLS:
1288 rc = lrmd_tls_connect(lrmd, fd);
1292 crm_err(
"Unsupported connection type: %d", native->type);
1296 rc = lrmd_handshake(lrmd, name);
1303 lrmd_api_connect_async(
lrmd_t * lrmd,
const char *name,
int timeout)
1308 if (!native->callback) {
1309 crm_err(
"Async connect not possible, no lrmd client callback set.");
1313 switch (native->type) {
1317 rc = lrmd_api_connect(lrmd, name, NULL);
1319 report_async_connection_result(lrmd, rc);
1322 #ifdef HAVE_GNUTLS_GNUTLS_H 1323 case CRM_CLIENT_TLS:
1324 rc = lrmd_tls_connect_async(lrmd, timeout);
1327 report_async_connection_result(lrmd, rc);
1332 crm_err(
"Unsupported connection type: %d", native->type);
1339 lrmd_ipc_disconnect(
lrmd_t * lrmd)
1343 if (native->source != NULL) {
1346 native->source = NULL;
1349 }
else if (native->ipc) {
1359 #ifdef HAVE_GNUTLS_GNUTLS_H 1361 lrmd_tls_disconnect(
lrmd_t * lrmd)
1365 if (native->remote->tls_session) {
1366 gnutls_bye(*native->remote->tls_session, GNUTLS_SHUT_RDWR);
1367 gnutls_deinit(*native->remote->tls_session);
1368 gnutls_free(native->remote->tls_session);
1369 native->remote->tls_session = 0;
1372 if (native->async_timer) {
1373 g_source_remove(native->async_timer);
1374 native->async_timer = 0;
1377 if (native->source != NULL) {
1380 native->source = NULL;
1382 }
else if (native->sock) {
1383 close(native->sock);
1387 if (native->pending_notify) {
1388 g_list_free_full(native->pending_notify, lrmd_free_xml);
1389 native->pending_notify = NULL;
1395 lrmd_api_disconnect(
lrmd_t * lrmd)
1399 crm_info(
"Disconnecting from %d lrmd service", native->type);
1400 switch (native->type) {
1402 lrmd_ipc_disconnect(lrmd);
1404 #ifdef HAVE_GNUTLS_GNUTLS_H 1405 case CRM_CLIENT_TLS:
1406 lrmd_tls_disconnect(lrmd);
1410 crm_err(
"Unsupported connection type: %d", native->type);
1413 free(native->token);
1414 native->token = NULL;
1416 free(native->peer_version);
1417 native->peer_version = NULL;
1422 lrmd_api_register_rsc(
lrmd_t * lrmd,
1428 xmlNode *data = NULL;
1430 if (!
class || !type || !rsc_id) {
1444 rc = lrmd_send_command(lrmd,
LRMD_OP_RSC_REG, data, NULL, 0, options, TRUE);
1466 const char *provider,
const char *type)
1472 rsc_info->
id = strdup(rsc_id);
1476 rsc_info->
class = strdup(standard);
1480 rsc_info->
provider = strdup(provider);
1484 rsc_info->
type = strdup(type);
1504 free(rsc_info->
type);
1505 free(rsc_info->
class);
1515 xmlNode *output = NULL;
1516 const char *
class = NULL;
1517 const char *provider = NULL;
1518 const char *type = NULL;
1522 lrmd_send_command(lrmd,
LRMD_OP_RSC_INFO, data, &output, 0, options, TRUE);
1533 if (!
class || !type) {
1551 native->callback = callback;
1559 native->proxy_callback = callback;
1560 native->proxy_callback_userdata = userdata;
1564 lrmd_internal_proxy_dispatch(
lrmd_t *lrmd, xmlNode *msg)
1568 if (native->proxy_callback) {
1570 native->proxy_callback(lrmd, native->proxy_callback_userdata, msg);
1583 return lrmd_send_xml_no_reply(lrmd, msg);
1587 stonith_get_metadata(
const char *provider,
const char *type,
char **output)
1594 stonith_api->
cmds->
free(stonith_api);
1596 if (*output == NULL) {
1603 lrmd_api_get_metadata(
lrmd_t *lrmd,
const char *standard,
const char *provider,
1604 const char *type,
char **output,
1608 output, options, NULL);
1612 lrmd_api_get_metadata_params(
lrmd_t *lrmd,
const char *standard,
1613 const char *provider,
const char *type,
1618 GHashTable *params_table = NULL;
1620 if (!standard || !type) {
1627 return stonith_get_metadata(provider, type, output);
1630 params_table = crm_str_table_new();
1632 g_hash_table_insert(params_table, strdup(param->key), strdup(param->value));
1640 if (action == NULL) {
1641 crm_err(
"Unable to retrieve meta-data for %s:%s:%s",
1642 standard, provider, type);
1647 crm_err(
"Failed to retrieve meta-data for %s:%s:%s",
1648 standard, provider, type);
1654 crm_err(
"Failed to receive meta-data for %s:%s:%s",
1655 standard, provider, type);
1667 lrmd_api_exec(
lrmd_t * lrmd,
const char *rsc_id,
const char *action,
const char *userdata,
int interval,
1685 for (tmp = params; tmp; tmp = tmp->
next) {
1689 rc = lrmd_send_command(lrmd,
LRMD_OP_RSC_EXEC, data, NULL, timeout, options, TRUE);
1698 lrmd_api_exec_alert(
lrmd_t *lrmd,
const char *alert_id,
const char *alert_path,
1711 for (tmp = params; tmp; tmp = tmp->
next) {
1724 lrmd_api_cancel(
lrmd_t * lrmd,
const char *rsc_id,
const char *action,
int interval)
1748 stonith_api->
cmds->
free(stonith_api);
1751 for (dIter = stonith_resources; dIter; dIter = dIter->
next) {
1754 *resources = lrmd_list_add(*resources, dIter->
value);
1763 lrmd_api_list_agents(
lrmd_t * lrmd,
lrmd_list_t ** resources,
const char *
class,
1764 const char *provider)
1769 rc += list_stonith_agents(resources);
1775 for (gIter = agents; gIter != NULL; gIter = gIter->next) {
1776 *resources = lrmd_list_add(*resources, (
const char *)gIter->data);
1779 g_list_free_full(agents, free);
1782 rc += list_stonith_agents(resources);
1787 crm_notice(
"No agents found for class %s",
class);
1788 rc = -EPROTONOSUPPORT;
1794 does_provider_have_agent(
const char *agent,
const char *provider,
const char *
class)
1797 GList *agents = NULL;
1801 for (gIter2 = agents; gIter2 != NULL; gIter2 = gIter2->next) {
1806 g_list_free_full(agents, free);
1812 lrmd_api_list_ocf_providers(
lrmd_t * lrmd,
const char *agent,
lrmd_list_t ** providers)
1815 char *provider = NULL;
1816 GList *ocf_providers = NULL;
1821 for (gIter = ocf_providers; gIter != NULL; gIter = gIter->next) {
1822 provider = gIter->data;
1823 if (!agent || does_provider_have_agent(agent, provider,
1825 *providers = lrmd_list_add(*providers, (
const char *)gIter->data);
1830 g_list_free_full(ocf_providers, free);
1838 GList *standards = NULL;
1843 for (gIter = standards; gIter != NULL; gIter = gIter->next) {
1844 *supported = lrmd_list_add(*supported, (
const char *)gIter->data);
1848 if (list_stonith_agents(NULL) > 0) {
1853 g_list_free_full(standards, free);
1863 new_lrmd = calloc(1,
sizeof(
lrmd_t));
1881 new_lrmd->
cmds->
exec = lrmd_api_exec;
1895 #ifdef HAVE_GNUTLS_GNUTLS_H 1899 if (!nodename && !server) {
1904 native->type = CRM_CLIENT_TLS;
1905 native->remote_nodename = nodename ? strdup(nodename) : strdup(server);
1906 native->server = server ? strdup(server) : strdup(nodename);
1907 native->port = port;
1908 if (native->port == 0) {
1914 crm_err(
"GNUTLS is not enabled for this build, remote LRMD client can not be created");
1931 #ifdef HAVE_GNUTLS_GNUTLS_H 1932 free(native->server);
1934 free(native->remote_nodename);
1935 free(native->remote);
1936 free(native->token);
1937 free(native->peer_version);
#define CRM_CHECK(expr, failure_action)
#define LRMD_OP_ALERT_EXEC
#define CRMD_METADATA_CALL_TIMEOUT
bool crm_ipc_connect(crm_ipc_t *client)
Establish an IPC connection to a Pacemaker component.
#define crm_notice(fmt, args...)
GHashTable * xml2list(xmlNode *parent)
lrmd_event_data_t * lrmd_copy_event(lrmd_event_data_t *event)
gboolean safe_str_neq(const char *a, const char *b)
void services_action_free(svc_action_t *op)
int crm_remote_ready(crm_remote_t *remote, int total_timeout)
gboolean crm_remote_recv(crm_remote_t *remote, int total_timeout, int *disconnected)
mainloop_io_t * mainloop_add_fd(const char *name, int priority, int fd, void *userdata, struct mainloop_fd_callbacks *callbacks)
#define F_LRMD_IS_IPC_PROVIDER
#define F_LRMD_IPC_SESSION
#define F_LRMD_RSC_EXEC_TIME
int(* list_agents)(stonith_t *stonith, int call_options, const char *namespace, stonith_key_value_t **devices, int timeout)
Retrieve a list of installed stonith agents.
#define F_LRMD_RSC_ACTION
#define LRMD_OP_RSC_CANCEL
int crm_ipc_get_fd(crm_ipc_t *client)
#define F_LRMD_RSC_OUTPUT
int(* connect_async)(lrmd_t *lrmd, const char *client_name, int timeout)
Establish an connection to lrmd, don't block while connecting.
void(* lrmd_event_callback)(lrmd_event_data_t *event)
svc_action_t * resources_action_create(const char *name, const char *standard, const char *provider, const char *agent, const char *action, int interval, int timeout, GHashTable *params, enum svc_action_flags flags)
Create a new resource action.
struct stonith_key_value_s * next
void lrmd_key_value_freeall(lrmd_key_value_t *head)
struct mainloop_io_s mainloop_io_t
void mainloop_set_trigger(crm_trigger_t *source)
#define DEFAULT_REMOTE_USERNAME
#define MAX_TLS_RECV_WAIT
int lrmd_internal_proxy_send(lrmd_t *lrmd, xmlNode *msg)
lrmd_rsc_info_t * lrmd_copy_rsc_info(lrmd_rsc_info_t *rsc_info)
#define F_LRMD_ALERT_PATH
long crm_ipc_read(crm_ipc_t *client)
gboolean mainloop_destroy_trigger(crm_trigger_t *source)
int(* cancel)(lrmd_t *lrmd, const char *rsc_id, const char *action, int interval)
Cancel a recurring command.
int crm_remote_tcp_connect(const char *host, int port)
Wrappers for and extensions to glib mainloop.
#define F_LRMD_PROTOCOL_VERSION
lrmd_t * lrmd_remote_api_new(const char *nodename, const char *server, int port)
Create a new remote lrmd connection using tls backend.
stonith_t * stonith_api_new(void)
xmlNode * string2xml(const char *input)
const char * crm_ipc_buffer(crm_ipc_t *client)
int remote_proxy_check(lrmd_t *lrmd, GHashTable *hash)
#define LRMD_OP_RSC_UNREG
#define DEFAULT_REMOTE_KEY_LOCATION
struct trigger_s crm_trigger_t
void hash2smartfield(gpointer key, gpointer value, gpointer user_data)
struct lrmd_private_s lrmd_private_t
int(* free)(stonith_t *st)
Destroy the stonith api structure.
int(* dispatch)(gpointer userdata)
#define crm_warn(fmt, args...)
int(* exec_alert)(lrmd_t *lrmd, const char *alert_id, const char *alert_path, int timeout, lrmd_key_value_t *params)
Execute an alert agent.
int(* poke_connection)(lrmd_t *lrmd)
Poke lrmd connection to verify it is still capable of serving requests.
#define PCMK_RESOURCE_CLASS_OCF
#define crm_debug(fmt, args...)
int crm_initiate_client_tls_handshake(crm_remote_t *remote, int timeout_ms)
struct crm_ipc_s crm_ipc_t
#define F_LRMD_RSC_EXIT_REASON
#define ALT_REMOTE_KEY_LOCATION
bool lrmd_dispatch(lrmd_t *lrmd)
Use after lrmd_poll returns 1 to read and dispatch a message.
struct lrmd_list_s * next
gboolean services_action_sync(svc_action_t *op)
#define LRMD_PROTOCOL_VERSION
xmlNode * crm_remote_parse_buffer(crm_remote_t *remote)
int(* get_metadata)(lrmd_t *lrmd, const char *class, const char *provider, const char *agent, char **output, enum lrmd_call_options options)
Get resource metadata for a specified resource agent.
lrmd_rsc_info_t *(* get_rsc_info)(lrmd_t *lrmd, const char *rsc_id, enum lrmd_call_options options)
Retrieve registration info for a rsc.
void lrmd_list_freeall(lrmd_list_t *head)
int(* connect)(lrmd_t *lrmd, const char *client_name, int *fd)
Connect from the lrmd.
#define crm_trace(fmt, args...)
crm_trigger_t * mainloop_add_trigger(int priority, int(*dispatch)(gpointer user_data), gpointer userdata)
#define LRMD_OP_NEW_CLIENT
xmlNode * create_xml_node(xmlNode *parent, const char *name)
int crm_element_value_int(xmlNode *data, const char *name, int *dest)
const char * crm_element_value(xmlNode *data, const char *name)
void stonith_key_value_freeall(stonith_key_value_t *kvp, int keys, int values)
lrmd_rsc_info_t * lrmd_new_rsc_info(const char *rsc_id, const char *standard, const char *provider, const char *type)
void mainloop_del_ipc_client(mainloop_io_t *client)
void crm_ipc_destroy(crm_ipc_t *client)
GList * resources_list_providers(const char *standard)
Get a list of providers.
lrmd_t * lrmd_api_new(void)
Create a new local lrmd connection.
int(* get_metadata_params)(lrmd_t *lrmd, const char *standard, const char *provider, const char *agent, char **output, enum lrmd_call_options options, lrmd_key_value_t *params)
Get resource metadata for a resource agent, passing parameters.
struct lrmd_key_value_s * next
#define F_LRMD_RSC_USERDATA_STR
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
void free_xml(xmlNode *child)
#define F_LRMD_RSC_INTERVAL
void lrmd_free_rsc_info(lrmd_rsc_info_t *rsc_info)
int crm_remote_tcp_connect_async(const char *host, int port, int timeout, int *timer_id, void *userdata, void(*callback)(void *userdata, int sock))
CRM_TRACE_INIT_DATA(lrmd)
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
int(* unregister_rsc)(lrmd_t *lrmd, const char *rsc_id, enum lrmd_call_options options)
Unregister a resource from the lrmd.
#define F_LRMD_RSC_START_DELAY
int(* disconnect)(lrmd_t *lrmd)
Disconnect from the lrmd.
bool crm_ipc_connected(crm_ipc_t *client)
int lrmd_poll(lrmd_t *lrmd, int timeout)
Poll for a specified timeout period to determine if a message is ready for dispatch.
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
#define PCMK_RESOURCE_CLASS_STONITH
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
int crm_ipc_ready(crm_ipc_t *client)
Check whether an IPC connection is ready to be read.
#define F_LRMD_RSC_RCCHANGE_TIME
int(* list_agents)(lrmd_t *lrmd, lrmd_list_t **agents, const char *class, const char *provider)
Retrieve a list of installed resource agents.
#define crm_log_xml_err(xml, text)
void lrmd_api_delete(lrmd_t *lrmd)
Destroy lrmd object.
#define F_LRMD_REMOTE_MSG_ID
#define crm_perror(level, fmt, args...)
Log a system error message.
const char * remote_nodename
lrmd_api_operations_t * cmds
crm_ipc_t * mainloop_get_ipc_client(mainloop_io_t *client)
GList * resources_list_standards(void)
#define crm_err(fmt, args...)
enum lrmd_callback_event type
lrmd_key_value_t * lrmd_key_value_add(lrmd_key_value_t *head, const char *key, const char *value)
stonith_api_operations_t * cmds
int crm_ipc_send(crm_ipc_t *client, xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
GHashTable * crm_str_table_dup(GHashTable *old_table)
int(* list_standards)(lrmd_t *lrmd, lrmd_list_t **standards)
Retrieve a list of standards supported by this machine/installation.
#define CRMD_ACTION_METADATA
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
GList * resources_list_agents(const char *standard, const char *provider)
Get a list of resource agents.
void * create_psk_tls_session(int csock, int type, void *credentials)
#define F_LRMD_RSC_RUN_TIME
int(* register_rsc)(lrmd_t *lrmd, const char *rsc_id, const char *class, const char *provider, const char *agent, enum lrmd_call_options options)
Register a resource with the lrmd.
int(* list_ocf_providers)(lrmd_t *lrmd, const char *agent, lrmd_list_t **providers)
Retrieve a list of resource agent providers.
void lrmd_internal_set_proxy_callback(lrmd_t *lrmd, void *userdata, void(*callback)(lrmd_t *lrmd, void *userdata, xmlNode *msg))
#define crm_log_xml_trace(xml, text)
bool crm_provider_required(const char *standard)
Check whether a resource standard requires a provider to be specified.
#define F_LRMD_CLIENTNAME
mainloop_io_t * mainloop_add_ipc_client(const char *name, int priority, size_t max_size, void *userdata, struct ipc_client_callbacks *callbacks)
#define F_LRMD_RSC_QUEUE_TIME
#define F_LRMD_RSC_DELETED
#define safe_str_eq(a, b)
#define F_LRMD_CALLBACK_TOKEN
int(* metadata)(stonith_t *st, int options, const char *device, const char *namespace, char **output, int timeout)
Get the metadata documentation for a resource.
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
void lrmd_free_event(lrmd_event_data_t *event)
#define F_LRMD_REMOTE_MSG_TYPE
void crm_ipc_close(crm_ipc_t *client)
int crm_remote_send(crm_remote_t *remote, xmlNode *msg)
#define crm_info(fmt, args...)
int(* is_connected)(lrmd_t *lrmd)
Is connected to lrmd daemon?
int(* dispatch)(const char *buffer, ssize_t length, gpointer userdata)
int crm_default_remote_port(void)
Get the default remote connection TCP port on this host.
void(* set_callback)(lrmd_t *lrmd, lrmd_event_callback callback)
Sets the callback to receive lrmd events on.
enum crm_ais_msg_types type
int(* exec)(lrmd_t *lrmd, const char *rsc_id, const char *action, const char *userdata, int interval, int timeout, int start_delay, enum lrmd_call_options options, lrmd_key_value_t *params)
Issue a command on a resource.