mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-06 04:28:29 +02:00
core: merge branch 'th/config-log-no-auto-default'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/290
This commit is contained in:
commit
41fc9196aa
9 changed files with 69 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
connection = nm_device_new_default_connection (device);
|
||||
if (!connection)
|
||||
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) {
|
||||
_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),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue