12 #if defined(US_AUTH_PEERCRED_UCRED) || defined(US_AUTH_PEERCRED_SOCKPEERCRED)
13 # ifdef US_AUTH_PEERCRED_UCRED
18 # include <sys/socket.h>
19 #elif defined(US_AUTH_GETPEERUCRED)
23 #include <sys/param.h>
26 #include <sys/types.h>
42 #define PCMK_IPC_VERSION 1
45 #define PCMK_IPC_DEFAULT_QUEUE_MAX 500
47 struct crm_ipc_response_header {
48 struct qb_ipc_response_header qb;
49 uint32_t size_uncompressed;
50 uint32_t size_compressed;
55 static int hdr_offset = 0;
56 static unsigned int ipc_buffer_max = 0;
57 static unsigned int pick_ipc_buffer(
unsigned int max);
62 if (hdr_offset == 0) {
63 hdr_offset =
sizeof(
struct crm_ipc_response_header);
65 if (ipc_buffer_max == 0) {
66 ipc_buffer_max = pick_ipc_buffer(0);
73 return pick_ipc_buffer(0);
77 generateReference(
const char *custom1,
const char *custom2)
79 static uint ref_counter = 0;
82 (custom1? custom1 :
"_empty_"),
83 (custom2? custom2 :
"_empty_"),
84 (
unsigned long)time(NULL), ref_counter++);
89 const char *host_to,
const char *sys_to,
90 const char *sys_from,
const char *uuid_from,
const char *origin)
92 char *true_from = NULL;
93 xmlNode *request = NULL;
94 char *reference = generateReference(task, sys_from);
96 if (uuid_from != NULL) {
98 }
else if (sys_from != NULL) {
99 true_from = strdup(sys_from);
101 crm_err(
"No sys from specified");
116 if (host_to != NULL && strlen(host_to) > 0) {
120 if (msg_data != NULL) {
133 create_reply_adv(xmlNode * original_request, xmlNode * xml_response_data,
const char *origin)
135 xmlNode *reply = NULL;
145 crm_err(
"Cannot create new_message, no message type in original message");
150 crm_err(
"Cannot create new_message, original message was not a request");
156 crm_err(
"Cannot create new_message, malloc failed");
172 if (host_from != NULL && strlen(host_from) > 0) {
176 if (xml_response_data != NULL) {
192 if (client_connections) {
193 return g_hash_table_lookup(client_connections, c);
207 if (client_connections &&
id) {
208 g_hash_table_iter_init(&iter, client_connections);
209 while (g_hash_table_iter_next(&iter, &key, (gpointer *) & client)) {
210 if (strcmp(client->
id,
id) == 0) {
216 crm_trace(
"No client found with id=%s",
id);
225 }
else if (c->
name == NULL && c->
id == NULL) {
227 }
else if (c->
name == NULL) {
237 switch (client_type) {
242 #ifdef HAVE_GNUTLS_GNUTLS_H
254 if (client_connections == NULL) {
256 client_connections = g_hash_table_new(g_direct_hash, g_direct_equal);
263 if (client_connections != NULL) {
264 int active = g_hash_table_size(client_connections);
267 crm_err(
"Exiting with %d active connections", active);
269 g_hash_table_destroy(client_connections); client_connections = NULL;
276 qb_ipcs_connection_t *c = NULL;
278 if (service == NULL) {
282 c = qb_ipcs_connection_first_get(service);
285 qb_ipcs_connection_t *last = c;
287 c = qb_ipcs_connection_next_get(service, last);
291 qb_ipcs_disconnect(last);
292 qb_ipcs_connection_unref(last);
307 client_from_connection(qb_ipcs_connection_t *c,
void *key, uid_t uid_client)
311 if (client == NULL) {
319 if (client->
user == NULL) {
320 client->
user = strdup(
"#unprivileged");
322 crm_err(
"Unable to enforce ACLs for user ID %d, assuming unprivileged",
335 if (client->
id == NULL) {
336 crm_err(
"Could not generate UUID for client");
344 g_hash_table_insert(client_connections, key, client);
358 crm_client_t *client = client_from_connection(NULL, key, 0);
367 static gid_t uid_cluster = 0;
368 static gid_t gid_cluster = 0;
374 if (uid_cluster == 0) {
376 static bool need_log = TRUE;
379 crm_warn(
"Could not find user and group IDs for user %s",
386 if (uid_client != 0) {
387 crm_trace(
"Giving access to group %u", gid_cluster);
389 qb_ipcs_connection_auth_set(c, -1, gid_cluster, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
395 client = client_from_connection(c, NULL, uid_client);
396 if (client == NULL) {
400 if ((uid_client == 0) || (uid_client == uid_cluster)) {
405 crm_debug(
"Connecting %p for uid=%d gid=%d pid=%u id=%s", c, uid_client, gid_client, client->
pid, client->
id);
410 static struct iovec *
411 pcmk__new_ipc_event()
413 struct iovec *iov = calloc(2,
sizeof(
struct iovec));
428 free(event[0].iov_base);
429 free(event[1].iov_base);
435 free_event(gpointer
data)
456 if (client_connections) {
458 crm_trace(
"Destroying %p/%p (%d remaining)",
459 c, c->
ipcs, crm_hash_table_size(client_connections) - 1);
460 g_hash_table_remove(client_connections, c->
ipcs);
463 crm_trace(
"Destroying remote connection %p (%d remaining)",
464 c, crm_hash_table_size(client_connections) - 1);
465 g_hash_table_remove(client_connections, c->
id);
505 if ((errno == 0) && (qmax_int > 0)) {
516 struct qb_ipcs_connection_stats stats;
518 stats.client_pid = 0;
519 qb_ipcs_connection_stats_get(c, &stats, 0);
520 return stats.client_pid;
527 char *uncompressed = NULL;
528 char *text = ((
char *)data) +
sizeof(
struct crm_ipc_response_header);
529 struct crm_ipc_response_header *header =
data;
532 *
id = ((
struct qb_ipc_response_header *)data)->id;
535 *flags = header->flags;
547 crm_err(
"Filtering incompatible v%d IPC message, we only support versions <= %d",
552 if (header->size_compressed) {
554 unsigned int size_u = 1 + header->size_uncompressed;
555 uncompressed = calloc(1, size_u);
557 crm_trace(
"Decompressing message data %u bytes into %u bytes",
558 header->size_compressed, size_u);
560 rc = BZ2_bzBuffToBuffDecompress(uncompressed, &size_u, text, header->size_compressed, 1, 0);
571 CRM_ASSERT(text[header->size_uncompressed - 1] == 0);
583 crm_ipcs_flush_events_cb(gpointer data)
600 delay_next_flush(
crm_client_t *c,
unsigned int queue_len)
603 guint delay = (queue_len < 5)? (1000 + 100 * queue_len) : 1500;
605 c->
event_timer = g_timeout_add(delay, crm_ipcs_flush_events_cb, c);
612 unsigned int sent = 0;
613 unsigned int queue_len = 0;
628 struct crm_ipc_response_header *header = NULL;
629 struct iovec *
event = NULL;
639 rc = qb_ipcs_event_sendv(c->
ipcs, event, 2);
646 header =
event[0].iov_base;
647 if (header->size_compressed) {
648 crm_trace(
"Event %d to %p[%d] (%lld compressed bytes) sent",
649 header->qb.id, c->
ipcs, c->
pid, (
long long) rc);
651 crm_trace(
"Event %d to %p[%d] (%lld bytes) sent: %.120s",
652 header->qb.id, c->
ipcs, c->
pid, (
long long) rc,
653 (
char *) (event[1].iov_base));
659 if (sent > 0 || queue_len) {
660 crm_trace(
"Sent %d events (%d remaining) for %p[%d]: %s (%lld)",
661 sent, queue_len, c->
ipcs, c->
pid,
672 if ((c->
queue_backlog <= 1) || (queue_len < c->queue_backlog)) {
674 crm_warn(
"Client with process ID %u has a backlog of %u messages "
677 crm_err(
"Evicting client with process ID %u due to backlog of %u messages "
680 qb_ipcs_disconnect(c->
ipcs);
686 delay_next_flush(c, queue_len);
697 crm_ipc_prepare(uint32_t request, xmlNode * message,
struct iovec ** result, uint32_t max_send_size)
699 static unsigned int biggest = 0;
701 unsigned int total = 0;
702 char *compressed = NULL;
704 struct crm_ipc_response_header *header = calloc(1,
sizeof(
struct crm_ipc_response_header));
710 if (max_send_size == 0) {
711 max_send_size = ipc_buffer_max;
717 iov = pcmk__new_ipc_event();
718 iov[0].iov_len = hdr_offset;
719 iov[0].iov_base = header;
722 header->size_uncompressed = 1 + strlen(buffer);
723 total = iov[0].iov_len + header->size_uncompressed;
725 if (total < max_send_size) {
726 iov[1].iov_base = buffer;
727 iov[1].iov_len = header->size_uncompressed;
730 unsigned int new_size = 0;
733 (buffer, header->size_uncompressed, max_send_size, &compressed, &new_size)) {
736 header->size_compressed = new_size;
738 iov[1].iov_len = header->size_compressed;
739 iov[1].iov_base = compressed;
743 biggest = QB_MAX(header->size_compressed, biggest);
746 ssize_t rc = -EMSGSIZE;
749 biggest = QB_MAX(header->size_uncompressed, biggest);
752 (
"Could not compress the message (%u bytes) into less than the configured ipc limit (%u bytes). "
753 "Set PCMK_ipc_buffer to a higher value (%u bytes suggested)",
754 header->size_uncompressed, max_send_size, 4 * biggest);
762 header->qb.size = iov[0].iov_len + iov[1].iov_len;
763 header->qb.id = (int32_t)request;
767 return header->qb.size;
774 static uint32_t
id = 1;
775 struct crm_ipc_response_header *header = iov[0].iov_base;
787 header->flags |=
flags;
789 header->qb.id =
id++;
796 struct iovec *iov_copy = pcmk__new_ipc_event();
799 iov_copy[0].iov_len = iov[0].iov_len;
800 iov_copy[0].iov_base = malloc(iov[0].iov_len);
801 memcpy(iov_copy[0].iov_base, iov[0].iov_base, iov[0].iov_len);
803 iov_copy[1].iov_len = iov[1].iov_len;
804 iov_copy[1].iov_base = malloc(iov[1].iov_len);
805 memcpy(iov_copy[1].iov_base, iov[1].iov_base, iov[1].iov_len);
807 add_event(c, iov_copy);
813 rc = qb_ipcs_response_sendv(c->
ipcs, iov, 2);
814 if (rc < header->qb.size) {
815 crm_notice(
"Response %d to pid %d failed: %s "
816 CRM_XS " bytes=%u rc=%lld ipcs=%p",
818 header->qb.size, (
long long) rc, c->
ipcs);
821 crm_trace(
"Response %d sent, %lld bytes to %p[%d]",
822 header->qb.id, (
long long) rc, c->
ipcs, c->
pid);
830 if (flags & crm_ipc_server_event) {
836 if (rc == -EPIPE || rc == -ENOTCONN) {
847 struct iovec *iov = NULL;
851 return -EDESTADDRREQ;
884 #define MIN_MSG_SIZE 12336
885 #define MAX_MSG_SIZE 128*1024
891 unsigned int max_buf_size;
893 unsigned int buf_size;
899 qb_ipcc_connection_t *ipc;
904 pick_ipc_buffer(
unsigned int max)
906 static unsigned int global_max = 0;
908 if (global_max == 0) {
909 const char *env = getenv(
"PCMK_ipc_buffer");
921 return QB_MAX(max, global_max);
931 client->name = strdup(name);
932 client->buf_size = pick_ipc_buffer(max_size);
933 client->buffer = malloc(client->buf_size);
936 client->max_buf_size = client->buf_size;
939 client->pfd.events = POLLIN;
940 client->pfd.revents = 0;
957 static uid_t cl_uid = 0;
958 static gid_t cl_gid = 0;
959 pid_t found_pid = 0; uid_t found_uid = 0; gid_t found_gid = 0;
962 client->need_reply = FALSE;
963 client->ipc = qb_ipcc_connect(client->name, client->buf_size);
965 if (client->ipc == NULL) {
971 if (client->pfd.fd < 0) {
979 if (!cl_uid && !cl_gid
989 &found_pid, &found_uid,
991 crm_err(
"Daemon (IPC %s) is not authentic:"
992 " process %lld (uid: %lld, gid: %lld)",
994 (
long long) found_uid, (
long long) found_gid);
996 errno = ECONNABORTED;
1001 crm_perror(LOG_ERR,
"Could not verify authenticity of daemon (IPC %s)",
1008 qb_ipcc_context_set(client->ipc, client);
1010 #ifdef HAVE_IPCS_GET_BUFFER_SIZE
1011 client->max_buf_size = qb_ipcc_get_buffer_size(client->ipc);
1012 if (client->max_buf_size > client->buf_size) {
1013 free(client->buffer);
1014 client->buffer = calloc(1, client->max_buf_size);
1015 client->buf_size = client->max_buf_size;
1026 crm_trace(
"Disconnecting %s IPC connection %p (%p)", client->name, client, client->ipc);
1029 qb_ipcc_connection_t *ipc = client->ipc;
1032 qb_ipcc_disconnect(ipc);
1041 if (client->ipc && qb_ipcc_is_connected(client->ipc)) {
1042 crm_notice(
"Destroying an active IPC connection to %s", client->name);
1053 crm_trace(
"Destroying IPC connection to %s: %p", client->name, client);
1054 free(client->buffer);
1065 if (client && client->ipc && (qb_ipcc_fd_get(client->ipc, &fd) == 0)) {
1069 crm_perror(LOG_ERR,
"Could not obtain file IPC descriptor for %s",
1070 (client? client->name :
"unspecified client"));
1079 if (client == NULL) {
1083 }
else if (client->ipc == NULL) {
1087 }
else if (client->pfd.fd < 0) {
1092 rc = qb_ipcc_is_connected(client->ipc);
1094 client->pfd.fd = -EINVAL;
1117 client->pfd.revents = 0;
1118 rc = poll(&(client->pfd), 1, 0);
1119 return (rc < 0)? -errno : rc;
1125 struct crm_ipc_response_header *header = (
struct crm_ipc_response_header *)(
void*)client->buffer;
1127 if (header->size_compressed) {
1129 unsigned int size_u = 1 + header->size_uncompressed;
1131 unsigned int new_buf_size = QB_MAX((hdr_offset + size_u), client->max_buf_size);
1132 char *uncompressed = calloc(1, new_buf_size);
1134 crm_trace(
"Decompressing message data %u bytes into %u bytes",
1135 header->size_compressed, size_u);
1137 rc = BZ2_bzBuffToBuffDecompress(uncompressed + hdr_offset, &size_u,
1138 client->buffer + hdr_offset, header->size_compressed, 1, 0);
1155 CRM_ASSERT(size_u == header->size_uncompressed);
1157 memcpy(uncompressed, client->buffer, hdr_offset);
1158 header = (
struct crm_ipc_response_header *)(
void*)uncompressed;
1160 free(client->buffer);
1161 client->buf_size = new_buf_size;
1162 client->buffer = uncompressed;
1165 CRM_ASSERT(client->buffer[hdr_offset + header->size_uncompressed - 1] == 0);
1172 struct crm_ipc_response_header *header = NULL;
1180 client->buffer[0] = 0;
1181 client->msg_size = qb_ipcc_event_recv(client->ipc, client->buffer,
1182 client->buf_size, 0);
1183 if (client->msg_size >= 0) {
1184 int rc = crm_ipc_decompress(client);
1190 header = (
struct crm_ipc_response_header *)(
void*)client->buffer;
1192 crm_err(
"Filtering incompatible v%d IPC message, we only support versions <= %d",
1197 crm_trace(
"Received %s event %d, size=%u, rc=%d, text: %.100s",
1198 client->name, header->qb.id, header->qb.size, client->msg_size,
1199 client->buffer + hdr_offset);
1206 crm_err(
"Connection to %s failed", client->name);
1211 return header->size_uncompressed;
1220 return client->buffer +
sizeof(
struct crm_ipc_response_header);
1226 struct crm_ipc_response_header *header = NULL;
1229 if (client->buffer == NULL) {
1233 header = (
struct crm_ipc_response_header *)(
void*)client->buffer;
1234 return header->flags;
1241 return client->name;
1245 internal_ipc_send_recv(
crm_ipc_t * client,
const void *iov)
1250 rc = qb_ipcc_sendv_recv(client->ipc, iov, 2, client->buffer, client->buf_size, -1);
1257 internal_ipc_send_request(
crm_ipc_t * client,
const void *iov,
int ms_timeout)
1260 time_t timeout = time(NULL) + 1 + (ms_timeout / 1000);
1263 rc = qb_ipcc_sendv(client->ipc, iov, 2);
1270 internal_ipc_get_reply(
crm_ipc_t * client,
int request_id,
int ms_timeout)
1272 time_t timeout = time(NULL) + 1 + (ms_timeout / 1000);
1278 crm_trace(
"client %s waiting on reply to msg id %d", client->name, request_id);
1281 rc = qb_ipcc_recv(client->ipc, client->buffer, client->buf_size, 1000);
1283 struct crm_ipc_response_header *hdr = NULL;
1285 int rc = crm_ipc_decompress(client);
1291 hdr = (
struct crm_ipc_response_header *)(
void*)client->buffer;
1292 if (hdr->qb.id == request_id) {
1295 }
else if (hdr->qb.id < request_id) {
1298 crm_err(
"Discarding old reply %d (need %d)", hdr->qb.id, request_id);
1304 crm_err(
"Discarding newer reply %d (need %d)", hdr->qb.id, request_id);
1309 crm_err(
"Server disconnected client %s while waiting for msg id %d", client->name,
1314 }
while (time(NULL) < timeout);
1325 static uint32_t
id = 0;
1326 static int factor = 8;
1327 struct crm_ipc_response_header *header;
1331 if (client == NULL) {
1337 crm_notice(
"Connection to %s closed", client->name);
1341 if (ms_timeout == 0) {
1345 if (client->need_reply) {
1346 crm_trace(
"Trying again to obtain pending reply from %s", client->name);
1347 rc = qb_ipcc_recv(client->ipc, client->buffer, client->buf_size, ms_timeout);
1349 crm_warn(
"Sending to %s (%p) is disabled until pending reply is received", client->name,
1354 crm_notice(
"Lost reply from %s (%p) finally arrived, sending re-enabled", client->name,
1356 client->need_reply = FALSE;
1367 header = iov[0].iov_base;
1368 header->flags |=
flags;
1375 if(header->size_compressed) {
1376 if(factor < 10 && (client->max_buf_size / 10) < (rc / factor)) {
1377 crm_notice(
"Compressed message exceeds %d0%% of the configured ipc limit (%u bytes), "
1378 "consider setting PCMK_ipc_buffer to %u or higher",
1379 factor, client->max_buf_size, 2 * client->max_buf_size);
1384 crm_trace(
"Sending from client: %s request id: %d bytes: %u timeout:%d msg...",
1385 client->name, header->qb.id, header->qb.size, ms_timeout);
1389 rc = internal_ipc_send_request(client, iov, ms_timeout);
1392 crm_trace(
"Failed to send from client %s request %d with %u bytes...",
1393 client->name, header->qb.id, header->qb.size);
1397 crm_trace(
"Message sent, not waiting for reply to %d from %s to %u bytes...",
1398 header->qb.id, client->name, header->qb.size);
1403 rc = internal_ipc_get_reply(client, header->qb.id, ms_timeout);
1412 client->need_reply = TRUE;
1416 rc = internal_ipc_send_recv(client, iov);
1420 struct crm_ipc_response_header *hdr = (
struct crm_ipc_response_header *)(
void*)client->buffer;
1422 crm_trace(
"Received response %d, size=%u, rc=%ld, text: %.200s", hdr->qb.id, hdr->qb.size,
1430 crm_trace(
"Response not received: rc=%ld, errno=%d", rc, errno);
1437 }
else if (rc == -ETIMEDOUT) {
1438 crm_warn(
"Request %d to %s (%p) failed: %s (%ld) after %dms",
1439 header->qb.id, client->name, client->ipc,
pcmk_strerror(rc), rc, ms_timeout);
1442 }
else if (rc <= 0) {
1443 crm_warn(
"Request %d to %s (%p) failed: %s (%ld)",
1444 header->qb.id, client->name, client->ipc,
pcmk_strerror(rc), rc);
1453 pid_t *gotpid, uid_t *gotuid, gid_t *gotgid) {
1455 pid_t found_pid = 0; uid_t found_uid = 0; gid_t found_gid = 0;
1456 #if defined(US_AUTH_PEERCRED_UCRED)
1458 socklen_t ucred_len =
sizeof(ucred);
1460 if (!getsockopt(sock, SOL_SOCKET, SO_PEERCRED,
1462 && ucred_len ==
sizeof(ucred)) {
1463 found_pid = ucred.pid; found_uid = ucred.uid; found_gid = ucred.gid;
1465 #elif defined(US_AUTH_PEERCRED_SOCKPEERCRED)
1466 struct sockpeercred sockpeercred;
1467 socklen_t sockpeercred_len =
sizeof(sockpeercred);
1469 if (!getsockopt(sock, SOL_SOCKET, SO_PEERCRED,
1470 &sockpeercred, &sockpeercred_len)
1471 && sockpeercred_len ==
sizeof(sockpeercred_len)) {
1472 found_pid = sockpeercred.pid;
1473 found_uid = sockpeercred.uid; found_gid = sockpeercred.gid;
1475 #elif defined(US_AUTH_GETPEEREID)
1476 if (!getpeereid(sock, &found_uid, &found_gid)) {
1479 #elif defined(US_AUTH_GETPEERUCRED)
1481 if (!getpeerucred(sock, &ucred)) {
1483 found_pid = ucred_getpid(ucred);
1484 found_uid = ucred_geteuid(ucred); found_gid = ucred_getegid(ucred);
1492 # error "No way to authenticate a Unix socket peer"
1496 if (gotpid != NULL) {
1497 *gotpid = found_pid;
1499 if (gotuid != NULL) {
1500 *gotuid = found_uid;
1502 if (gotgid != NULL) {
1503 *gotgid = found_gid;
1505 ret = (found_uid == 0 || found_uid == refuid || found_gid == refgid);
1515 gid_t refgid, pid_t *gotpid) {
1516 static char last_asked_name[PATH_MAX / 2] =
"";
1518 pid_t found_pid = 0; uid_t found_uid = 0; gid_t found_gid = 0;
1519 qb_ipcc_connection_t *c;
1521 if ((c = qb_ipcc_connect(name, 0)) == NULL) {
1524 }
else if ((ret = qb_ipcc_fd_get(c, &fd))) {
1525 crm_err(
"Could not get fd from %s IPC: %s (%d)", name,
1530 &found_pid, &found_uid,
1533 crm_err(
"Could not get peer credentials from %s IPC", name);
1535 crm_err(
"Could not get peer credentials from %s IPC: %s (%d)",
1541 if (gotpid != NULL) {
1542 *gotpid = found_pid;
1546 crm_err(
"Daemon (IPC %s) effectively blocked with unauthorized"
1547 " process %lld (uid: %lld, gid: %lld)",
1549 (
long long) found_uid, (
long long) found_gid);
1551 }
else if ((found_uid != refuid || found_gid != refgid)
1552 && strncmp(last_asked_name, name,
sizeof(last_asked_name))) {
1553 if (!found_uid && refuid) {
1554 crm_warn(
"Daemon (IPC %s) runs as root, whereas the expected"
1555 " credentials are %lld:%lld, hazard of violating"
1556 " the least privilege principle",
1557 name, (
long long) refuid, (
long long) refgid);
1559 crm_notice(
"Daemon (IPC %s) runs as %lld:%lld, whereas the"
1560 " expected credentials are %lld:%lld, which may"
1561 " mean a different set of privileges than expected",
1562 name, (
long long) found_uid, (
long long) found_gid,
1563 (
long long) refuid, (
long long) refgid);
1565 memccpy(last_asked_name, name,
'\0',
sizeof(last_asked_name));
1570 qb_ipcc_disconnect(c);
1581 const char *client_name,
const char *major_version,
const char *minor_version)
1583 xmlNode *hello_node = NULL;
1584 xmlNode *hello = NULL;
1586 if (uuid == NULL || strlen(uuid) == 0
1587 || client_name == NULL || strlen(client_name) == 0
1588 || major_version == NULL || strlen(major_version) == 0
1589 || minor_version == NULL || strlen(minor_version) == 0) {
1590 crm_err(
"Missing fields, Hello message will not be valid.");
1595 crm_xml_add(hello_node,
"major_version", major_version);
1596 crm_xml_add(hello_node,
"minor_version", minor_version);
1597 crm_xml_add(hello_node,
"client_name", client_name);
#define CRM_CHECK(expr, failure_action)
void crm_client_destroy(crm_client_t *c)
void crm_write_blackbox(int nsig, struct qb_log_callsite *callsite)
bool crm_ipc_connect(crm_ipc_t *client)
Establish an IPC connection to a Pacemaker component.
#define crm_notice(fmt, args...)
const char * pcmk_strerror(int rc)
const char * bz2_strerror(int rc)
char * crm_generate_uuid(void)
int crm_ipc_get_fd(crm_ipc_t *client)
crm_client_t * crm_client_alloc(void *key)
Allocate a new crm_client_t object and generate its ID.
void crm_client_disconnect_all(qb_ipcs_service_t *s)
qb_ipcs_connection_t * ipcs
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.
xmlNode * crm_ipcs_recv(crm_client_t *c, void *data, size_t size, uint32_t *id, uint32_t *flags)
long long crm_int_helper(const char *text, char **end_text)
xmlNode * create_reply_adv(xmlNode *request, xmlNode *xml_response_data, const char *origin)
#define PCMK__SPECIAL_PID_AS_0(p)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
int crm_parse_int(const char *text, const char *default_text)
Parse an integer value from a string.
#define PCMK__SPECIAL_PID
struct crm_remote_s * remote
int crm_user_lookup(const char *name, uid_t *uid, gid_t *gid)
#define CRM_LOG_ASSERT(expr)
long crm_ipc_read(crm_ipc_t *client)
#define clear_bit(word, bit)
char * strerror(int errnum)
xmlNode * create_hello_message(const char *uuid, const char *client_name, const char *major_version, const char *minor_version)
uint32_t crm_ipc_buffer_flags(crm_ipc_t *client)
crm_client_t * crm_client_get(qb_ipcs_connection_t *c)
ssize_t crm_ipcs_flush_events(crm_client_t *c)
void crm_client_init(void)
xmlNode * string2xml(const char *input)
const char * crm_ipc_buffer(crm_ipc_t *client)
void crm_ipcs_send_ack(crm_client_t *c, uint32_t request, uint32_t flags, const char *tag, const char *function, int line)
const char * crm_client_type_text(enum client_type client_type)
#define crm_warn(fmt, args...)
#define set_bit(word, bit)
#define crm_debug(fmt, args...)
struct crm_ipc_s crm_ipc_t
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define crm_trace(fmt, args...)
xmlNode * create_xml_node(xmlNode *parent, const char *name)
ssize_t crm_ipcs_send(crm_client_t *c, uint32_t request, xmlNode *message, enum crm_ipc_flags flags)
unsigned int crm_ipc_default_buffer_size(void)
void crm_ipc_destroy(crm_ipc_t *client)
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
void free_xml(xmlNode *child)
void pcmk_free_ipc_event(struct iovec *event)
Free an I/O vector created by crm_ipc_prepare()
unsigned int queue_backlog
bool crm_ipc_connected(crm_ipc_t *client)
bool crm_compress_string(const char *data, int length, int max, char **result, unsigned int *result_len)
int crm_ipc_ready(crm_ipc_t *client)
Check whether an IPC connection is ready to be read.
#define PCMK_IPC_DEFAULT_QUEUE_MAX
const char * crm_ipc_name(crm_ipc_t *client)
#define crm_perror(level, fmt, args...)
Log a system error message.
#define crm_err(fmt, args...)
int crm_ipc_send(crm_ipc_t *client, xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
xmlNode * create_request_adv(const char *task, xmlNode *xml_data, const char *host_to, const char *sys_to, const char *sys_from, const char *uuid_from, const char *origin)
#define crm_log_xml_notice(xml, text)
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
crm_client_t * crm_client_get_by_id(const char *id)
char * dump_xml_unformatted(xmlNode *msg)
GHashTable * client_connections
#define XML_ATTR_RESPONSE
ssize_t crm_ipc_prepare(uint32_t request, xmlNode *message, struct iovec **result, uint32_t max_send_size)
void crm_client_cleanup(void)
bool crm_set_client_queue_max(crm_client_t *client, const char *qmax)
Raise IPC eviction threshold for a client, if allowed.
int crm_ipcs_client_pid(qb_ipcs_connection_t *c)
Wrappers for and extensions to libqb IPC.
char * generate_hash_key(const char *crm_msg_reference, const char *sys)
#define crm_log_xml_trace(xml, text)
const char * crm_client_name(crm_client_t *c)
crm_client_t * crm_client_new(qb_ipcs_connection_t *c, uid_t uid, gid_t gid)
void crm_ipc_close(crm_ipc_t *client)
int pcmk__ipc_is_authentic_process_active(const char *name, uid_t refuid, gid_t refgid, pid_t *gotpid)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#define create_request(task, xml_data, host_to, sys_to, sys_from, uuid_from)
ssize_t crm_ipcs_sendv(crm_client_t *c, struct iovec *iov, enum crm_ipc_flags flags)
#define crm_info(fmt, args...)
char * uid2username(uid_t uid)
enum crm_ais_msg_types type
int crm_ipc_is_authentic_process(int sock, uid_t refuid, gid_t refgid, pid_t *gotpid, uid_t *gotuid, gid_t *gotgid)
Check the authenticity of the IPC socket peer process.