Commit e127aa02 authored by spiiroin's avatar spiiroin

Merge branch 'jb45869_default_mode' into 'master'

Fix handling of fallback setting values

See merge request !50
parents e26c0a46 a7b8df3d
......@@ -77,7 +77,6 @@ static char *config_get_network_interface (void);
static char *config_get_network_gateway (void);
static char *config_get_network_netmask (void);
static char *config_get_network_nat_interface(void);
static void config_setup_default_values (GKeyFile *settingsfile);
static int config_get_conf_int (const gchar *entry, const gchar *key);
char *config_get_conf_string (const gchar *entry, const gchar *key);
static char *config_get_kcmdline_string (const char *entry);
......@@ -261,13 +260,6 @@ static char * config_get_network_nat_interface(void)
return config_get_conf_string(NETWORK_ENTRY, NETWORK_NAT_INTERFACE_KEY);
}
static void config_setup_default_values(GKeyFile *settingsfile)
{
LOG_REGISTER_CONTEXT;
g_key_file_set_string(settingsfile, MODE_SETTING_ENTRY, MODE_SETTING_KEY, MODE_DEVELOPER );
}
static int config_get_conf_int(const gchar *entry, const gchar *key)
{
LOG_REGISTER_CONTEXT;
......@@ -407,7 +399,6 @@ set_config_result_t config_set_config_setting(const char *entry, const char *key
config_load_static_config(static_ini);
/* Merge static and dynamic settings */
config_setup_default_values(active_ini);
config_merge_data(active_ini, static_ini);
config_load_dynamic_config(active_ini);
......@@ -823,6 +814,10 @@ static void config_load_static_config(GKeyFile *ini)
if( glob(pattern, 0, config_glob_error_cb, &gb) != 0 )
log_debug("no configuration ini-files found");
/* Seed with default values */
g_key_file_set_string(ini, MODE_SETTING_ENTRY, MODE_SETTING_KEY, MODE_ASK);
/* Override with content from config files */
for( size_t i = 0; i < gb.gl_pathc; ++i ) {
const char *path = gb.gl_pathv[i];
if( strcmp(path, USB_MODED_STATIC_CONFIG_FILE) )
......@@ -839,6 +834,23 @@ static bool config_load_legacy_config(GKeyFile *ini)
bool ack = false;
if( access(USB_MODED_STATIC_CONFIG_FILE, F_OK) != -1 )
ack = config_merge_from_file(ini, USB_MODED_STATIC_CONFIG_FILE);
/* A mode=ask setting in legacy config can be either
* something user has selected, or merely configured
* default. As the latter case interferes with evaluation
* of priority ordered static configuration files, ignore
* such settings.
*/
gchar *val = g_key_file_get_value(ini, MODE_SETTING_ENTRY,
MODE_SETTING_KEY, 0);
if( val ) {
if( !g_strcmp0(val, MODE_ASK) ) {
g_key_file_remove_key(ini, MODE_SETTING_ENTRY,
MODE_SETTING_KEY, 0);
}
g_free(val);
}
return ack;
}
......@@ -909,9 +921,6 @@ bool config_init(void)
GKeyFile *static_ini = g_key_file_new();
GKeyFile *active_ini = g_key_file_new();
/* Setup built-in defaults */
config_setup_default_values(active_ini);
/* Load static configuration */
config_load_static_config(static_ini);
......@@ -942,7 +951,6 @@ static GKeyFile *config_get_settings(void)
LOG_REGISTER_CONTEXT;
GKeyFile *ini = g_key_file_new();
config_setup_default_values(ini);
config_load_static_config(ini);
config_load_dynamic_config(ini);
return ini;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment