Sfoglia il codice sorgente

coroparse: Store subsections of logging_daemon

Store full path instead of just key name.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse 9 mesi fa
parent
commit
e40a570f52
1 ha cambiato i file con 11 aggiunte e 3 eliminazioni
  1. 11 3
      exec/coroparse.c

+ 11 - 3
exec/coroparse.c

@@ -981,14 +981,14 @@ static int main_config_parser_cb(const char *path,
 			add_as_string = 0;
 			add_as_string = 0;
 			break;
 			break;
 		case MAIN_CP_CB_DATA_STATE_LOGGING_DAEMON:
 		case MAIN_CP_CB_DATA_STATE_LOGGING_DAEMON:
-			if (strcmp(key, "subsys") == 0) {
+			if (strcmp(path, "logging.logging_daemon.subsys") == 0) {
 				data->subsys = strdup(value);
 				data->subsys = strdup(value);
 				if (data->subsys == NULL) {
 				if (data->subsys == NULL) {
 					*error_string = "Can't alloc memory";
 					*error_string = "Can't alloc memory";
 
 
 					return (0);
 					return (0);
 				}
 				}
-			} else if (strcmp(key, "name") == 0) {
+			} else if (strcmp(path, "logging.logging_daemon.name") == 0) {
 				data->logging_daemon_name = strdup(value);
 				data->logging_daemon_name = strdup(value);
 				if (data->logging_daemon_name == NULL) {
 				if (data->logging_daemon_name == NULL) {
 					*error_string = "Can't alloc memory";
 					*error_string = "Can't alloc memory";
@@ -996,6 +996,14 @@ static int main_config_parser_cb(const char *path,
 					return (0);
 					return (0);
 				}
 				}
 			} else {
 			} else {
+				path_prefix = "logging.logging_daemon.";
+				if (strlen(path) < strlen(path_prefix) ||
+				    strncmp(path, path_prefix, strlen(path_prefix)) != 0) {
+					*error_string = "Internal error - incorrect path prefix for logging daemon state";
+
+					return (0);
+				}
+
 				kv_item = malloc(sizeof(*kv_item));
 				kv_item = malloc(sizeof(*kv_item));
 				if (kv_item == NULL) {
 				if (kv_item == NULL) {
 					*error_string = "Can't alloc memory";
 					*error_string = "Can't alloc memory";
@@ -1004,7 +1012,7 @@ static int main_config_parser_cb(const char *path,
 				}
 				}
 				memset(kv_item, 0, sizeof(*kv_item));
 				memset(kv_item, 0, sizeof(*kv_item));
 
 
-				kv_item->key = strdup(key);
+				kv_item->key = strdup(path + strlen(path_prefix));
 				kv_item->value = strdup(value);
 				kv_item->value = strdup(value);
 				if (kv_item->key == NULL || kv_item->value == NULL) {
 				if (kv_item->key == NULL || kv_item->value == NULL) {
 					free(kv_item->key);
 					free(kv_item->key);