40#include <sys/socket.h>
43#include <netinet/in.h>
60#define LOGSYS_UTILS_ONLY 1
101 const char **error_string,
135static int read_config_file_into_icmap(
136 const char **error_string,
icmap_map_t config_map);
137static char error_string_response[512];
139static int uid_determine (
const char *req_user)
142 struct passwd passwd;
143 struct passwd* pwdptr = &passwd;
144 struct passwd* temp_pwd_pt;
150 id = strtol(req_user, &ep, 10);
151 if (*req_user !=
'\0' && *ep ==
'\0' &&
id >= 0 &&
id <= UINT_MAX) {
155 pwdlinelen = sysconf (_SC_GETPW_R_SIZE_MAX);
157 if (pwdlinelen == -1) {
161 pwdbuffer = malloc (pwdlinelen);
163 while ((rc = getpwnam_r (req_user, pwdptr, pwdbuffer, pwdlinelen, &temp_pwd_pt)) == ERANGE) {
167 if (pwdlinelen <= 32678) {
168 n = realloc (pwdbuffer, pwdlinelen);
177 sprintf (error_string_response,
"getpwnam_r(): %s", strerror(rc));
180 if (temp_pwd_pt == NULL) {
182 sprintf (error_string_response,
183 "The '%s' user is not found in /etc/passwd, please read the documentation.",
187 pw_uid = passwd.pw_uid;
193static int gid_determine (
const char *req_group)
195 int corosync_gid = 0;
197 struct group * grpptr = &group;
198 struct group * temp_grp_pt;
204 id = strtol(req_group, &ep, 10);
205 if (*req_group !=
'\0' && *ep ==
'\0' &&
id >= 0 &&
id <= UINT_MAX) {
209 grplinelen = sysconf (_SC_GETGR_R_SIZE_MAX);
211 if (grplinelen == -1) {
215 grpbuffer = malloc (grplinelen);
217 while ((rc = getgrnam_r (req_group, grpptr, grpbuffer, grplinelen, &temp_grp_pt)) == ERANGE) {
221 if (grplinelen <= 32678) {
222 n = realloc (grpbuffer, grplinelen);
231 sprintf (error_string_response,
"getgrnam_r(): %s", strerror(rc));
234 if (temp_grp_pt == NULL) {
236 sprintf (error_string_response,
237 "The '%s' group is not found in /etc/group, please read the documentation.",
241 corosync_gid = group.gr_gid;
246static char *strchr_rs (
const char *haystack,
int byte)
248 const char *end_address = strchr (haystack,
byte);
252 while (*end_address ==
' ' || *end_address ==
'\t' || (
unsigned char)*end_address == 0xA0)
256 return ((
char *) end_address);
261 if (read_config_file_into_icmap(error_string, config_map)) {
268static char *remove_whitespace(
char *
string,
int remove_colon_and_brace)
274 while (*start ==
' ' || *start ==
'\t' || (
unsigned char)*start == 0xA0)
277 end = start+(strlen(start))-1;
278 while ((*end ==
' ' || *end ==
'\t' || (
unsigned char)*end == 0xA0 || (remove_colon_and_brace && (*end ==
':' || *end ==
'{'))) && end > start)
288static int parse_section(FILE *fp,
292 const char **error_string,
304 static char formated_err[384];
305 const char *tmp_error_string;
307 if (strcmp(path,
"") == 0) {
311 tmp_error_string = NULL;
313 while (fgets (line,
sizeof (line), fp)) {
316 if (strlen(line) > 0) {
321 if ((line[strlen(line) - 1] !=
'\n') && !feof(fp)) {
322 tmp_error_string =
"Line too long";
326 if (line[strlen(line) - 1] ==
'\n')
327 line[strlen(line) - 1] =
'\0';
328 if (strlen (line) > 0 && line[strlen(line) - 1] ==
'\r')
329 line[strlen(line) - 1] =
'\0';
334 for (i = strlen (line) - 1; i > -1; i--) {
335 if (line[i] ==
'\t' || line[i] ==
' ' || (
unsigned char)line[i] == 0xA0) {
343 for (i = 0; i < strlen (line); i++) {
344 if (line[i] !=
'\t' && line[i] !=
' ' && (
unsigned char)line[i] != 0xA0) {
359 if ((loc = strchr_rs (line,
'{'))) {
365 section = remove_whitespace(line, 1);
366 after_section = remove_whitespace(loc, 0);
368 if (strcmp(section,
"") == 0) {
369 tmp_error_string =
"Missing section name before opening bracket '{'";
373 if (strcmp(after_section,
"") != 0) {
374 tmp_error_string =
"Extra characters after opening bracket '{'";
379 tmp_error_string =
"Start of section makes total cmap path too long";
382 strcpy(new_keyname, path);
383 if (strcmp(path,
"") != 0) {
384 strcat(new_keyname,
".");
386 strcat(new_keyname, section);
391 &tmp_error_string, config_map,
user_data)) {
395 if (parse_section(fp, fname, line_no, new_keyname, error_string, depth + 1, newstate,
403 if ((loc = strchr_rs (line,
':'))) {
408 key = remove_whitespace(line, 1);
409 value = remove_whitespace(loc, 0);
412 tmp_error_string =
"New key makes total cmap path too long";
415 strcpy(new_keyname, path);
416 if (strcmp(path,
"") != 0) {
417 strcat(new_keyname,
".");
419 strcat(new_keyname, key);
429 if (strchr_rs (line,
'}')) {
431 trimmed_line = remove_whitespace(line, 0);
433 if (strcmp(trimmed_line,
"}") != 0) {
434 tmp_error_string =
"Extra characters before or after closing bracket '}'";
439 tmp_error_string =
"Unexpected closing brace";
455 tmp_error_string =
"Line is not opening or closing section or key value";
459 if (strcmp(path,
"") != 0) {
460 tmp_error_string =
"Missing closing brace";
464 if (strcmp(path,
"") == 0) {
471 if (snprintf(formated_err,
sizeof(formated_err),
"parser error: %s:%u: %s", fname, *line_no,
472 tmp_error_string) >=
sizeof(formated_err)) {
473 *error_string =
"Can't format parser error message";
475 *error_string = formated_err;
481static int safe_atoq_range(
icmap_value_types_t value_type,
long long int *min_val,
long long int *max_val)
483 switch (value_type) {
505 long long int min_val, max_val;
510 val = strtoll(str, &endptr, 10);
511 if (errno == ERANGE) {
519 if (*endptr !=
'\0') {
523 if (safe_atoq_range(target_type, &min_val, &max_val) != 0) {
527 if (val < min_val || val > max_val) {
535static int str_to_ull(
const char *str,
unsigned long long int *res)
537 unsigned long long int val;
542 val = strtoull(str, &endptr, 10);
543 if (errno == ERANGE) {
551 if (*endptr !=
'\0') {
559static int handle_crypto_model(
const char *val,
const char **error_string)
563 "Invalid crypto model. Should be ", error_string) == 1) {
570static int handle_compress_model(
const char *val,
const char **error_string)
574 "Invalid compression model. Should be ", error_string) == 1) {
581static int main_config_parser_cb(
const char *path,
586 const char **error_string,
592 long long int min_val, max_val;
594 unsigned long long int ull;
597 static char formated_err[256];
600 struct qb_list_head *iter, *tmp_iter;
609 if (strlen(path) >=
sizeof(key_name)) {
610 if (snprintf(formated_err,
sizeof(formated_err),
611 "Can't store path \"%s\" into key_name", path) >=
sizeof(formated_err)) {
612 *error_string =
"Can't format path into key_name error message";
614 *error_string = formated_err;
622 strncpy(key_name, path,
sizeof(key_name) - 1);
638 if ((strcmp(path,
"pload.count") == 0) ||
639 (strcmp(path,
"pload.size") == 0)) {
641 if (safe_atoq(
value, &val, val_type) != 0) {
645 goto icmap_set_error;
651 if ((strcmp(path,
"quorum.expected_votes") == 0) ||
652 (strcmp(path,
"quorum.votes") == 0) ||
653 (strcmp(path,
"quorum.last_man_standing_window") == 0) ||
654 (strcmp(path,
"quorum.leaving_timeout") == 0)) {
656 if (safe_atoq(
value, &val, val_type) != 0) {
660 goto icmap_set_error;
665 if ((strcmp(path,
"quorum.two_node") == 0) ||
666 (strcmp(path,
"quorum.expected_votes_tracking") == 0) ||
667 (strcmp(path,
"quorum.allow_downscale") == 0) ||
668 (strcmp(path,
"quorum.wait_for_all") == 0) ||
669 (strcmp(path,
"quorum.auto_tie_breaker") == 0) ||
670 (strcmp(path,
"quorum.last_man_standing") == 0)) {
672 if (safe_atoq(
value, &val, val_type) != 0) {
676 goto icmap_set_error;
682 if ((strcmp(path,
"quorum.device.timeout") == 0) ||
683 (strcmp(path,
"quorum.device.sync_timeout") == 0) ||
684 (strcmp(path,
"quorum.device.votes") == 0)) {
686 if (safe_atoq(
value, &val, val_type) != 0) {
690 goto icmap_set_error;
694 if ((strcmp(path,
"quorum.device.master_wins") == 0)) {
696 if (safe_atoq(
value, &val, val_type) != 0) {
700 goto icmap_set_error;
706 if ((strcmp(path,
"totem.version") == 0) ||
707 (strcmp(path,
"totem.nodeid") == 0) ||
708 (strcmp(path,
"totem.threads") == 0) ||
709 (strcmp(path,
"totem.token") == 0) ||
710 (strcmp(path,
"totem.token_coefficient") == 0) ||
711 (strcmp(path,
"totem.token_retransmit") == 0) ||
712 (strcmp(path,
"totem.token_warning") == 0) ||
713 (strcmp(path,
"totem.hold") == 0) ||
714 (strcmp(path,
"totem.token_retransmits_before_loss_const") == 0) ||
715 (strcmp(path,
"totem.join") == 0) ||
716 (strcmp(path,
"totem.send_join") == 0) ||
717 (strcmp(path,
"totem.consensus") == 0) ||
718 (strcmp(path,
"totem.merge") == 0) ||
719 (strcmp(path,
"totem.downcheck") == 0) ||
720 (strcmp(path,
"totem.fail_recv_const") == 0) ||
721 (strcmp(path,
"totem.seqno_unchanged_const") == 0) ||
722 (strcmp(path,
"totem.rrp_token_expired_timeout") == 0) ||
723 (strcmp(path,
"totem.rrp_problem_count_timeout") == 0) ||
724 (strcmp(path,
"totem.rrp_problem_count_threshold") == 0) ||
725 (strcmp(path,
"totem.rrp_problem_count_mcast_threshold") == 0) ||
726 (strcmp(path,
"totem.rrp_autorecovery_check_timeout") == 0) ||
727 (strcmp(path,
"totem.heartbeat_failures_allowed") == 0) ||
728 (strcmp(path,
"totem.max_network_delay") == 0) ||
729 (strcmp(path,
"totem.window_size") == 0) ||
730 (strcmp(path,
"totem.max_messages") == 0) ||
731 (strcmp(path,
"totem.miss_count_const") == 0) ||
732 (strcmp(path,
"totem.knet_pmtud_interval") == 0) ||
733 (strcmp(path,
"totem.knet_mtu") == 0) ||
734 (strcmp(path,
"totem.knet_compression_threshold") == 0) ||
735 (strcmp(path,
"totem.netmtu") == 0)) {
737 if (safe_atoq(
value, &val, val_type) != 0) {
741 goto icmap_set_error;
745 if (strcmp(path,
"totem.knet_compression_level") == 0) {
747 if (safe_atoq(
value, &val, val_type) != 0) {
751 goto icmap_set_error;
755 if (strcmp(path,
"totem.config_version") == 0) {
756 if (str_to_ull(
value, &ull) != 0) {
760 goto icmap_set_error;
764 if (strcmp(path,
"totem.ip_version") == 0) {
765 if ((strcmp(
value,
"ipv4") != 0) &&
766 (strcmp(
value,
"ipv6") != 0) &&
767 (strcmp(
value,
"ipv6-4") != 0) &&
768 (strcmp(
value,
"ipv4-6") != 0)) {
769 *error_string =
"Invalid ip_version type";
774 if (strcmp(path,
"totem.crypto_model") == 0) {
775 if (handle_crypto_model(
value, error_string) != 0) {
780 if (strcmp(path,
"totem.crypto_cipher") == 0) {
781 if ((strcmp(
value,
"none") != 0) &&
782 (strcmp(
value,
"aes256") != 0) &&
783 (strcmp(
value,
"aes192") != 0) &&
784 (strcmp(
value,
"aes128") != 0)) {
785 *error_string =
"Invalid cipher type. "
786 "Should be none, aes256, aes192 or aes128";
791 if (strcmp(path,
"totem.crypto_hash") == 0) {
792 if ((strcmp(
value,
"none") != 0) &&
793 (strcmp(
value,
"md5") != 0) &&
794 (strcmp(
value,
"sha1") != 0) &&
795 (strcmp(
value,
"sha256") != 0) &&
796 (strcmp(
value,
"sha384") != 0) &&
797 (strcmp(
value,
"sha512") != 0)) {
798 *error_string =
"Invalid hash type. "
799 "Should be none, md5, sha1, sha256, sha384 or sha512";
805 if (strcmp(path,
"totem.knet_compression_model") == 0) {
806 if (handle_compress_model(
value, error_string) != 0) {
814 if (strcmp(path,
"system.qb_ipc_type") == 0) {
815 if ((strcmp(
value,
"native") != 0) &&
816 (strcmp(
value,
"shm") != 0) &&
817 (strcmp(
value,
"socket") != 0)) {
818 *error_string =
"Invalid system.qb_ipc_type";
823 if (strcmp(path,
"system.sched_rr") == 0) {
824 if ((strcmp(
value,
"yes") != 0) &&
825 (strcmp(
value,
"no") != 0)) {
826 *error_string =
"Invalid system.sched_rr value";
831 if (strcmp(path,
"system.move_to_root_cgroup") == 0) {
832 if ((strcmp(
value,
"yes") != 0) &&
833 (strcmp(
value,
"no") != 0) &&
834 (strcmp(
value,
"auto") != 0)) {
835 *error_string =
"Invalid system.move_to_root_cgroup";
840 if (strcmp(path,
"system.allow_knet_handle_fallback") == 0) {
841 if ((strcmp(
value,
"yes") != 0) &&
842 (strcmp(
value,
"no") != 0)) {
843 *error_string =
"Invalid system.allow_knet_handle_fallback";
851 if (strcmp(path,
"totem.interface.linknumber") == 0) {
853 if (safe_atoq(
value, &val, val_type) != 0) {
860 if (strcmp(path,
"totem.interface.bindnetaddr") == 0) {
864 if (strcmp(path,
"totem.interface.mcastaddr") == 0) {
868 if (strcmp(path,
"totem.interface.broadcast") == 0) {
872 if (strcmp(path,
"totem.interface.mcastport") == 0) {
874 if (safe_atoq(
value, &val, val_type) != 0) {
880 if (strcmp(path,
"totem.interface.ttl") == 0) {
882 if (safe_atoq(
value, &val, val_type) != 0) {
888 if (strcmp(path,
"totem.interface.knet_link_priority") == 0) {
890 if (safe_atoq(
value, &val, val_type) != 0) {
896 if (strcmp(path,
"totem.interface.knet_ping_interval") == 0) {
898 if (safe_atoq(
value, &val, val_type) != 0) {
904 if (strcmp(path,
"totem.interface.knet_ping_timeout") == 0) {
906 if (safe_atoq(
value, &val, val_type) != 0) {
912 if (strcmp(path,
"totem.interface.knet_ping_precision") == 0) {
914 if (safe_atoq(
value, &val, val_type) != 0) {
920 if (strcmp(path,
"totem.interface.knet_pong_count") == 0) {
922 if (safe_atoq(
value, &val, val_type) != 0) {
928 if (strcmp(path,
"totem.interface.knet_transport") == 0) {
935 if (strcmp(key,
"subsys") == 0) {
937 if (data->
subsys == NULL) {
938 *error_string =
"Can't alloc memory";
943 kv_item = malloc(
sizeof(*kv_item));
944 if (kv_item == NULL) {
945 *error_string =
"Can't alloc memory";
949 memset(kv_item, 0,
sizeof(*kv_item));
951 kv_item->
key = strdup(key);
953 if (kv_item->
key == NULL || kv_item->
value == NULL) {
955 free(kv_item->
value);
957 *error_string =
"Can't alloc memory";
961 qb_list_init(&kv_item->
list);
967 if (strcmp(key,
"subsys") == 0) {
969 if (data->
subsys == NULL) {
970 *error_string =
"Can't alloc memory";
974 }
else if (strcmp(key,
"name") == 0) {
977 *error_string =
"Can't alloc memory";
982 kv_item = malloc(
sizeof(*kv_item));
983 if (kv_item == NULL) {
984 *error_string =
"Can't alloc memory";
988 memset(kv_item, 0,
sizeof(*kv_item));
990 kv_item->
key = strdup(key);
992 if (kv_item->
key == NULL || kv_item->
value == NULL) {
994 free(kv_item->
value);
996 *error_string =
"Can't alloc memory";
1000 qb_list_init(&kv_item->
list);
1006 if (strcmp(key,
"uid") == 0) {
1007 uid = uid_determine(
value);
1009 *error_string = error_string_response;
1015 goto icmap_set_error;
1018 }
else if (strcmp(key,
"gid") == 0) {
1019 gid = gid_determine(
value);
1021 *error_string = error_string_response;
1027 goto icmap_set_error;
1031 *error_string =
"uidgid: Only uid and gid are allowed items";
1036 if (strcmp(key,
"memberaddr") != 0) {
1037 *error_string =
"Only memberaddr is allowed in member section";
1042 kv_item = malloc(
sizeof(*kv_item));
1043 if (kv_item == NULL) {
1044 *error_string =
"Can't alloc memory";
1048 memset(kv_item, 0,
sizeof(*kv_item));
1050 kv_item->
key = strdup(key);
1052 if (kv_item->
key == NULL || kv_item->
value == NULL) {
1054 free(kv_item->
value);
1056 *error_string =
"Can't alloc memory";
1060 qb_list_init(&kv_item->
list);
1068 if ((strcmp(key,
"nodeid") == 0) ||
1069 (strcmp(key,
"quorum_votes") == 0)) {
1071 if (safe_atoq(
value, &val, val_type) != 0) {
1076 goto icmap_set_error;
1081 if (add_as_string) {
1083 goto icmap_set_error;
1089 if (strcmp(key,
"watchdog_timeout") == 0) {
1091 if (safe_atoq(
value, &val, val_type) != 0) {
1095 goto icmap_set_error;
1102 if (strcmp(key,
"poll_period") == 0) {
1103 if (str_to_ull(
value, &ull) != 0) {
1107 goto icmap_set_error;
1114 if (strcmp(key,
"poll_period") == 0) {
1115 if (str_to_ull(
value, &ull) != 0) {
1119 goto icmap_set_error;
1126 if (add_as_string) {
1128 goto icmap_set_error;
1133 if (strcmp(path,
"totem.interface") == 0) {
1146 if (strcmp(path,
"totem") == 0) {
1149 if (strcmp(path,
"system") == 0) {
1152 if (strcmp(path,
"logging.logger_subsys") == 0) {
1157 if (strcmp(path,
"logging.logging_daemon") == 0) {
1163 if (strcmp(path,
"uidgid") == 0) {
1166 if (strcmp(path,
"totem.interface.member") == 0) {
1169 if (strcmp(path,
"quorum") == 0) {
1172 if (strcmp(path,
"quorum.device") == 0) {
1175 if (strcmp(path,
"nodelist") == 0) {
1179 if (strcmp(path,
"nodelist.node") == 0) {
1182 if (strcmp(path,
"resources") == 0) {
1185 if (strcmp(path,
"resources.system") == 0) {
1188 if (strcmp(path,
"resources.system.memory_used") == 0) {
1191 if (strcmp(path,
"resources.process") == 0) {
1194 if (strcmp(path,
"resources.process.memory_used") == 0) {
1212 if (cs_err !=
CS_OK) {
1213 goto icmap_set_error;
1225 if (cs_err !=
CS_OK) {
1226 goto icmap_set_error;
1238 if (cs_err !=
CS_OK) {
1239 goto icmap_set_error;
1248 goto icmap_set_error;
1252 if (data->
ttl > -1) {
1256 goto icmap_set_error;
1264 goto icmap_set_error;
1272 goto icmap_set_error;
1280 goto icmap_set_error;
1288 goto icmap_set_error;
1296 goto icmap_set_error;
1305 if (cs_err !=
CS_OK) {
1306 goto icmap_set_error;
1319 free(kv_item->
value);
1324 if (cs_err !=
CS_OK) {
1325 goto icmap_set_error;
1331 if (data->
subsys == NULL) {
1332 *error_string =
"No subsys key in logger_subsys directive";
1344 free(kv_item->
value);
1348 if (cs_err !=
CS_OK) {
1349 goto icmap_set_error;
1359 if (cs_err !=
CS_OK) {
1360 goto icmap_set_error;
1365 *error_string =
"No name key in logging_daemon directive";
1373 if (data->
subsys == NULL) {
1380 "logging.logging_daemon.%s.%s",
1386 "logging.logger_subsys.%s.%s",
1391 "logging.logging_daemon.%s.%s.%s",
1398 free(kv_item->
value);
1402 if (cs_err !=
CS_OK) {
1403 goto icmap_set_error;
1407 if (data->
subsys == NULL) {
1424 if (cs_err !=
CS_OK) {
1428 goto icmap_set_error;
1439 if (cs_err !=
CS_OK) {
1440 goto icmap_set_error;
1478 min_val = max_val = 0;
1483 assert(safe_atoq_range(val_type, &min_val, &max_val) == 0);
1485 if (snprintf(formated_err,
sizeof(formated_err),
1486 "Value of key \"%s\" is expected to be integer in range (%lld..%lld), but \"%s\" was given",
1487 key_name, min_val, max_val,
value) >=
sizeof(formated_err)) {
1488 *error_string =
"Can't format parser error message";
1490 *error_string = formated_err;
1496 if (snprintf(formated_err,
sizeof(formated_err),
1497 "Can't store key \"%s\" into icmap, returned error is %s",
1498 key_name,
cs_strerror(cs_err)) >=
sizeof(formated_err)) {
1499 *error_string =
"Can't format parser error message";
1501 *error_string = formated_err;
1507static int uidgid_config_parser_cb(
const char *path,
1512 const char **error_string,
1518 static char formated_err[256];
1527 if (strcmp(path,
"uidgid.uid") == 0) {
1528 uid = uid_determine(
value);
1530 *error_string = error_string_response;
1536 goto icmap_set_error;
1538 }
else if (strcmp(path,
"uidgid.gid") == 0) {
1539 gid = gid_determine(
value);
1541 *error_string = error_string_response;
1547 goto icmap_set_error;
1550 *error_string =
"uidgid: Only uid and gid are allowed items";
1555 if (strcmp(path,
"uidgid") != 0) {
1556 *error_string =
"uidgid: Can't add subsection different than uidgid";
1567 if (snprintf(formated_err,
sizeof(formated_err),
1568 "Can't store key \"%s\" into icmap, returned error is %s",
1569 key_name,
cs_strerror(cs_err)) >=
sizeof(formated_err)) {
1570 *error_string =
"Can't format parser error message";
1572 *error_string = formated_err;
1578static int read_uidgid_files_into_icmap(
1579 const char **error_string,
1585 struct dirent *dirent;
1586 char filename[PATH_MAX + FILENAME_MAX + 1];
1587 char uidgid_dirname[PATH_MAX + FILENAME_MAX + 1];
1589 struct stat stat_buf;
1597 res = snprintf(filename,
sizeof(filename),
"%s",
1599 if (res >=
sizeof(filename)) {
1600 *error_string =
"uidgid.d path too long";
1605 dirname_res = dirname(filename);
1607 res = snprintf(uidgid_dirname,
sizeof(uidgid_dirname),
"%s/%s",
1608 dirname_res,
"uidgid.d");
1609 if (res >=
sizeof(uidgid_dirname)) {
1610 *error_string =
"uidgid.d path too long";
1615 dp = opendir (uidgid_dirname);
1620 for (dirent = readdir(dp);
1622 dirent = readdir(dp)) {
1624 res = snprintf(filename,
sizeof (filename),
"%s/%s", uidgid_dirname, dirent->d_name);
1625 if (res >=
sizeof(filename)) {
1627 *error_string =
"uidgid.d dirname path too long";
1631 res = stat (filename, &stat_buf);
1632 if (res == 0 && S_ISREG(stat_buf.st_mode)) {
1634 fp = fopen (filename,
"r");
1635 if (fp == NULL)
continue;
1640 res = parse_section(fp, filename, &line_no, key_name, error_string, 0, state,
1641 uidgid_config_parser_cb, config_map, NULL);
1658static int read_config_file_into_icmap(
1659 const char **error_string,
1663 const char *filename;
1664 char *error_reason = error_string_response;
1673 fp = fopen (filename,
"r");
1675 char error_str[100];
1676 const char *error_ptr = qb_strerror_r(errno, error_str,
sizeof(error_str));
1677 snprintf (error_reason,
sizeof(error_string_response),
1678 "Can't read file %s: %s",
1679 filename, error_ptr);
1680 *error_string = error_reason;
1687 res = parse_section(fp, filename, &line_no, key_name, error_string, 0, state,
1688 main_config_parser_cb, config_map, &data);
1693 res = read_uidgid_files_into_icmap(error_string, config_map);
1697 snprintf (error_reason,
sizeof(error_string_response),
1698 "Successfully read main configuration file '%s'.", filename);
1699 *error_string = error_reason;
int(* parser_cb_f)(const char *path, char *key, char *value, enum main_cp_cb_data_state *state, enum parser_cb_type type, const char **error_string, icmap_map_t config_map, void *user_data)
@ MAIN_CP_CB_DATA_STATE_LOGGING_DAEMON
@ MAIN_CP_CB_DATA_STATE_RESOURCES_PROCESS_MEMUSED
@ MAIN_CP_CB_DATA_STATE_RESOURCES_SYSTEM_MEMUSED
@ MAIN_CP_CB_DATA_STATE_MEMBER
@ MAIN_CP_CB_DATA_STATE_UIDGID
@ MAIN_CP_CB_DATA_STATE_INTERFACE
@ MAIN_CP_CB_DATA_STATE_NORMAL
@ MAIN_CP_CB_DATA_STATE_PLOAD
@ MAIN_CP_CB_DATA_STATE_LOGGER_SUBSYS
@ MAIN_CP_CB_DATA_STATE_TOTEM
@ MAIN_CP_CB_DATA_STATE_RESOURCES_PROCESS
@ MAIN_CP_CB_DATA_STATE_SYSTEM
@ MAIN_CP_CB_DATA_STATE_QUORUM
@ MAIN_CP_CB_DATA_STATE_QDEVICE
@ MAIN_CP_CB_DATA_STATE_RESOURCES_SYSTEM
@ MAIN_CP_CB_DATA_STATE_NODELIST_NODE
@ MAIN_CP_CB_DATA_STATE_RESOURCES
@ MAIN_CP_CB_DATA_STATE_NODELIST
int coroparse_configparse(icmap_map_t config_map, const char **error_string)
@ PARSER_CB_SECTION_START
const char * cs_strerror(cs_error_t err)
cs_strerror
cs_error_t
The cs_error_t enum.
cs_error_t icmap_set_uint16_r(const icmap_map_t map, const char *key_name, uint16_t value)
cs_error_t icmap_set_uint32_r(const icmap_map_t map, const char *key_name, uint32_t value)
icmap_value_types_t
Possible types of value.
cs_error_t icmap_set_uint8_r(const icmap_map_t map, const char *key_name, uint8_t value)
cs_error_t icmap_set_uint64_r(const icmap_map_t map, const char *key_name, uint64_t value)
cs_error_t icmap_set_int32_r(const icmap_map_t map, const char *key_name, int32_t value)
cs_error_t icmap_set_string_r(const icmap_map_t map, const char *key_name, const char *value)
#define ICMAP_KEYNAME_MAXLEN
Maximum length of key in icmap.
const char * corosync_get_config_file(void)
struct qb_list_head logger_subsys_items_head
char * logging_daemon_name
struct qb_list_head member_items_head
int util_is_valid_knet_crypto_model(const char *val, const char **list_str, int machine_parseable_str, const char *error_string_prefix, const char **error_string)
int util_is_valid_knet_compress_model(const char *val, const char **list_str, int machine_parseable_str, const char *error_string_prefix, const char **error_string)