diff --git a/include/event_log.h b/include/event_log.h index a70503ea6..e264e81d1 100644 --- a/include/event_log.h +++ b/include/event_log.h @@ -72,6 +72,15 @@ typedef struct _REventLogger { void (*writer)(REventLogger* logger, const GLogField *fields, gsize n_fields); } REventLogger; +/** + * Tests type string for being a supported event log type. + * + * @param type Type string to test + * + * @return TRUE if supported, FALSE otherwise + */ +gboolean r_event_log_is_supported_type(const gchar *type); + /** * Custom structured logging function. * diff --git a/src/config_file.c b/src/config_file.c index fee16050c..53838e6c5 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -275,7 +275,14 @@ static gboolean r_event_log_parse_config_sections(GKeyFile *key_file, RaucConfig return FALSE; } for (gsize j = 0; j < entries; j++) { - /* FIXME: handle invalid values */ + if (!r_event_log_is_supported_type(logger->events[j])) { + g_set_error( + error, + G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE, + "Unsupported event log type '%s'", logger->events[j]); + return FALSE; + } } g_key_file_remove_key(key_file, *group, "events", NULL); diff --git a/src/event_log.c b/src/event_log.c index 725b33fce..91017ff8e 100644 --- a/src/event_log.c +++ b/src/event_log.c @@ -9,6 +9,21 @@ #include "context.h" #include "event_log.h" +static const gchar *supported_event_types[] = { + "all", + R_EVENT_LOG_TYPE_BOOT, + R_EVENT_LOG_TYPE_MARK, + R_EVENT_LOG_TYPE_INSTALL, + R_EVENT_LOG_TYPE_SERVICE, + R_EVENT_LOG_TYPE_WRITE_SLOT, + NULL +}; + +gboolean r_event_log_is_supported_type(const gchar *type) +{ + return g_strv_contains(supported_event_types, type); +} + void r_event_log_message(const gchar *type, const gchar *message, ...) { va_list list;