pacemaker  1.1.14-70404b0
Scalable High-Availability cluster resource manager
ipc.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <crm_internal.h>
20 
21 #include <sys/param.h>
22 
23 #include <stdio.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <unistd.h>
27 #include <grp.h>
28 
29 #include <errno.h>
30 #include <fcntl.h>
31 #include <bzlib.h>
32 
33 #include <crm/crm.h>
34 #include <crm/msg_xml.h>
35 #include <crm/common/ipc.h>
36 #include <crm/common/ipcs.h>
37 
38 #define PCMK_IPC_VERSION 1
39 
40 struct crm_ipc_response_header {
41  struct qb_ipc_response_header qb;
42  uint32_t size_uncompressed;
43  uint32_t size_compressed;
45  uint8_t version; /* Protect against version changes for anyone that might bother to statically link us */
46 };
47 
48 static int hdr_offset = 0;
49 static unsigned int ipc_buffer_max = 0;
50 static unsigned int pick_ipc_buffer(unsigned int max);
51 
52 static inline void
53 crm_ipc_init(void)
54 {
55  if (hdr_offset == 0) {
56  hdr_offset = sizeof(struct crm_ipc_response_header);
57  }
58  if (ipc_buffer_max == 0) {
59  ipc_buffer_max = pick_ipc_buffer(0);
60  }
61 }
62 
63 unsigned int
65 {
66  return pick_ipc_buffer(0);
67 }
68 
69 static char *
70 generateReference(const char *custom1, const char *custom2)
71 {
72  static uint ref_counter = 0;
73  const char *local_cust1 = custom1;
74  const char *local_cust2 = custom2;
75  int reference_len = 4;
76  char *since_epoch = NULL;
77 
78  reference_len += 20; /* too big */
79  reference_len += 40; /* too big */
80 
81  if (local_cust1 == NULL) {
82  local_cust1 = "_empty_";
83  }
84  reference_len += strlen(local_cust1);
85 
86  if (local_cust2 == NULL) {
87  local_cust2 = "_empty_";
88  }
89  reference_len += strlen(local_cust2);
90 
91  since_epoch = calloc(1, reference_len);
92 
93  if (since_epoch != NULL) {
94  sprintf(since_epoch, "%s-%s-%lu-%u",
95  local_cust1, local_cust2, (unsigned long)time(NULL), ref_counter++);
96  }
97 
98  return since_epoch;
99 }
100 
101 xmlNode *
102 create_request_adv(const char *task, xmlNode * msg_data,
103  const char *host_to, const char *sys_to,
104  const char *sys_from, const char *uuid_from, const char *origin)
105 {
106  char *true_from = NULL;
107  xmlNode *request = NULL;
108  char *reference = generateReference(task, sys_from);
109 
110  if (uuid_from != NULL) {
111  true_from = generate_hash_key(sys_from, uuid_from);
112  } else if (sys_from != NULL) {
113  true_from = strdup(sys_from);
114  } else {
115  crm_err("No sys from specified");
116  }
117 
118  /* host_from will get set for us if necessary by CRMd when routed */
119  request = create_xml_node(NULL, __FUNCTION__);
120  crm_xml_add(request, F_CRM_ORIGIN, origin);
121  crm_xml_add(request, F_TYPE, T_CRM);
124  crm_xml_add(request, F_CRM_REFERENCE, reference);
125  crm_xml_add(request, F_CRM_TASK, task);
126  crm_xml_add(request, F_CRM_SYS_TO, sys_to);
127  crm_xml_add(request, F_CRM_SYS_FROM, true_from);
128 
129  /* HOSTTO will be ignored if it is to the DC anyway. */
130  if (host_to != NULL && strlen(host_to) > 0) {
131  crm_xml_add(request, F_CRM_HOST_TO, host_to);
132  }
133 
134  if (msg_data != NULL) {
135  add_message_xml(request, F_CRM_DATA, msg_data);
136  }
137  free(reference);
138  free(true_from);
139 
140  return request;
141 }
142 
143 /*
144  * This method adds a copy of xml_response_data
145  */
146 xmlNode *
147 create_reply_adv(xmlNode * original_request, xmlNode * xml_response_data, const char *origin)
148 {
149  xmlNode *reply = NULL;
150 
151  const char *host_from = crm_element_value(original_request, F_CRM_HOST_FROM);
152  const char *sys_from = crm_element_value(original_request, F_CRM_SYS_FROM);
153  const char *sys_to = crm_element_value(original_request, F_CRM_SYS_TO);
154  const char *type = crm_element_value(original_request, F_CRM_MSG_TYPE);
155  const char *operation = crm_element_value(original_request, F_CRM_TASK);
156  const char *crm_msg_reference = crm_element_value(original_request, F_CRM_REFERENCE);
157 
158  if (type == NULL) {
159  crm_err("Cannot create new_message, no message type in original message");
160  CRM_ASSERT(type != NULL);
161  return NULL;
162 #if 0
163  } else if (strcasecmp(XML_ATTR_REQUEST, type) != 0) {
164  crm_err("Cannot create new_message, original message was not a request");
165  return NULL;
166 #endif
167  }
168  reply = create_xml_node(NULL, __FUNCTION__);
169  if (reply == NULL) {
170  crm_err("Cannot create new_message, malloc failed");
171  return NULL;
172  }
173 
174  crm_xml_add(reply, F_CRM_ORIGIN, origin);
175  crm_xml_add(reply, F_TYPE, T_CRM);
178  crm_xml_add(reply, F_CRM_REFERENCE, crm_msg_reference);
179  crm_xml_add(reply, F_CRM_TASK, operation);
180 
181  /* since this is a reply, we reverse the from and to */
182  crm_xml_add(reply, F_CRM_SYS_TO, sys_from);
183  crm_xml_add(reply, F_CRM_SYS_FROM, sys_to);
184 
185  /* HOSTTO will be ignored if it is to the DC anyway. */
186  if (host_from != NULL && strlen(host_from) > 0) {
187  crm_xml_add(reply, F_CRM_HOST_TO, host_from);
188  }
189 
190  if (xml_response_data != NULL) {
191  add_message_xml(reply, F_CRM_DATA, xml_response_data);
192  }
193 
194  return reply;
195 }
196 
197 /* Libqb based IPC */
198 
199 /* Server... */
200 
201 GHashTable *client_connections = NULL;
202 
203 crm_client_t *
204 crm_client_get(qb_ipcs_connection_t * c)
205 {
206  if (client_connections) {
207  return g_hash_table_lookup(client_connections, c);
208  }
209 
210  crm_trace("No client found for %p", c);
211  return NULL;
212 }
213 
214 crm_client_t *
215 crm_client_get_by_id(const char *id)
216 {
217  gpointer key;
218  crm_client_t *client;
219  GHashTableIter iter;
220 
221  if (client_connections && id) {
222  g_hash_table_iter_init(&iter, client_connections);
223  while (g_hash_table_iter_next(&iter, &key, (gpointer *) & client)) {
224  if (strcmp(client->id, id) == 0) {
225  return client;
226  }
227  }
228  }
229 
230  crm_trace("No client found with id=%s", id);
231  return NULL;
232 }
233 
234 const char *
236 {
237  if (c == NULL) {
238  return "null";
239  } else if (c->name == NULL && c->id == NULL) {
240  return "unknown";
241  } else if (c->name == NULL) {
242  return c->id;
243  } else {
244  return c->name;
245  }
246 }
247 
248 void
250 {
251  if (client_connections == NULL) {
252  crm_trace("Creating client hash table");
253  client_connections = g_hash_table_new(g_direct_hash, g_direct_equal);
254  }
255 }
256 
257 void
259 {
260  if (client_connections != NULL) {
261  int active = g_hash_table_size(client_connections);
262 
263  if (active) {
264  crm_err("Exiting with %d active connections", active);
265  }
266  g_hash_table_destroy(client_connections); client_connections = NULL;
267  }
268 }
269 
270 void
271 crm_client_disconnect_all(qb_ipcs_service_t *service)
272 {
273  qb_ipcs_connection_t *c = qb_ipcs_connection_first_get(service);
274 
275  while (c != NULL) {
276  qb_ipcs_connection_t *last = c;
277 
278  c = qb_ipcs_connection_next_get(service, last);
279 
280  /* There really shouldn't be anyone connected at this point */
281  crm_notice("Disconnecting client %p, pid=%d...", last, crm_ipcs_client_pid(last));
282  qb_ipcs_disconnect(last);
283  qb_ipcs_connection_unref(last);
284  }
285 }
286 
287 crm_client_t *
288 crm_client_new(qb_ipcs_connection_t * c, uid_t uid_client, gid_t gid_client)
289 {
290  static uid_t uid_server = 0;
291  static gid_t gid_cluster = 0;
292 
293  crm_client_t *client = NULL;
294 
295  CRM_LOG_ASSERT(c);
296  if (c == NULL) {
297  return NULL;
298  }
299 
300  if (gid_cluster == 0) {
301  uid_server = getuid();
302  if(crm_user_lookup(CRM_DAEMON_USER, NULL, &gid_cluster) < 0) {
303  static bool have_error = FALSE;
304  if(have_error == FALSE) {
305  crm_warn("Could not find group for user %s", CRM_DAEMON_USER);
306  have_error = TRUE;
307  }
308  }
309  }
310 
311  if(gid_cluster != 0 && gid_client != 0) {
312  uid_t best_uid = -1; /* Passing -1 to chown(2) means don't change */
313 
314  if(uid_client == 0 || uid_server == 0) { /* Someone is priveliged, but the other may not be */
315  best_uid = QB_MAX(uid_client, uid_server);
316  crm_trace("Allowing user %u to clean up after disconnect", best_uid);
317  }
318 
319  crm_trace("Giving access to group %u", gid_cluster);
320  qb_ipcs_connection_auth_set(c, best_uid, gid_cluster, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
321  }
322 
323  crm_client_init();
324 
325  /* TODO: Do our own auth checking, return NULL if unauthorized */
326  client = calloc(1, sizeof(crm_client_t));
327 
328  client->ipcs = c;
329  client->kind = CRM_CLIENT_IPC;
330  client->pid = crm_ipcs_client_pid(c);
331 
332  client->id = crm_generate_uuid();
333 
334  crm_debug("Connecting %p for uid=%d gid=%d pid=%u id=%s", c, uid_client, gid_client, client->pid, client->id);
335 
336 #if ENABLE_ACL
337  client->user = uid2username(uid_client);
338 #endif
339 
340  g_hash_table_insert(client_connections, c, client);
341  return client;
342 }
343 
344 void
346 {
347  if (c == NULL) {
348  return;
349  }
350 
351  if (client_connections) {
352  if (c->ipcs) {
353  crm_trace("Destroying %p/%p (%d remaining)",
354  c, c->ipcs, crm_hash_table_size(client_connections) - 1);
355  g_hash_table_remove(client_connections, c->ipcs);
356 
357  } else {
358  crm_trace("Destroying remote connection %p (%d remaining)",
359  c, crm_hash_table_size(client_connections) - 1);
360  g_hash_table_remove(client_connections, c->id);
361  }
362  }
363 
364  if (c->event_timer) {
365  g_source_remove(c->event_timer);
366  }
367 
368  crm_debug("Destroying %d events", g_list_length(c->event_queue));
369  while (c->event_queue) {
370  struct iovec *event = c->event_queue->data;
371 
372  c->event_queue = g_list_remove(c->event_queue, event);
373  free(event[0].iov_base);
374  free(event[1].iov_base);
375  free(event);
376  }
377 
378  free(c->id);
379  free(c->name);
380  free(c->user);
381  if (c->remote) {
382  if (c->remote->auth_timeout) {
383  g_source_remove(c->remote->auth_timeout);
384  }
385  free(c->remote->buffer);
386  free(c->remote);
387  }
388  free(c);
389 }
390 
391 int
392 crm_ipcs_client_pid(qb_ipcs_connection_t * c)
393 {
394  struct qb_ipcs_connection_stats stats;
395 
396  stats.client_pid = 0;
397  qb_ipcs_connection_stats_get(c, &stats, 0);
398  return stats.client_pid;
399 }
400 
401 xmlNode *
403 {
404  xmlNode *xml = NULL;
405  char *uncompressed = NULL;
406  char *text = ((char *)data) + sizeof(struct crm_ipc_response_header);
407  struct crm_ipc_response_header *header = data;
408 
409  if (id) {
410  *id = ((struct qb_ipc_response_header *)data)->id;
411  }
412  if (flags) {
413  *flags = header->flags;
414  }
415 
416  if (is_set(header->flags, crm_ipc_proxied)) {
417  /* mark this client as being the endpoint of a proxy connection.
418  * Proxy connections responses are sent on the event channel to avoid
419  * blocking the proxy daemon (crmd) */
421  }
422 
423  if(header->version > PCMK_IPC_VERSION) {
424  crm_err("Filtering incompatible v%d IPC message, we only support versions <= %d",
425  header->version, PCMK_IPC_VERSION);
426  return NULL;
427  }
428 
429  if (header->size_compressed) {
430  int rc = 0;
431  unsigned int size_u = 1 + header->size_uncompressed;
432  uncompressed = calloc(1, size_u);
433 
434  crm_trace("Decompressing message data %u bytes into %u bytes",
435  header->size_compressed, size_u);
436 
437  rc = BZ2_bzBuffToBuffDecompress(uncompressed, &size_u, text, header->size_compressed, 1, 0);
438  text = uncompressed;
439 
440  if (rc != BZ_OK) {
441  crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
442  free(uncompressed);
443  return NULL;
444  }
445  }
446 
447  CRM_ASSERT(text[header->size_uncompressed - 1] == 0);
448 
449  crm_trace("Received %.200s", text);
450  xml = string2xml(text);
451 
452  free(uncompressed);
453  return xml;
454 }
455 
457 
458 static gboolean
459 crm_ipcs_flush_events_cb(gpointer data)
460 {
461  crm_client_t *c = data;
462 
463  c->event_timer = 0;
465  return FALSE;
466 }
467 
468 ssize_t
470 {
471  int sent = 0;
472  ssize_t rc = 0;
473  int queue_len = 0;
474 
475  if (c == NULL) {
476  return pcmk_ok;
477 
478  } else if (c->event_timer) {
479  /* There is already a timer, wait until it goes off */
480  crm_trace("Timer active for %p - %d", c->ipcs, c->event_timer);
481  return pcmk_ok;
482  }
483 
484  queue_len = g_list_length(c->event_queue);
485  while (c->event_queue && sent < 100) {
486  struct crm_ipc_response_header *header = NULL;
487  struct iovec *event = c->event_queue->data;
488 
489  rc = qb_ipcs_event_sendv(c->ipcs, event, 2);
490  if (rc < 0) {
491  break;
492  }
493 
494  sent++;
495  header = event[0].iov_base;
496  if (header->size_compressed) {
497  crm_trace("Event %d to %p[%d] (%d compressed bytes) sent",
498  header->qb.id, c->ipcs, c->pid, rc);
499  } else {
500  crm_trace("Event %d to %p[%d] (%d bytes) sent: %.120s",
501  header->qb.id, c->ipcs, c->pid, rc, event[1].iov_base);
502  }
503 
504  c->event_queue = g_list_remove(c->event_queue, event);
505  free(event[0].iov_base);
506  free(event[1].iov_base);
507  free(event);
508  }
509 
510  queue_len -= sent;
511  if (sent > 0 || c->event_queue) {
512  crm_trace("Sent %d events (%d remaining) for %p[%d]: %s (%d)",
513  sent, queue_len, c->ipcs, c->pid, pcmk_strerror(rc < 0 ? rc : 0), rc);
514  }
515 
516  if (c->event_queue) {
517  if (queue_len % 100 == 0 && queue_len > 99) {
518  crm_warn("Event queue for %p[%d] has grown to %d", c->ipcs, c->pid, queue_len);
519 
520  } else if (queue_len > 500) {
521  crm_err("Evicting slow client %p[%d]: event queue reached %d entries",
522  c->ipcs, c->pid, queue_len);
523  qb_ipcs_disconnect(c->ipcs);
524  return rc;
525  }
526 
527  c->event_timer = g_timeout_add(1000 + 100 * queue_len, crm_ipcs_flush_events_cb, c);
528  }
529 
530  return rc;
531 }
532 
533 ssize_t
534 crm_ipc_prepare(uint32_t request, xmlNode * message, struct iovec ** result, uint32_t max_send_size)
535 {
536  static unsigned int biggest = 0;
537  struct iovec *iov;
538  unsigned int total = 0;
539  char *compressed = NULL;
540  char *buffer = dump_xml_unformatted(message);
541  struct crm_ipc_response_header *header = calloc(1, sizeof(struct crm_ipc_response_header));
542 
543  CRM_ASSERT(result != NULL);
544 
545  crm_ipc_init();
546 
547  if (max_send_size == 0) {
548  max_send_size = ipc_buffer_max;
549  }
550 
551  CRM_LOG_ASSERT(max_send_size != 0);
552 
553  *result = NULL;
554  iov = calloc(2, sizeof(struct iovec));
555 
556 
557  iov[0].iov_len = hdr_offset;
558  iov[0].iov_base = header;
559 
560  header->version = PCMK_IPC_VERSION;
561  header->size_uncompressed = 1 + strlen(buffer);
562  total = iov[0].iov_len + header->size_uncompressed;
563 
564  if (total < max_send_size) {
565  iov[1].iov_base = buffer;
566  iov[1].iov_len = header->size_uncompressed;
567 
568  } else {
569  unsigned int new_size = 0;
570 
572  (buffer, header->size_uncompressed, max_send_size, &compressed, &new_size)) {
573 
574  header->flags |= crm_ipc_compressed;
575  header->size_compressed = new_size;
576 
577  iov[1].iov_len = header->size_compressed;
578  iov[1].iov_base = compressed;
579 
580  free(buffer);
581 
582  biggest = QB_MAX(header->size_compressed, biggest);
583 
584  } else {
585  ssize_t rc = -EMSGSIZE;
586 
587  crm_log_xml_trace(message, "EMSGSIZE");
588  biggest = QB_MAX(header->size_uncompressed, biggest);
589 
590  crm_err
591  ("Could not compress the message (%u bytes) into less than the configured ipc limit (%u bytes). "
592  "Set PCMK_ipc_buffer to a higher value (%u bytes suggested)",
593  header->size_uncompressed, max_send_size, 4 * biggest);
594 
595  free(compressed);
596  free(buffer);
597  free(header);
598  free(iov);
599 
600  return rc;
601  }
602  }
603 
604  header->qb.size = iov[0].iov_len + iov[1].iov_len;
605  header->qb.id = (int32_t)request; /* Replying to a specific request */
606 
607  *result = iov;
608  CRM_ASSERT(header->qb.size > 0);
609  return header->qb.size;
610 }
611 
612 ssize_t
613 crm_ipcs_sendv(crm_client_t * c, struct iovec * iov, enum crm_ipc_flags flags)
614 {
615  ssize_t rc;
616  static uint32_t id = 1;
617  struct crm_ipc_response_header *header = iov[0].iov_base;
618 
620  /* _ALL_ replies to proxied connections need to be sent as events */
621  if (is_not_set(flags, crm_ipc_server_event)) {
622  flags |= crm_ipc_server_event;
623  /* this flag lets us know this was originally meant to be a response.
624  * even though we're sending it over the event channel. */
626  }
627  }
628 
629  header->flags |= flags;
630  if (flags & crm_ipc_server_event) {
631  header->qb.id = id++; /* We don't really use it, but doesn't hurt to set one */
632 
633  if (flags & crm_ipc_server_free) {
634  crm_trace("Sending the original to %p[%d]", c->ipcs, c->pid);
635  c->event_queue = g_list_append(c->event_queue, iov);
636 
637  } else {
638  struct iovec *iov_copy = calloc(2, sizeof(struct iovec));
639 
640  crm_trace("Sending a copy to %p[%d]", c->ipcs, c->pid);
641  iov_copy[0].iov_len = iov[0].iov_len;
642  iov_copy[0].iov_base = malloc(iov[0].iov_len);
643  memcpy(iov_copy[0].iov_base, iov[0].iov_base, iov[0].iov_len);
644 
645  iov_copy[1].iov_len = iov[1].iov_len;
646  iov_copy[1].iov_base = malloc(iov[1].iov_len);
647  memcpy(iov_copy[1].iov_base, iov[1].iov_base, iov[1].iov_len);
648 
649  c->event_queue = g_list_append(c->event_queue, iov_copy);
650  }
651 
652  } else {
653  CRM_LOG_ASSERT(header->qb.id != 0); /* Replying to a specific request */
654 
655  rc = qb_ipcs_response_sendv(c->ipcs, iov, 2);
656  if (rc < header->qb.size) {
657  crm_notice("Response %d to %p[%d] (%u bytes) failed: %s (%d)",
658  header->qb.id, c->ipcs, c->pid, header->qb.size, pcmk_strerror(rc), rc);
659 
660  } else {
661  crm_trace("Response %d sent, %d bytes to %p[%d]", header->qb.id, rc, c->ipcs, c->pid);
662  }
663 
664  if (flags & crm_ipc_server_free) {
665  free(iov[0].iov_base);
666  free(iov[1].iov_base);
667  free(iov);
668  }
669  }
670 
671  if (flags & crm_ipc_server_event) {
672  rc = crm_ipcs_flush_events(c);
673  } else {
675  }
676 
677  if (rc == -EPIPE || rc == -ENOTCONN) {
678  crm_trace("Client %p disconnected", c->ipcs);
679  }
680 
681  return rc;
682 }
683 
684 ssize_t
685 crm_ipcs_send(crm_client_t * c, uint32_t request, xmlNode * message,
686  enum crm_ipc_flags flags)
687 {
688  struct iovec *iov = NULL;
689  ssize_t rc = 0;
690 
691  if(c == NULL) {
692  return -EDESTADDRREQ;
693  }
694  crm_ipc_init();
695 
696  rc = crm_ipc_prepare(request, message, &iov, ipc_buffer_max);
697  if (rc > 0) {
698  rc = crm_ipcs_sendv(c, iov, flags | crm_ipc_server_free);
699 
700  } else {
701  free(iov);
702  crm_notice("Message to %p[%d] failed: %s (%d)",
703  c->ipcs, c->pid, pcmk_strerror(rc), rc);
704  }
705 
706  return rc;
707 }
708 
709 void
710 crm_ipcs_send_ack(crm_client_t * c, uint32_t request, uint32_t flags, const char *tag, const char *function,
711  int line)
712 {
713  if (flags & crm_ipc_client_response) {
714  xmlNode *ack = create_xml_node(NULL, tag);
715 
716  crm_trace("Ack'ing msg from %s (%p)", crm_client_name(c), c);
717  c->request_id = 0;
718  crm_xml_add(ack, "function", function);
719  crm_xml_add_int(ack, "line", line);
720  crm_ipcs_send(c, request, ack, flags);
721  free_xml(ack);
722  }
723 }
724 
725 /* Client... */
726 
727 #define MIN_MSG_SIZE 12336 /* sizeof(struct qb_ipc_connection_response) */
728 #define MAX_MSG_SIZE 128*1024 /* 128k default */
729 
730 struct crm_ipc_s {
731  struct pollfd pfd;
732 
733  /* the max size we can send/receive over ipc */
734  unsigned int max_buf_size;
735  /* Size of the allocated 'buffer' */
736  unsigned int buf_size;
737  int msg_size;
738  int need_reply;
739  char *buffer;
740  char *name;
741  uint32_t buffer_flags;
742 
743  qb_ipcc_connection_t *ipc;
744 
745 };
746 
747 static unsigned int
748 pick_ipc_buffer(unsigned int max)
749 {
750  static unsigned int global_max = 0;
751 
752  if(global_max == 0) {
753  const char *env = getenv("PCMK_ipc_buffer");
754 
755  if (env) {
756  int env_max = crm_parse_int(env, "0");
757 
758  global_max = (env_max > 0)? env_max : MAX_MSG_SIZE;
759 
760  } else {
761  global_max = MAX_MSG_SIZE;
762  }
763  }
764 
765  return QB_MAX(max, global_max);
766 }
767 
768 crm_ipc_t *
769 crm_ipc_new(const char *name, size_t max_size)
770 {
771  crm_ipc_t *client = NULL;
772 
773  client = calloc(1, sizeof(crm_ipc_t));
774 
775  client->name = strdup(name);
776  client->buf_size = pick_ipc_buffer(max_size);
777  client->buffer = malloc(client->buf_size);
778 
779  /* Clients initiating connection pick the max buf size */
780  client->max_buf_size = client->buf_size;
781 
782  client->pfd.fd = -1;
783  client->pfd.events = POLLIN;
784  client->pfd.revents = 0;
785 
786  return client;
787 }
788 
796 bool
798 {
799  client->need_reply = FALSE;
800  client->ipc = qb_ipcc_connect(client->name, client->buf_size);
801 
802  if (client->ipc == NULL) {
803  crm_debug("Could not establish %s connection: %s (%d)", client->name, pcmk_strerror(errno), errno);
804  return FALSE;
805  }
806 
807  client->pfd.fd = crm_ipc_get_fd(client);
808  if (client->pfd.fd < 0) {
809  crm_debug("Could not obtain file descriptor for %s connection: %s (%d)", client->name, pcmk_strerror(errno), errno);
810  return FALSE;
811  }
812 
813  qb_ipcc_context_set(client->ipc, client);
814 
815 #ifdef HAVE_IPCS_GET_BUFFER_SIZE
816  client->max_buf_size = qb_ipcc_get_buffer_size(client->ipc);
817  if (client->max_buf_size > client->buf_size) {
818  free(client->buffer);
819  client->buffer = calloc(1, client->max_buf_size);
820  client->buf_size = client->max_buf_size;
821  }
822 #endif
823 
824  return TRUE;
825 }
826 
827 void
829 {
830  if (client) {
831  crm_trace("Disconnecting %s IPC connection %p (%p.%p)", client->name, client, client->ipc);
832 
833  if (client->ipc) {
834  qb_ipcc_connection_t *ipc = client->ipc;
835 
836  client->ipc = NULL;
837  qb_ipcc_disconnect(ipc);
838  }
839  }
840 }
841 
842 void
844 {
845  if (client) {
846  if (client->ipc && qb_ipcc_is_connected(client->ipc)) {
847  crm_notice("Destroying an active IPC connection to %s", client->name);
848  /* The next line is basically unsafe
849  *
850  * If this connection was attached to mainloop and mainloop is active,
851  * the 'disconnected' callback will end up back here and we'll end
852  * up free'ing the memory twice - something that can still happen
853  * even without this if we destroy a connection and it closes before
854  * we call exit
855  */
856  /* crm_ipc_close(client); */
857  }
858  crm_trace("Destroying IPC connection to %s: %p", client->name, client);
859  free(client->buffer);
860  free(client->name);
861  free(client);
862  }
863 }
864 
865 int
867 {
868  int fd = 0;
869 
870  if (client && client->ipc && (qb_ipcc_fd_get(client->ipc, &fd) == 0)) {
871  return fd;
872  }
873  errno = EINVAL;
874  crm_perror(LOG_ERR, "Could not obtain file IPC descriptor for %s",
875  (client? client->name : "unspecified client"));
876  return -errno;
877 }
878 
879 bool
881 {
882  bool rc = FALSE;
883 
884  if (client == NULL) {
885  crm_trace("No client");
886  return FALSE;
887 
888  } else if (client->ipc == NULL) {
889  crm_trace("No connection");
890  return FALSE;
891 
892  } else if (client->pfd.fd < 0) {
893  crm_trace("Bad descriptor");
894  return FALSE;
895  }
896 
897  rc = qb_ipcc_is_connected(client->ipc);
898  if (rc == FALSE) {
899  client->pfd.fd = -EINVAL;
900  }
901  return rc;
902 }
903 
904 int
906 {
907  CRM_ASSERT(client != NULL);
908 
909  if (crm_ipc_connected(client) == FALSE) {
910  return -ENOTCONN;
911  }
912 
913  client->pfd.revents = 0;
914  return poll(&(client->pfd), 1, 0);
915 }
916 
917 static int
918 crm_ipc_decompress(crm_ipc_t * client)
919 {
920  struct crm_ipc_response_header *header = (struct crm_ipc_response_header *)(void*)client->buffer;
921 
922  if (header->size_compressed) {
923  int rc = 0;
924  unsigned int size_u = 1 + header->size_uncompressed;
925  /* never let buf size fall below our max size required for ipc reads. */
926  unsigned int new_buf_size = QB_MAX((hdr_offset + size_u), client->max_buf_size);
927  char *uncompressed = calloc(1, new_buf_size);
928 
929  crm_trace("Decompressing message data %u bytes into %u bytes",
930  header->size_compressed, size_u);
931 
932  rc = BZ2_bzBuffToBuffDecompress(uncompressed + hdr_offset, &size_u,
933  client->buffer + hdr_offset, header->size_compressed, 1, 0);
934 
935  if (rc != BZ_OK) {
936  crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
937  free(uncompressed);
938  return -EILSEQ;
939  }
940 
941  /*
942  * This assert no longer holds true. For an identical msg, some clients may
943  * require compression, and others may not. If that same msg (event) is sent
944  * to multiple clients, it could result in some clients receiving a compressed
945  * msg even though compression was not explicitly required for them.
946  *
947  * CRM_ASSERT((header->size_uncompressed + hdr_offset) >= ipc_buffer_max);
948  */
949  CRM_ASSERT(size_u == header->size_uncompressed);
950 
951  memcpy(uncompressed, client->buffer, hdr_offset); /* Preserve the header */
952  header = (struct crm_ipc_response_header *)(void*)uncompressed;
953 
954  free(client->buffer);
955  client->buf_size = new_buf_size;
956  client->buffer = uncompressed;
957  }
958 
959  CRM_ASSERT(client->buffer[hdr_offset + header->size_uncompressed - 1] == 0);
960  return pcmk_ok;
961 }
962 
963 long
965 {
966  struct crm_ipc_response_header *header = NULL;
967 
968  CRM_ASSERT(client != NULL);
969  CRM_ASSERT(client->ipc != NULL);
970  CRM_ASSERT(client->buffer != NULL);
971 
972  crm_ipc_init();
973 
974  client->buffer[0] = 0;
975  client->msg_size = qb_ipcc_event_recv(client->ipc, client->buffer, client->buf_size - 1, 0);
976  if (client->msg_size >= 0) {
977  int rc = crm_ipc_decompress(client);
978 
979  if (rc != pcmk_ok) {
980  return rc;
981  }
982 
983  header = (struct crm_ipc_response_header *)(void*)client->buffer;
984  if(header->version > PCMK_IPC_VERSION) {
985  crm_err("Filtering incompatible v%d IPC message, we only support versions <= %d",
986  header->version, PCMK_IPC_VERSION);
987  return -EBADMSG;
988  }
989 
990  crm_trace("Received %s event %d, size=%u, rc=%d, text: %.100s",
991  client->name, header->qb.id, header->qb.size, client->msg_size,
992  client->buffer + hdr_offset);
993 
994  } else {
995  crm_trace("No message from %s received: %s", client->name, pcmk_strerror(client->msg_size));
996  }
997 
998  if (crm_ipc_connected(client) == FALSE || client->msg_size == -ENOTCONN) {
999  crm_err("Connection to %s failed", client->name);
1000  }
1001 
1002  if (header) {
1003  /* Data excluding the header */
1004  return header->size_uncompressed;
1005  }
1006  return -ENOMSG;
1007 }
1008 
1009 const char *
1011 {
1012  CRM_ASSERT(client != NULL);
1013  return client->buffer + sizeof(struct crm_ipc_response_header);
1014 }
1015 
1016 uint32_t
1018 {
1019  struct crm_ipc_response_header *header = NULL;
1020 
1021  CRM_ASSERT(client != NULL);
1022  if (client->buffer == NULL) {
1023  return 0;
1024  }
1025 
1026  header = (struct crm_ipc_response_header *)(void*)client->buffer;
1027  return header->flags;
1028 }
1029 
1030 const char *
1032 {
1033  CRM_ASSERT(client != NULL);
1034  return client->name;
1035 }
1036 
1037 static int
1038 internal_ipc_send_recv(crm_ipc_t * client, const void *iov)
1039 {
1040  int rc = 0;
1041 
1042  do {
1043  rc = qb_ipcc_sendv_recv(client->ipc, iov, 2, client->buffer, client->buf_size, -1);
1044  } while (rc == -EAGAIN && crm_ipc_connected(client));
1045 
1046  return rc;
1047 }
1048 
1049 static int
1050 internal_ipc_send_request(crm_ipc_t * client, const void *iov, int ms_timeout)
1051 {
1052  int rc = 0;
1053  time_t timeout = time(NULL) + 1 + (ms_timeout / 1000);
1054 
1055  do {
1056  rc = qb_ipcc_sendv(client->ipc, iov, 2);
1057  } while (rc == -EAGAIN && time(NULL) < timeout && crm_ipc_connected(client));
1058 
1059  return rc;
1060 }
1061 
1062 static int
1063 internal_ipc_get_reply(crm_ipc_t * client, int request_id, int ms_timeout)
1064 {
1065  time_t timeout = time(NULL) + 1 + (ms_timeout / 1000);
1066  int rc = 0;
1067 
1068  crm_ipc_init();
1069 
1070  /* get the reply */
1071  crm_trace("client %s waiting on reply to msg id %d", client->name, request_id);
1072  do {
1073 
1074  rc = qb_ipcc_recv(client->ipc, client->buffer, client->buf_size, 1000);
1075  if (rc > 0) {
1076  struct crm_ipc_response_header *hdr = NULL;
1077 
1078  int rc = crm_ipc_decompress(client);
1079 
1080  if (rc != pcmk_ok) {
1081  return rc;
1082  }
1083 
1084  hdr = (struct crm_ipc_response_header *)(void*)client->buffer;
1085  if (hdr->qb.id == request_id) {
1086  /* Got it */
1087  break;
1088  } else if (hdr->qb.id < request_id) {
1089  xmlNode *bad = string2xml(crm_ipc_buffer(client));
1090 
1091  crm_err("Discarding old reply %d (need %d)", hdr->qb.id, request_id);
1092  crm_log_xml_notice(bad, "OldIpcReply");
1093 
1094  } else {
1095  xmlNode *bad = string2xml(crm_ipc_buffer(client));
1096 
1097  crm_err("Discarding newer reply %d (need %d)", hdr->qb.id, request_id);
1098  crm_log_xml_notice(bad, "ImpossibleReply");
1099  CRM_ASSERT(hdr->qb.id <= request_id);
1100  }
1101  } else if (crm_ipc_connected(client) == FALSE) {
1102  crm_err("Server disconnected client %s while waiting for msg id %d", client->name,
1103  request_id);
1104  break;
1105  }
1106 
1107  } while (time(NULL) < timeout);
1108 
1109  return rc;
1110 }
1111 
1112 int
1113 crm_ipc_send(crm_ipc_t * client, xmlNode * message, enum crm_ipc_flags flags, int32_t ms_timeout,
1114  xmlNode ** reply)
1115 {
1116  long rc = 0;
1117  struct iovec *iov;
1118  static uint32_t id = 0;
1119  static int factor = 8;
1120  struct crm_ipc_response_header *header;
1121 
1122  crm_ipc_init();
1123 
1124  if (client == NULL) {
1125  crm_notice("Invalid connection");
1126  return -ENOTCONN;
1127 
1128  } else if (crm_ipc_connected(client) == FALSE) {
1129  /* Don't even bother */
1130  crm_notice("Connection to %s closed", client->name);
1131  return -ENOTCONN;
1132  }
1133 
1134  if (ms_timeout == 0) {
1135  ms_timeout = 5000;
1136  }
1137 
1138  if (client->need_reply) {
1139  crm_trace("Trying again to obtain pending reply from %s", client->name);
1140  rc = qb_ipcc_recv(client->ipc, client->buffer, client->buf_size, ms_timeout);
1141  if (rc < 0) {
1142  crm_warn("Sending to %s (%p) is disabled until pending reply is received", client->name,
1143  client->ipc);
1144  return -EALREADY;
1145 
1146  } else {
1147  crm_notice("Lost reply from %s (%p) finally arrived, sending re-enabled", client->name,
1148  client->ipc);
1149  client->need_reply = FALSE;
1150  }
1151  }
1152 
1153  id++;
1154  CRM_LOG_ASSERT(id != 0); /* Crude wrap-around detection */
1155  rc = crm_ipc_prepare(id, message, &iov, client->max_buf_size);
1156  if(rc < 0) {
1157  return rc;
1158  }
1159 
1160  header = iov[0].iov_base;
1161  header->flags |= flags;
1162 
1163  if(is_set(flags, crm_ipc_proxied)) {
1164  /* Don't look for a synchronous response */
1166  }
1167 
1168  if(header->size_compressed) {
1169  if(factor < 10 && (client->max_buf_size / 10) < (rc / factor)) {
1170  crm_notice("Compressed message exceeds %d0%% of the configured ipc limit (%u bytes), "
1171  "consider setting PCMK_ipc_buffer to %u or higher",
1172  factor, client->max_buf_size, 2 * client->max_buf_size);
1173  factor++;
1174  }
1175  }
1176 
1177  crm_trace("Sending from client: %s request id: %d bytes: %u timeout:%d msg...",
1178  client->name, header->qb.id, header->qb.size, ms_timeout);
1179 
1180  if (ms_timeout > 0 || is_not_set(flags, crm_ipc_client_response)) {
1181 
1182  rc = internal_ipc_send_request(client, iov, ms_timeout);
1183 
1184  if (rc <= 0) {
1185  crm_trace("Failed to send from client %s request %d with %u bytes...",
1186  client->name, header->qb.id, header->qb.size);
1187  goto send_cleanup;
1188 
1189  } else if (is_not_set(flags, crm_ipc_client_response)) {
1190  crm_trace("Message sent, not waiting for reply to %d from %s to %u bytes...",
1191  header->qb.id, client->name, header->qb.size);
1192 
1193  goto send_cleanup;
1194  }
1195 
1196  rc = internal_ipc_get_reply(client, header->qb.id, ms_timeout);
1197  if (rc < 0) {
1198  /* No reply, for now, disable sending
1199  *
1200  * The alternative is to close the connection since we don't know
1201  * how to detect and discard out-of-sequence replies
1202  *
1203  * TODO - implement the above
1204  */
1205  client->need_reply = TRUE;
1206  }
1207 
1208  } else {
1209  rc = internal_ipc_send_recv(client, iov);
1210  }
1211 
1212  if (rc > 0) {
1213  struct crm_ipc_response_header *hdr = (struct crm_ipc_response_header *)(void*)client->buffer;
1214 
1215  crm_trace("Received response %d, size=%u, rc=%ld, text: %.200s", hdr->qb.id, hdr->qb.size,
1216  rc, crm_ipc_buffer(client));
1217 
1218  if (reply) {
1219  *reply = string2xml(crm_ipc_buffer(client));
1220  }
1221 
1222  } else {
1223  crm_trace("Response not received: rc=%ld, errno=%d", rc, errno);
1224  }
1225 
1226  send_cleanup:
1227  if (crm_ipc_connected(client) == FALSE) {
1228  crm_notice("Connection to %s closed: %s (%ld)", client->name, pcmk_strerror(rc), rc);
1229 
1230  } else if (rc == -ETIMEDOUT) {
1231  crm_warn("Request %d to %s (%p) failed: %s (%ld) after %dms",
1232  header->qb.id, client->name, client->ipc, pcmk_strerror(rc), rc, ms_timeout);
1233  crm_write_blackbox(0, NULL);
1234 
1235  } else if (rc <= 0) {
1236  crm_warn("Request %d to %s (%p) failed: %s (%ld)",
1237  header->qb.id, client->name, client->ipc, pcmk_strerror(rc), rc);
1238  }
1239 
1240  free(header);
1241  free(iov[1].iov_base);
1242  free(iov);
1243  return rc;
1244 }
1245 
1246 /* Utils */
1247 
1248 xmlNode *
1249 create_hello_message(const char *uuid,
1250  const char *client_name, const char *major_version, const char *minor_version)
1251 {
1252  xmlNode *hello_node = NULL;
1253  xmlNode *hello = NULL;
1254 
1255  if (uuid == NULL || strlen(uuid) == 0
1256  || client_name == NULL || strlen(client_name) == 0
1257  || major_version == NULL || strlen(major_version) == 0
1258  || minor_version == NULL || strlen(minor_version) == 0) {
1259  crm_err("Missing fields, Hello message will not be valid.");
1260  return NULL;
1261  }
1262 
1263  hello_node = create_xml_node(NULL, XML_TAG_OPTIONS);
1264  crm_xml_add(hello_node, "major_version", major_version);
1265  crm_xml_add(hello_node, "minor_version", minor_version);
1266  crm_xml_add(hello_node, "client_name", client_name);
1267  crm_xml_add(hello_node, "client_uuid", uuid);
1268 
1269  crm_trace("creating hello message");
1270  hello = create_request(CRM_OP_HELLO, hello_node, NULL, NULL, client_name, uuid);
1271  free_xml(hello_node);
1272 
1273  return hello;
1274 }
#define F_CRM_TASK
Definition: msg_xml.h:56
const char * crm_ipc_buffer(crm_ipc_t *client)
Definition: ipc.c:1010
#define F_CRM_REFERENCE
Definition: msg_xml.h:62
void crm_write_blackbox(int nsig, struct qb_log_callsite *callsite)
Definition: logging.c:407
A dumping ground.
#define F_TYPE
Definition: msg_xml.h:34
void crm_ipc_close(crm_ipc_t *client)
Definition: ipc.c:828
#define crm_notice(fmt, args...)
Definition: logging.h:250
char * crm_generate_uuid(void)
Definition: utils.c:2314
uint32_t crm_ipc_buffer_flags(crm_ipc_t *client)
Definition: ipc.c:1017
int crm_ipc_send(crm_ipc_t *client, xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
Definition: ipc.c:1113
#define F_CRM_HOST_TO
Definition: msg_xml.h:57
#define XML_TAG_OPTIONS
Definition: msg_xml.h:120
const char * pcmk_strerror(int rc)
Definition: logging.c:1113
crm_client_t * crm_client_get(qb_ipcs_connection_t *c)
Definition: ipc.c:204
uint32_t flags
Definition: ipcs.h:79
qb_ipcs_connection_t * ipcs
Definition: ipcs.h:90
#define F_CRM_MSG_TYPE
Definition: msg_xml.h:58
uint32_t size
Definition: internal.h:52
int request_id
Definition: ipcs.h:78
#define CRM_FEATURE_SET
Definition: crm.h:38
#define F_CRM_HOST_FROM
Definition: msg_xml.h:61
#define pcmk_ok
Definition: error.h:42
#define T_CRM
Definition: msg_xml.h:46
crm_client_t * crm_client_get_by_id(const char *id)
Definition: ipc.c:215
xmlNode * create_reply_adv(xmlNode *original_request, xmlNode *xml_response_data, const char *origin)
Definition: ipc.c:147
char * buffer
Definition: ipcs.h:43
bool crm_ipc_connect(crm_ipc_t *client)
Establish an IPC connection to a Pacemaker component.
Definition: ipc.c:797
int crm_parse_int(const char *text, const char *default_text)
Definition: utils.c:643
#define PCMK_IPC_VERSION
Definition: ipc.c:38
struct crm_remote_s * remote
Definition: ipcs.h:92
int crm_user_lookup(const char *name, uid_t *uid, gid_t *gid)
Definition: utils.c:455
#define CRM_LOG_ASSERT(expr)
Definition: logging.h:150
void crm_client_destroy(crm_client_t *c)
Definition: ipc.c:345
int crm_ipc_get_fd(crm_ipc_t *client)
Definition: ipc.c:866
void crm_client_init(void)
Definition: ipc.c:249
#define clear_bit(word, bit)
Definition: crm_internal.h:199
void crm_client_disconnect_all(qb_ipcs_service_t *service)
Definition: ipc.c:271
ssize_t crm_ipc_prepare(uint32_t request, xmlNode *message, struct iovec **result, uint32_t max_send_size)
Definition: ipc.c:534
char * user
Definition: ipcs.h:74
ssize_t crm_ipcs_flush_events(crm_client_t *c)
Definition: ipc.c:469
xmlNode * string2xml(const char *input)
Definition: xml.c:2957
char version[256]
Definition: plugin.c:84
#define MAX_MSG_SIZE
Definition: ipc.c:728
#define XML_ATTR_REQUEST
Definition: msg_xml.h:125
ssize_t crm_ipcs_sendv(crm_client_t *c, struct iovec *iov, enum crm_ipc_flags flags)
Definition: ipc.c:613
#define crm_warn(fmt, args...)
Definition: logging.h:249
crm_client_t * crm_client_new(qb_ipcs_connection_t *c, uid_t uid_client, gid_t gid_client)
Definition: ipc.c:288
uint64_t flags
Definition: remote.c:121
#define crm_debug(fmt, args...)
Definition: logging.h:253
#define F_CRM_SYS_TO
Definition: msg_xml.h:59
struct crm_ipc_s crm_ipc_t
Definition: ipc.h:61
const char * crm_ipc_name(crm_ipc_t *client)
Definition: ipc.c:1031
GList * event_queue
Definition: ipcs.h:83
GHashTable * client_connections
Definition: ipc.c:201
unsigned int crm_ipc_default_buffer_size(void)
Definition: ipc.c:64
#define crm_trace(fmt, args...)
Definition: logging.h:254
void crm_ipc_destroy(crm_ipc_t *client)
Definition: ipc.c:843
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition: xml.c:2793
const char * crm_element_value(xmlNode *data, const char *name)
Definition: xml.c:5839
#define CRM_DAEMON_USER
Definition: config.h:47
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
Definition: xml.c:3332
void free_xml(xmlNode *child)
Definition: xml.c:2848
void crm_ipcs_send_ack(crm_client_t *c, uint32_t request, uint32_t flags, const char *tag, const char *function, int line)
Definition: ipc.c:710
xmlNode * crm_ipcs_recv(crm_client_t *c, void *data, size_t size, uint32_t *id, uint32_t *flags)
Definition: ipc.c:402
int auth_timeout
Definition: ipcs.h:46
#define F_CRM_DATA
Definition: msg_xml.h:55
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Definition: xml.c:2695
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Definition: xml.c:2783
ssize_t crm_ipcs_send(crm_client_t *c, uint32_t request, xmlNode *message, enum crm_ipc_flags flags)
Definition: ipc.c:685
uint pid
Definition: ipcs.h:67
int event_timer
Definition: ipcs.h:82
#define crm_perror(level, fmt, args...)
Log a system error message.
Definition: logging.h:226
bool crm_compress_string(const char *data, int length, int max, char **result, unsigned int *result_len)
Definition: utils.c:2358
xmlNode * create_hello_message(const char *uuid, const char *client_name, const char *major_version, const char *minor_version)
Definition: ipc.c:1249
#define CRM_OP_HELLO
Definition: crm.h:106
#define crm_err(fmt, args...)
Definition: logging.h:248
const char * bz2_strerror(int rc)
Definition: logging.c:1176
#define F_CRM_SYS_FROM
Definition: msg_xml.h:60
#define crm_log_xml_notice(xml, text)
Definition: logging.h:259
char * dump_xml_unformatted(xmlNode *msg)
Definition: xml.c:3987
int crm_ipc_ready(crm_ipc_t *client)
Definition: ipc.c:905
#define uint32_t
Definition: stdint.in.h:158
#define XML_ATTR_RESPONSE
Definition: msg_xml.h:126
#define CRM_ASSERT(expr)
Definition: error.h:35
char data[0]
Definition: internal.h:58
long crm_ipc_read(crm_ipc_t *client)
Definition: ipc.c:964
char * id
Definition: ipcs.h:72
#define uint8_t
Definition: stdint.in.h:144
Wrappers for and extensions to libqb IPC.
char * generate_hash_key(const char *crm_msg_reference, const char *sys)
Definition: utils.c:421
#define F_CRM_ORIGIN
Definition: msg_xml.h:64
int crm_ipcs_client_pid(qb_ipcs_connection_t *c)
Definition: ipc.c:392
#define crm_log_xml_trace(xml, text)
Definition: logging.h:262
void crm_client_cleanup(void)
Definition: ipc.c:258
enum client_type kind
Definition: ipcs.h:88
const char * crm_client_name(crm_client_t *c)
Definition: ipc.c:235
bool crm_ipc_connected(crm_ipc_t *client)
Definition: ipc.c:880
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
Definition: ipc.c:769
char * name
Definition: ipcs.h:73
crm_ipc_flags
Definition: ipc.h:41
xmlNode * create_request_adv(const char *task, xmlNode *msg_data, const char *host_to, const char *sys_to, const char *sys_from, const char *uuid_from, const char *origin)
Definition: ipc.c:102
#define create_request(task, xml_data, host_to, sys_to, sys_from, uuid_from)
Definition: ipc.h:34
char * uid2username(uid_t uid)
#define F_CRM_VERSION
Definition: msg_xml.h:63
enum crm_ais_msg_types type
Definition: internal.h:51
#define int32_t
Definition: stdint.in.h:157