17 #include <sys/types.h>
33 #ifdef HAVE_GNUTLS_GNUTLS_H
35 # include <gnutls/gnutls.h>
38 #include <sys/socket.h>
39 #include <netinet/in.h>
40 #include <netinet/ip.h>
41 #include <arpa/inet.h>
44 #define MAX_TLS_RECV_WAIT 10000
48 static int lrmd_api_disconnect(
lrmd_t * lrmd);
49 static int lrmd_api_is_connected(
lrmd_t * lrmd);
53 static void lrmd_internal_proxy_dispatch(
lrmd_t *lrmd, xmlNode *msg);
56 #ifdef HAVE_GNUTLS_GNUTLS_H
57 # define LRMD_CLIENT_HANDSHAKE_TIMEOUT 5000
58 gnutls_psk_client_credentials_t psk_cred_s;
59 int lrmd_tls_set_key(gnutls_datum_t * key);
60 static void lrmd_tls_disconnect(
lrmd_t * lrmd);
61 static int global_remote_msg_id = 0;
63 static void lrmd_tls_connection_destroy(gpointer userdata);
66 typedef struct lrmd_private_s {
77 char *remote_nodename;
78 #ifdef HAVE_GNUTLS_GNUTLS_H
81 gnutls_psk_client_credentials_t psk_cred_c;
91 int expected_late_replies;
92 GList *pending_notify;
99 void (*proxy_callback)(
lrmd_t *lrmd,
void *userdata, xmlNode *msg);
100 void *proxy_callback_userdata;
105 lrmd_list_add(
lrmd_list_t * head,
const char *value)
110 p->
val = strdup(value);
113 while (end && end->
next) {
132 char *val = (
char *)head->
val;
147 p->
key = strdup(key);
148 p->
value = strdup(value);
151 while (end && end->
next) {
190 copy->
rsc_id =
event->rsc_id ? strdup(event->
rsc_id) : NULL;
193 copy->
output =
event->output ? strdup(event->
output) : NULL;
209 free((
char *)event->
rsc_id);
212 free((
char *)event->
output);
216 g_hash_table_destroy(event->
params);
222 lrmd_dispatch_internal(
lrmd_t * lrmd, xmlNode * msg)
229 if (proxy_session != NULL) {
231 lrmd_internal_proxy_dispatch(lrmd, msg);
233 }
else if (!native->callback) {
235 crm_trace(
"notify event received but client has not set callback");
239 event.remote_nodename = native->remote_nodename;
259 event.t_run = (
unsigned int) epoch;
262 event.t_rcchange = (
unsigned int) epoch;
283 native->callback(&event);
286 g_hash_table_destroy(event.params);
292 lrmd_ipc_dispatch(
const char *buffer, ssize_t length, gpointer userdata)
299 if (!native->callback) {
305 rc = lrmd_dispatch_internal(lrmd, msg);
310 #ifdef HAVE_GNUTLS_GNUTLS_H
312 lrmd_free_xml(gpointer userdata)
318 lrmd_tls_connected(
lrmd_t * lrmd)
322 if (native->remote->tls_session) {
330 lrmd_tls_dispatch(gpointer userdata)
336 int disconnected = 0;
338 if (lrmd_tls_connected(lrmd) == FALSE) {
339 crm_trace(
"TLS dispatch triggered after disconnect");
347 if (native->pending_notify) {
350 crm_trace(
"Processing pending notifies");
351 for (iter = native->pending_notify; iter; iter = iter->next) {
352 lrmd_dispatch_internal(lrmd, iter->data);
354 g_list_free_full(native->pending_notify, lrmd_free_xml);
355 native->pending_notify = NULL;
372 lrmd_dispatch_internal(lrmd, xml);
374 if (native->expected_late_replies > 0) {
375 native->expected_late_replies--;
380 crm_err(
"Got outdated Pacemaker Remote reply %d", reply_id);
388 crm_info(
"Lost %s executor connection while reading data",
389 (native->remote_nodename? native->remote_nodename :
"local"));
390 lrmd_tls_disconnect(lrmd);
403 switch (native->type) {
407 #ifdef HAVE_GNUTLS_GNUTLS_H
409 if (native->pending_notify) {
416 crm_err(
"Unsupported connection type: %d", native->type);
431 switch (private->type) {
437 lrmd_ipc_dispatch(msg, strlen(msg), lrmd);
441 #ifdef HAVE_GNUTLS_GNUTLS_H
443 lrmd_tls_dispatch(lrmd);
447 crm_err(
"Unsupported connection type: %d", private->type);
450 if (lrmd_api_is_connected(lrmd) == FALSE) {
459 lrmd_create_op(
const char *token,
const char *op, xmlNode *
data,
int timeout,
478 crm_trace(
"Created executor %s command with call options %.8lx (%d)",
479 op, (
long)options, options);
484 lrmd_ipc_connection_destroy(gpointer userdata)
489 crm_info(
"IPC connection destroyed");
493 native->source = NULL;
495 if (native->callback) {
498 event.remote_nodename = native->remote_nodename;
499 native->callback(&event);
503 #ifdef HAVE_GNUTLS_GNUTLS_H
505 lrmd_tls_connection_destroy(gpointer userdata)
510 crm_info(
"TLS connection destroyed");
512 if (native->remote->tls_session) {
513 gnutls_bye(*native->remote->tls_session, GNUTLS_SHUT_RDWR);
514 gnutls_deinit(*native->remote->tls_session);
515 gnutls_free(native->remote->tls_session);
517 if (native->psk_cred_c) {
518 gnutls_psk_free_client_credentials(native->psk_cred_c);
523 if (native->process_notify) {
525 native->process_notify = NULL;
527 if (native->pending_notify) {
528 g_list_free_full(native->pending_notify, lrmd_free_xml);
529 native->pending_notify = NULL;
532 free(native->remote->buffer);
533 native->remote->buffer = NULL;
536 native->psk_cred_c = NULL;
537 native->remote->tls_session = NULL;
540 if (native->callback) {
544 native->callback(&event);
558 lrmd_tls_recv_reply(
lrmd_t * lrmd,
int total_timeout,
int expected_reply_id,
int *disconnected)
562 time_t start = time(NULL);
563 const char *msg_type = NULL;
565 int remaining_timeout = 0;
578 if (remaining_timeout) {
579 remaining_timeout = total_timeout - ((time(NULL) - start) * 1000);
581 remaining_timeout = total_timeout;
583 if (remaining_timeout <= 0) {
584 crm_err(
"Never received the expected reply during the timeout period, disconnecting.");
585 *disconnected = TRUE;
592 crm_err(
"Unable to receive expected reply, disconnecting.");
593 *disconnected = TRUE;
595 }
else if (*disconnected) {
606 crm_err(
"Empty msg type received while waiting for reply");
612 native->pending_notify = g_list_append(native->pending_notify, xml);
613 if (native->process_notify) {
620 crm_err(
"Expected a reply, got %s", msg_type);
623 }
else if (reply_id != expected_reply_id) {
624 if (native->expected_late_replies > 0) {
625 native->expected_late_replies--;
627 crm_err(
"Got outdated reply, expected id %d got id %d", expected_reply_id, reply_id);
634 if (native->remote->buffer && native->process_notify) {
642 lrmd_tls_send(
lrmd_t * lrmd, xmlNode * msg)
647 global_remote_msg_id++;
648 if (global_remote_msg_id <= 0) {
649 global_remote_msg_id = 1;
654 crm_err(
"Disconnecting because TLS message could not be sent to Pacemaker Remote");
655 lrmd_tls_disconnect(lrmd);
662 lrmd_tls_send_recv(
lrmd_t * lrmd, xmlNode * msg,
int timeout, xmlNode ** reply)
665 int disconnected = 0;
668 if (lrmd_tls_connected(lrmd) == FALSE) {
672 rc = lrmd_tls_send(lrmd, msg);
677 xml = lrmd_tls_recv_reply(lrmd, timeout, global_remote_msg_id, &disconnected);
680 crm_err(
"Pacemaker Remote disconnected while waiting for reply to request id %d",
681 global_remote_msg_id);
682 lrmd_tls_disconnect(lrmd);
685 crm_err(
"Did not receive reply from Pacemaker Remote for request id %d (timeout %dms)",
686 global_remote_msg_id, timeout);
701 lrmd_send_xml(
lrmd_t * lrmd, xmlNode * msg,
int timeout, xmlNode ** reply)
706 switch (native->type) {
710 #ifdef HAVE_GNUTLS_GNUTLS_H
712 rc = lrmd_tls_send_recv(lrmd, msg, timeout, reply);
716 crm_err(
"Unsupported connection type: %d", native->type);
723 lrmd_send_xml_no_reply(
lrmd_t * lrmd, xmlNode * msg)
728 switch (native->type) {
732 #ifdef HAVE_GNUTLS_GNUTLS_H
734 rc = lrmd_tls_send(lrmd, msg);
739 native->expected_late_replies++;
744 crm_err(
"Unsupported connection type: %d", native->type);
751 lrmd_api_is_connected(
lrmd_t * lrmd)
755 switch (native->type) {
759 #ifdef HAVE_GNUTLS_GNUTLS_H
761 return lrmd_tls_connected(lrmd);
765 crm_err(
"Unsupported connection type: %d", native->type);
790 lrmd_send_command(
lrmd_t *lrmd,
const char *op, xmlNode *
data,
791 xmlNode **output_data,
int timeout,
796 xmlNode *op_msg = NULL;
797 xmlNode *op_reply = NULL;
799 if (!lrmd_api_is_connected(lrmd)) {
804 crm_err(
"No operation specified");
810 crm_trace(
"Sending %s op to executor", op);
812 op_msg = lrmd_create_op(native->token, op,
data, timeout, options);
814 if (op_msg == NULL) {
819 rc = lrmd_send_xml(lrmd, op_msg, timeout, &op_reply);
821 rc = lrmd_send_xml_no_reply(lrmd, op_msg);
826 crm_perror(LOG_ERR,
"Couldn't perform %s operation (timeout=%d): %d", op, timeout, rc);
830 }
else if(op_reply == NULL) {
845 *output_data = op_reply;
850 if (lrmd_api_is_connected(lrmd) == FALSE) {
851 crm_err(
"Executor disconnected");
860 lrmd_api_poke_connection(
lrmd_t * lrmd)
883 value = g_hash_table_lookup(hash,
"stonith-watchdog-timeout");
893 lrmd_handshake(
lrmd_t * lrmd,
const char *name)
897 xmlNode *reply = NULL;
906 if (native->proxy_callback) {
910 rc = lrmd_send_xml(lrmd, hello, -1, &reply);
913 crm_perror(LOG_DEBUG,
"Couldn't complete registration with the executor API: %d", rc);
915 }
else if (reply == NULL) {
916 crm_err(
"Did not receive registration reply");
926 crm_err(
"Executor protocol version mismatch between client (%s) and server (%s)",
931 crm_err(
"Invalid registration message: %s", msg_type);
934 }
else if (tmp_ticket == NULL) {
935 crm_err(
"No registration token provided");
939 crm_trace(
"Obtained registration token: %s", tmp_ticket);
940 native->token = strdup(tmp_ticket);
950 lrmd_api_disconnect(lrmd);
956 lrmd_ipc_connect(
lrmd_t * lrmd,
int *fd)
963 .destroy = lrmd_ipc_connection_destroy
973 }
else if (native->ipc) {
974 crm_perror(LOG_ERR,
"Connection to executor failed");
982 if (native->ipc == NULL) {
983 crm_debug(
"Could not connect to the executor API");
990 #ifdef HAVE_GNUTLS_GNUTLS_H
992 copy_gnutls_datum(gnutls_datum_t *dest, gnutls_datum_t *source)
994 dest->data = gnutls_malloc(source->size);
996 memcpy(dest->data, source->data, source->size);
997 dest->size = source->size;
1001 clear_gnutls_datum(gnutls_datum_t *datum)
1003 gnutls_free(datum->data);
1008 #define KEY_READ_LEN 256
1011 set_key(gnutls_datum_t * key,
const char *location)
1014 size_t buf_len = KEY_READ_LEN;
1015 static gnutls_datum_t key_cache = { 0, };
1016 static time_t key_cache_updated = 0;
1018 if (location == NULL) {
1022 if (key_cache.data != NULL) {
1023 if ((time(NULL) - key_cache_updated) < 60) {
1024 copy_gnutls_datum(key, &key_cache);
1025 crm_debug(
"Using cached Pacemaker Remote key");
1028 clear_gnutls_datum(&key_cache);
1029 key_cache_updated = 0;
1030 crm_debug(
"Cleared Pacemaker Remote key cache");
1034 stream = fopen(location,
"r");
1039 key->data = gnutls_malloc(buf_len);
1041 while (!feof(stream)) {
1042 int next = fgetc(stream);
1045 if (!feof(stream)) {
1046 crm_err(
"Error reading Pacemaker Remote key; copy in memory may be corrupted");
1050 if (key->size == buf_len) {
1051 buf_len = key->size + KEY_READ_LEN;
1052 key->data = gnutls_realloc(key->data, buf_len);
1055 key->data[key->size++] = (
unsigned char) next;
1059 if (key->size == 0) {
1060 clear_gnutls_datum(key);
1064 if (key_cache.data == NULL) {
1065 copy_gnutls_datum(&key_cache, key);
1066 key_cache_updated = time(NULL);
1067 crm_debug(
"Cached Pacemaker Remote key");
1074 lrmd_tls_set_key(gnutls_datum_t * key)
1076 const char *specific_location = getenv(
"PCMK_authkey_location");
1078 if (set_key(key, specific_location) == 0) {
1079 crm_debug(
"Using custom authkey location %s", specific_location);
1082 }
else if (specific_location) {
1083 crm_err(
"No valid Pacemaker Remote key found at %s, trying default location", specific_location);
1096 lrmd_gnutls_global_init(
void)
1098 static int gnutls_init = 0;
1101 crm_gnutls_global_init();
1108 report_async_connection_result(
lrmd_t * lrmd,
int rc)
1112 if (native->callback) {
1115 event.remote_nodename = native->remote_nodename;
1116 event.connection_rc = rc;
1117 native->callback(&event);
1121 #ifdef HAVE_GNUTLS_GNUTLS_H
1123 lrmd_tcp_connect_cb(
void *userdata,
int sock)
1130 .destroy = lrmd_tls_connection_destroy,
1133 gnutls_datum_t psk_key = { NULL, 0 };
1135 native->async_timer = 0;
1138 lrmd_tls_connection_destroy(lrmd);
1139 crm_info(
"Could not connect to Pacemaker Remote at %s:%d",
1140 native->server, native->port);
1141 report_async_connection_result(lrmd, rc);
1149 native->sock = sock;
1151 rc = lrmd_tls_set_key(&psk_key);
1153 crm_warn(
"Could not set key for Pacemaker Remote at %s:%d " CRM_XS " rc=%d",
1154 native->server, native->port, rc);
1155 lrmd_tls_connection_destroy(lrmd);
1156 report_async_connection_result(lrmd, rc);
1160 gnutls_psk_allocate_client_credentials(&native->psk_cred_c);
1162 gnutls_free(psk_key.data);
1164 native->remote->tls_session = pcmk__new_tls_session(sock, GNUTLS_CLIENT,
1166 native->psk_cred_c);
1167 if (native->remote->tls_session == NULL) {
1168 lrmd_tls_connection_destroy(lrmd);
1169 report_async_connection_result(lrmd, -EPROTO);
1173 if (crm_initiate_client_tls_handshake(native->remote, LRMD_CLIENT_HANDSHAKE_TIMEOUT) != 0) {
1174 crm_warn(
"Disconnecting after TLS handshake with Pacemaker Remote server %s:%d failed",
1175 native->server, native->port);
1176 gnutls_deinit(*native->remote->tls_session);
1177 gnutls_free(native->remote->tls_session);
1178 native->remote->tls_session = NULL;
1179 lrmd_tls_connection_destroy(lrmd);
1184 crm_info(
"TLS connection to Pacemaker Remote server %s:%d succeeded",
1185 native->server, native->port);
1188 native->server, native->port);
1192 mainloop_add_fd(name, G_PRIORITY_HIGH, native->sock, lrmd, &lrmd_tls_callbacks);
1194 rc = lrmd_handshake(lrmd, name);
1197 report_async_connection_result(lrmd, rc);
1202 lrmd_tls_connect_async(
lrmd_t * lrmd,
int timeout )
1208 lrmd_gnutls_global_init();
1210 &timer_id, lrmd, lrmd_tcp_connect_cb);
1214 native->sock = sock;
1215 native->async_timer = timer_id;
1220 lrmd_tls_connect(
lrmd_t * lrmd,
int *fd)
1224 .destroy = lrmd_tls_connection_destroy,
1230 gnutls_datum_t psk_key = { NULL, 0 };
1232 lrmd_gnutls_global_init();
1236 crm_warn(
"Could not establish Pacemaker Remote connection to %s", native->server);
1237 lrmd_tls_connection_destroy(lrmd);
1241 native->sock = sock;
1243 rc = lrmd_tls_set_key(&psk_key);
1245 lrmd_tls_connection_destroy(lrmd);
1249 gnutls_psk_allocate_client_credentials(&native->psk_cred_c);
1251 gnutls_free(psk_key.data);
1253 native->remote->tls_session = pcmk__new_tls_session(sock, GNUTLS_CLIENT,
1255 native->psk_cred_c);
1256 if (native->remote->tls_session == NULL) {
1257 lrmd_tls_connection_destroy(lrmd);
1261 if (crm_initiate_client_tls_handshake(native->remote, LRMD_CLIENT_HANDSHAKE_TIMEOUT) != 0) {
1262 crm_err(
"Session creation for %s:%d failed", native->server, native->port);
1263 gnutls_deinit(*native->remote->tls_session);
1264 gnutls_free(native->remote->tls_session);
1265 native->remote->tls_session = NULL;
1266 lrmd_tls_connection_destroy(lrmd);
1270 crm_info(
"Client TLS connection established with Pacemaker Remote server %s:%d", native->server,
1277 native->server, native->port);
1281 mainloop_add_fd(name, G_PRIORITY_HIGH, native->sock, lrmd, &lrmd_tls_callbacks);
1289 lrmd_api_connect(
lrmd_t * lrmd,
const char *name,
int *fd)
1294 switch (native->type) {
1296 rc = lrmd_ipc_connect(lrmd, fd);
1298 #ifdef HAVE_GNUTLS_GNUTLS_H
1299 case CRM_CLIENT_TLS:
1300 rc = lrmd_tls_connect(lrmd, fd);
1304 crm_err(
"Unsupported connection type: %d", native->type);
1308 rc = lrmd_handshake(lrmd, name);
1315 lrmd_api_connect_async(
lrmd_t * lrmd,
const char *name,
int timeout)
1320 CRM_CHECK(native && native->callback,
return -1);
1322 switch (native->type) {
1326 rc = lrmd_api_connect(lrmd, name, NULL);
1328 report_async_connection_result(lrmd, rc);
1331 #ifdef HAVE_GNUTLS_GNUTLS_H
1332 case CRM_CLIENT_TLS:
1333 rc = lrmd_tls_connect_async(lrmd, timeout);
1336 report_async_connection_result(lrmd, rc);
1341 crm_err(
"Unsupported connection type: %d", native->type);
1348 lrmd_ipc_disconnect(
lrmd_t * lrmd)
1352 if (native->source != NULL) {
1355 native->source = NULL;
1358 }
else if (native->ipc) {
1368 #ifdef HAVE_GNUTLS_GNUTLS_H
1370 lrmd_tls_disconnect(
lrmd_t * lrmd)
1374 if (native->remote->tls_session) {
1375 gnutls_bye(*native->remote->tls_session, GNUTLS_SHUT_RDWR);
1376 gnutls_deinit(*native->remote->tls_session);
1377 gnutls_free(native->remote->tls_session);
1378 native->remote->tls_session = 0;
1381 if (native->async_timer) {
1382 g_source_remove(native->async_timer);
1383 native->async_timer = 0;
1386 if (native->source != NULL) {
1389 native->source = NULL;
1391 }
else if (native->sock) {
1392 close(native->sock);
1396 if (native->pending_notify) {
1397 g_list_free_full(native->pending_notify, lrmd_free_xml);
1398 native->pending_notify = NULL;
1404 lrmd_api_disconnect(
lrmd_t * lrmd)
1408 crm_info(
"Disconnecting %s %s executor connection",
1410 (native->remote_nodename? native->remote_nodename :
"local"));
1411 switch (native->type) {
1413 lrmd_ipc_disconnect(lrmd);
1415 #ifdef HAVE_GNUTLS_GNUTLS_H
1416 case CRM_CLIENT_TLS:
1417 lrmd_tls_disconnect(lrmd);
1421 crm_err(
"Unsupported connection type: %d", native->type);
1424 free(native->token);
1425 native->token = NULL;
1427 free(native->peer_version);
1428 native->peer_version = NULL;
1433 lrmd_api_register_rsc(
lrmd_t * lrmd,
1439 xmlNode *
data = NULL;
1441 if (!
class || !
type || !rsc_id) {
1477 const char *provider,
const char *
type)
1483 rsc_info->
id = strdup(rsc_id);
1487 rsc_info->
standard = strdup(standard);
1491 rsc_info->
provider = strdup(provider);
1515 free(rsc_info->
type);
1526 xmlNode *output = NULL;
1527 const char *
class = NULL;
1528 const char *provider = NULL;
1529 const char *
type = NULL;
1544 if (!
class || !
type) {
1571 lrmd_api_get_recurring_ops(
lrmd_t *lrmd,
const char *rsc_id,
int timeout_ms,
1574 xmlNode *
data = NULL;
1575 xmlNode *output_xml = NULL;
1578 if (output == NULL) {
1590 timeout_ms, options, TRUE);
1596 if ((rc !=
pcmk_ok) || (output_xml == NULL)) {
1603 if (rsc_id == NULL) {
1604 crm_err(
"Could not parse recurring operation information from executor");
1613 op_info->
rsc_id = strdup(rsc_id);
1619 *output = g_list_prepend(*output, op_info);
1632 native->callback = callback;
1640 native->proxy_callback = callback;
1641 native->proxy_callback_userdata = userdata;
1645 lrmd_internal_proxy_dispatch(
lrmd_t *lrmd, xmlNode *msg)
1649 if (native->proxy_callback) {
1651 native->proxy_callback(lrmd, native->proxy_callback_userdata, msg);
1664 return lrmd_send_xml_no_reply(lrmd, msg);
1668 stonith_get_metadata(
const char *provider,
const char *
type,
char **output)
1673 if (stonith_api == NULL) {
1674 crm_err(
"Could not get fence agent meta-data: API memory allocation failed");
1679 provider, output, 0);
1680 if ((rc ==
pcmk_ok) && (*output == NULL)) {
1683 stonith_api->
cmds->
free(stonith_api);
1688 lrmd_api_get_metadata(
lrmd_t *lrmd,
const char *standard,
const char *provider,
1689 const char *
type,
char **output,
1693 output, options, NULL);
1697 lrmd_api_get_metadata_params(
lrmd_t *lrmd,
const char *standard,
1698 const char *provider,
const char *
type,
1703 GHashTable *params_table = NULL;
1705 if (!standard || !
type) {
1712 return stonith_get_metadata(provider,
type, output);
1715 params_table = crm_str_table_new();
1717 g_hash_table_insert(params_table, strdup(param->key), strdup(param->value));
1725 if (action == NULL) {
1726 crm_err(
"Unable to retrieve meta-data for %s:%s:%s",
1727 standard, provider,
type);
1732 crm_err(
"Failed to retrieve meta-data for %s:%s:%s",
1733 standard, provider,
type);
1739 crm_err(
"Failed to receive meta-data for %s:%s:%s",
1740 standard, provider,
type);
1752 lrmd_api_exec(
lrmd_t *lrmd,
const char *rsc_id,
const char *action,
1753 const char *userdata, guint interval_ms,
1771 for (tmp = params; tmp; tmp = tmp->
next) {
1784 lrmd_api_exec_alert(
lrmd_t *lrmd,
const char *alert_id,
const char *alert_path,
1797 for (tmp = params; tmp; tmp = tmp->
next) {
1810 lrmd_api_cancel(
lrmd_t *lrmd,
const char *rsc_id,
const char *action,
1833 if (stonith_api == NULL) {
1834 crm_err(
"Could not list fence agents: API memory allocation failed");
1838 &stonith_resources, 0);
1839 stonith_api->
cmds->
free(stonith_api);
1841 for (dIter = stonith_resources; dIter; dIter = dIter->
next) {
1844 *resources = lrmd_list_add(*resources, dIter->
value);
1853 lrmd_api_list_agents(
lrmd_t * lrmd,
lrmd_list_t ** resources,
const char *
class,
1854 const char *provider)
1857 int stonith_count = 0;
1866 for (gIter = agents; gIter != NULL; gIter = gIter->next) {
1867 *resources = lrmd_list_add(*resources, (
const char *)gIter->data);
1870 g_list_free_full(agents, free);
1877 if (stonith_count) {
1879 stonith_count = list_stonith_agents(resources);
1880 if (stonith_count > 0) {
1881 rc += stonith_count;
1885 crm_notice(
"No agents found for class %s",
class);
1886 rc = -EPROTONOSUPPORT;
1892 does_provider_have_agent(
const char *agent,
const char *provider,
const char *
class)
1895 GList *agents = NULL;
1899 for (gIter2 = agents; gIter2 != NULL; gIter2 = gIter2->next) {
1904 g_list_free_full(agents, free);
1910 lrmd_api_list_ocf_providers(
lrmd_t * lrmd,
const char *agent,
lrmd_list_t ** providers)
1913 char *provider = NULL;
1914 GList *ocf_providers = NULL;
1919 for (gIter = ocf_providers; gIter != NULL; gIter = gIter->next) {
1920 provider = gIter->data;
1921 if (!agent || does_provider_have_agent(agent, provider,
1923 *providers = lrmd_list_add(*providers, (
const char *)gIter->data);
1928 g_list_free_full(ocf_providers, free);
1936 GList *standards = NULL;
1941 for (gIter = standards; gIter != NULL; gIter = gIter->next) {
1942 *supported = lrmd_list_add(*supported, (
const char *)gIter->data);
1946 if (list_stonith_agents(NULL) > 0) {
1951 g_list_free_full(standards, free);
1961 new_lrmd = calloc(1,
sizeof(
lrmd_t));
1980 new_lrmd->
cmds->
exec = lrmd_api_exec;
1994 #ifdef HAVE_GNUTLS_GNUTLS_H
1998 if (!nodename && !server) {
2003 native->type = CRM_CLIENT_TLS;
2004 native->remote_nodename = nodename ? strdup(nodename) : strdup(server);
2005 native->server = server ? strdup(server) : strdup(nodename);
2006 native->port = port;
2007 if (native->port == 0) {
2013 crm_err(
"Cannot communicate with Pacemaker Remote because GnuTLS is not enabled for this build");
2029 #ifdef HAVE_GNUTLS_GNUTLS_H
2030 free(native->server);
2032 free(native->remote_nodename);
2033 free(native->remote);
2034 free(native->token);
2035 free(native->peer_version);