pacemaker  2.0.2-debe490
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
corosync.c
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2019 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #include <crm_internal.h>
11 
12 #include <sys/socket.h>
13 #include <netinet/in.h>
14 #include <arpa/inet.h>
15 #include <netdb.h>
16 #include <inttypes.h> /* U64T ~ PRIu64 */
17 
18 #include <bzlib.h>
19 
20 #include <crm/common/ipc.h>
21 #include <crm/cluster/internal.h>
22 #include <crm/common/mainloop.h>
23 #include <sys/utsname.h>
24 
25 #include <qb/qbipcc.h>
26 #include <qb/qbutil.h>
27 
28 #include <corosync/corodefs.h>
29 #include <corosync/corotypes.h>
30 #include <corosync/hdb.h>
31 #include <corosync/cfg.h>
32 #include <corosync/cmap.h>
33 #include <corosync/quorum.h>
34 
35 #include <crm/msg_xml.h>
36 
37 #include <crm/common/ipc_internal.h> /* PCMK__SPECIAL_PID* */
38 
39 quorum_handle_t pcmk_quorum_handle = 0;
40 
41 gboolean(*quorum_app_callback) (unsigned long long seq, gboolean quorate) = NULL;
42 
43 char *
45 {
46  if (node && is_corosync_cluster()) {
47  if (node->id > 0) {
48  return crm_strdup_printf("%u", node->id);
49  } else {
50  crm_info("Node %s is not yet known by corosync", node->uname);
51  }
52  }
53  return NULL;
54 }
55 
56 /*
57  * CFG functionality stolen from node_name() in corosync-quorumtool.c
58  * This resolves the first address assigned to a node and returns the name or IP address.
59  */
60 char *
61 corosync_node_name(uint64_t /*cmap_handle_t */ cmap_handle, uint32_t nodeid)
62 {
63  int lpc = 0;
64  cs_error_t rc = CS_OK;
65  int retries = 0;
66  char *name = NULL;
67  cmap_handle_t local_handle = 0;
68  int fd = -1;
69  uid_t found_uid = 0;
70  gid_t found_gid = 0;
71  pid_t found_pid = 0;
72  int rv;
73 
74  if (nodeid == 0) {
75  nodeid = get_local_nodeid(0);
76  }
77 
78  if (cmap_handle == 0 && local_handle == 0) {
79  retries = 0;
80  crm_trace("Initializing CMAP connection");
81  do {
82  rc = cmap_initialize(&local_handle);
83  if (rc != CS_OK) {
84  retries++;
85  crm_debug("API connection setup failed: %s. Retrying in %ds", cs_strerror(rc),
86  retries);
87  sleep(retries);
88  }
89 
90  } while (retries < 5 && rc != CS_OK);
91 
92  if (rc != CS_OK) {
93  crm_warn("Could not connect to Cluster Configuration Database API, error %s",
94  cs_strerror(rc));
95  local_handle = 0;
96  }
97  }
98 
99  if (cmap_handle == 0) {
100  cmap_handle = local_handle;
101 
102  rc = cmap_fd_get(cmap_handle, &fd);
103  if (rc != CS_OK) {
104  crm_err("Could not obtain the CMAP API connection: %s (%d)",
105  cs_strerror(rc), rc);
106  goto bail;
107  }
108 
109  /* CMAP provider run as root (in given user namespace, anyway)? */
110  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
111  &found_uid, &found_gid))) {
112  crm_err("CMAP provider is not authentic:"
113  " process %lld (uid: %lld, gid: %lld)",
114  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
115  (long long) found_uid, (long long) found_gid);
116  goto bail;
117  } else if (rv < 0) {
118  crm_err("Could not verify authenticity of CMAP provider: %s (%d)",
119  strerror(-rv), -rv);
120  goto bail;
121  }
122  }
123 
124  while (name == NULL && cmap_handle != 0) {
125  uint32_t id = 0;
126  char *key = NULL;
127 
128  key = crm_strdup_printf("nodelist.node.%d.nodeid", lpc);
129  rc = cmap_get_uint32(cmap_handle, key, &id);
130  crm_trace("Checking %u vs %u from %s", nodeid, id, key);
131  free(key);
132 
133  if (rc != CS_OK) {
134  break;
135  }
136 
137  if (nodeid == id) {
138  crm_trace("Searching for node name for %u in nodelist.node.%d %s", nodeid, lpc, name);
139  if (name == NULL) {
140  key = crm_strdup_printf("nodelist.node.%d.name", lpc);
141  cmap_get_string(cmap_handle, key, &name);
142  crm_trace("%s = %s", key, name);
143  free(key);
144  }
145  if (name == NULL) {
146  key = crm_strdup_printf("nodelist.node.%d.ring0_addr", lpc);
147  cmap_get_string(cmap_handle, key, &name);
148  crm_trace("%s = %s", key, name);
149 
150  if (node_name_is_valid(key, name) == FALSE) {
151  free(name);
152  name = NULL;
153  }
154  free(key);
155  }
156  break;
157  }
158 
159  lpc++;
160  }
161 
162 bail:
163  if(local_handle) {
164  cmap_finalize(local_handle);
165  }
166 
167  if (name == NULL) {
168  crm_info("Unable to get node name for nodeid %u", nodeid);
169  }
170  return name;
171 }
172 
173 void
175 {
176  cluster_disconnect_cpg(cluster);
177  if (pcmk_quorum_handle) {
178  quorum_finalize(pcmk_quorum_handle);
179  pcmk_quorum_handle = 0;
180  }
181  crm_notice("Disconnected from Corosync");
182 }
183 
184 static int
185 pcmk_quorum_dispatch(gpointer user_data)
186 {
187  int rc = 0;
188 
189  rc = quorum_dispatch(pcmk_quorum_handle, CS_DISPATCH_ALL);
190  if (rc < 0) {
191  crm_err("Connection to the Quorum API failed: %d", rc);
192  pcmk_quorum_handle = 0;
193  return -1;
194  }
195  return 0;
196 }
197 
198 static void
199 pcmk_quorum_notification(quorum_handle_t handle,
200  uint32_t quorate,
201  uint64_t ring_id, uint32_t view_list_entries, uint32_t * view_list)
202 {
203  int i;
204  GHashTableIter iter;
205  crm_node_t *node = NULL;
206  static gboolean init_phase = TRUE;
207 
208  if (quorate != crm_have_quorum) {
209  if (quorate) {
210  crm_notice("Quorum acquired " CRM_XS " membership=%" U64T " members=%lu",
211  ring_id, (long unsigned int)view_list_entries);
212  } else {
213  crm_warn("Quorum lost " CRM_XS " membership=%" U64T " members=%lu",
214  ring_id, (long unsigned int)view_list_entries);
215  }
216  crm_have_quorum = quorate;
217 
218  } else {
219  crm_info("Quorum %s " CRM_XS " membership=%" U64T " members=%lu",
220  (quorate? "retained" : "still lost"), ring_id,
221  (long unsigned int)view_list_entries);
222  }
223 
224  if (view_list_entries == 0 && init_phase) {
225  crm_info("Corosync membership is still forming, ignoring");
226  return;
227  }
228 
229  init_phase = FALSE;
230 
231  /* Reset last_seen for all cached nodes so we can tell which ones aren't
232  * in the view list */
233  g_hash_table_iter_init(&iter, crm_peer_cache);
234  while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &node)) {
235  node->last_seen = 0;
236  }
237 
238  /* Update the peer cache for each node in view list */
239  for (i = 0; i < view_list_entries; i++) {
240  uint32_t id = view_list[i];
241 
242  crm_debug("Member[%d] %u ", i, id);
243 
244  /* Get this node's peer cache entry (adding one if not already there) */
245  node = crm_get_peer(id, NULL);
246  if (node->uname == NULL) {
247  char *name = corosync_node_name(0, id);
248 
249  crm_info("Obtaining name for new node %u", id);
250  node = crm_get_peer(id, name);
251  free(name);
252  }
253 
254  /* Update the node state (including updating last_seen to ring_id) */
255  crm_update_peer_state(__FUNCTION__, node, CRM_NODE_MEMBER, ring_id);
256  }
257 
258  /* Remove any peer cache entries we didn't update */
259  crm_reap_unseen_nodes(ring_id);
260 
261  if (quorum_app_callback) {
262  quorum_app_callback(ring_id, quorate);
263  }
264 }
265 
266 quorum_callbacks_t quorum_callbacks = {
267  .quorum_notify_fn = pcmk_quorum_notification,
268 };
269 
270 gboolean
271 cluster_connect_quorum(gboolean(*dispatch) (unsigned long long, gboolean),
272  void (*destroy) (gpointer))
273 {
274  cs_error_t rc;
275  int fd = 0;
276  int quorate = 0;
277  uint32_t quorum_type = 0;
278  struct mainloop_fd_callbacks quorum_fd_callbacks;
279  uid_t found_uid = 0;
280  gid_t found_gid = 0;
281  pid_t found_pid = 0;
282  int rv;
283 
284  quorum_fd_callbacks.dispatch = pcmk_quorum_dispatch;
285  quorum_fd_callbacks.destroy = destroy;
286 
287  crm_debug("Configuring Pacemaker to obtain quorum from Corosync");
288 
289  rc = quorum_initialize(&pcmk_quorum_handle, &quorum_callbacks, &quorum_type);
290  if (rc != CS_OK) {
291  crm_err("Could not connect to the Quorum API: %s (%d)",
292  cs_strerror(rc), rc);
293  goto bail;
294 
295  } else if (quorum_type != QUORUM_SET) {
296  crm_err("Corosync quorum is not configured");
297  goto bail;
298  }
299 
300  rc = quorum_fd_get(pcmk_quorum_handle, &fd);
301  if (rc != CS_OK) {
302  crm_err("Could not obtain the Quorum API connection: %s (%d)",
303  strerror(rc), rc);
304  goto bail;
305  }
306 
307  /* Quorum provider run as root (in given user namespace, anyway)? */
308  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
309  &found_uid, &found_gid))) {
310  crm_err("Quorum provider is not authentic:"
311  " process %lld (uid: %lld, gid: %lld)",
312  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
313  (long long) found_uid, (long long) found_gid);
314  rc = CS_ERR_ACCESS;
315  goto bail;
316  } else if (rv < 0) {
317  crm_err("Could not verify authenticity of Quorum provider: %s (%d)",
318  strerror(-rv), -rv);
319  rc = CS_ERR_ACCESS;
320  goto bail;
321  }
322 
323  rc = quorum_getquorate(pcmk_quorum_handle, &quorate);
324  if (rc != CS_OK) {
325  crm_err("Could not obtain the current Quorum API state: %d", rc);
326  goto bail;
327  }
328 
329  if (quorate) {
330  crm_notice("Quorum acquired");
331  } else {
332  crm_warn("Quorum lost");
333  }
335  crm_have_quorum = quorate;
336 
337  rc = quorum_trackstart(pcmk_quorum_handle, CS_TRACK_CHANGES | CS_TRACK_CURRENT);
338  if (rc != CS_OK) {
339  crm_err("Could not setup Quorum API notifications: %d", rc);
340  goto bail;
341  }
342 
343  mainloop_add_fd("quorum", G_PRIORITY_HIGH, fd, dispatch, &quorum_fd_callbacks);
344 
345  corosync_initialize_nodelist(NULL, FALSE, NULL);
346 
347  bail:
348  if (rc != CS_OK) {
349  quorum_finalize(pcmk_quorum_handle);
350  return FALSE;
351  }
352  return TRUE;
353 }
354 
355 gboolean
357 {
358  int retries = 0;
359 
360  while (retries < 5) {
361  int rc = init_cs_connection_once(cluster);
362 
363  retries++;
364 
365  switch (rc) {
366  case CS_OK:
367  return TRUE;
368  break;
369  case CS_ERR_TRY_AGAIN:
370  case CS_ERR_QUEUE_FULL:
371  sleep(retries);
372  break;
373  default:
374  return FALSE;
375  }
376  }
377 
378  crm_err("Could not connect to corosync after %d retries", retries);
379  return FALSE;
380 }
381 
382 gboolean
384 {
385  crm_node_t *peer = NULL;
386  enum cluster_type_e stack = get_cluster_type();
387 
388  crm_peer_init();
389 
390  /* Here we just initialize comms */
391  if (stack != pcmk_cluster_corosync) {
392  crm_err("Invalid cluster type: %s (%d)", name_for_cluster_type(stack), stack);
393  return FALSE;
394  }
395 
396  if (cluster_connect_cpg(cluster) == FALSE) {
397  return FALSE;
398  }
399  crm_info("Connection to '%s': established", name_for_cluster_type(stack));
400 
401  cluster->nodeid = get_local_nodeid(0);
402  if(cluster->nodeid == 0) {
403  crm_err("Could not establish local nodeid");
404  return FALSE;
405  }
406 
407  cluster->uname = get_node_name(0);
408  if(cluster->uname == NULL) {
409  crm_err("Could not establish local node name");
410  return FALSE;
411  }
412 
413  /* Ensure the local node always exists */
414  peer = crm_get_peer(cluster->nodeid, cluster->uname);
415  cluster->uuid = get_corosync_uuid(peer);
416 
417  return TRUE;
418 }
419 
420 gboolean
421 check_message_sanity(const AIS_Message * msg, const char *data)
422 {
423  gboolean sane = TRUE;
424  int dest = msg->host.type;
425  int tmp_size = msg->header.size - sizeof(AIS_Message);
426 
427  if (sane && msg->header.size == 0) {
428  crm_warn("Message with no size");
429  sane = FALSE;
430  }
431 
432  if (sane && msg->header.error != CS_OK) {
433  crm_warn("Message header contains an error: %d", msg->header.error);
434  sane = FALSE;
435  }
436 
437  if (sane && ais_data_len(msg) != tmp_size) {
438  crm_warn("Message payload size is incorrect: expected %d, got %d", ais_data_len(msg),
439  tmp_size);
440  sane = TRUE;
441  }
442 
443  if (sane && ais_data_len(msg) == 0) {
444  crm_warn("Message with no payload");
445  sane = FALSE;
446  }
447 
448  if (sane && data && msg->is_compressed == FALSE) {
449  int str_size = strlen(data) + 1;
450 
451  if (ais_data_len(msg) != str_size) {
452  int lpc = 0;
453 
454  crm_warn("Message payload is corrupted: expected %d bytes, got %d",
455  ais_data_len(msg), str_size);
456  sane = FALSE;
457  for (lpc = (str_size - 10); lpc < msg->size; lpc++) {
458  if (lpc < 0) {
459  lpc = 0;
460  }
461  crm_debug("bad_data[%d]: %d / '%c'", lpc, data[lpc], data[lpc]);
462  }
463  }
464  }
465 
466  if (sane == FALSE) {
467  crm_err("Invalid message %d: (dest=%s:%s, from=%s:%s.%u, compressed=%d, size=%d, total=%d)",
468  msg->id, ais_dest(&(msg->host)), msg_type2text(dest),
469  ais_dest(&(msg->sender)), msg_type2text(msg->sender.type),
470  msg->sender.pid, msg->is_compressed, ais_data_len(msg), msg->header.size);
471 
472  } else {
473  crm_trace
474  ("Verified message %d: (dest=%s:%s, from=%s:%s.%u, compressed=%d, size=%d, total=%d)",
475  msg->id, ais_dest(&(msg->host)), msg_type2text(dest), ais_dest(&(msg->sender)),
476  msg_type2text(msg->sender.type), msg->sender.pid, msg->is_compressed,
477  ais_data_len(msg), msg->header.size);
478  }
479 
480  return sane;
481 }
482 
483 enum cluster_type_e
485 {
486  int rc = CS_OK;
487  cmap_handle_t handle;
488 
489  rc = cmap_initialize(&handle);
490 
491  switch(rc) {
492  case CS_OK:
493  break;
494  case CS_ERR_SECURITY:
495  crm_debug("Failed to initialize the cmap API: Permission denied (%d)", rc);
496  /* It's there, we just can't talk to it.
497  * Good enough for us to identify as 'corosync'
498  */
499  return pcmk_cluster_corosync;
500 
501  default:
502  crm_info("Failed to initialize the cmap API: %s (%d)",
503  ais_error2text(rc), rc);
504  return pcmk_cluster_unknown;
505  }
506 
507  cmap_finalize(handle);
508  return pcmk_cluster_corosync;
509 }
510 
511 gboolean
513 {
514  if (node == NULL) {
515  crm_trace("NULL");
516  return FALSE;
517 
518  } else if (safe_str_neq(node->state, CRM_NODE_MEMBER)) {
519  crm_trace("%s: state=%s", node->uname, node->state);
520  return FALSE;
521 
522  } else if ((node->processes & crm_proc_cpg) == 0) {
523  crm_trace("%s: processes=%.16x", node->uname, node->processes);
524  return FALSE;
525  }
526  return TRUE;
527 }
528 
529 gboolean
530 corosync_initialize_nodelist(void *cluster, gboolean force_member, xmlNode * xml_parent)
531 {
532  int lpc = 0;
533  cs_error_t rc = CS_OK;
534  int retries = 0;
535  gboolean any = FALSE;
536  cmap_handle_t cmap_handle;
537  int fd = -1;
538  uid_t found_uid = 0;
539  gid_t found_gid = 0;
540  pid_t found_pid = 0;
541  int rv;
542 
543  do {
544  rc = cmap_initialize(&cmap_handle);
545  if (rc != CS_OK) {
546  retries++;
547  crm_debug("API connection setup failed: %s. Retrying in %ds", cs_strerror(rc),
548  retries);
549  sleep(retries);
550  }
551 
552  } while (retries < 5 && rc != CS_OK);
553 
554  if (rc != CS_OK) {
555  crm_warn("Could not connect to Cluster Configuration Database API, error %d", rc);
556  return FALSE;
557  }
558 
559  rc = cmap_fd_get(cmap_handle, &fd);
560  if (rc != CS_OK) {
561  crm_err("Could not obtain the CMAP API connection: %s (%d)",
562  cs_strerror(rc), rc);
563  goto bail;
564  }
565 
566  /* CMAP provider run as root (in given user namespace, anyway)? */
567  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
568  &found_uid, &found_gid))) {
569  crm_err("CMAP provider is not authentic:"
570  " process %lld (uid: %lld, gid: %lld)",
571  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
572  (long long) found_uid, (long long) found_gid);
573  goto bail;
574  } else if (rv < 0) {
575  crm_err("Could not verify authenticity of CMAP provider: %s (%d)",
576  strerror(-rv), -rv);
577  goto bail;
578  }
579 
580  crm_peer_init();
581  crm_trace("Initializing corosync nodelist");
582  for (lpc = 0; TRUE; lpc++) {
583  uint32_t nodeid = 0;
584  char *name = NULL;
585  char *key = NULL;
586 
587  key = crm_strdup_printf("nodelist.node.%d.nodeid", lpc);
588  rc = cmap_get_uint32(cmap_handle, key, &nodeid);
589  free(key);
590 
591  if (rc != CS_OK) {
592  break;
593  }
594 
595  name = corosync_node_name(cmap_handle, nodeid);
596  if (name != NULL) {
597  GHashTableIter iter;
598  crm_node_t *node = NULL;
599 
600  g_hash_table_iter_init(&iter, crm_peer_cache);
601  while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &node)) {
602  if(node && node->uname && strcasecmp(node->uname, name) == 0) {
603  if (node->id && node->id != nodeid) {
604  crm_crit("Nodes %u and %u share the same name '%s': shutting down", node->id,
605  nodeid, name);
607  }
608  }
609  }
610  }
611 
612  if (nodeid > 0 || name != NULL) {
613  crm_trace("Initializing node[%d] %u = %s", lpc, nodeid, name);
614  crm_get_peer(nodeid, name);
615  }
616 
617  if (nodeid > 0 && name != NULL) {
618  any = TRUE;
619 
620  if (xml_parent) {
621  xmlNode *node = create_xml_node(xml_parent, XML_CIB_TAG_NODE);
622 
623  crm_xml_set_id(node, "%u", nodeid);
624  crm_xml_add(node, XML_ATTR_UNAME, name);
625  if (force_member) {
627  }
628  }
629  }
630 
631  free(name);
632  }
633 bail:
634  cmap_finalize(cmap_handle);
635  return any;
636 }
637 
638 char *
640 {
641  cmap_handle_t handle;
642  char *cluster_name = NULL;
643  cs_error_t rc = CS_OK;
644  int fd = -1;
645  uid_t found_uid = 0;
646  gid_t found_gid = 0;
647  pid_t found_pid = 0;
648  int rv;
649 
650  rc = cmap_initialize(&handle);
651  if (rc != CS_OK) {
652  crm_info("Failed to initialize the cmap API: %s (%d)",
653  cs_strerror(rc), rc);
654  return NULL;
655  }
656 
657  rc = cmap_fd_get(handle, &fd);
658  if (rc != CS_OK) {
659  crm_err("Could not obtain the CMAP API connection: %s (%d)",
660  cs_strerror(rc), rc);
661  goto bail;
662  }
663 
664  /* CMAP provider run as root (in given user namespace, anyway)? */
665  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
666  &found_uid, &found_gid))) {
667  crm_err("CMAP provider is not authentic:"
668  " process %lld (uid: %lld, gid: %lld)",
669  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
670  (long long) found_uid, (long long) found_gid);
671  goto bail;
672  } else if (rv < 0) {
673  crm_err("Could not verify authenticity of CMAP provider: %s (%d)",
674  strerror(-rv), -rv);
675  goto bail;
676  }
677 
678  rc = cmap_get_string(handle, "totem.cluster_name", &cluster_name);
679  if (rc != CS_OK) {
680  crm_info("Cannot get totem.cluster_name: %s (%d)", cs_strerror(rc), rc);
681 
682  } else {
683  crm_debug("cmap totem.cluster_name = '%s'", cluster_name);
684  }
685 
686 bail:
687  cmap_finalize(handle);
688  return cluster_name;
689 }
690 
691 int
692 corosync_cmap_has_config(const char *prefix)
693 {
694  cs_error_t rc = CS_OK;
695  int retries = 0;
696  static int found = -1;
697  cmap_handle_t cmap_handle;
698  cmap_iter_handle_t iter_handle;
699  char key_name[CMAP_KEYNAME_MAXLEN + 1];
700  int fd = -1;
701  uid_t found_uid = 0;
702  gid_t found_gid = 0;
703  pid_t found_pid = 0;
704  int rv;
705 
706  if(found != -1) {
707  return found;
708  }
709 
710  do {
711  rc = cmap_initialize(&cmap_handle);
712  if (rc != CS_OK) {
713  retries++;
714  crm_debug("API connection setup failed: %s. Retrying in %ds", cs_strerror(rc),
715  retries);
716  sleep(retries);
717  }
718 
719  } while (retries < 5 && rc != CS_OK);
720 
721  if (rc != CS_OK) {
722  crm_warn("Could not connect to Cluster Configuration Database API: %s (rc=%d)",
723  cs_strerror(rc), rc);
724  return -1;
725  }
726 
727  rc = cmap_fd_get(cmap_handle, &fd);
728  if (rc != CS_OK) {
729  crm_err("Could not obtain the CMAP API connection: %s (%d)",
730  cs_strerror(rc), rc);
731  goto bail;
732  }
733 
734  /* CMAP provider run as root (in given user namespace, anyway)? */
735  if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid,
736  &found_uid, &found_gid))) {
737  crm_err("CMAP provider is not authentic:"
738  " process %lld (uid: %lld, gid: %lld)",
739  (long long) PCMK__SPECIAL_PID_AS_0(found_pid),
740  (long long) found_uid, (long long) found_gid);
741  goto bail;
742  } else if (rv < 0) {
743  crm_err("Could not verify authenticity of CMAP provider: %s (%d)",
744  strerror(-rv), -rv);
745  goto bail;
746  }
747 
748  rc = cmap_iter_init(cmap_handle, prefix, &iter_handle);
749  if (rc != CS_OK) {
750  crm_warn("Failed to initialize iteration for corosync cmap '%s': %s (rc=%d)",
751  prefix, cs_strerror(rc), rc);
752  goto bail;
753  }
754 
755  found = 0;
756  while ((rc = cmap_iter_next(cmap_handle, iter_handle, key_name, NULL, NULL)) == CS_OK) {
757  crm_trace("'%s' is configured in corosync cmap: %s", prefix, key_name);
758  found++;
759  break;
760  }
761  cmap_iter_finalize(cmap_handle, iter_handle);
762 
763 bail:
764  cmap_finalize(cmap_handle);
765 
766  return found;
767 }
enum crm_ais_msg_types type
Definition: internal.h:22
#define crm_notice(fmt, args...)
Definition: logging.h:242
gboolean is_compressed
Definition: internal.h:31
uint32_t size
Definition: internal.h:36
#define crm_crit(fmt, args...)
Definition: logging.h:239
gboolean safe_str_neq(const char *a, const char *b)
Definition: strings.c:157
mainloop_io_t * mainloop_add_fd(const char *name, int priority, int fd, void *userdata, struct mainloop_fd_callbacks *callbacks)
Definition: mainloop.c:864
uint32_t nodeid
Definition: cluster.h:76
quorum_callbacks_t quorum_callbacks
Definition: corosync.c:266
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
Definition: results.c:476
void crm_reap_unseen_nodes(uint64_t ring_id)
Definition: membership.c:977
char * corosync_node_name(uint64_tcmap_handle, uint32_t nodeid)
Definition: corosync.c:61
quorum_handle_t pcmk_quorum_handle
Definition: corosync.c:39
uint32_t id
Definition: cluster.h:62
#define XML_ATTR_TYPE
Definition: msg_xml.h:99
gboolean crm_have_quorum
Definition: membership.c:56
void terminate_cs_connection(crm_cluster_t *cluster)
Definition: corosync.c:174
void crm_peer_init(void)
Definition: membership.c:390
#define PCMK__SPECIAL_PID_AS_0(p)
Definition: ipc_internal.h:34
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
Definition: nvpair.c:275
crm_node_t * crm_get_peer(unsigned int id, const char *uname)
Definition: membership.c:653
int(* dispatch)(gpointer userdata)
Definition: mainloop.h:92
char * uuid
Definition: cluster.h:74
char * get_node_name(uint32_t nodeid)
Definition: cluster.c:130
char * strerror(int errnum)
gboolean cluster_connect_quorum(gboolean(*dispatch)(unsigned long long, gboolean), void(*destroy)(gpointer))
Definition: corosync.c:271
Wrappers for and extensions to glib mainloop.
gboolean init_cs_connection(crm_cluster_t *cluster)
Definition: corosync.c:356
gboolean crm_is_corosync_peer_active(const crm_node_t *node)
Definition: corosync.c:512
void cluster_disconnect_cpg(crm_cluster_t *cluster)
Definition: cpg.c:51
#define crm_warn(fmt, args...)
Definition: logging.h:241
uint32_t processes
Definition: cluster.h:59
char * corosync_cluster_name(void)
Definition: corosync.c:639
#define crm_debug(fmt, args...)
Definition: logging.h:245
void(* destroy)(gpointer userdata)
Definition: mainloop.h:93
cluster_type_e
Definition: cluster.h:174
gboolean(* quorum_app_callback)(unsigned long long seq, gboolean quorate)
Definition: corosync.c:41
#define crm_trace(fmt, args...)
Definition: logging.h:246
AIS_Host sender
Definition: internal.h:34
uint32_t id
Definition: internal.h:30
#define XML_ATTR_UNAME
Definition: msg_xml.h:118
gboolean check_message_sanity(const AIS_Message *msg, const char *data)
Definition: corosync.c:421
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition: xml.c:1890
struct crm_ais_msg_s AIS_Message
Definition: internal.h:16
#define ais_data_len(msg)
Definition: internal.h:125
int corosync_cmap_has_config(const char *prefix)
Definition: corosync.c:692
#define CRM_NODE_MEMBER
Definition: cluster.h:31
enum cluster_type_e find_corosync_variant(void)
Definition: corosync.c:484
#define XML_CIB_TAG_NODE
Definition: msg_xml.h:159
const char * name_for_cluster_type(enum cluster_type_e type)
Definition: cluster.c:234
gboolean init_cs_connection_once(crm_cluster_t *cluster)
Definition: corosync.c:383
gboolean is_corosync_cluster(void)
Definition: cluster.c:328
#define CRM_XS
Definition: logging.h:34
crm_node_t * crm_update_peer_state(const char *source, crm_node_t *node, const char *state, int membership)
Update a node&#39;s state and membership information.
Definition: membership.c:965
char * uname
Definition: cluster.h:75
uint32_t get_local_nodeid(cpg_handle_t handle)
Definition: cpg.c:65
gboolean node_name_is_valid(const char *key, const char *name)
Definition: cluster.c:334
#define crm_err(fmt, args...)
Definition: logging.h:240
void crm_xml_set_id(xmlNode *xml, const char *format,...) __attribute__((__format__(__printf__
char data[0]
Definition: internal.h:92
char * state
Definition: cluster.h:56
char * get_corosync_uuid(crm_node_t *node)
Definition: corosync.c:44
#define U64T
Definition: config.h:598
Wrappers for and extensions to libqb IPC.
uint32_t pid
Definition: internal.h:20
char * uname
Definition: cluster.h:54
uint64_t last_seen
Definition: cluster.h:58
AIS_Host host
Definition: internal.h:33
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
GHashTable * crm_peer_cache
Definition: membership.c:34
#define crm_info(fmt, args...)
Definition: logging.h:243
gboolean corosync_initialize_nodelist(void *cluster, gboolean force_member, xmlNode *xml_parent)
Definition: corosync.c:530
gboolean cluster_connect_cpg(crm_cluster_t *cluster)
Definition: cpg.c:537
enum cluster_type_e get_cluster_type(void)
Definition: cluster.c:273
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.
Definition: ipc.c:1452