plugin.c 18 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager system settings service (ifnet)
 *
 * Mu Qiao <qiaomuf@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Copyright (C) 1999-2010 Gentoo Foundation, Inc.
 */

#include <string.h>

#include <gmodule.h>
#include <glib.h>
#include <gio/gio.h>

#include <nm-utils.h>
#include <nm-setting-connection.h>

#include "NetworkManager.h"
#include "nm-system-config-interface.h"
#include "nm-ifnet-connection.h"
35
#include "nm-config.h"
36 37 38 39 40 41 42 43

#include "plugin.h"
#include "net_utils.h"
#include "net_parser.h"
#include "wpa_parser.h"
#include "connection_parser.h"

#define IFNET_PLUGIN_NAME_PRINT "ifnet"
44
#define IFNET_PLUGIN_INFO "(C) 1999-2010 Gentoo Foundation, Inc. To report bugs please use bugs.gentoo.org with [networkmanager] or [qiaomuf] prefix."
45 46 47 48 49
#define IFNET_SYSTEM_HOSTNAME_FILE "/etc/conf.d/hostname"
#define IFNET_MANAGE_WELL_KNOWN_DEFAULT TRUE
#define IFNET_KEY_FILE_KEY_MANAGED "managed"

typedef struct {
50
	GHashTable *connections;  /* uuid::connection */
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
	gchar *hostname;
	gboolean unmanaged_well_known;

	GFileMonitor *hostname_monitor;
	GFileMonitor *net_monitor;
	GFileMonitor *wpa_monitor;

} SCPluginIfnetPrivate;

typedef void (*FileChangedFn) (gpointer user_data);

typedef struct {
	FileChangedFn callback;
	gpointer user_data;
} FileMonitorInfo;

Dan Williams's avatar
Dan Williams committed
67
static void system_config_interface_init (NMSystemConfigInterface *class);
68

Dan Williams's avatar
Dan Williams committed
69
static void reload_connections (gpointer config);
70 71

G_DEFINE_TYPE_EXTENDED (SCPluginIfnet, sc_plugin_ifnet, G_TYPE_OBJECT, 0,
Dan Williams's avatar
Dan Williams committed
72
                        G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, system_config_interface_init))
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
#define SC_PLUGIN_IFNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFNET, SCPluginIfnetPrivate))
/*
static void
ignore_cb(NMSettingsConnectionInterface * connection,
	  GError * error, gpointer user_data)
{
}
*/
static const char *
get_hostname (NMSystemConfigInterface * config)
{
	return SC_PLUGIN_IFNET_GET_PRIVATE (config)->hostname;
}

static void
update_system_hostname (gpointer config)
{
	SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config);

92 93
	if (priv->hostname)
		g_free (priv->hostname);
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
	priv->hostname = read_hostname (IFNET_SYSTEM_HOSTNAME_FILE);

	g_object_notify (G_OBJECT (config),
			 NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME);
	PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Hostname updated to: %s",
		      priv->hostname);
}

static void
write_system_hostname (NMSystemConfigInterface * config,
		       const gchar * newhostname)
{
	SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config);

	g_return_if_fail (newhostname);
	PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Write system hostname: %s",
		      newhostname);
111
	if (write_hostname (IFNET_SYSTEM_HOSTNAME_FILE, newhostname)) {
112
		g_free (priv->hostname);
113 114 115 116 117 118 119 120 121
		priv->hostname = g_strdup (newhostname);
		g_object_notify (G_OBJECT (config),
				 NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME);
	} else
		PLUGIN_WARN (IFNET_PLUGIN_NAME,
			     "Write system hostname: %s failed", newhostname);
}

static gboolean
122
is_managed_plugin (void)
123
{
124 125 126 127 128 129 130 131 132 133
	char *result = NULL;

	result = nm_config_get_value (nm_config_get (),
	                              IFNET_KEY_FILE_GROUP, IFNET_KEY_FILE_KEY_MANAGED,
	                              NULL);
	if (result) {
		gboolean ret = is_true (result);
		g_free (result);
		return ret;
	}
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
	return IFNET_MANAGE_WELL_KNOWN_DEFAULT;
}

