summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-06-27 09:09:29 +0200
committerThomas Haller <thaller@redhat.com>2019-06-27 11:48:23 +0200
commit33c676c6ff9df552be47a062ea6b398f6613dc78 (patch)
tree8a1295387eac03c7d8263a97bb6344657a21f152
parent299042685f9a8c2e8bfc59315da5f4ec898cea3a (diff)
downloadNetworkManager-th/settings-seen-bssid-and-timestamps.tar.gz
settings: use nm_connection_to_dbus_full() to avoid cloning the connection during GetSettings()th/settings-seen-bssid-and-timestamps
-rw-r--r--src/settings/nm-settings-connection.c73
1 files changed, 33 insertions, 40 deletions
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
index 5f3f6498a4..6368b3d5a0 100644
--- a/src/settings/nm-settings-connection.c
+++ b/src/settings/nm-settings-connection.c
@@ -1398,48 +1398,41 @@ get_settings_auth_cb (NMSettingsConnection *self,
GError *error,
gpointer data)
{
- if (error)
- g_dbus_method_invocation_return_gerror (context, error);
- else {
- gs_unref_object NMConnection *dupl_con = NULL;
- GVariant *settings;
- NMSettingConnection *s_con;
- NMSettingWireless *s_wifi;
- guint64 timestamp = 0;
- gs_free const char **bssids = NULL;
-
- dupl_con = nm_simple_connection_new_clone (nm_settings_connection_get_connection (self));
-
- /* Timestamp is not updated in connection's 'timestamp' property,
- * because it would force updating the connection and in turn
- * writing to /etc periodically, which we want to avoid. Rather real
- * timestamps are kept track of in a private variable. So, substitute
- * timestamp property with the real one here before returning the settings.
- */
- nm_settings_connection_get_timestamp (self, &timestamp);
- if (timestamp) {
- s_con = nm_connection_get_setting_connection (dupl_con);
- g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, timestamp, NULL);
- }
- /* Seen BSSIDs are not updated in 802-11-wireless 'seen-bssids' property
- * from the same reason as timestamp. Thus we put it here to GetSettings()
- * return settings too.
- */
- bssids = nm_settings_connection_get_seen_bssids (self);
- if (bssids) {
- s_wifi = nm_connection_get_setting_wireless (dupl_con);
- if (s_wifi)
- g_object_set (s_wifi, NM_SETTING_WIRELESS_SEEN_BSSIDS, bssids, NULL);
- }
+ gs_free const char **seen_bssids = NULL;
+ NMConnectionSerializationOptions options = {
+ };
+ GVariant *settings;
- /* Secrets should *never* be returned by the GetSettings method, they
- * get returned by the GetSecrets method which can be better
- * protected against leakage of secrets to unprivileged callers.
- */
- settings = nm_connection_to_dbus (dupl_con, NM_CONNECTION_SERIALIZE_NO_SECRETS);
- g_dbus_method_invocation_return_value (context,
- g_variant_new ("(@a{sa{sv}})", settings));
+ if (error) {
+ g_dbus_method_invocation_return_gerror (context, error);
+ return;
}
+
+ /* Timestamp is not updated in connection's 'timestamp' property,
+ * because it would force updating the connection and in turn
+ * writing to /etc periodically, which we want to avoid. Rather real
+ * timestamps are kept track of in a private variable. So, substitute
+ * timestamp property with the real one here before returning the settings.
+ */
+ options.timestamp.has = TRUE;
+ nm_settings_connection_get_timestamp (self, &options.timestamp.val);
+
+ /* Seen BSSIDs are not updated in 802-11-wireless 'seen-bssids' property
+ * from the same reason as timestamp. Thus we put it here to GetSettings()
+ * return settings too.
+ */
+ seen_bssids = nm_settings_connection_get_seen_bssids (self);
+ options.seen_bssids = seen_bssids;
+
+ /* Secrets should *never* be returned by the GetSettings method, they
+ * get returned by the GetSecrets method which can be better
+ * protected against leakage of secrets to unprivileged callers.
+ */
+ settings = nm_connection_to_dbus_full (nm_settings_connection_get_connection (self),
+ NM_CONNECTION_SERIALIZE_NO_SECRETS,
+ &options);
+ g_dbus_method_invocation_return_value (context,
+ g_variant_new ("(@a{sa{sv}})", settings));
}
static void