summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-09-26 19:34:13 +0200
committerThomas Haller <thaller@redhat.com>2019-09-26 19:34:13 +0200
commit41fc9196aacddd8dd68a5a3e67fa715886c7730a (patch)
treed8bf08c837cd1142d28fa52c276c4153d6d38846
parentad3ef326aa7a645d6a81808115c894ef1b882cae (diff)
parent9cec6a1bc14bb1b0af0121eb327288d32e3edb9c (diff)
downloadNetworkManager-41fc9196aacddd8dd68a5a3e67fa715886c7730a.tar.gz
core: merge branch 'th/config-log-no-auto-default'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/290
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.c18
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.h2
-rw-r--r--src/main.c4
-rw-r--r--src/nm-config-data.c15
-rw-r--r--src/nm-config-data.h7
-rw-r--r--src/nm-config.c8
-rw-r--r--src/nm-config.h2
-rw-r--r--src/settings/nm-settings.c21
-rw-r--r--src/tests/config/test-config.c2
9 files changed, 68 insertions, 11 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c
index dd98c982cc..a344f9d502 100644
--- a/shared/nm-glib-aux/nm-shared-utils.c
+++ b/shared/nm-glib-aux/nm-shared-utils.c
@@ -2871,6 +2871,24 @@ nm_utils_g_slist_strlist_cmp (const GSList *a, const GSList *b)
}
}
+char *
+nm_utils_g_slist_strlist_join (const GSList *a, const char *separator)
+{
+ GString *str = NULL;
+
+ if (!a)
+ return NULL;
+
+ for (; a; a = a->next) {
+ if (!str)
+ str = g_string_new (NULL);
+ else
+ g_string_append (str, separator);
+ g_string_append (str, a->data);
+ }
+ return g_string_free (str, FALSE);
+}
+
/*****************************************************************************/
gpointer
diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h
index 44dff90a8f..95719c4455 100644
--- a/shared/nm-glib-aux/nm-shared-utils.h
+++ b/shared/nm-glib-aux/nm-shared-utils.h
@@ -993,6 +993,8 @@ GSList *nm_utils_g_slist_find_str (const GSList *list,
int nm_utils_g_slist_strlist_cmp (const GSList *a, const GSList *b);
+char *nm_utils_g_slist_strlist_join (const GSList *a, const char *separator);
+
/*****************************************************************************/
gssize nm_utils_ptrarray_find_binary_search (gconstpointer *list,
diff --git a/src/main.c b/src/main.c
index 86b87dc971..41c1753b7e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -166,7 +166,7 @@ print_config (NMConfigCmdLineOptions *config_cli)
config_data = nm_config_get_data (config);
fprintf (stdout, "# NetworkManager configuration: %s\n", nm_config_data_get_config_description (config_data));
- nm_config_data_log (config_data, "", "", stdout);
+ nm_config_data_log (config_data, "", "", nm_config_get_no_auto_default_file (config), stdout);
return 0;
}
@@ -373,7 +373,7 @@ main (int argc, char *argv[])
nm_config_get_first_start (config) ? "for the first time" : "after a restart");
nm_log_info (LOGD_CORE, "Read config: %s", nm_config_data_get_config_description (nm_config_get_data (config)));
- nm_config_data_log (nm_config_get_data (config), "CONFIG: ", " ", NULL);
+ nm_config_data_log (nm_config_get_data (config), "CONFIG: ", " ", nm_config_get_no_auto_default_file (config), NULL);
if (error_invalid_logging_config) {
nm_log_warn (LOGD_CORE, "config: invalid logging configuration: %s", error_invalid_logging_config->message);
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index 961812c33e..b932d96145 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -82,8 +82,12 @@ typedef struct {
int autoconnect_retries_default;
struct {
+
+ /* from /var/lib/NetworkManager/no-auto-default.state */
char **arr;
GSList *specs;
+
+ /* from main.no-auto-default setting in NetworkManager.conf. */
GSList *specs_config;
} no_auto_default;
@@ -601,6 +605,7 @@ void
nm_config_data_log (const NMConfigData *self,
const char *prefix,
const char *key_prefix,
+ const char *no_auto_default_file,
/* FILE* */ gpointer print_stream)
{
const NMConfigDataPrivate *priv;
@@ -693,6 +698,16 @@ nm_config_data_log (const NMConfigData *self,
}
}
+ _LOG (stream, prefix, "");
+ _LOG (stream, prefix, "# no-auto-default file \"%s\"", no_auto_default_file);
+ {
+ gs_free char *msg = NULL;
+
+ msg = nm_utils_g_slist_strlist_join (priv->no_auto_default.specs, ",");
+ if (msg)
+ _LOG (stream, prefix, "# no-auto-default specs \"%s\"", msg);
+ }
+
#undef _LOG
}
diff --git a/src/nm-config-data.h b/src/nm-config-data.h
index 76d4432ce9..db294a21b3 100644
--- a/src/nm-config-data.h
+++ b/src/nm-config-data.h
@@ -111,9 +111,10 @@ NMConfigData *nm_config_data_new_update_no_auto_default (const NMConfigData *bas
NMConfigChangeFlags nm_config_data_diff (NMConfigData *old_data, NMConfigData *new_data);
void nm_config_data_log (const NMConfigData *self,
- const char *prefix,
- const char *key_prefix,
- /* FILE* */ gpointer print_stream);
+ const char *prefix,
+ const char *key_prefix,
+ const char *no_auto_default_file,
+ /* FILE* */ gpointer print_stream);
const char *nm_config_data_get_config_main_file (const NMConfigData *config_data);
const char *nm_config_data_get_config_description (const NMConfigData *config_data);
diff --git a/src/nm-config.c b/src/nm-config.c
index 88640eb4c9..0c82f2474e 100644
--- a/src/nm-config.c
+++ b/src/nm-config.c
@@ -331,6 +331,12 @@ nm_config_get_first_start (NMConfig *config)
return NM_CONFIG_GET_PRIVATE (config)->cli.first_start;
}
+const char *
+nm_config_get_no_auto_default_file (NMConfig *config)
+{
+ return NM_CONFIG_GET_PRIVATE (config)->no_auto_default_file;
+}
+
/*****************************************************************************/
static char **
@@ -2690,7 +2696,7 @@ _set_config_data (NMConfig *self, NMConfigData *new_data, NMConfigChangeFlags re
_LOGI ("signal: %s (%s)",
nm_config_change_flags_to_string (changes, NULL, 0),
nm_config_data_get_config_description (new_data));
- nm_config_data_log (new_data, "CONFIG: ", " ", NULL);
+ nm_config_data_log (new_data, "CONFIG: ", " ", priv->no_auto_default_file, NULL);
priv->config_data = new_data;
} else if (had_new_data)
_LOGI ("signal: %s (no changes from disk)", nm_config_change_flags_to_string (changes, NULL, 0));
diff --git a/src/nm-config.h b/src/nm-config.h
index 7e1644dfa4..7cab4fc981 100644
--- a/src/nm-config.h
+++ b/src/nm-config.h
@@ -150,6 +150,8 @@ gboolean nm_config_get_is_debug (NMConfig *config);
gboolean nm_config_get_first_start (NMConfig *config);
+const char *nm_config_get_no_auto_default_file (NMConfig *config);
+
void nm_config_set_values (NMConfig *self,
GKeyFile *keyfile_intern_new,
gboolean allow_write,
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index fdd5835c59..61f9eccc87 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -3431,14 +3431,27 @@ device_realized (NMDevice *device, GParamSpec *pspec, NMSettings *self)
*/
if ( !NM_DEVICE_GET_CLASS (self)->new_default_connection
|| !nm_device_get_managed (device, FALSE)
- || g_object_get_qdata (G_OBJECT (device), _default_wired_connection_quark ())
- || have_connection_for_device (self, device)
- || nm_config_get_no_auto_default_for_device (priv->config, device))
+ || g_object_get_qdata (G_OBJECT (device), _default_wired_connection_quark ()))
return;
+ if (nm_config_get_no_auto_default_for_device (priv->config, device)) {
+ _LOGT ("auto-default: cannot create auto-default connection for device %s: disabled by \"no-auto-default\"",
+ nm_device_get_iface (device));
+ return;
+ }
+
+ if (have_connection_for_device (self, device)) {
+ _LOGT ("auto-default: cannot create auto-default connection for device %s: already has a profile",
+ nm_device_get_iface (device));
+ return;
+ }
+
connection = nm_device_new_default_connection (device);
- if (!connection)
+ if (!connection) {
+ _LOGT ("auto-default: cannot create auto-default connection for device %s",
+ nm_device_get_iface (device));
return;
+ }
_LOGT ("auto-default: creating in-memory connection %s (%s) for device %s",
nm_connection_get_uuid (connection),
diff --git a/src/tests/config/test-config.c b/src/tests/config/test-config.c
index 01977ad759..348397ccdf 100644
--- a/src/tests/config/test-config.c
+++ b/src/tests/config/test-config.c
@@ -524,7 +524,7 @@ test_config_confdir (void)
g_assert_cmpstr (value, ==, "VAL5");
g_free (value);
- nm_config_data_log (nm_config_get_data_orig (config), ">>> TEST: ", " ", NULL);
+ nm_config_data_log (nm_config_get_data_orig (config), ">>> TEST: ", " ", "/test/file/name", NULL);
}
static void