static void
file_changed (GFileMonitor * monitor,
	      GFile * file,
	      GFile * other_file,
	      GFileMonitorEvent event_type, gpointer user_data)
{
	FileMonitorInfo *info;

	switch (event_type) {
	case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
		info = (FileMonitorInfo *) user_data;
		info->callback (info->user_data);
		break;
	default:
		break;
	}
}

static GFileMonitor *
monitor_file_changes (const char *filename,
		      FileChangedFn callback, gpointer user_data)
{
	GFile *file;
	GFileMonitor *monitor;
	FileMonitorInfo *info;
	GError **error = NULL;

	if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR))
		return NULL;
	file = g_file_new_for_path (filename);
	monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, error);
	g_object_unref (file);

	if (monitor) {
		info = g_new0 (FileMonitorInfo, 1);
		info->callback = callback;
		info->user_data = user_data;
		g_object_weak_ref (G_OBJECT (monitor), (GWeakNotify) g_free,
				   info);
		g_signal_connect (monitor, "changed", G_CALLBACK (file_changed),
				  info);
	} else
		PLUGIN_WARN (IFNET_PLUGIN_NAME,
			     "Monitoring %s failed, error: %s", filename,
			     error == NULL ? "nothing" : (*error)->message);

	return monitor;
}

static void
setup_monitors (NMIfnetConnection * connection, gpointer user_data)
{
	SCPluginIfnet *self = SC_PLUGIN_IFNET (user_data);
	SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self);

	priv->hostname_monitor =
	    monitor_file_changes (IFNET_SYSTEM_HOSTNAME_FILE,
				  update_system_hostname, user_data);
	priv->net_monitor =
	    monitor_file_changes (CONF_NET_FILE, reload_connections, user_data);
	priv->wpa_monitor =
	    monitor_file_changes (WPA_SUPPLICANT_CONF, reload_connections,
				  user_data);
}

static void
cancel_monitors (NMIfnetConnection * connection, gpointer user_data)
{
	SCPluginIfnet *self = SC_PLUGIN_IFNET (user_data);
	SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self);

	if (priv->hostname_monitor) {
		g_file_monitor_cancel (priv->hostname_monitor);
		g_object_unref (priv->hostname_monitor);
	}
	if (priv->net_monitor) {
		g_file_monitor_cancel (priv->net_monitor);
		g_object_unref (priv->net_monitor);
	}
	if (priv->wpa_monitor) {
		g_file_monitor_cancel (priv->wpa_monitor);
		g_object_unref (priv->wpa_monitor);
	}
}

static void
reload_connections (gpointer config)
{
	SCPluginIfnet *self = SC_PLUGIN_IFNET (config);
	SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self);
	GList *conn_names = NULL, *n_iter = NULL;
228 229 230
	gboolean auto_refresh = FALSE;
	char *str_auto_refresh;
	GError *error = NULL;
231 232

	/* save names for removing unused connections */
233
	GHashTable *new_connections = NULL;
234
	GHashTableIter iter;
235 236
	const char *uuid;
	NMSettingsConnection *candidate;
237 238 239 240 241 242

	if (priv->unmanaged_well_known)
		return;

	if (!reload_parsers ())
		return;
243

244
	PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Loading connections");
245

246 247 248 249 250 251 252 253 254 255
	str_auto_refresh = nm_config_get_value (nm_config_get (),
	                                        IFNET_KEY_FILE_GROUP, "auto_refresh",
	                                        NULL);
	if (str_auto_refresh && is_true (str_auto_refresh))
		auto_refresh = TRUE;
	g_free (str_auto_refresh);

	new_connections = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);

	/* Reread on-disk data and refresh in-memory connections from it */
