Skip to content

Commit

Permalink
renaming configoverwrite to configoverwrite (and similar)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Aurich committed Jan 14, 2025
1 parent 9afb425 commit dc5b6b8
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ Command Line Tool

Options:
-c, --conf=FILENAME config file
-C, --cmdconf=SECTION:KEY=VALUE config settings that overwrite parameters from the config file
-C, --cmdconf=SECTION:KEY=VALUE config settings that override parameters from the config file
--keyring=PEMFILE keyring file
--mount=PATH mount prefix
-d, --debug enable debug output
Expand Down
10 changes: 5 additions & 5 deletions include/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ typedef enum {
} RContextConfigMode;

typedef struct {
gchar *overwrite_section;
gchar *overwrite_name;
gchar *overwrite_value;
} ConfigFileOverwrite;
gchar *override_section;
gchar *override_name;
gchar *override_value;
} ConfigFileOverride;

typedef struct {
/* a busy context must not be reconfigured */
Expand All @@ -36,7 +36,7 @@ typedef struct {
/* system configuration data */
RContextConfigMode configmode;
gchar *configpath;
GList *configoverwrite;
GList *configoverride;
RaucConfig *config;

/* system status (not available when using per-slot status file) */
Expand Down
8 changes: 4 additions & 4 deletions src/config_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,10 +743,10 @@ gboolean load_config(const gchar *filename, RaucConfig **config, GError **error)
return FALSE;
}

//process overwrites
for (GList *l = r_context_conf()->configoverwrite; l != NULL; l = l->next) {
ConfigFileOverwrite *overwrite = (ConfigFileOverwrite *)l->data;
g_key_file_set_value(key_file, overwrite->overwrite_section, overwrite->overwrite_name, overwrite->overwrite_value);
//process overrides
for (GList *l = r_context_conf()->configoverride; l != NULL; l = l->next) {
ConfigFileOverride *override = (ConfigFileOverride *)l->data;
g_key_file_set_value(key_file, override->override_section, override->override_name, override->override_value);
}

/* parse [system] section */
Expand Down
10 changes: 5 additions & 5 deletions src/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,12 +871,12 @@ void r_context_clean(void)

g_clear_pointer(&context->config, free_config);

for (GList *l = context->configoverwrite; l != NULL; l = l->next) {
ConfigFileOverwrite *overwrite = (ConfigFileOverwrite *)l->data;
g_clear_pointer(&overwrite->overwrite_section, g_free);
g_clear_pointer(&overwrite, g_free);
for (GList *l = context->configoverride; l != NULL; l = l->next) {
ConfigFileOverride *override = (ConfigFileOverride *)l->data;
g_clear_pointer(&override->override_section, g_free);
g_clear_pointer(&override, g_free);
}
g_clear_pointer(&context->configoverwrite, g_list_free);
g_clear_pointer(&context->configoverride, g_list_free);

g_clear_pointer(&context->system_status, r_system_status_free);

Expand Down
16 changes: 8 additions & 8 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2646,13 +2646,13 @@ static void create_option_groups(void)
g_option_group_add_entries(service_group, entries_service);
}

static gboolean append_config_overwrite(gchar *section, gchar *name, gchar *value)
static gboolean append_config_override(gchar *section, gchar *name, gchar *value)
{
ConfigFileOverwrite *overwrite = g_new(ConfigFileOverwrite, 1);
overwrite->overwrite_section = section;
overwrite->overwrite_name = name;
overwrite->overwrite_value = value;
r_context_conf()->configoverwrite = g_list_append(r_context_conf()->configoverwrite, overwrite);
ConfigFileOverride *override = g_new(ConfigFileOverride, 1);
override->override_section = section;
override->override_name = name;
override->override_value = value;
r_context_conf()->configoverride = g_list_append(r_context_conf()->configoverride, override);
return TRUE;
}

Expand All @@ -2678,7 +2678,7 @@ static gboolean collect_config_values(const gchar *option_name, const gchar *val
*equal_delimiter = 0;
equal_delimiter++;

return append_config_overwrite(copy, colon_delimiter, equal_delimiter);
return append_config_override(copy, colon_delimiter, equal_delimiter);
}

static void cmdline_handler(int argc, char **argv)
Expand All @@ -2689,7 +2689,7 @@ static void cmdline_handler(int argc, char **argv)
g_autoptr(GOptionContext) context = NULL;
GOptionEntry entries[] = {
{"conf", 'c', 0, G_OPTION_ARG_FILENAME, &confpath, "config file", "FILENAME"},
{"cmdconf", 'C', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, collect_config_values, "config settings that overwrite parameters from the config file", "SECTION:KEY=VALUE" },
{"cmdconf", 'C', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, collect_config_values, "config settings that override parameters from the config file", "SECTION:KEY=VALUE" },
/* NOTE: cert and key kept for backwards-compatibility, but made invisible */
{"cert", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &certpath, "cert file or PKCS#11 URL", "PEMFILE|PKCS11-URL"},
{"key", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &keypath, "key file or PKCS#11 URL", "PEMFILE|PKCS11-URL"},
Expand Down
34 changes: 17 additions & 17 deletions test/config_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ path=/dev/null\n\
allow-partial-chain=true\n\
check-crl=true\n\
check-purpose=codesign\n";
const gchar *overwrite_cfg_file = "\
const gchar *override_cfg_file = "\
[system]\n\
compatible=FooCorp Super BarBazzer\n\
bootloader=barebox\n\
Expand Down Expand Up @@ -1103,23 +1103,23 @@ check-crl=true\n";

g_free(pathname);
g_clear_pointer(&config, free_config);
pathname = write_tmp_file(fixture->tmpdir, "overwrite.conf", overwrite_cfg_file, NULL);
pathname = write_tmp_file(fixture->tmpdir, "override.conf", override_cfg_file, NULL);
g_assert_nonnull(pathname);
ConfigFileOverwrite *overwrite = g_new(ConfigFileOverwrite, 1);
overwrite->overwrite_section = g_strdup("keyring:check-purpose=codesign");
overwrite->overwrite_name = strchr(overwrite->overwrite_section, ':');
overwrite->overwrite_value = strchr(overwrite->overwrite_section, '=');
*overwrite->overwrite_name++ = '\0';
*overwrite->overwrite_value++ = '\0';
r_context_conf()->configoverwrite = g_list_append(r_context_conf()->configoverwrite, overwrite);

ConfigFileOverwrite *overwrite2 = g_new(ConfigFileOverwrite, 1);
overwrite2->overwrite_section = g_strdup("keyring:check-crl=false");
overwrite2->overwrite_name = strchr(overwrite2->overwrite_section, ':');
overwrite2->overwrite_value = strchr(overwrite2->overwrite_section, '=');
*overwrite2->overwrite_name++ = '\0';
*overwrite2->overwrite_value++ = '\0';
r_context_conf()->configoverwrite = g_list_append(r_context_conf()->configoverwrite, overwrite2);
ConfigFileOverride *override = g_new(ConfigFileOverride, 1);
override->override_section = g_strdup("keyring:check-purpose=codesign");
override->override_name = strchr(override->override_section, ':');
override->override_value = strchr(override->override_section, '=');
*override->override_name++ = '\0';
*override->override_value++ = '\0';
r_context_conf()->configoverride = g_list_append(r_context_conf()->configoverride, override);

ConfigFileOverride *override2 = g_new(ConfigFileOverride, 1);
override2->override_section = g_strdup("keyring:check-crl=false");
override2->override_name = strchr(override2->override_section, ':');
override2->override_value = strchr(override2->override_section, '=');
*override2->override_name++ = '\0';
*override2->override_value++ = '\0';
r_context_conf()->configoverride = g_list_append(r_context_conf()->configoverride, override2);

res = load_config(pathname, &config, &ierror);
g_assert_no_error(ierror);
Expand Down

0 comments on commit dc5b6b8

Please sign in to comment.