core: print the internal configuration file with "--print-config"
When there is a non-empty internal configuration file, print it in the output of "NetworkManager --print-config". Before: NetworkManager --print-config: # NetworkManager configuration: /etc/NetworkManager/NetworkManager.conf, /usr/lib/NetworkManager/conf.d/{00-server.conf,22-eth-mac-addr.conf} ... After: NetworkManager --print-config: # NetworkManager configuration: /etc/NetworkManager/NetworkManager.conf, /usr/lib/NetworkManager/conf.d/{00-server.conf,22-eth-mac-addr.conf}, /var/lib/NetworkManager/NetworkManager-intern.conf ... Tests needs to be changed because now writing to the internal file causes a change of the description of the NMConfigData and therefore the NM_CONFIG_CHANGE_CONFIG_FILES flag is set.
This commit is contained in:
@@ -2823,7 +2823,7 @@ nm_config_reload(NMConfig *self, NMConfigChangeFlags reload_flags, gboolean emit
|
||||
char *config_main_file = NULL;
|
||||
char *config_description = NULL;
|
||||
gs_strfreev char **no_auto_default = NULL;
|
||||
gboolean intern_config_needs_rewrite;
|
||||
gboolean intern_config_needs_rewrite = FALSE;
|
||||
gs_unref_ptrarray GPtrArray *warnings = NULL;
|
||||
guint i;
|
||||
|
||||
@@ -2875,6 +2875,13 @@ nm_config_reload(NMConfig *self, NMConfigChangeFlags reload_flags, gboolean emit
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (keyfile_intern) {
|
||||
gs_free char *desc = config_description;
|
||||
|
||||
config_description =
|
||||
g_strdup_printf("%s, %s", config_description, priv->intern_config_file);
|
||||
}
|
||||
|
||||
new_data = nm_config_data_new(config_main_file,
|
||||
config_description,
|
||||
(const char *const *) no_auto_default,
|
||||
@@ -3055,7 +3062,7 @@ init_sync(GInitable *initable, GCancellable *cancellable, GError **error)
|
||||
gs_strfreev char **no_auto_default = NULL;
|
||||
gs_unref_ptrarray GPtrArray *warnings = NULL;
|
||||
gs_free char *configure_and_quit = NULL;
|
||||
gboolean intern_config_needs_rewrite;
|
||||
gboolean intern_config_needs_rewrite = FALSE;
|
||||
const char *s;
|
||||
|
||||
if (priv->config_dir) {
|
||||
@@ -3130,6 +3137,13 @@ init_sync(GInitable *initable, GCancellable *cancellable, GError **error)
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (keyfile_intern) {
|
||||
gs_free char *desc = config_description;
|
||||
|
||||
config_description =
|
||||
g_strdup_printf("%s, %s", config_description, priv->intern_config_file);
|
||||
}
|
||||
|
||||
priv->config_data_orig = nm_config_data_new(config_main_file,
|
||||
config_description,
|
||||
(const char *const *) no_auto_default,
|
||||
|
@@ -965,7 +965,8 @@ _set_values_user_atomic_section_1_set(NMConfig *config,
|
||||
g_key_file_set_string(keyfile, "atomic-prefix-1.section-b", "key1", "user-value1");
|
||||
g_key_file_set_string(keyfile, "non-atomic-prefix-1.section-a", "nap1-key1", "user-value1");
|
||||
g_key_file_set_string(keyfile, "non-atomic-prefix-1.section-a", "nap1-key2", "user-value2");
|
||||
*out_expected_changes = NM_CONFIG_CHANGE_VALUES | NM_CONFIG_CHANGE_VALUES_USER;
|
||||
*out_expected_changes =
|
||||
NM_CONFIG_CHANGE_VALUES | NM_CONFIG_CHANGE_VALUES_USER | NM_CONFIG_CHANGE_CONFIG_FILES;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -976,7 +977,9 @@ _set_values_user_atomic_section_1_check(NMConfig *config,
|
||||
NMConfigData *old_data)
|
||||
{
|
||||
if (is_change_event)
|
||||
g_assert(changes == (NM_CONFIG_CHANGE_VALUES | NM_CONFIG_CHANGE_VALUES_USER));
|
||||
g_assert(changes
|
||||
== (NM_CONFIG_CHANGE_VALUES | NM_CONFIG_CHANGE_VALUES_USER
|
||||
| NM_CONFIG_CHANGE_CONFIG_FILES));
|
||||
assert_config_value(config_data, "atomic-prefix-1.section-a", "key1", "user-value1");
|
||||
assert_config_value(config_data, "atomic-prefix-1.section-a", "key2", "user-value2");
|
||||
assert_config_value(config_data, "atomic-prefix-1.section-b", "key1", "user-value1");
|
||||
|
Reference in New Issue
Block a user