256 257
	conn_names = ifnet_get_connection_names ();
	for (n_iter = conn_names; n_iter; n_iter = g_list_next (n_iter)) {
258
		NMIfnetConnection *new;
259
		NMIfnetConnection *old;
260
		const char *conn_name = n_iter->data;
261

262 263 264
		/* read the new connection */
		new = nm_ifnet_connection_new (conn_name, NULL);
		if (!new)
265
			continue;
266 267 268 269 270 271

		g_signal_connect (G_OBJECT (new), "ifnet_setup_monitors",
		                  G_CALLBACK (setup_monitors), config);
		g_signal_connect (G_OBJECT (new), "ifnet_cancel_monitors",
		                  G_CALLBACK (cancel_monitors), config);

272 273
		old = g_hash_table_lookup (priv->connections,
		                           nm_connection_get_uuid (NM_CONNECTION (new)));
274
		if (old && new) {
275 276 277 278
			if (auto_refresh) {
				/* If connection has changed, remove the old one and add the
				 * new one to force a disconnect/reconnect with new settings
				 */
279
				if (!nm_connection_compare (NM_CONNECTION (old),
280
				                            NM_CONNECTION (new),
281 282
				                            NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS |
				                              NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) {
283 284
					PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Auto refreshing %s", conn_name);

285
					nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (old));
286 287 288 289 290
					g_hash_table_remove (priv->connections,
					                     nm_connection_get_uuid (NM_CONNECTION (old)));
					g_hash_table_insert (priv->connections,
					                     (gpointer) nm_connection_get_uuid (NM_CONNECTION (new)),
					                     g_object_ref (new));
291
					if (is_managed_plugin () && is_managed (conn_name))
292
						g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, new);
293
				}
294 295
			} else {
				/* Update existing connection with new settings */
296 297 298 299 300 301 302 303 304
				if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (old),
				                                              NM_CONNECTION (new),
				                                              FALSE,  /* don't set Unsaved */
				                                              &error)) {
					/* Shouldn't ever get here as 'new' was verified by the reader already */
					g_assert_no_error (error);
				}
				PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Connection %s updated",
				              nm_connection_get_id (NM_CONNECTION (new)));
305 306 307
			}
			g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
		} else if (new) {
308 309 310
			g_hash_table_insert (priv->connections,
			                     (gpointer) nm_connection_get_uuid (NM_CONNECTION (new)),
			                     g_object_ref (new));
311
			if (is_managed_plugin () && is_managed (conn_name))
312
				g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, new);
313
		}
314 315 316 317 318

		/* Track all valid connections so we can remove deleted ones later */
		g_hash_table_insert (new_connections,
		                     (gpointer) nm_connection_get_uuid (NM_CONNECTION (new)),
		                     new);
319
	}
320

321 322 323 324 325 326
	/* remove deleted/unused connections */
	g_hash_table_iter_init (&iter, priv->connections);
	while (g_hash_table_iter_next (&iter, (gpointer) &uuid, (gpointer) &candidate)) {
		if (!g_hash_table_lookup (new_connections, uuid)) {
			nm_settings_connection_signal_remove (candidate);
			g_hash_table_iter_remove (&iter);
327 328
		}
	}
329
	g_hash_table_destroy (new_connections);
330 331 332
	g_list_free (conn_names);
}

Mu Qiao's avatar
Mu Qiao committed
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
static void
check_flagged_secrets (NMSetting  *setting,
                       const char *key,
                       const GValue *value,
                       GParamFlags flags,
                       gpointer user_data)
{
	gboolean *is_system_secret = user_data;

	if (flags & NM_SETTING_PARAM_SECRET) {
		NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;

		nm_setting_get_secret_flags (setting, key, &secret_flags, NULL);

		if (secret_flags != NM_SETTING_SECRET_FLAG_NONE) {
			*is_system_secret = TRUE;
		}
	}
}

353
static NMSettingsConnection *
Dan Williams's avatar
Dan Williams committed
354
add_connection (NMSystemConfigInterface *config,
355
                NMConnection *source,
Dan Williams's avatar
Dan Williams committed
356
                GError **error)
357
{
358
	SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config);
Mu Qiao's avatar
Mu Qiao committed
359
	gboolean has_flagged_secrets = FALSE;
