mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 04:00:17 +01:00
settings: ensure that "plugins-=ifcfg-rh" works with the default plugins
On Fedora/RHEL, the default for main.plugins is "ifcfg-rh". You would expect that a single configuration file [main] plugins-=ifcfg-rh would result in an empty list of plugins (which subsequently gets completed with "keyfile"). That didn't happen due to a bug. Fix it.
This commit is contained in:
parent
5cdb636301
commit
f588dabb4f
2 changed files with 19 additions and 8 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include "devices/nm-device.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-keyfile/nm-keyfile-internal.h"
|
||||
#include "nm-keyfile/nm-keyfile-utils.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -215,6 +216,7 @@ nm_config_data_get_value_int64 (const NMConfigData *self, const char *group, con
|
|||
char **
|
||||
nm_config_data_get_plugins (const NMConfigData *self, gboolean allow_default)
|
||||
{
|
||||
gs_free_error GError *error = NULL;
|
||||
const NMConfigDataPrivate *priv;
|
||||
char **list;
|
||||
|
||||
|
|
@ -222,8 +224,9 @@ nm_config_data_get_plugins (const NMConfigData *self, gboolean allow_default)
|
|||
|
||||
priv = NM_CONFIG_DATA_GET_PRIVATE (self);
|
||||
|
||||
list = g_key_file_get_string_list (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NULL, NULL);
|
||||
if (!list && allow_default) {
|
||||
list = g_key_file_get_string_list (priv->keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NULL, &error);
|
||||
if ( nm_keyfile_error_is_not_found (error)
|
||||
&& allow_default) {
|
||||
gs_unref_keyfile GKeyFile *kf = nm_config_create_keyfile ();
|
||||
|
||||
/* let keyfile split the default string according to its own escaping rules. */
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-keyfile/nm-keyfile-internal.h"
|
||||
#include "nm-keyfile/nm-keyfile-utils.h"
|
||||
|
||||
#define DEFAULT_CONFIG_MAIN_FILE NMCONFDIR "/NetworkManager.conf"
|
||||
#define DEFAULT_CONFIG_DIR NMCONFDIR "/conf.d"
|
||||
|
|
@ -977,7 +978,7 @@ read_config (GKeyFile *keyfile, gboolean is_base_config,
|
|||
gsize key_len;
|
||||
|
||||
key = keys[k];
|
||||
g_assert (key && *key);
|
||||
nm_assert (key && *key);
|
||||
|
||||
if ( _HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_WAS)
|
||||
|| _HAS_PREFIX (key, NM_CONFIG_KEYFILE_KEYPREFIX_SET)) {
|
||||
|
|
@ -996,6 +997,7 @@ read_config (GKeyFile *keyfile, gboolean is_base_config,
|
|||
&& (last_char == '+' || last_char == '-')) {
|
||||
gs_free char *base_key = g_strndup (key, key_len - 1);
|
||||
gboolean is_string_list;
|
||||
gboolean old_val_was_set = FALSE;
|
||||
|
||||
is_string_list = _setting_is_string_list (group, base_key);
|
||||
|
||||
|
|
@ -1007,13 +1009,19 @@ read_config (GKeyFile *keyfile, gboolean is_base_config,
|
|||
gs_free char **new_val = NULL;
|
||||
|
||||
if (is_string_list) {
|
||||
old_val = g_key_file_get_string_list (keyfile, group, base_key, NULL, NULL);
|
||||
gs_free_error GError *old_error = NULL;
|
||||
|
||||
old_val = g_key_file_get_string_list (keyfile, group, base_key, NULL, &old_error);
|
||||
new_val = g_key_file_get_string_list (kf, group, key, NULL, NULL);
|
||||
if (!old_val && !g_key_file_has_key (keyfile, group, base_key, NULL)) {
|
||||
/* we must fill the unspecified value with the compile-time default. */
|
||||
if (nm_streq (group, NM_CONFIG_KEYFILE_GROUP_MAIN) && nm_streq (base_key, "plugins")) {
|
||||
if ( nm_streq (group, NM_CONFIG_KEYFILE_GROUP_MAIN)
|
||||
&& nm_streq (base_key, "plugins")) {
|
||||
old_val_was_set = !nm_keyfile_error_is_not_found (old_error);
|
||||
if ( !old_val
|
||||
&& !old_val_was_set) {
|
||||
/* we must fill the unspecified value with the compile-time default. */
|
||||
g_key_file_set_value (keyfile, group, base_key, NM_CONFIG_DEFAULT_MAIN_PLUGINS);
|
||||
old_val = g_key_file_get_string_list (keyfile, group, base_key, NULL, NULL);
|
||||
old_val_was_set = TRUE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1059,7 +1067,7 @@ read_config (GKeyFile *keyfile, gboolean is_base_config,
|
|||
g_key_file_set_value (keyfile, group, base_key, specs_joined);
|
||||
}
|
||||
} else {
|
||||
if (is_string_list)
|
||||
if (is_string_list && !old_val_was_set)
|
||||
g_key_file_remove_key (keyfile, group, base_key, NULL);
|
||||
else
|
||||
g_key_file_set_value (keyfile, group, base_key, "");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue