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:
@@ -2819,12 +2819,12 @@ nm_config_reload(NMConfig *self, NMConfigChangeFlags reload_flags, gboolean emit
|
|||||||
NMConfigPrivate *priv;
|
NMConfigPrivate *priv;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GKeyFile *keyfile, *keyfile_intern;
|
GKeyFile *keyfile, *keyfile_intern;
|
||||||
NMConfigData *new_data = NULL;
|
NMConfigData *new_data = NULL;
|
||||||
char *config_main_file = NULL;
|
char *config_main_file = NULL;
|
||||||
char *config_description = NULL;
|
char *config_description = NULL;
|
||||||
gs_strfreev char **no_auto_default = 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;
|
gs_unref_ptrarray GPtrArray *warnings = NULL;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
g_return_if_fail(NM_IS_CONFIG(self));
|
g_return_if_fail(NM_IS_CONFIG(self));
|
||||||
@@ -2875,6 +2875,13 @@ nm_config_reload(NMConfig *self, NMConfigChangeFlags reload_flags, gboolean emit
|
|||||||
NULL);
|
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,
|
new_data = nm_config_data_new(config_main_file,
|
||||||
config_description,
|
config_description,
|
||||||
(const char *const *) no_auto_default,
|
(const char *const *) no_auto_default,
|
||||||
@@ -3046,16 +3053,16 @@ nm_config_kernel_command_line_nm_debug(void)
|
|||||||
static gboolean
|
static gboolean
|
||||||
init_sync(GInitable *initable, GCancellable *cancellable, GError **error)
|
init_sync(GInitable *initable, GCancellable *cancellable, GError **error)
|
||||||
{
|
{
|
||||||
NMConfig *self = NM_CONFIG(initable);
|
NMConfig *self = NM_CONFIG(initable);
|
||||||
NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE(self);
|
NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE(self);
|
||||||
nm_auto_unref_keyfile GKeyFile *keyfile = NULL;
|
nm_auto_unref_keyfile GKeyFile *keyfile = NULL;
|
||||||
nm_auto_unref_keyfile GKeyFile *keyfile_intern = NULL;
|
nm_auto_unref_keyfile GKeyFile *keyfile_intern = NULL;
|
||||||
gs_free char *config_main_file = NULL;
|
gs_free char *config_main_file = NULL;
|
||||||
gs_free char *config_description = NULL;
|
gs_free char *config_description = NULL;
|
||||||
gs_strfreev char **no_auto_default = NULL;
|
gs_strfreev char **no_auto_default = NULL;
|
||||||
gs_unref_ptrarray GPtrArray *warnings = NULL;
|
gs_unref_ptrarray GPtrArray *warnings = NULL;
|
||||||
gs_free char *configure_and_quit = NULL;
|
gs_free char *configure_and_quit = NULL;
|
||||||
gboolean intern_config_needs_rewrite;
|
gboolean intern_config_needs_rewrite = FALSE;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
if (priv->config_dir) {
|
if (priv->config_dir) {
|
||||||
@@ -3130,6 +3137,13 @@ init_sync(GInitable *initable, GCancellable *cancellable, GError **error)
|
|||||||
NULL);
|
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,
|
priv->config_data_orig = nm_config_data_new(config_main_file,
|
||||||
config_description,
|
config_description,
|
||||||
(const char *const *) no_auto_default,
|
(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, "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-key1", "user-value1");
|
||||||
g_key_file_set_string(keyfile, "non-atomic-prefix-1.section-a", "nap1-key2", "user-value2");
|
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
|
static void
|
||||||
@@ -976,7 +977,9 @@ _set_values_user_atomic_section_1_check(NMConfig *config,
|
|||||||
NMConfigData *old_data)
|
NMConfigData *old_data)
|
||||||
{
|
{
|
||||||
if (is_change_event)
|
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", "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-a", "key2", "user-value2");
|
||||||
assert_config_value(config_data, "atomic-prefix-1.section-b", "key1", "user-value1");
|
assert_config_value(config_data, "atomic-prefix-1.section-b", "key1", "user-value1");
|
||||||
|
Reference in New Issue
Block a user