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;
277 native->callback(&event);
280 g_hash_table_destroy(event.params);
286 lrmd_ipc_dispatch(
const char *buffer, ssize_t length, gpointer userdata)
293 if (!native->callback) {
299 rc = lrmd_dispatch_internal(lrmd, msg);
304 #ifdef HAVE_GNUTLS_GNUTLS_H
306 lrmd_free_xml(gpointer userdata)
312 lrmd_tls_connected(
lrmd_t * lrmd)
316 if (native->remote->tls_session) {
324 lrmd_tls_dispatch(gpointer userdata)
330 int disconnected = 0;
332 if (lrmd_tls_connected(lrmd) == FALSE) {
333 crm_trace(
"TLS dispatch triggered after disconnect");
341 if (native->pending_notify) {
344 crm_trace(
"Processing pending notifies");
345 for (iter = native->pending_notify; iter; iter = iter->next) {
346 lrmd_dispatch_internal(lrmd, iter->data);
348 g_list_free_full(native->pending_notify, lrmd_free_xml);
349 native->pending_notify = NULL;
366 lrmd_dispatch_internal(lrmd, xml);
368 if (native->expected_late_replies > 0) {
369 native->expected_late_replies--;
374 crm_err(
"Got outdated Pacemaker Remote reply %d", reply_id);
382 crm_info(
"Lost %s executor connection while reading data",
383 (native->remote_nodename? native->remote_nodename :
"local"));
384 lrmd_tls_disconnect(lrmd);
397 switch (native->type) {
401 #ifdef HAVE_GNUTLS_GNUTLS_H
403 if (native->pending_notify) {
410 crm_err(
"Unsupported connection type: %d", native->type);
425 switch (private->type) {
431 lrmd_ipc_dispatch(msg, strlen(msg), lrmd);
435 #ifdef HAVE_GNUTLS_GNUTLS_H
437 lrmd_tls_dispatch(lrmd);
441 crm_err(
"Unsupported connection type: %d", private->type);
444 if (lrmd_api_is_connected(lrmd) == FALSE) {
453 lrmd_create_op(
const char *token,
const char *op, xmlNode *
data,
int timeout,
472 crm_trace(
"Created executor %s command with call options %.8lx (%d)",
473 op, (
long)options, options);
478 lrmd_ipc_connection_destroy(gpointer userdata)
483 crm_info(
"IPC connection destroyed");
487 native->source = NULL;
489 if (native->callback) {
492 event.remote_nodename = native->remote_nodename;
493 native->callback(&event);
497 #ifdef HAVE_GNUTLS_GNUTLS_H
499 lrmd_tls_connection_destroy(gpointer userdata)
504 crm_info(
"TLS connection destroyed");
506 if (native->remote->tls_session) {
507 gnutls_bye(*native->remote->tls_session, GNUTLS_SHUT_RDWR);
508 gnutls_deinit(*native->remote->tls_session);
509 gnutls_free(native->remote->tls_session);
511 if (native->psk_cred_c) {
512 gnutls_psk_free_client_credentials(native->psk_cred_c);
517 if (native->process_notify) {
519 native->process_notify = NULL;
521 if (native->pending_notify) {
522 g_list_free_full(native->pending_notify, lrmd_free_xml);
523 native->pending_notify = NULL;
526 free(native->remote->buffer);
527 native->remote->buffer = NULL;
530 native->psk_cred_c = NULL;
531 native->remote->tls_session = NULL;
534 if (native->callback) {
538 native->callback(&event);
552 lrmd_tls_recv_reply(
lrmd_t * lrmd,
int total_timeout,
int expected_reply_id,
int *disconnected)
556 time_t start = time(NULL);
557 const char *msg_type = NULL;
559 int remaining_timeout = 0;
572 if (remaining_timeout) {
573 remaining_timeout = total_timeout - ((time(NULL) - start) * 1000);
575 remaining_timeout = total_timeout;
577 if (remaining_timeout <= 0) {
578 crm_err(
"Never received the expected reply during the timeout period, disconnecting.");
579 *disconnected = TRUE;
586 crm_err(
"Unable to receive expected reply, disconnecting.");
587 *disconnected = TRUE;
589 }
else if (*disconnected) {
600 crm_err(
"Empty msg type received while waiting for reply");
606 native->pending_notify = g_list_append(native->pending_notify, xml);
607 if (native->process_notify) {
614 crm_err(
"Expected a reply, got %s", msg_type);
617 }
else if (reply_id != expected_reply_id) {
618 if (native->expected_late_replies > 0) {
619 native->expected_late_replies--;
621 crm_err(
"Got outdated reply, expected id %d got id %d", expected_reply_id, reply_id);
628 if (native->remote->buffer && native->process_notify) {
636 lrmd_tls_send(
lrmd_t * lrmd, xmlNode * msg)
641 global_remote_msg_id++;
642 if (global_remote_msg_id <= 0) {
643 global_remote_msg_id = 1;
646 rc = lrmd_tls_send_msg(native->remote, msg, global_remote_msg_id,
"request");
648 crm_err(
"Disconnecting because TLS message could not be sent to Pacemaker Remote");
649 lrmd_tls_disconnect(lrmd);
656 lrmd_tls_send_recv(
lrmd_t * lrmd, xmlNode * msg,
int timeout, xmlNode ** reply)
659 int disconnected = 0;
662 if (lrmd_tls_connected(lrmd) == FALSE) {
666 rc = lrmd_tls_send(lrmd, msg);
671 xml = lrmd_tls_recv_reply(lrmd, timeout, global_remote_msg_id, &disconnected);
674 crm_err(
"Pacemaker Remote disconnected while waiting for reply to request id %d",
675 global_remote_msg_id);
676 lrmd_tls_disconnect(lrmd);
679 crm_err(
"Did not receive reply from Pacemaker Remote for request id %d (timeout %dms)",
680 global_remote_msg_id, timeout);
695 lrmd_send_xml(
lrmd_t * lrmd, xmlNode * msg,
int timeout, xmlNode ** reply)
700 switch (native->type) {
704 #ifdef HAVE_GNUTLS_GNUTLS_H
706 rc = lrmd_tls_send_recv(lrmd, msg, timeout, reply);
710 crm_err(
"Unsupported connection type: %d", native->type);
717 lrmd_send_xml_no_reply(
lrmd_t * lrmd, xmlNode * msg)
722 switch (native->type) {
726 #ifdef HAVE_GNUTLS_GNUTLS_H
728 rc = lrmd_tls_send(lrmd, msg);
733 native->expected_late_replies++;
738 crm_err(
"Unsupported connection type: %d", native->type);
745 lrmd_api_is_connected(
lrmd_t * lrmd)
749 switch (native->type) {
753 #ifdef HAVE_GNUTLS_GNUTLS_H
755 return lrmd_tls_connected(lrmd);
759 crm_err(
"Unsupported connection type: %d", native->type);
784 lrmd_send_command(
lrmd_t *lrmd,
const char *op, xmlNode *
data,
785 xmlNode **output_data,
int timeout,
790 xmlNode *op_msg = NULL;
791 xmlNode *op_reply = NULL;
793 if (!lrmd_api_is_connected(lrmd)) {
798 crm_err(
"No operation specified");
804 crm_trace(
"Sending %s op to executor", op);
806 op_msg = lrmd_create_op(native->token, op,
data, timeout, options);
808 if (op_msg == NULL) {
813 rc = lrmd_send_xml(lrmd, op_msg, timeout, &op_reply);
815 rc = lrmd_send_xml_no_reply(lrmd, op_msg);
820 crm_perror(LOG_ERR,
"Couldn't perform %s operation (timeout=%d): %d", op, timeout, rc);
824 }
else if(op_reply == NULL) {
839 *output_data = op_reply;
844 if (lrmd_api_is_connected(lrmd) == FALSE) {
845 crm_err(
"Executor disconnected");
854 lrmd_api_poke_connection(
lrmd_t * lrmd)
877 value = g_hash_table_lookup(hash,
"stonith-watchdog-timeout");
887 lrmd_handshake(
lrmd_t * lrmd,
const char *name)
891 xmlNode *reply = NULL;
900 if (native->proxy_callback) {
904 rc = lrmd_send_xml(lrmd, hello, -1, &reply);
907 crm_perror(LOG_DEBUG,
"Couldn't complete registration with the executor API: %d", rc);
909 }
else if (reply == NULL) {
910 crm_err(
"Did not receive registration reply");
920 crm_err(
"Executor protocol version mismatch between client (%s) and server (%s)",
925 crm_err(
"Invalid registration message: %s", msg_type);
928 }
else if (tmp_ticket == NULL) {
929 crm_err(
"No registration token provided");
933 crm_trace(
"Obtained registration token: %s", tmp_ticket);
934 native->token = strdup(tmp_ticket);
944 lrmd_api_disconnect(lrmd);
950 lrmd_ipc_connect(
lrmd_t * lrmd,
int *fd)
957 .destroy = lrmd_ipc_connection_destroy
967 }
else if (native->ipc) {
968 crm_perror(LOG_ERR,
"Connection to executor failed");
976 if (native->ipc == NULL) {
977 crm_debug(
"Could not connect to the executor API");
984 #ifdef HAVE_GNUTLS_GNUTLS_H
986 copy_gnutls_datum(gnutls_datum_t *dest, gnutls_datum_t *source)
988 dest->data = gnutls_malloc(source->size);
990 memcpy(dest->data, source->data, source->size);
991 dest->size = source->size;
995 clear_gnutls_datum(gnutls_datum_t *datum)
997 gnutls_free(datum->data);
1002 #define KEY_READ_LEN 256
1005 set_key(gnutls_datum_t * key,
const char *location)
1008 size_t buf_len = KEY_READ_LEN;
1009 static gnutls_datum_t key_cache = { 0, };
1010 static time_t key_cache_updated = 0;
1012 if (location == NULL) {
1016 if (key_cache.data != NULL) {
1017 if ((time(NULL) - key_cache_updated) < 60) {
1018 copy_gnutls_datum(key, &key_cache);
1019 crm_debug(
"Using cached Pacemaker Remote key");
1022 clear_gnutls_datum(&key_cache);
1023 key_cache_updated = 0;
1024 crm_debug(
"Cleared Pacemaker Remote key cache");
1028 stream = fopen(location,
"r");
1033 key->data = gnutls_malloc(buf_len);
1035 while (!feof(stream)) {
1036 int next = fgetc(stream);
1039 if (!feof(stream)) {
1040 crm_err(
"Error reading Pacemaker Remote key; copy in memory may be corrupted");
1044 if (key->size == buf_len) {
1045 buf_len = key->size + KEY_READ_LEN;
1046 key->data = gnutls_realloc(key->data, buf_len);
1049 key->data[key->size++] = (
unsigned char) next;
1053 if (key->size == 0) {
1054 clear_gnutls_datum(key);
1058 if (key_cache.data == NULL) {
1059 copy_gnutls_datum(&key_cache, key);
1060 key_cache_updated = time(NULL);
1061 crm_debug(
"Cached Pacemaker Remote key");
1068 lrmd_tls_set_key(gnutls_datum_t * key)
1070 const char *specific_location = getenv(
"PCMK_authkey_location");
1072 if (set_key(key, specific_location) == 0) {
1073 crm_debug(
"Using custom authkey location %s", specific_location);
1076 }
else if (specific_location) {
1077 crm_err(
"No valid Pacemaker Remote key found at %s, trying default location", specific_location);
1090 lrmd_gnutls_global_init(
void)
1092 static int gnutls_init = 0;
1095 crm_gnutls_global_init();
1102 report_async_connection_result(
lrmd_t * lrmd,
int rc)
1106 if (native->callback) {
1109 event.remote_nodename = native->remote_nodename;
1110 event.connection_rc = rc;
1111 native->callback(&event);
1115 #ifdef HAVE_GNUTLS_GNUTLS_H
1117 lrmd_tcp_connect_cb(
void *userdata,
int sock)
1124 .destroy = lrmd_tls_connection_destroy,
1127 gnutls_datum_t psk_key = { NULL, 0 };
1129 native->async_timer = 0;
1132 lrmd_tls_connection_destroy(lrmd);
1133 crm_info(
"Could not connect to Pacemaker Remote at %s:%d",
1134 native->server, native->port);
1135 report_async_connection_result(lrmd, rc);
1143 native->sock = sock;
1145 rc = lrmd_tls_set_key(&psk_key);
1147 crm_warn(
"Could not set key for Pacemaker Remote at %s:%d " CRM_XS " rc=%d",
1148 native->server, native->port, rc);
1149 lrmd_tls_connection_destroy(lrmd);
1150 report_async_connection_result(lrmd, rc);
1154 gnutls_psk_allocate_client_credentials(&native->psk_cred_c);
1156 gnutls_free(psk_key.data);
1158 native->remote->tls_session = pcmk__new_tls_session(sock, GNUTLS_CLIENT,
1160 native->psk_cred_c);
1161 if (native->remote->tls_session == NULL) {
1162 lrmd_tls_connection_destroy(lrmd);
1163 report_async_connection_result(lrmd, -EPROTO);
1167 if (crm_initiate_client_tls_handshake(native->remote, LRMD_CLIENT_HANDSHAKE_TIMEOUT) != 0) {
1168 crm_warn(
"Disconnecting after TLS handshake with Pacemaker Remote server %s:%d failed",
1169 native->server, native->port);
1170 gnutls_deinit(*native->remote->tls_session);
1171 gnutls_free(native->remote->tls_session);
1172 native->remote->tls_session = NULL;
1173 lrmd_tls_connection_destroy(lrmd);
1178 crm_info(
"TLS connection to Pacemaker Remote server %s:%d succeeded",
1179 native->server, native->port);
1182 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 Pacemaker Remote 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);
1247 native->remote->tls_session = pcmk__new_tls_session(sock, GNUTLS_CLIENT,
1249 native->psk_cred_c);
1250 if (native->remote->tls_session == NULL) {
1251 lrmd_tls_connection_destroy(lrmd);
1255 if (crm_initiate_client_tls_handshake(native->remote, LRMD_CLIENT_HANDSHAKE_TIMEOUT) != 0) {
1256 crm_err(
"Session creation for %s:%d failed", native->server, native->port);
1257 gnutls_deinit(*native->remote->tls_session);
1258 gnutls_free(native->remote->tls_session);
1259 native->remote->tls_session = NULL;
1260 lrmd_tls_connection_destroy(lrmd);
1264 crm_info(
"Client TLS connection established with Pacemaker Remote server %s:%d", native->server,
1271 native->server, native->port);
1275 mainloop_add_fd(name, G_PRIORITY_HIGH, native->sock, lrmd, &lrmd_tls_callbacks);
1283 lrmd_api_connect(
lrmd_t * lrmd,
const char *name,
int *fd)
1288 switch (native->type) {
1290 rc = lrmd_ipc_connect(lrmd, fd);
1292 #ifdef HAVE_GNUTLS_GNUTLS_H
1293 case CRM_CLIENT_TLS:
1294 rc = lrmd_tls_connect(lrmd, fd);
1298 crm_err(
"Unsupported connection type: %d", native->type);
1302 rc = lrmd_handshake(lrmd, name);
1309 lrmd_api_connect_async(
lrmd_t * lrmd,
const char *name,
int timeout)
1314 CRM_CHECK(native && native->callback,
return -1);
1316 switch (native->type) {
1320 rc = lrmd_api_connect(lrmd, name, NULL);
1322 report_async_connection_result(lrmd, rc);
1325 #ifdef HAVE_GNUTLS_GNUTLS_H
1326 case CRM_CLIENT_TLS:
1327 rc = lrmd_tls_connect_async(lrmd, timeout);
1330 report_async_connection_result(lrmd, rc);
1335 crm_err(
"Unsupported connection type: %d", native->type);
1342 lrmd_ipc_disconnect(
lrmd_t * lrmd)
1346 if (native->source != NULL) {
1349 native->source = NULL;
1352 }
else if (native->ipc) {
1362 #ifdef HAVE_GNUTLS_GNUTLS_H
1364 lrmd_tls_disconnect(
lrmd_t * lrmd)
1368 if (native->remote->tls_session) {
1369 gnutls_bye(*native->remote->tls_session, GNUTLS_SHUT_RDWR);
1370 gnutls_deinit(*native->remote->tls_session);
1371 gnutls_free(native->remote->tls_session);
1372 native->remote->tls_session = 0;
1375 if (native->async_timer) {
1376 g_source_remove(native->async_timer);
1377 native->async_timer = 0;
1380 if (native->source != NULL) {
1383 native->source = NULL;
1385 }
else if (native->sock) {
1386 close(native->sock);
1390 if (native->pending_notify) {
1391 g_list_free_full(native->pending_notify, lrmd_free_xml);
1392 native->pending_notify = NULL;
1398 lrmd_api_disconnect(
lrmd_t * lrmd)
1402 crm_info(
"Disconnecting %s %s executor connection",
1404 (native->remote_nodename? native->remote_nodename :
"local"));
1405 switch (native->type) {
1407 lrmd_ipc_disconnect(lrmd);
1409 #ifdef HAVE_GNUTLS_GNUTLS_H
1410 case CRM_CLIENT_TLS:
1411 lrmd_tls_disconnect(lrmd);
1415 crm_err(
"Unsupported connection type: %d", native->type);
1418 free(native->token);
1419 native->token = NULL;
1421 free(native->peer_version);
1422 native->peer_version = NULL;
1427 lrmd_api_register_rsc(
lrmd_t * lrmd,
1433 xmlNode *
data = NULL;
1435 if (!
class || !
type || !rsc_id) {
1471 const char *provider,
const char *
type)
1477 rsc_info->
id = strdup(rsc_id);
1481 rsc_info->
standard = strdup(standard);
1485 rsc_info->
provider = strdup(provider);
1509 free(rsc_info->
type);
1520 xmlNode *output = NULL;
1521 const char *
class = NULL;
1522 const char *provider = NULL;
1523 const char *
type = NULL;
1538 if (!
class || !
type) {
1565 lrmd_api_get_recurring_ops(
lrmd_t *lrmd,
const char *rsc_id,
int timeout_ms,
1568 xmlNode *
data = NULL;
1569 xmlNode *output_xml = NULL;
1572 if (output == NULL) {
1584 timeout_ms, options, TRUE);
1590 if ((rc !=
pcmk_ok) || (output_xml == NULL)) {
1597 if (rsc_id == NULL) {
1598 crm_err(
"Could not parse recurring operation information from executor");
1607 op_info->
rsc_id = strdup(rsc_id);
1613 *output = g_list_prepend(*output, op_info);
1626 native->callback = callback;
1634 native->proxy_callback = callback;
1635 native->proxy_callback_userdata = userdata;
1639 lrmd_internal_proxy_dispatch(
lrmd_t *lrmd, xmlNode *msg)
1643 if (native->proxy_callback) {
1645 native->proxy_callback(lrmd, native->proxy_callback_userdata, msg);
1658 return lrmd_send_xml_no_reply(lrmd, msg);
1662 stonith_get_metadata(
const char *provider,
const char *
type,
char **output)
1669 stonith_api->
cmds->
free(stonith_api);
1671 if (*output == NULL) {
1678 lrmd_api_get_metadata(
lrmd_t *lrmd,
const char *standard,
const char *provider,
1679 const char *
type,
char **output,
1683 output, options, NULL);
1687 lrmd_api_get_metadata_params(
lrmd_t *lrmd,
const char *standard,
1688 const char *provider,
const char *
type,
1693 GHashTable *params_table = NULL;
1695 if (!standard || !
type) {
1702 return stonith_get_metadata(provider,
type, output);
1705 params_table = crm_str_table_new();
1707 g_hash_table_insert(params_table, strdup(param->key), strdup(param->value));
1715 if (action == NULL) {
1716 crm_err(
"Unable to retrieve meta-data for %s:%s:%s",
1717 standard, provider,
type);
1722 crm_err(
"Failed to retrieve meta-data for %s:%s:%s",
1723 standard, provider,
type);
1729 crm_err(
"Failed to receive meta-data for %s:%s:%s",
1730 standard, provider,
type);
1742 lrmd_api_exec(
lrmd_t *lrmd,
const char *rsc_id,
const char *action,
1743 const char *userdata, guint interval_ms,
1761 for (tmp = params; tmp; tmp = tmp->
next) {
1774 lrmd_api_exec_alert(
lrmd_t *lrmd,
const char *alert_id,
const char *alert_path,
1787 for (tmp = params; tmp; tmp = tmp->
next) {
1800 lrmd_api_cancel(
lrmd_t *lrmd,
const char *rsc_id,
const char *action,
1825 stonith_api->
cmds->
free(stonith_api);
1828 for (dIter = stonith_resources; dIter; dIter = dIter->
next) {
1831 *resources = lrmd_list_add(*resources, dIter->
value);
1840 lrmd_api_list_agents(
lrmd_t * lrmd,
lrmd_list_t ** resources,
const char *
class,
1841 const char *provider)
1846 rc += list_stonith_agents(resources);
1852 for (gIter = agents; gIter != NULL; gIter = gIter->next) {
1853 *resources = lrmd_list_add(*resources, (
const char *)gIter->data);
1856 g_list_free_full(agents, free);
1859 rc += list_stonith_agents(resources);
1864 crm_notice(
"No agents found for class %s",
class);
1865 rc = -EPROTONOSUPPORT;
1871 does_provider_have_agent(
const char *agent,
const char *provider,
const char *
class)
1874 GList *agents = NULL;
1878 for (gIter2 = agents; gIter2 != NULL; gIter2 = gIter2->next) {
1883 g_list_free_full(agents, free);
1889 lrmd_api_list_ocf_providers(
lrmd_t * lrmd,
const char *agent,
lrmd_list_t ** providers)
1892 char *provider = NULL;
1893 GList *ocf_providers = NULL;
1898 for (gIter = ocf_providers; gIter != NULL; gIter = gIter->next) {
1899 provider = gIter->data;
1900 if (!agent || does_provider_have_agent(agent, provider,
1902 *providers = lrmd_list_add(*providers, (
const char *)gIter->data);
1907 g_list_free_full(ocf_providers, free);
1915 GList *standards = NULL;
1920 for (gIter = standards; gIter != NULL; gIter = gIter->next) {
1921 *supported = lrmd_list_add(*supported, (
const char *)gIter->data);
1925 if (list_stonith_agents(NULL) > 0) {
1930 g_list_free_full(standards, free);
1940 new_lrmd = calloc(1,
sizeof(
lrmd_t));
1959 new_lrmd->
cmds->
exec = lrmd_api_exec;
1973 #ifdef HAVE_GNUTLS_GNUTLS_H
1977 if (!nodename && !server) {
1982 native->type = CRM_CLIENT_TLS;
1983 native->remote_nodename = nodename ? strdup(nodename) : strdup(server);
1984 native->server = server ? strdup(server) : strdup(nodename);
1985 native->port = port;
1986 if (native->port == 0) {
1992 crm_err(
"Cannot communicate with Pacemaker Remote because GnuTLS is not enabled for this build");
2008 #ifdef HAVE_GNUTLS_GNUTLS_H
2009 free(native->server);
2011 free(native->remote_nodename);
2012 free(native->remote);
2013 free(native->token);
2014 free(native->peer_version);