26 #include <sys/param.h> 27 #include <sys/types.h> 30 #include <sys/utsname.h> 43 #include <qb/qbdefs.h> 55 #include <libxml2/libxml/relaxng.h> 66 # define PW_BUFFER_LEN 500 80 static struct crm_option *crm_long_options = NULL;
81 static const char *crm_app_description = NULL;
82 static char *crm_short_options = NULL;
83 static const char *crm_app_usage = NULL;
98 free(crm_short_options);
199 if(stat(value, &st) != 0) {
200 crm_err(
"Script %s does not exist", value);
204 if(S_ISREG(st.st_mode) == 0) {
205 crm_err(
"Script %s is not a regular file", value);
209 if( (st.st_mode & (S_IXUSR | S_IXGRP )) == 0) {
210 crm_err(
"Script %s is not executable", value);
221 long number = strtol(value, &end, 10);
223 if(end && end[0] !=
'%') {
225 }
else if(number < 0) {
298 const char *name,
const char *old_name,
const char *def_value)
300 const char *value = NULL;
304 if (options != NULL) {
305 value = g_hash_table_lookup(options, name);
308 if (value == NULL && old_name && options != NULL) {
309 value = g_hash_table_lookup(options, old_name);
312 " cluster option '%s'", old_name, name);
313 g_hash_table_insert(options, strdup(name), strdup(value));
314 value = g_hash_table_lookup(options, old_name);
319 crm_trace(
"Using default value '%s' for cluster option '%s'", def_value, name);
321 if (options == NULL) {
324 }
else if(def_value == NULL) {
328 g_hash_table_insert(options, strdup(name), strdup(def_value));
329 value = g_hash_table_lookup(options, name);
332 if (validate && validate(value) == FALSE) {
334 " Defaulting to %s", value, name, def_value);
335 g_hash_table_replace(options, strdup(name), strdup(def_value));
336 value = g_hash_table_lookup(options, name);
346 const char *value = NULL;
347 gboolean found = FALSE;
349 for (lpc = 0; lpc < len; lpc++) {
353 option_list[lpc].is_valid,
354 option_list[lpc].name,
355 option_list[lpc].alt_name, option_list[lpc].default_value);
368 fprintf(stdout,
"<?xml version=\"1.0\"?>" 369 "<!DOCTYPE resource-agent SYSTEM \"ra-api-1.dtd\">\n" 370 "<resource-agent name=\"%s\">\n" 371 " <version>%s</version>\n" 372 " <longdesc lang=\"en\">%s</longdesc>\n" 373 " <shortdesc lang=\"en\">%s</shortdesc>\n" 374 " <parameters>\n", name, version, desc_long, desc_short);
376 for (lpc = 0; lpc < len; lpc++) {
377 if (option_list[lpc].description_long == NULL && option_list[lpc].description_short == NULL) {
380 fprintf(stdout,
" <parameter name=\"%s\" unique=\"0\">\n" 381 " <shortdesc lang=\"en\">%s</shortdesc>\n" 382 " <content type=\"%s\" default=\"%s\"/>\n" 383 " <longdesc lang=\"en\">%s%s%s</longdesc>\n" 385 option_list[lpc].name,
386 option_list[lpc].description_short,
387 option_list[lpc].
type,
388 option_list[lpc].default_value,
389 option_list[lpc].description_long ? option_list[lpc].
390 description_long : option_list[lpc].description_short,
391 option_list[lpc].values ?
" Allowed values: " :
"",
392 option_list[lpc].values ? option_list[lpc].values :
"");
394 fprintf(stdout,
" </parameters>\n</resource-agent>\n");
402 for (lpc = 0; lpc < len; lpc++) {
404 option_list[lpc].is_valid,
405 option_list[lpc].name,
406 option_list[lpc].alt_name, option_list[lpc].default_value);
413 char *hash_key =
crm_concat(sys ? sys :
"none", crm_msg_reference,
'_');
415 crm_trace(
"created hash key: (%s)", hash_key);
426 struct passwd *pwentry = NULL;
433 *uid = pwentry->pw_uid;
436 *gid = pwentry->pw_gid;
438 crm_trace(
"Cluster user %s has uid=%d gid=%d", name, pwentry->pw_uid, pwentry->pw_gid);
441 crm_err(
"Cluster user %s does not exist", name);
449 crm_version_helper(
const char *text,
char **end_text)
451 int atoi_result = -1;
457 if (text != NULL && text[0] != 0) {
458 atoi_result = (int)strtol(text, end_text, 10);
460 if (errno == EINVAL) {
461 crm_err(
"Conversion of '%s' %c failed", text, text[0]);
478 char *ver1_copy = NULL, *ver2_copy = NULL;
479 char *rest1 = NULL, *rest2 = NULL;
481 if (version1 == NULL && version2 == NULL) {
483 }
else if (version1 == NULL) {
485 }
else if (version2 == NULL) {
489 ver1_copy = strdup(version1);
490 ver2_copy = strdup(version2);
500 if (rest1 == rest2) {
505 digit1 = crm_version_helper(rest1, &rest1);
509 digit2 = crm_version_helper(rest2, &rest2);
512 if (digit1 < digit2) {
516 }
else if (digit1 > digit2) {
521 if (rest1 != NULL && rest1[0] ==
'.') {
524 if (rest1 != NULL && rest1[0] == 0) {
528 if (rest2 != NULL && rest2[0] ==
'.') {
531 if (rest2 != NULL && rest2[0] == 0) {
540 crm_trace(
"%s == %s (%d)", version1, version2, lpc);
542 crm_trace(
"%s < %s (%d)", version1, version2, lpc);
544 crm_trace(
"%s > %s (%d)", version1, version2, lpc);
553 # define NUMCHARS "0123456789." 557 # define WHITESPACE " \t\n\r\f" 563 unsigned long long msec = 0;
568 }
else if (input[0] !=
'P') {
588 const char *cp = input;
590 long long multiplier = 1000;
591 long long divisor = 1;
593 char *end_text = NULL;
605 if (strchr(
NUMCHARS, *cp) == NULL) {
609 if (strncasecmp(units,
"ms", 2) == 0 || strncasecmp(units,
"msec", 4) == 0) {
612 }
else if (strncasecmp(units,
"us", 2) == 0 || strncasecmp(units,
"usec", 4) == 0) {
615 }
else if (strncasecmp(units,
"s", 1) == 0 || strncasecmp(units,
"sec", 3) == 0) {
618 }
else if (strncasecmp(units,
"m", 1) == 0 || strncasecmp(units,
"min", 3) == 0) {
619 multiplier = 60 * 1000;
621 }
else if (strncasecmp(units,
"h", 1) == 0 || strncasecmp(units,
"hr", 2) == 0) {
622 multiplier = 60 * 60 * 1000;
624 }
else if (*units !=
EOS && *units !=
'\n' && *units !=
'\r') {
629 if (msec > LLONG_MAX/multiplier) {
661 parse_op_key(
const char *key,
char **rsc_id,
char **op_type,
int *interval)
664 char *mutable_key = NULL;
665 char *mutable_key_ptr = NULL;
666 int len = 0, offset = 0, ch = 0;
676 while (offset > 0 && isdigit(key[offset])) {
677 int digits = len - offset;
679 ch = key[offset] -
'0';
691 CRM_CHECK(key[offset] ==
'_',
return FALSE);
693 mutable_key = strdup(key);
694 mutable_key[offset] = 0;
697 while (offset > 0 && key[offset] !=
'_') {
701 CRM_CHECK(key[offset] ==
'_', free(mutable_key);
704 mutable_key_ptr = mutable_key + offset + 1;
706 crm_trace(
" Action: %s", mutable_key_ptr);
708 *op_type = strdup(mutable_key_ptr);
710 mutable_key[offset] = 0;
713 CRM_CHECK(mutable_key != mutable_key_ptr, free(mutable_key);
716 notify = strstr(mutable_key,
"_post_notify");
717 if (notify &&
safe_str_eq(notify,
"_post_notify")) {
721 notify = strstr(mutable_key,
"_pre_notify");
722 if (notify &&
safe_str_eq(notify,
"_pre_notify")) {
727 *rsc_id = mutable_key;
740 CRM_CHECK(notify_type != NULL,
return NULL);
742 len += strlen(op_type);
743 len += strlen(rsc_id);
744 len += strlen(notify_type);
749 sprintf(op_id,
"%s_%s_notify_%s_0", rsc_id, notify_type, op_type);
758 char *fail_state = NULL;
760 CRM_CHECK(transition_key != NULL,
return NULL);
762 len += strlen(transition_key);
764 fail_state = malloc(len);
765 if (fail_state != NULL) {
766 snprintf(fail_state, len,
"%d:%s", op_status, transition_key);
775 char *fail_state = NULL;
777 CRM_CHECK(transition_key != NULL,
return NULL);
779 len += strlen(transition_key);
781 fail_state = malloc(len);
782 if (fail_state != NULL) {
783 snprintf(fail_state, len,
"%d:%d;%s", op_status, op_rc, transition_key);
790 int *
op_status,
int *op_rc,
int *target_rc)
794 gboolean result = TRUE;
798 CRM_CHECK(op_status != NULL,
return FALSE);
800 key = calloc(1, strlen(magic) + 1);
801 res = sscanf(magic,
"%d:%d;%s", op_status, op_rc, key);
803 crm_warn(
"Only found %d items in: '%s'", res, magic);
818 char *fail_state = NULL;
824 fail_state = malloc(len);
825 if (fail_state != NULL) {
826 snprintf(fail_state, len,
"%d:%d:%d:%-*s", action_id, transition_id, target_rc, 36, node);
836 gboolean done = FALSE;
839 CRM_CHECK(target_rc != NULL,
return FALSE);
840 CRM_CHECK(action_id != NULL,
return FALSE);
841 CRM_CHECK(transition_id != NULL,
return FALSE);
843 *uuid = calloc(1, 37);
844 res = sscanf(key,
"%d:%d:%d:%36s", action_id, transition_id, target_rc, *uuid);
857 res = sscanf(key,
"%d:%d:%36s", action_id, transition_id, *uuid);
860 res = sscanf(key,
"%d:%36s", transition_id, *uuid);
863 }
else if (res != 3) {
873 res = sscanf(key,
"%d:%36s", transition_id, *uuid);
877 crm_crit(
"Unhandled sscanf result (%d) for %s", res, key);
880 if (strlen(*uuid) != 36) {
881 crm_warn(
"Bad UUID (%s) in sscanf result (%d) for %s", *uuid, res, key);
885 crm_err(
"Cannot decode '%s' rc=%d", key, res);
901 char *timeout = NULL;
902 char *interval = NULL;
904 const char *attr_filter[] = {
913 gboolean do_delete = FALSE;
915 static int meta_len = 0;
921 if (param_set == NULL) {
925 for (lpc = 0; lpc <
DIMOF(attr_filter); lpc++) {
937 xmlAttrPtr xIter = param_set->properties;
940 const char *prop_name = (
const char *)xIter->name;
944 if (strncasecmp(prop_name,
CRM_META, meta_len) == 0) {
956 if (timeout != NULL) {
970 crm_abort(
const char *file,
const char *
function,
int line,
971 const char *assert_condition, gboolean do_core, gboolean do_fork)
980 if(crm_is_daemon == FALSE) {
988 if (do_core == FALSE) {
989 crm_err(
"%s: Triggered assert at %s:%d : %s",
function, file, line, assert_condition);
992 }
else if (do_fork) {
996 crm_err(
"%s: Triggered fatal assert at %s:%d : %s",
function, file, line, assert_condition);
1000 crm_crit(
"%s: Cannot create core for non-fatal assert at %s:%d : %s",
1001 function, file, line, assert_condition);
1004 }
else if(pid == 0) {
1011 crm_err(
"%s: Forked child %d to record non-fatal assert at %s:%d : %s",
1012 function, pid, file, line, assert_condition);
1016 rc = waitpid(pid, &status, 0);
1021 }
while(errno == EINTR);
1023 if (errno == ECHILD) {
1025 crm_trace(
"Cannot wait on forked child %d - SIGCHLD is probably set to SIG_IGN", pid);
1028 crm_perror(LOG_ERR,
"Cannot wait on forked child %d", pid);
1034 static int have_proc_pid = 0;
1036 if(have_proc_pid == 0) {
1037 char proc_path[PATH_MAX], exe_path[PATH_MAX];
1040 snprintf(proc_path,
sizeof(proc_path),
"/proc/%lu/exe", (
long unsigned int)getpid());
1043 if(readlink(proc_path, exe_path, PATH_MAX - 1) < 0) {
1051 }
else if (kill(pid, 0) < 0 && errno == ESRCH) {
1054 }
else if(daemon == NULL || have_proc_pid == -1) {
1059 char proc_path[PATH_MAX], exe_path[PATH_MAX], myexe_path[PATH_MAX];
1062 snprintf(proc_path,
sizeof(proc_path),
"/proc/%lu/exe", pid);
1064 rc = readlink(proc_path, exe_path, PATH_MAX - 1);
1065 if (rc < 0 && errno == EACCES) {
1066 crm_perror(LOG_INFO,
"Could not read from %s", proc_path);
1068 }
else if (rc < 0) {
1069 crm_perror(LOG_ERR,
"Could not read from %s", proc_path);
1076 if(daemon[0] !=
'/') {
1077 rc = snprintf(myexe_path,
sizeof(proc_path),
CRM_DAEMON_DIR"/%s", daemon);
1080 rc = snprintf(myexe_path,
sizeof(proc_path),
"%s", daemon);
1084 if (strcmp(exe_path, myexe_path) == 0) {
1092 #define LOCKSTRLEN 11 1102 if ((fd = open(filename, O_RDONLY)) < 0) {
1106 if (fstat(fd, &sbuf) >= 0 && sbuf.st_size <
LOCKSTRLEN) {
1112 if (read(fd, buf,
sizeof(buf)) < 1) {
1116 if (sscanf(buf,
"%lu", &pid) > 0) {
1120 crm_trace(
"Got pid %lu from %s\n", pid, filename);
1141 }
else if (mypid && pid == mypid) {
1150 }
else if (mypid && pid != mypid) {
1159 crm_lock_pidfile(
const char *filename,
const char *name)
1165 mypid = (
unsigned long)getpid();
1168 if (rc == -ENOENT) {
1176 if ((fd = open(filename, O_CREAT | O_WRONLY | O_EXCL, 0644)) < 0) {
1181 snprintf(buf,
sizeof(buf),
"%*lu\n",
LOCKSTRLEN - 1, mypid);
1186 crm_perror(LOG_ERR,
"Incomplete write to %s", filename);
1198 const char *devnull =
"/dev/null";
1200 if (daemonize == FALSE) {
1206 if(rc <
pcmk_ok && rc != -ENOENT) {
1208 crm_err(
"%s: already running [pid %ld in %s]", name, pid, pidfile);
1209 printf(
"%s: already running [pid %ld in %s]\n", name, pid, pidfile);
1215 fprintf(stderr,
"%s: could not start daemon\n", name);
1219 }
else if (pid > 0) {
1223 rc = crm_lock_pidfile(pidfile, name);
1226 printf(
"Could not lock '%s' for %s: %s (%d)\n", pidfile, name,
pcmk_strerror(rc), rc);
1230 umask(S_IWGRP | S_IWOTH | S_IROTH);
1232 close(STDIN_FILENO);
1233 (void)open(devnull, O_RDONLY);
1234 close(STDOUT_FILENO);
1235 (void)open(devnull, O_WRONLY);
1236 close(STDERR_FILENO);
1237 (void)open(devnull, O_WRONLY);
1245 char *crm_name = NULL;
1251 max = strlen(crm_name);
1252 for (; lpc < max; lpc++) {
1253 switch (crm_name[lpc]) {
1255 crm_name[lpc] =
'_';
1266 const char *value = NULL;
1270 value = g_hash_table_lookup(hash, key);
1277 static struct option *
1278 crm_create_long_opts(
struct crm_option *long_options)
1280 struct option *long_opts = NULL;
1282 #ifdef HAVE_GETOPT_H 1283 int index = 0, lpc = 0;
1292 long_opts = realloc_safe(long_opts, (index + 1) *
sizeof(
struct option));
1293 long_opts[index].name =
"__dummmy__";
1294 long_opts[index].has_arg = 0;
1295 long_opts[index].flag = 0;
1296 long_opts[index].val =
'_';
1299 for (lpc = 0; long_options[lpc].
name != NULL; lpc++) {
1300 if (long_options[lpc].name[0] ==
'-') {
1304 long_opts = realloc_safe(long_opts, (index + 1) *
sizeof(
struct option));
1307 long_opts[index].name = long_options[lpc].
name;
1308 long_opts[index].has_arg = long_options[lpc].
has_arg;
1309 long_opts[index].flag = long_options[lpc].
flag;
1310 long_opts[index].val = long_options[lpc].
val;
1315 long_opts = realloc_safe(long_opts, (index + 1) *
sizeof(
struct option));
1316 long_opts[index].name = NULL;
1317 long_opts[index].has_arg = 0;
1318 long_opts[index].flag = 0;
1319 long_opts[index].val = 0;
1327 const char *app_desc)
1329 if (short_options) {
1330 crm_short_options = strdup(short_options);
1332 }
else if (long_options) {
1334 int opt_string_len = 0;
1335 char *local_short_options = NULL;
1337 for (lpc = 0; long_options[lpc].
name != NULL; lpc++) {
1338 if (long_options[lpc].val && long_options[lpc].val !=
'-' && long_options[lpc].val < UCHAR_MAX) {
1339 local_short_options = realloc_safe(local_short_options, opt_string_len + 4);
1340 local_short_options[opt_string_len++] = long_options[lpc].
val;
1342 if (long_options[lpc].has_arg == optional_argument) {
1343 local_short_options[opt_string_len++] =
':';
1345 if (long_options[lpc].has_arg >= required_argument) {
1346 local_short_options[opt_string_len++] =
':';
1348 local_short_options[opt_string_len] = 0;
1351 crm_short_options = local_short_options;
1352 crm_trace(
"Generated short option string: '%s'", local_short_options);
1356 crm_long_options = long_options;
1359 crm_app_description = app_desc;
1362 crm_app_usage = app_usage;
1375 #ifdef HAVE_GETOPT_H 1376 static struct option *long_opts = NULL;
1378 if (long_opts == NULL && crm_long_options) {
1379 long_opts = crm_create_long_opts(crm_long_options);
1384 int flag = getopt_long(argc, argv, crm_short_options, long_opts, index);
1388 if (long_opts[*index].val) {
1389 return long_opts[*index].val;
1390 }
else if (longname) {
1391 *longname = long_opts[*index].name;
1393 crm_notice(
"Unhandled option --%s", long_opts[*index].name);
1410 if (crm_short_options) {
1411 return getopt(argc, argv, crm_short_options);
1421 FILE *stream = (exit_code ? stderr : stdout);
1423 if (cmd ==
'v' || cmd ==
'$') {
1425 fprintf(stream,
"Written by Andrew Beekhof\n");
1436 if (crm_app_usage) {
1440 if (crm_long_options) {
1441 fprintf(stream,
"Options:\n");
1442 for (i = 0; crm_long_options[i].
name != NULL; i++) {
1446 fprintf(stream,
"%s\n\n", crm_long_options[i].desc);
1449 fprintf(stream,
"\t#%s\n\n", crm_long_options[i].desc);
1451 }
else if (crm_long_options[i].val ==
'-' && crm_long_options[i].desc) {
1452 fprintf(stream,
"%s\n", crm_long_options[i].desc);
1456 if (crm_long_options[i].val && crm_long_options[i].val <= UCHAR_MAX) {
1457 fprintf(stream,
" -%c,", crm_long_options[i].val);
1461 fprintf(stream,
" --%s%s\t%s\n", crm_long_options[i].name,
1462 crm_long_options[i].has_arg == optional_argument ?
"[=value]" :
1463 crm_long_options[i].has_arg == required_argument ?
"=value" :
"",
1464 crm_long_options[i].desc ? crm_long_options[i].desc :
"");
1468 }
else if (crm_short_options) {
1469 fprintf(stream,
"Usage: %s - %s\n",
crm_system_name, crm_app_description);
1470 for (i = 0; crm_short_options[i] != 0; i++) {
1471 int has_arg = no_argument ;
1473 if (crm_short_options[i + 1] ==
':') {
1474 if (crm_short_options[i + 2] ==
':')
1475 has_arg = optional_argument ;
1477 has_arg = required_argument ;
1480 fprintf(stream,
" -%c %s\n", crm_short_options[i],
1481 has_arg == optional_argument ?
"[value]" :
1482 has_arg == required_argument ?
"{value}" :
"");
1494 qb_ipcs_service_t **ipcs_rw,
1495 qb_ipcs_service_t **ipcs_shm,
1496 struct qb_ipcs_service_handlers *ro_cb,
1497 struct qb_ipcs_service_handlers *rw_cb)
1503 if (*ipcs_ro == NULL || *ipcs_rw == NULL || *ipcs_shm == NULL) {
1504 crm_err(
"Failed to create cib servers: exiting and inhibiting respawn.");
1505 crm_warn(
"Verify pacemaker and pacemaker_remote are not both enabled.");
1511 qb_ipcs_service_t *ipcs_rw,
1512 qb_ipcs_service_t *ipcs_shm)
1514 qb_ipcs_destroy(ipcs_ro);
1515 qb_ipcs_destroy(ipcs_rw);
1516 qb_ipcs_destroy(ipcs_shm);
1530 if (*ipcs == NULL) {
1531 crm_err(
"Failed to create attrd servers: exiting and inhibiting respawn.");
1532 crm_warn(
"Verify pacemaker and pacemaker_remote are not both enabled.");
1542 if (*ipcs == NULL) {
1543 crm_err(
"Failed to create stonith-ng servers: exiting and inhibiting respawn.");
1544 crm_warn(
"Verify pacemaker and pacemaker_remote are not both enabled.");
1549 #define FAKE_TE_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 1558 char *digest = NULL;
1559 xmlNode *args_xml = NULL;
1561 if (op->
params == NULL) {
1568 #ifdef ENABLE_VERSIONED_ATTRS 1569 crm_summarize_versioned_params(args_xml, op->versioned_params);
1578 do_crm_log(level,
"Calculated digest %s for %s (%s). Source: %s\n",
1579 digest,
ID(update), magic, digest_source);
1580 free(digest_source);
1620 if (target_rc != op->
rc) {
1630 int target_rc,
const char * node,
const char * origin,
int level)
1635 char *op_id_additional = NULL;
1636 char *local_user_data = NULL;
1637 const char *exit_reason = NULL;
1639 xmlNode *xml_op = NULL;
1640 const char *task = NULL;
1641 gboolean dc_munges_migrate_ops = (
compare_version(caller_version,
"3.0.3") < 0);
1642 gboolean dc_needs_unique_ops = (
compare_version(caller_version,
"3.0.6") < 0);
1645 do_crm_log(level,
"%s: Updating resource %s after %s op %s (interval=%d)",
1649 crm_trace(
"DC version: %s", caller_version);
1670 }
else if (dc_munges_migrate_ops
1677 if (dc_needs_unique_ops && op->
interval > 0) {
1678 op_id = strdup(key);
1701 op_id = strdup(key);
1709 if (xml_op == NULL) {
1714 crm_debug(
"Generating fake transition key for:" 1715 " %s_%s_%d %d from %s",
1742 crm_trace(
"Timing data (%s_%s_%d): last=%u change=%u exec=%u queue=%u",
1778 append_digest(op, xml_op, caller_version, magic, LOG_DEBUG);
1780 if (op_id_additional) {
1782 op_id = op_id_additional;
1783 op_id_additional = NULL;
1787 if (local_user_data) {
1788 free(local_user_data);
1801 if(user == NULL || strlen(user) == 0) {
1808 }
else if (strcmp(user,
"root") == 0) {
1811 crm_trace(
"acls required for %s", user);
1823 struct passwd *pwent = getpwuid(uid);
1825 if (pwent == NULL) {
1826 crm_perror(LOG_ERR,
"Cannot get password entry of uid: %d", uid);
1830 return strdup(pwent->pw_name);
1838 static const char *effective_user = NULL;
1839 const char *requested_user = NULL;
1840 const char *user = NULL;
1842 if(effective_user == NULL) {
1847 if(requested_user == NULL) {
1851 if (is_privileged(effective_user) == FALSE) {
1853 user = effective_user;
1855 }
else if(peer_user == NULL && requested_user == NULL) {
1857 user = effective_user;
1859 }
else if(peer_user == NULL) {
1861 user = requested_user;
1863 }
else if (is_privileged(peer_user) == FALSE) {
1867 }
else if (requested_user == NULL) {
1873 user = requested_user;
1885 return requested_user;
1892 CRM_CHECK(user != NULL && request != NULL && field != NULL,
return);
1895 if (is_privileged(user) == FALSE) {
1916 if (*handle == NULL) {
1917 *handle = dlopen(lib, RTLD_LAZY);
1921 crm_err(
"%sCould not open %s: %s", fatal ?
"Fatal: " :
"", lib, dlerror());
1928 a_function = dlsym(*handle, fn);
1929 if (a_function == NULL) {
1931 crm_err(
"%sCould not find %s in %s: %s", fatal ?
"Fatal: " :
"", fn, lib, error);
1947 #ifdef HAVE_UUID_UUID_H 1948 # include <uuid/uuid.h> 1954 unsigned char uuid[16];
1955 char *buffer = malloc(37);
1957 uuid_generate(uuid);
1958 uuid_unparse(uuid, buffer);
1988 int lpc = 0, len = 0;
1989 char *digest = NULL;
1992 if (buffer == NULL) {
1995 len = strlen(buffer);
1997 crm_trace(
"Beginning digest of %d bytes", len);
2002 sprintf(digest + (2 * lpc),
"%02x", raw_digest[lpc]);
2008 crm_err(
"Could not create digest");
2013 #ifdef HAVE_GNUTLS_GNUTLS_H 2015 crm_gnutls_global_init(
void)
2017 signal(SIGPIPE, SIG_IGN);
2018 gnutls_global_init();
#define CRM_CHECK(expr, failure_action)
#define XML_RSC_OP_LAST_CHANGE
void * find_library_function(void **handle, const char *lib, const char *fn, gboolean fatal)
void verify_all_options(GHashTable *options, pe_cluster_option *option_list, int len)
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, int *interval)
void crm_write_blackbox(int nsig, struct qb_log_callsite *callsite)
long long crm_get_msec(const char *input)
int crm_get_option_long(int argc, char **argv, int *index, const char **longname)
#define crm_notice(fmt, args...)
int crm_user_lookup(const char *name, uid_t *uid, gid_t *gid)
#define CRMD_ACTION_MIGRATED
void crm_enable_stderr(int enable)
void * convert_const_pointer(const void *ptr)
#define crm_crit(fmt, args...)
gboolean check_utilization(const char *value)
const char * crm_meta_value(GHashTable *hash, const char *field)
#define XML_ATTR_TRANSITION_MAGIC
void cib_ipc_servers_destroy(qb_ipcs_service_t *ipcs_ro, qb_ipcs_service_t *ipcs_rw, qb_ipcs_service_t *ipcs_shm)
void attrd_ipc_server_init(qb_ipcs_service_t **ipcs, struct qb_ipcs_service_handlers *cb)
struct crm_time_s crm_time_t
const char * pcmk_strerror(int rc)
gboolean check_time(const char *value)
#define crm_config_err(fmt...)
void crm_make_daemon(const char *name, gboolean daemonize, const char *pidfile)
void crm_xml_cleanup(void)
gboolean decode_transition_key(const char *key, char **uuid, int *transition_id, int *action_id, int *target_rc)
long long crm_int_helper(const char *text, char **end_text)
#define CRMD_ACTION_NOTIFY
void cib_ipc_servers_init(qb_ipcs_service_t **ipcs_ro, qb_ipcs_service_t **ipcs_rw, qb_ipcs_service_t **ipcs_shm, struct qb_ipcs_service_handlers *ro_cb, struct qb_ipcs_service_handlers *rw_cb)
char * crm_md5sum(const char *buffer)
xmlNode * find_entity(xmlNode *parent, const char *node_name, const char *id)
#define XML_RSC_OP_T_EXEC
bool crm_is_daemon_name(const char *name)
Check whether a string represents a cluster daemon name.
char * generate_transition_key(int transition_id, int action_id, int target_rc, const char *node)
#define XML_LRM_ATTR_INTERVAL
gboolean crm_config_warning
int crm_help(char cmd, int exit_code)
#define XML_LRM_ATTR_OP_DIGEST
void mainloop_cleanup(void)
int crm_parse_int(const char *text, const char *default_text)
char * crm_element_value_copy(xmlNode *data, const char *name)
crm_time_t * crm_time_parse_duration(const char *duration_str)
#define CRM_LOG_ASSERT(expr)
void crm_set_options(const char *short_options, const char *app_usage, struct crm_option *long_options, const char *app_desc)
const char * get_cluster_pref(GHashTable *options, pe_cluster_option *option_list, int len, const char *name)
#define XML_RSC_OP_T_QUEUE
#define PACEMAKER_VERSION
Wrappers for and extensions to glib mainloop.
gboolean check_positive_number(const char *value)
void config_metadata(const char *name, const char *version, const char *desc_short, const char *desc_long, pe_cluster_option *option_list, int len)
long crm_read_pidfile(const char *filename)
const char * crm_xml_replace(xmlNode *node, const char *name, const char *value)
bool pcmk_acl_required(const char *user)
void stonith_ipc_server_init(qb_ipcs_service_t **ipcs, struct qb_ipcs_service_handlers *cb)
#define CRMD_ACTION_START
xmlNode * create_operation_update(xmlNode *parent, lrmd_event_data_t *op, const char *caller_version, int target_rc, const char *node, const char *origin, int level)
char * crm_meta_name(const char *field)
gboolean check_quorum(const char *value)
#define XML_LRM_ATTR_TASK_KEY
#define XML_LRM_ATTR_TASK
void hash2field(gpointer key, gpointer value, gpointer user_data)
char * calculate_operation_digest(xmlNode *local_cib, const char *version)
Calculate and return digest of XML operation.
#define crm_warn(fmt, args...)
int crm_pid_active(long pid, const char *daemon)
int daemon(int nochdir, int noclose)
char * generate_hash_key(const char *crm_msg_reference, const char *sys)
#define crm_debug(fmt, args...)
void determine_request_user(const char *user, xmlNode *request, const char *field)
char * score2char(int score)
#define pcmk_option_example
unsigned long long crm_get_interval(const char *input)
gboolean did_rsc_op_fail(lrmd_event_data_t *op, int target_rc)
#define crm_trace(fmt, args...)
#define do_crm_log(level, fmt, args...)
Log a message.
const char * cluster_option(GHashTable *options, gboolean(*validate)(const char *), const char *name, const char *old_name, const char *def_value)
#define pcmk_option_paragraph
Wrappers for and extensions to libxml2.
xmlNode * create_xml_node(xmlNode *parent, const char *name)
const char * crm_element_value(xmlNode *data, const char *name)
#define XML_LRM_ATTR_MIGRATE_TARGET
char * crm_generate_uuid(void)
#define XML_LRM_ATTR_EXIT_REASON
void free_xml(xmlNode *child)
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
char * crm_itoa_stack(int an_int, char *buf, size_t len)
void filter_action_parameters(xmlNode *param_set, const char *version)
CRM_TRACE_INIT_DATA(common)
gboolean decode_transition_magic(const char *magic, char **uuid, int *transition_id, int *action_id, int *op_status, int *op_rc, int *target_rc)
#define XML_LRM_ATTR_TARGET_UUID
long long int crm_time_get_seconds(crm_time_t *dt)
#define DAEMON_RESPAWN_STOP
int compare_version(const char *version1, const char *version2)
gboolean check_script(const char *value)
#define crm_config_warn(fmt...)
#define XML_ATTR_TRANSITION_KEY
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
unsigned int get_crm_log_level(void)
#define CRM_SYSTEM_STONITHD
int crm_str_to_boolean(const char *s, int *ret)
void crm_abort(const char *file, const char *function, int line, const char *assert_condition, gboolean do_core, gboolean do_fork)
char * generate_notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
#define CRM_SYSTEM_TENGINE
gboolean check_timer(const char *value)
long crm_pidfile_inuse(const char *filename, long mypid, const char *daemon)
#define crm_perror(level, fmt, args...)
Log a system error message.
char * generate_transition_magic_v202(const char *transition_key, int op_status)
int char2score(const char *score)
#define crm_err(fmt, args...)
gboolean check_number(const char *value)
void xml_remove_prop(xmlNode *obj, const char *name)
int rsc_op_expected_rc(lrmd_event_data_t *op)
char * dump_xml_unformatted(xmlNode *msg)
#define XML_LRM_ATTR_CALLID
#define CRMD_ACTION_MIGRATE
#define XML_LRM_ATTR_OPSTATUS
#define XML_ATTR_CRM_VERSION
#define pcmk_option_hidden
int crm_get_option(int argc, char **argv, int *index)
char * generate_op_key(const char *rsc_id, const char *op_type, int interval)
Generate an operation key.
void * md5_buffer(const char *buffer, size_t len, void *resblock)
Wrappers for and extensions to libqb IPC.
#define PACKAGE_BUGREPORT
char * generate_transition_magic(const char *transition_key, int op_status, int op_rc)
const char * crm_acl_get_set_user(xmlNode *request, const char *field, const char *peer_user)
gboolean crm_config_error
#define XML_LRM_ATTR_TARGET
#define XML_LRM_TAG_RSC_OP
#define XML_RSC_OP_LAST_RUN
char * crm_concat(const char *prefix, const char *suffix, char join)
char * crm_itoa(int an_int)
#define safe_str_eq(a, b)
qb_ipcs_service_t * mainloop_add_ipc_server(const char *name, enum qb_ipc_type type, struct qb_ipcs_service_handlers *callbacks)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#define XML_LRM_ATTR_MIGRATE_SOURCE
gboolean check_boolean(const char *value)
char * uid2username(uid_t uid)
char * score2char_stack(int score, char *buf, size_t len)
qb_ipcs_service_t * crmd_ipc_server_init(struct qb_ipcs_service_handlers *cb)
enum crm_ais_msg_types type
#define CRMD_ACTION_STATUS
void crm_time_free(crm_time_t *dt)