360 361 362 363
	NMSettingConnection *s_con;

	s_con = nm_connection_get_setting_connection (source);
	g_assert (s_con);
Mu Qiao's avatar
Mu Qiao committed
364 365 366

	/* If the connection is not available for all users, ignore
	 * it as this plugin only deals with System Connections */
367
	if (nm_setting_connection_get_num_permissions (s_con))
Mu Qiao's avatar
Mu Qiao committed
368 369 370 371 372
		return NULL;

	/* If the connection has flagged secrets, ignore
	 * it as this plugin does not deal with user agent service */
	nm_connection_for_each_setting_value (source, check_flagged_secrets, &has_flagged_secrets);
373 374
	if (has_flagged_secrets)
		return NULL;
Mu Qiao's avatar
Mu Qiao committed
375

376 377
	if (!ifnet_add_new_connection (source, CONF_NET_FILE, WPA_SUPPLICANT_CONF, NULL, NULL, error))
		return NULL;
378

379 380
	reload_connections (config);
	return g_hash_table_lookup (priv->connections, nm_connection_get_uuid (source));
381 382 383 384 385
}

static void
check_unmanaged (gpointer key, gpointer data, gpointer user_data)
{
386
	NMIfnetConnection *connection = NM_IFNET_CONNECTION (data);
387
	GSList **list = (GSList **) user_data;
388
	const char *mac, *conn_name;
389
	char *unmanaged_spec;
390 391
	GSList *iter;

392 393
	conn_name = nm_ifnet_connection_get_conn_name (connection);

394 395
	if (is_managed (conn_name))
		return;
396

397
	PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Checking unmanaged: %s", conn_name);
398 399 400 401 402
	mac = ifnet_get_data (conn_name, "mac");
	if (mac)
		unmanaged_spec = g_strdup_printf ("mac:%s", mac);
	else
		unmanaged_spec = g_strdup_printf ("interface-name:%s", conn_name);
403 404 405

	/* Just return if the unmanaged spec is already in the list */
	for (iter = *list; iter; iter = g_slist_next (iter)) {
406
		if (g_str_equal (iter->data, unmanaged_spec)) {
407
			g_free (unmanaged_spec);
408
			return;
409
		}
410 411 412
	}

	PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Add unmanaged: %s", unmanaged_spec);
413
	*list = g_slist_prepend (*list, unmanaged_spec);
414 415 416 417 418 419 420 421 422
}

static GSList *
get_unmanaged_specs (NMSystemConfigInterface * config)
{
	SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config);
	GSList *list = NULL;

	PLUGIN_PRINT (IFNET_PLUGIN_NAME, "getting unmanaged specs...");
423
	g_hash_table_foreach (priv->connections, check_unmanaged, &list);
424 425 426 427
	return list;
}

static void
428
init (NMSystemConfigInterface *config)
429 430 431 432 433
{
	SCPluginIfnet *self = SC_PLUGIN_IFNET (config);
	SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self);

	PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Initializing!");
434 435

	priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
436 437 438
	priv->unmanaged_well_known = !is_managed_plugin ();
	PLUGIN_PRINT (IFNET_PLUGIN_NAME, "management mode: %s",
		      priv->unmanaged_well_known ? "unmanaged" : "managed");
439

440 441 442 443 444 445 446 447
	setup_monitors (NULL, config);
	reload_connections (config);
	update_system_hostname (self);

	PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Initialzation complete!");
}

static GSList *
448
get_connections (NMSystemConfigInterface *config)
449 450 451 452
{
	SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config);
	GSList *connections = NULL;
	GHashTableIter iter;
453
	NMIfnetConnection *connection;
454

455
	PLUGIN_PRINT (IFNET_PLUGIN_NAME, "(%p) ... get_connections.", config);
456 457
	if (priv->unmanaged_well_known) {
		PLUGIN_PRINT (IFNET_PLUGIN_NAME,
458 459
		              "(%p) ... get_connections (managed=false): return empty list.",
		              config);
460 461 462
		return NULL;
	}

