From 5420a1ea1bcd5022dc7bbab7e38b2f3a7ff61837 Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Thu, 16 Jun 2016 21:51:37 +0100 Subject: [PATCH] Ensure os-core bundle is listed in groups.ini If the os-core bundle is not listed in groups.ini we will run into problems later on, including segfaults when processing bundle includes. Check the os-core bundle is listed in the groups.ini during initialisation and error gracefully when it is not. Signed-off-by: Joshua Lock --- src/create_update.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/create_update.c b/src/create_update.c index f395bb7..9026a57 100644 --- a/src/create_update.c +++ b/src/create_update.c @@ -212,6 +212,25 @@ static int check_build_env(void) return 0; } +static int check_group_file(void) +{ + int ret = -1; + + // Ensure the os-core group is defined + while (1) { + char *group = next_group(); + if (!group) { + break; + } + if (strcmp(group, "os-core") == 0) { + ret = 0; + break; + } + } + + return ret; +} + int main(int argc, char **argv) { struct manifest *new_core = NULL; @@ -270,6 +289,11 @@ int main(int argc, char **argv) string_or_die(&file_path, "%s/groups.ini", state_dir); read_group_file(file_path); free(file_path); + ret = check_group_file(); + if (ret != 0) { + printf("os-core bundle is not listed in groups.ini, this is required.\n"); + goto exit; + } read_current_version("LAST_VER"); printf("Last processed version is %i\n", current_version);