diff options
-rw-r--r-- | src/settings/nm-settings.c | 70 |
1 files changed, 64 insertions, 6 deletions
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 29a943b0ed..08f1b57930 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -78,6 +78,8 @@ #include "NetworkManagerUtils.h" #include "nm-dispatcher.h" #include "nm-hostname-manager.h" +#include "nm-keyfile-internal.h" +#include "nm-keyfile-utils.h" /*****************************************************************************/ @@ -893,6 +895,29 @@ openconnect_migrate_hack (NMConnection *connection) } } +static gboolean +write_handler (NMConnection *connection, + GKeyFile *keyfile, + NMKeyfileWriteType type, + void *type_data, + void *user_data, + GError **error) +{ + if (type == NM_KEYFILE_WRITE_TYPE_SECRET) { + NMKeyfileWriteTypeDataSecret *data = type_data; + const char *alias; + + alias = nm_keyfile_plugin_get_alias_for_setting_name (data->setting_name); + + g_key_file_set_string (keyfile, + alias ?: data->setting_name, + data->key, + "<hidden>"); + return TRUE; + } + return FALSE; +} + static void claim_connection (NMSettings *self, NMSettingsConnection *sett_conn) { @@ -978,12 +1003,45 @@ claim_connection (NMSettings *self, NMSettingsConnection *sett_conn) path = nm_dbus_object_export (NM_DBUS_OBJECT (sett_conn)); - nm_utils_log_connection_diff (nm_settings_connection_get_connection (sett_conn), - NULL, - LOGL_DEBUG, - LOGD_CORE, - "new connection", "++ ", - path); + if (nm_logging_enabled (LOGL_DEBUG, LOGD_CORE)) { + GKeyFile *key_file; + NMConnection *conn; + const char *conn_type; + + conn = nm_settings_connection_get_connection (sett_conn); + conn_type = nm_connection_get_connection_type (conn); + + nm_log (LOGL_DEBUG, LOGD_CORE, NULL, NULL, + "connection '%s' (%p/%s/%s%s%s):%s%s%s", + nm_settings_connection_get_id (sett_conn), + conn, G_OBJECT_TYPE_NAME (conn), + NM_PRINT_FMT_QUOTE_STRING (conn_type), + NM_PRINT_FMT_QUOTED (path, " [", path, "]", "")); + + key_file = nm_keyfile_write (conn, write_handler, NULL, &error); + if (key_file) { + char **groups, **keys; + guint g, k; + + groups = g_key_file_get_groups (key_file, NULL); + for (g = 0; groups && groups[g]; g++) { + keys = g_key_file_get_keys (key_file, groups[g], NULL, NULL); + for (k = 0; keys && keys[k]; k++) { + nm_log (LOGL_DEBUG, LOGD_CORE, NULL, NULL, + " %s.%s = %s", + groups[g], + keys[k], + g_key_file_get_string (key_file, groups[g], keys[k], NULL)); + } + g_free (keys); + } + g_free (groups); + } else { + nm_log (LOGL_DEBUG, LOGD_CORE, NULL, NULL, + "ERROR: can't display connection as keyfile: %s", error->message); + g_clear_error (&error); + } + } /* Only emit the individual connection-added signal after connections * have been initially loaded. |