463 464 465 466 467 468 469
	g_hash_table_iter_init (&iter, priv->connections);
	while (g_hash_table_iter_next (&iter, NULL, (gpointer) &connection)) {
		if (is_managed (nm_ifnet_connection_get_conn_name (connection)))
			connections = g_slist_prepend (connections, connection);
	}
	PLUGIN_PRINT (IFNET_PLUGIN_NAME, "(%p) connections count: %d",
	              config, g_slist_length (connections));
470 471 472 473
	return connections;
}

static void
Dan Williams's avatar
Dan Williams committed
474
system_config_interface_init (NMSystemConfigInterface *class)
475
{
476
	class->init = init;
Dan Williams's avatar
Dan Williams committed
477 478 479
	class->get_connections = get_connections;
	class->get_unmanaged_specs = get_unmanaged_specs;
	class->add_connection = add_connection;
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
}

static void
sc_plugin_ifnet_init (SCPluginIfnet * plugin)
{
}

static void
get_property (GObject * object, guint prop_id, GValue * value,
	      GParamSpec * pspec)
{
	NMSystemConfigInterface *self = NM_SYSTEM_CONFIG_INTERFACE (object);

	switch (prop_id) {
	case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME:
		g_value_set_string (value, IFNET_PLUGIN_NAME_PRINT);
		break;
	case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO:
		g_value_set_string (value, IFNET_PLUGIN_INFO);
		break;
	case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES:
		g_value_set_uint (value,
				  NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS
				  |
				  NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME);
		break;
	case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME:
		g_value_set_string (value, get_hostname (self));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}

static void
set_property (GObject * object, guint prop_id, const GValue * value,
	      GParamSpec * pspec)
{
	switch (prop_id) {
	case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME:{
			const gchar *hostname = g_value_get_string (value);

			if (hostname && strlen (hostname) < 1)
				hostname = NULL;
			write_system_hostname (NM_SYSTEM_CONFIG_INTERFACE
					       (object), hostname);
			break;
		}
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}

static void
dispose (GObject * object)
{
	SCPluginIfnet *plugin = SC_PLUGIN_IFNET (object);
	SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (plugin);

	cancel_monitors (NULL, object);
542 543 544
	if (priv->connections) {
		g_hash_table_destroy (priv->connections);
		priv->connections = NULL;
545 546
	}

547
	g_free (priv->hostname);
548 549
	priv->hostname = NULL;

550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
	ifnet_destroy ();
	wpa_parser_destroy ();
	G_OBJECT_CLASS (sc_plugin_ifnet_parent_class)->dispose (object);
}

static void
sc_plugin_ifnet_class_init (SCPluginIfnetClass * req_class)
{
	GObjectClass *object_class = G_OBJECT_CLASS (req_class);

	g_type_class_add_private (req_class, sizeof (SCPluginIfnetPrivate));

	object_class->dispose = dispose;
	object_class->get_property = get_property;
	object_class->set_property = set_property;

	g_object_class_override_property (object_class,
					  NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME,
					  NM_SYSTEM_CONFIG_INTERFACE_NAME);

	g_object_class_override_property (object_class,
					  NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO,
					  NM_SYSTEM_CONFIG_INTERFACE_INFO);

	g_object_class_override_property (object_class,
					  NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES,
					  NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES);

	g_object_class_override_property (object_class,
					  NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME,
					  NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME);
}

G_MODULE_EXPORT GObject *
584
nm_system_config_factory (void)
585 586
{
	static SCPluginIfnet *singleton = NULL;
587
	SCPluginIfnetPrivate *priv;
588

589 590
	if (!singleton) {
		singleton = SC_PLUGIN_IFNET (g_object_new (SC_TYPE_PLUGIN_IFNET, NULL));
591
		priv = SC_PLUGIN_IFNET_GET_PRIVATE (singleton);
592
	} else
593
		g_object_ref (singleton);
594

595 596
	return G_OBJECT (singleton);
}