Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
usb-moded
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mer-core
usb-moded
Commits
e127aa02
Commit
e127aa02
authored
May 15, 2019
by
spiiroin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'jb45869_default_mode' into 'master'
Fix handling of fallback setting values See merge request
!50
parents
e26c0a46
a7b8df3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
13 deletions
+21
-13
src/usb_moded-config.c
src/usb_moded-config.c
+21
-13
No files found.
src/usb_moded-config.c
View file @
e127aa02
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment