docs/settings-spec.html
docs/spec.html
++examples/C/add-connection-glib
++examples/C/get-active-connections
++examples/C/get-ap-info-libnm-glib
++examples/C/list-connections-dbus
++examples/C/list-connections-libnm-glib
++
callouts/nm-dhcp-client.action
callouts/nm-avahi-autoipd.action
callouts/nm-dispatcher.action
libnm-util/tests/test-general
libnm-util/tests/test-need-secrets
libnm-util/tests/test-setting-8021x
+libnm-glib/tests/test-remote-settings-client
src/tests/test-dhcp-options
src/tests/test-policy-hosts
+src/tests/test-wifi-ap-utils
+ src/dhcp-manager/tests/test-dhcp-dhclient
system-settings/plugins/keyfile/tests/test-keyfile
system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh
system-settings/plugins/ifcfg-rh/tests/network-scripts/Test_Write_*
system-settings/plugins/ifcfg-rh/tests/network-scripts/*-Test_Write_*
system-settings/plugins/ifupdown/tests/test-ifupdown
++system-settings/plugins/ifnet/tests/check_ifnet
m4/gtk-doc.m4
m4/intltool.m4
fprintf (stderr,
_("Usage: nmcli con { COMMAND | help }\n"
" COMMAND := { list | status | up | down }\n\n"
- " list [id <id> | uuid <id> | system | user]\n"
+ " list [id <id> | uuid <id>]\n"
" status\n"
- " up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [--nowait] [--timeout <timeout>]\n"
+ " up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [nsp <name>] [--nowait] [--timeout <timeout>]\n"
" down id <id> | uuid <id>\n"));
}
src/dnsmasq-manager/Makefile
src/modem-manager/Makefile
src/bluez-manager/Makefile
-src/system-settings/Makefile
+src/settings/Makefile
+ src/wimax/Makefile
src/backends/Makefile
libnm-util/libnm-util.pc
libnm-util/Makefile
echo systemd support: no
fi
+if test -n "${with_ck}"; then
+ echo ConsoleKit support: ${with_ck}
+else
+ echo ConsoleKit support: no
+fi
+
+ if test "${enable_wimax}" = "yes"; then
+ echo WiMAX support: yes
+ else
+ echo WiMAX support: no
+ fi
+
echo
echo Building documentation: ${with_docs}
echo Building tests: ${with_tests}
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
-- * (C) Copyright 2010 Red Hat, Inc.
++ * (C) Copyright 2011 Red Hat, Inc.
*/
/*
/* Create a D-Bus proxy; NM_DBUS_* defined in NetworkManager.h */
proxy = dbus_g_proxy_new_for_name (bus,
-- NM_DBUS_SERVICE_SYSTEM_SETTINGS,
++ NM_DBUS_SERVICE,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS);
--- /dev/null
- * (C) Copyright 2010 Red Hat, Inc.
+ /*
+ * 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.
+ *
- NM_DBUS_SERVICE_SYSTEM_SETTINGS,
++ * (C) Copyright 2011 Red Hat, Inc.
+ */
+
+ /*
+ * The example shows how to list connections from System Settings service using direct
+ * D-Bus call of ListConnections method.
+ * The example uses dbus-glib, libnm-util libraries.
+ *
+ * Compile with:
+ * gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util` list-connections-dbus.c -o list-connections-dbus
+ */
+
+ #include <glib.h>
+ #include <dbus/dbus-glib.h>
+ #include <stdio.h>
+
+ #include <NetworkManager.h>
+ #include <nm-utils.h>
+
+ #define DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH))
+
+ static void
+ list_connections (DBusGProxy *proxy)
+ {
+ int i;
+ GError *error = NULL;
+ GPtrArray *con_array;
+
+ /* Call ListConnections D-Bus method */
+ dbus_g_proxy_call (proxy, "ListConnections", &error,
+ /* No input arguments */
+ G_TYPE_INVALID,
+ DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &con_array, /* Return values */
+ G_TYPE_INVALID);
+
+ for (i = 0; con_array && i < con_array->len; i++) {
+ char *connection_path = g_ptr_array_index (con_array, i);
+ printf ("%s\n", connection_path);
+ g_free (connection_path);
+ }
+ g_ptr_array_free (con_array, TRUE);
+ }
+
+ int main (int argc, char *argv[])
+ {
+ DBusGConnection *bus;
+ DBusGProxy *proxy;
+
+ /* Initialize GType system */
+ g_type_init ();
+
+ /* Get system bus */
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+
+ /* Create a D-Bus proxy; NM_DBUS_* defined in NetworkManager.h */
+ proxy = dbus_g_proxy_new_for_name (bus,
++ NM_DBUS_SERVICE,
+ NM_DBUS_PATH_SETTINGS,
+ NM_DBUS_IFACE_SETTINGS);
+
+ /* List connections of system settings service */
+ list_connections (proxy);
+
+ g_object_unref (proxy);
+ dbus_g_connection_unref (bus);
+
+ return 0;
+ }
--- /dev/null
- * (C) Copyright 2010 Red Hat, Inc.
+ /*
+ * 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.
+ *
-#include <nm-remote-settings-system.h>
-#include <nm-settings-interface.h>
++ * (C) Copyright 2011 Red Hat, Inc.
+ */
+
+ /*
+ * The example shows how to list connections from System Settings service using libnm-glib
+ * (that wraps direct D-Bus calls).
+ * The example uses dbus-glib, libnm-util and libnm-glib libraries.
+ *
+ * Compile with:
+ * gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util libnm-glib` list-connections-libnm-glib.c -o list-connections-libnm-glib
+ */
+
+ #include <glib.h>
+ #include <dbus/dbus-glib.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <signal.h>
+
+ #include <nm-connection.h>
+ #include <nm-setting-connection.h>
+ #include <NetworkManager.h>
+ #include <nm-utils.h>
+ #include <nm-remote-settings.h>
-get_connections_cb (NMSettingsInterface *settings, gpointer user_data)
+
+
+ /* Global variables */
+ GMainLoop *loop = NULL; /* Main loop variable - needed for waiting for signal */
+ int result = EXIT_SUCCESS;
+
+ static void
+ signal_handler (int signo)
+ {
+ if (signo == SIGINT || signo == SIGTERM) {
+ g_message ("Caught signal %d, shutting down...", signo);
+ g_main_loop_quit (loop);
+ }
+ }
+
+ static void
+ setup_signals (void)
+ {
+ struct sigaction action;
+ sigset_t mask;
+
+ sigemptyset (&mask);
+ action.sa_handler = signal_handler;
+ action.sa_mask = mask;
+ action.sa_flags = 0;
+ sigaction (SIGTERM, &action, NULL);
+ sigaction (SIGINT, &action, NULL);
+ }
+
+ /* Print details of connection */
+ static void
+ show_connection (NMConnection *data, gpointer user_data)
+ {
+ NMConnection *connection = (NMConnection *) data;
+ NMSettingConnection *s_con;
+ guint64 timestamp;
+ char *timestamp_str;
+ char timestamp_real_str[64];
+ const char *val1, *val2, *val3, *val4, *val5;
+
+ s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+ if (s_con) {
+ /* Get various info from NMSettingConnection and show it */
+ timestamp = nm_setting_connection_get_timestamp (s_con);
+ timestamp_str = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp);
+ strftime (timestamp_real_str, sizeof (timestamp_real_str), "%c", localtime ((time_t *) ×tamp));
+
+ val1 = nm_setting_connection_get_id (s_con);
+ val2 = nm_setting_connection_get_uuid (s_con);
+ val3 = nm_setting_connection_get_connection_type (s_con);
+ val4 = nm_connection_get_path (connection);
+ val5 = timestamp ? timestamp_real_str : "never";
+
+ printf ("%-25s | %s | %-15s | %-43s | %s\n", val1, val2, val3, val4, val5);
+
+ g_free (timestamp_str);
+ }
+ }
+
+ /* This callback is called when connections from the settings service are ready.
+ * Now the connections can be listed.
+ */
+ static void
- GSList *system_connections;
++get_connections_cb (NMRemoteSettings *settings, gpointer user_data)
+ {
- system_connections = nm_settings_interface_list_connections (settings);
++ GSList *connections;
+
- printf ("System connections:\n===================\n");
++ connections = nm_remote_settings_list_connections (settings);
+
- g_slist_foreach (system_connections, (GFunc) show_connection, NULL);
++ printf ("Connections:\n===================\n");
+
- g_slist_free (system_connections);
++ g_slist_foreach (connections, (GFunc) show_connection, NULL);
+
- NMRemoteSettingsSystem *system_settings;
- gboolean system_settings_running;
++ g_slist_free (connections);
+ g_object_unref (settings);
+
+ /* We are done, exit main loop */
+ g_main_loop_quit (loop);
+ }
+
+ /* Get system settings and then connect to connections-read signal */
+ static gboolean
+ list_connections (gpointer data)
+ {
+ DBusGConnection *bus = (DBusGConnection *) data;
- if (!(system_settings = nm_remote_settings_system_new (bus))) {
++ NMRemoteSettings *settings;
++ gboolean settings_running;
+
+ /* Get system settings */
- g_object_get (system_settings, NM_REMOTE_SETTINGS_SERVICE_RUNNING, &system_settings_running, NULL);
++ if (!(settings = nm_remote_settings_new (bus))) {
+ g_message ("Error: Could not get system settings.");
+ result = EXIT_FAILURE;
+ g_main_loop_quit (loop);
+ return FALSE;
+ }
+
+ /* Find out whether setting service is running */
- if (!system_settings_running) {
++ g_object_get (settings, NM_REMOTE_SETTINGS_SERVICE_RUNNING, &settings_running, NULL);
+
- g_signal_connect (system_settings, NM_SETTINGS_INTERFACE_CONNECTIONS_READ,
++ if (!settings_running) {
+ g_message ("Error: Can't obtain connections: settings service is not running.");
+ result = EXIT_FAILURE;
+ g_main_loop_quit (loop);
+ return FALSE;
+ }
+
+ /* Connect to signal "connections-read" - emitted when connections are fetched and ready */
++ g_signal_connect (settings, NM_REMOTE_SETTINGS_CONNECTIONS_READ,
+ G_CALLBACK (get_connections_cb), NULL);
+
+ return FALSE;
+ }
+
+ int main (int argc, char *argv[])
+ {
+ DBusGConnection *bus;
+
+ /* Initialize GType system */
+ g_type_init ();
+
+ /* Get system bus */
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+
+ /* Run list_connections from main loop, because we need to wait for "connections-read"
+ * signal to have connections ready. The execution will be finished in get_connections_cb()
+ * callback on the signal.
+ */
+ g_idle_add (list_connections, bus);
+
+ loop = g_main_loop_new (NULL, FALSE); /* Create main loop */
+ setup_signals (); /* Setup UNIX signals */
+ g_main_loop_run (loop); /* Run main loop */
+
+ g_main_loop_unref (loop);
+ dbus_g_connection_unref (bus);
+
+ return result;
+ }
# Connections in NM are a collection of settings that describe everything
# needed to connect to a specific network. Lets get those details so we
# can find the user-readable name of the connection.
- con_path = prop_iface.Get("org.freedesktop.NetworkManager.ActiveConnection", "Connection")
+ con_path = prop_iface.Get("org.freedesktop.NetworkManager.Connection.Active", "Connection")
- con_service = prop_iface.Get("org.freedesktop.NetworkManager.Connection.Active", "ServiceName")
-
- # ask the provider of the connection for its details
- service_proxy = bus.get_object(con_service, con_path)
- con_iface = dbus.Interface(service_proxy, "org.freedesktop.NetworkManagerSettings.Connection")
+ service_proxy = bus.get_object("org.freedesktop.NetworkManager", con_path)
+ con_iface = dbus.Interface(service_proxy, "org.freedesktop.NetworkManager.Settings.Connection")
con_details = con_iface.GetSettings()
con_name = con_details['connection']['id']
nm-active-connection.xml \
nm-dhcp4-config.xml \
nm-dhcp6-config.xml \
- nm-agent-manager.xml
++ nm-agent-manager.xml \
+ nm-wimax-nsp.xml
nm-device-ethernet-bindings.h \
nm-device-wifi-bindings.h \
nm-device-bt-bindings.h \
- nm-exported-connection-glue.h \
- nm-exported-connection-bindings.h \
- nm-settings-glue.h \
+ nm-sysconfig-connection-bindings.h \
+ nm-device-wimax-bindings.h \
nm-settings-bindings.h \
- nm-settings-system-bindings.h \
nm-vpn-connection-bindings.h \
nm-vpn-plugin-glue.h \
nm-active-connection-bindings.h \
nm-ip6-config.h \
nm-dhcp6-config.h \
nm-remote-connection.h \
- nm-settings-interface.h \
- nm-settings-system-interface.h \
nm-remote-settings.h \
- nm-secret-agent.h
- nm-remote-settings-system.h \
- nm-settings-connection-interface.h \
- nm-exported-connection.h \
- nm-settings-service.h \
++ nm-secret-agent.h \
+ nm-device-wimax.h \
+ nm-wimax-nsp.h
libnm_glib_la_SOURCES = \
nm-object.c \
nm-dhcp6-config.c \
nm-remote-connection.c \
nm-remote-connection-private.h \
- nm-settings-interface.c \
- nm-settings-system-interface.c \
nm-remote-settings.c \
- nm-secret-agent.c
- nm-remote-settings-system.c \
- nm-settings-connection-interface.c \
- nm-exported-connection.c \
- nm-settings-service.c \
++ nm-secret-agent.c \
+ nm-device-wimax.c \
+ nm-wimax-nsp.c
libnm_glib_la_LIBADD = \
$(top_builddir)/libnm-util/libnm-util.la \
nm-dhcp6-config-bindings.h: $(top_srcdir)/introspection/nm-dhcp6-config.xml
$(AM_V_GEN) dbus-binding-tool --prefix=nm_dhcp6_config --mode=glib-client --output=$@ $<
+nm-secret-agent-glue.h: $(top_srcdir)/introspection/nm-secret-agent.xml
+ $(AM_V_GEN) dbus-binding-tool --prefix=nm_secret_agent --mode=glib-server --output=$@ $<
+
+ nm-device-wimax-bindings.h: $(top_srcdir)/introspection/nm-device-wimax.xml
+ dbus-binding-tool --prefix=nm_device_wimax --mode=glib-client --output=$@ $<
+
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libnm-glib.pc libnm-glib-vpn.pc
nm_dhcp4_config_get_options;
nm_dhcp4_config_get_type;
nm_dhcp4_config_new;
- nm_exported_connection_export;
- nm_exported_connection_get_type;
- nm_exported_connection_new;
+ nm_dhcp6_config_get_one_option;
+ nm_dhcp6_config_get_options;
+ nm_dhcp6_config_get_type;
+ nm_dhcp6_config_new;
nm_gsm_device_get_type;
nm_gsm_device_new;
nm_ip4_config_get_addresses;
property_changed_info);
}
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK "org.freedesktop.NetworkManager.enable-disable-network"
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI "org.freedesktop.NetworkManager.enable-disable-wifi"
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN "org.freedesktop.NetworkManager.enable-disable-wwan"
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX "org.freedesktop.NetworkManager.enable-disable-wimax"
-#define NM_AUTH_PERMISSION_USE_USER_CONNECTIONS "org.freedesktop.NetworkManager.use-user-connections"
+#define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK "org.freedesktop.NetworkManager.enable-disable-network"
+#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI "org.freedesktop.NetworkManager.enable-disable-wifi"
+#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN "org.freedesktop.NetworkManager.enable-disable-wwan"
++#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX "org.freedesktop.NetworkManager.enable-disable-wimax"
+#define NM_AUTH_PERMISSION_SLEEP_WAKE "org.freedesktop.NetworkManager.sleep-wake"
+#define NM_AUTH_PERMISSION_NETWORK_CONTROL "org.freedesktop.NetworkManager.network-control"
+#define NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED "org.freedesktop.NetworkManager.wifi.share.protected"
+#define NM_AUTH_PERMISSION_WIFI_SHARE_OPEN "org.freedesktop.NetworkManager.wifi.share.open"
+#define NM_AUTH_PERMISSION_SETTINGS_CONNECTION_MODIFY "org.freedesktop.NetworkManager.settings.modify"
+#define NM_AUTH_PERMISSION_SETTINGS_HOSTNAME_MODIFY "org.freedesktop.NetworkManager.settings.hostname.modify"
static NMClientPermission
nm_permission_to_client (const char *nm)
return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI;
else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN))
return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS))
- return NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX))
+ return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_SLEEP_WAKE))
+ return NM_CLIENT_PERMISSION_SLEEP_WAKE;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_NETWORK_CONTROL))
+ return NM_CLIENT_PERMISSION_NETWORK_CONTROL;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED))
+ return NM_CLIENT_PERMISSION_WIFI_SHARE_PROTECTED;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_WIFI_SHARE_OPEN))
+ return NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_SETTINGS_CONNECTION_MODIFY))
+ return NM_CLIENT_PERMISSION_SETTINGS_CONNECTION_MODIFY;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_SETTINGS_HOSTNAME_MODIFY))
+ return NM_CLIENT_PERMISSION_SETTINGS_HOSTNAME_MODIFY;
+
return NM_CLIENT_PERMISSION_NONE;
}
NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK = 1,
NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI = 2,
NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN = 3,
- NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS = 4,
- NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX = 5,
+ NM_CLIENT_PERMISSION_SLEEP_WAKE = 4,
+ NM_CLIENT_PERMISSION_NETWORK_CONTROL = 5,
+ NM_CLIENT_PERMISSION_WIFI_SHARE_PROTECTED = 6,
+ NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN = 7,
+ NM_CLIENT_PERMISSION_SETTINGS_CONNECTION_MODIFY = 8,
+ NM_CLIENT_PERMISSION_SETTINGS_HOSTNAME_MODIFY = 9,
++ NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX = 10,
- NM_CLIENT_PERMISSION_LAST = NM_CLIENT_PERMISSION_SETTINGS_HOSTNAME_MODIFY
+ NM_CLIENT_PERMISSION_LAST = NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX
} NMClientPermission;
typedef enum {
--- /dev/null
- -DSERVICEDIR=\"$(builddir)\" \
+INCLUDES = \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/libnm-util \
+ -I$(top_srcdir)/libnm-glib
+
+noinst_PROGRAMS = test-remote-settings-client
+
+####### remote settings client test #######
+
+test_remote_settings_client_SOURCES = \
+ test-remote-settings-client.c
+
+test_remote_settings_client_CPPFLAGS = \
- EXTRA_DIST = test-remote-settings-service.py
+ $(GLIB_CFLAGS) \
+ $(DBUS_CFLAGS)
+
+test_remote_settings_client_LDADD = \
+ $(top_builddir)/libnm-util/libnm-util.la \
+ $(top_builddir)/libnm-glib/libnm-glib-test.la \
+ $(GLIB_LIBS) \
+ $(DBUS_LIBS)
+
+###########################################
+
- $(abs_builddir)/test-remote-settings-client
++TEST_RSS_BIN = test-remote-settings-service.py
++
++EXTRA_DIST = $(TEST_RSS_BIN)
+
+if WITH_TESTS
+
+check-local: test-remote-settings-client
++ $(abs_builddir)/test-remote-settings-client $(abs_srcdir) $(TEST_RSS_BIN)
+
+endif
+
--- /dev/null
- #define SERVICE_FILE "test-remote-settings-service.py"
-
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * 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, 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) 2010 Red Hat, Inc.
+ *
+ */
+
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <glib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <signal.h>
+
+#include <NetworkManager.h>
+
+#include <nm-setting-connection.h>
+#include <nm-setting-wired.h>
+#include <nm-utils.h>
+
+#include "nm-remote-settings.h"
+
- char *service_argv[3] = { SERVICEDIR "/" SERVICE_FILE, SERVICE_FILE, NULL };
+static GPid spid = 0;
+static NMRemoteSettings *settings = NULL;
+
+/*******************************************************************/
+
+static void
+cleanup (void)
+{
+ if (settings)
+ g_object_unref (settings);
+ kill (spid, SIGTERM);
+}
+
+#define test_assert(condition) \
+do { \
+ if (!G_LIKELY (condition)) \
+ cleanup (); \
+ g_assert (condition); \
+} while (0)
+
+/*******************************************************************/
+
+typedef struct {
+ gboolean done;
+ NMRemoteConnection *connection;
+} AddInfo;
+
+static void
+add_cb (NMRemoteSettings *s,
+ NMRemoteConnection *connection,
+ GError *error,
+ gpointer user_data)
+{
+ AddInfo *info = user_data;
+
+ if (error)
+ g_warning ("Add error: %s", error->message);
+
+ info->done = TRUE;
+ info->connection = connection;
+}
+
+static void
+test_add_connection (void)
+{
+ NMConnection *connection;
+ NMSettingConnection *s_con;
+ NMSettingWired *s_wired;
+ char *uuid;
+ gboolean success;
+ time_t start, now;
+ AddInfo info = { FALSE, NULL };
+
+ connection = nm_connection_new ();
+
+ s_con = (NMSettingConnection *) nm_setting_connection_new ();
+ uuid = nm_utils_uuid_generate ();
+ g_object_set (G_OBJECT (s_con),
+ NM_SETTING_CONNECTION_ID, "blahblahblah",
+ NM_SETTING_CONNECTION_UUID, uuid,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
+ NULL);
+ g_free (uuid);
+ nm_connection_add_setting (connection, NM_SETTING (s_con));
+
+ s_wired = (NMSettingWired *) nm_setting_wired_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_wired));
+
+ success = nm_remote_settings_add_connection (settings,
+ connection,
+ add_cb,
+ &info);
+ test_assert (success == TRUE);
+
+ start = time (NULL);
+ do {
+ now = time (NULL);
+ g_main_context_iteration (NULL, FALSE);
+ } while ((info.done == FALSE) && (now - start < 5));
+ test_assert (info.done == TRUE);
+ test_assert (info.connection != NULL);
+
+ /* Make sure the connection is the same as what we added */
+ test_assert (nm_connection_compare (connection,
+ NM_CONNECTION (info.connection),
+ NM_SETTING_COMPARE_FLAG_EXACT) == TRUE);
+}
+
+/*******************************************************************/
+
+static void
+deleted_cb (DBusGProxy *proxy,
+ DBusGProxyCall *call,
+ gpointer user_data)
+{
+ GError *error = NULL;
+ gboolean success;
+
+ success = dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ if (!success)
+ g_warning ("Failed to delete connection: %s", error->message);
+ test_assert (success == TRUE);
+ test_assert (error == NULL);
+}
+
+static void
+removed_cb (NMRemoteConnection *connection, gpointer user_data)
+{
+ gboolean *done = user_data;
+
+ *done = TRUE;
+}
+
+static void
+test_remove_connection (DBusGConnection *bus)
+{
+ NMRemoteConnection *connection;
+ time_t start, now;
+ GSList *list, *iter;
+ DBusGProxy *proxy;
+ gboolean done = FALSE;
+ char *path;
+
+ /* Find a connection to delete */
+ list = nm_remote_settings_list_connections (settings);
+ test_assert (g_slist_length (list) > 0);
+
+ connection = NM_REMOTE_CONNECTION (list->data);
+ path = g_strdup (nm_connection_get_path (NM_CONNECTION (connection)));
+ g_signal_connect (connection, "removed", G_CALLBACK (removed_cb), &done);
+
+ proxy = dbus_g_proxy_new_for_name (bus,
+ NM_DBUS_SERVICE,
+ path,
+ NM_DBUS_IFACE_SETTINGS_CONNECTION);
+ test_assert (proxy != NULL);
+
+ /* Bypass the NMRemoteSettings object so we can test it independently */
+ dbus_g_proxy_begin_call (proxy, "Delete", deleted_cb, NULL, NULL, G_TYPE_INVALID);
+
+ start = time (NULL);
+ do {
+ now = time (NULL);
+ g_main_context_iteration (NULL, FALSE);
+ } while ((done == FALSE) && (now - start < 5));
+ test_assert (done == TRUE);
+
+ /* Ensure NMRemoteSettings no longer has the connection */
+ list = nm_remote_settings_list_connections (settings);
+ for (iter = list; iter; iter = g_slist_next (iter)) {
+ NMConnection *candidate = NM_CONNECTION (iter->data);
+
+ test_assert ((gpointer) connection != (gpointer) candidate);
+ test_assert (strcmp (path, nm_connection_get_path (candidate)) != 0);
+ }
+
+ g_free (path);
+ g_object_unref (proxy);
+}
+
+/*******************************************************************/
+
+#if GLIB_CHECK_VERSION(2,25,12)
+typedef GTestFixtureFunc TCFunc;
+#else
+typedef void (*TCFunc)(void);
+#endif
+
+#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL)
+
+int main (int argc, char **argv)
+{
+ GTestSuite *suite;
- if (!g_spawn_async (SERVICEDIR, service_argv, NULL, 0, NULL, NULL, &spid, &error)) {
- g_warning ("Error spawning " SERVICE_FILE ": %s", error->message);
++ char *service_argv[3] = { NULL, NULL, NULL };
+ int ret;
+ GError *error = NULL;
+ DBusGConnection *bus;
+ int i = 100;
+
++ g_assert (argc == 3);
++
+ g_type_init ();
+
+ g_test_init (&argc, &argv, NULL);
+
+ bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (!bus) {
+ g_warning ("Error connecting to D-Bus: %s", error->message);
+ g_assert (error == NULL);
+ }
+
++ service_argv[0] = g_strdup_printf ("%s/%s", argv[1], argv[2]);
++ if (!g_spawn_async (argv[1], service_argv, NULL, 0, NULL, NULL, &spid, &error)) {
++ g_warning ("Error spawning %s: %s", argv[2], error->message);
+ g_assert (error == NULL);
+ }
+
+ /* Wait until the service is registered on the bus */
+ while (i > 0) {
+ g_usleep (G_USEC_PER_SEC / 50);
+ if (dbus_bus_name_has_owner (dbus_g_connection_get_connection (bus),
+ "org.freedesktop.NetworkManager",
+ NULL))
+ break;
+ i--;
+ }
+ test_assert (i > 0);
+
+ settings = nm_remote_settings_new (bus);
+ test_assert (settings != NULL);
+
+ suite = g_test_get_root ();
+
+ g_test_suite_add (suite, TESTCASE (test_add_connection, NULL));
+ g_test_suite_add (suite, TESTCASE (test_remove_connection, bus));
+
+ ret = g_test_run ();
+
+ cleanup ();
+
+ return ret;
+}
+
.B domains=\fI<domain1>,<domain2>, ...\fP
The following log domains are available: [NONE, HW, RKILL, ETHER, WIFI, BT, MB,
DHCP4, DHCP6, PPP, WIFI_SCAN, IP4, IP6, AUTOIP4, DNS, VPN, SHARING, SUPPLICANT,
- USER_SET, SETTINGS, SUSPEND, CORE, DEVICE, OLPC]. When "NONE" is given by itself,
- logging is disabled. MB = Mobile Broadband, AGENTS = secret agents operations
- and communication, SETTINGS = settings/config service operations, OLPC = OLPC
- Mesh device operations, CORE = core daemon operations, DEVICE = activation and
- general interface operations.
-USER_SET, SYS_SET, SUSPEND, CORE, DEVICE, OLPC, WIMAX]. When "NONE" is given by
-itself, logging is disabled. MB = Mobile Broadband, USER_SET = user settings
-operations and communication, SYS_SET = system settings service operations, OLPC
-= OLPC Mesh device operations, CORE = core daemon operations, DEVICE = activation
-and general interface operations.
++AGENTS, SETTINGS, SUSPEND, CORE, DEVICE, OLPC, WIMAX]. When "NONE" is given by
++itself, logging is disabled. MB = Mobile Broadband, AGENTS = secret agents
++operations and communication, SETTINGS = settings/config service operations,
++OLPC = OLPC Mesh device operations, CORE = core daemon operations, DEVICE =
++activation and general interface operations.
.SH "SEE ALSO"
.BR http://live.gnome.org/NetworkManager/SystemSettings
.sp
src/nm-netlink-monitor.c
src/main.c
src/dhcp-manager/nm-dhcp-dhclient.c
+ src/dhcp-manager/nm-dhcp-dhclient-utils.c
src/dhcp-manager/nm-dhcp-manager.c
--src/logging/nm-logging.c
src/dns-manager/nm-dns-manager.c
-src/system-settings/nm-default-wired-connection.c
++src/logging/nm-logging.c
++src/modem-manager/nm-modem-cdma.c
++src/modem-manager/nm-modem-gsm.c
++src/nm-device-bt.c
++src/nm-device-ethernet.c
++src/nm-device-olpc-mesh.c
+src/settings/nm-default-wired-connection.c
system-settings/plugins/ifcfg-rh/reader.c
system-settings/plugins/ifnet/connection_parser.c
</defaults>
</action>
- <action id="org.freedesktop.NetworkManager.use-user-connections">
- <_description>Allow use of user-specific connections</_description>
- <_message>System policy prevents use of user-specific connections</_message>
+ <action id="org.freedesktop.NetworkManager.enable-disable-wimax">
+ <_description>Enable or disable WiMAX mobile broadband devices</_description>
+ <_message>System policy prevents enabling or disabling WiMAX mobile broadband devices</_message>
+ <defaults>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>yes</allow_active>
+ </defaults>
+ </action>
+
+ <action id="org.freedesktop.NetworkManager.network-control">
+ <_description>Allow control of network connections</_description>
+ <_message>System policy prevents control of network connections</_message>
<defaults>
<allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active>
dnsmasq-manager \
modem-manager \
bluez-manager \
- settings \
- . \
- tests
- system-settings
++ settings
- INCLUDES = -I${top_srcdir} \
- -I${top_srcdir}/include \
- -I${top_builddir}/marshallers \
+ if WITH_WIMAX
+ SUBDIRS += wimax
+ endif
+
+ SUBDIRS += . tests
+
+ INCLUDES = -I${top_srcdir} \
+ -I${top_srcdir}/include \
+ -I${top_builddir}/marshallers \
-I${top_srcdir}/src/logging \
-I${top_srcdir}/src/dns-manager \
- -I${top_srcdir}/src/vpn-manager \
- -I${top_srcdir}/src/dhcp-manager \
- -I${top_srcdir}/src/ip6-manager \
- -I${top_srcdir}/src/supplicant-manager \
- -I${top_srcdir}/src/dnsmasq-manager \
- -I${top_srcdir}/src/modem-manager \
+ -I${top_srcdir}/src/vpn-manager \
+ -I${top_srcdir}/src/dhcp-manager \
+ -I${top_srcdir}/src/ip6-manager \
+ -I${top_srcdir}/src/supplicant-manager \
+ -I${top_srcdir}/src/dnsmasq-manager \
+ -I${top_srcdir}/src/modem-manager \
-I$(top_srcdir)/src/bluez-manager \
- -I$(top_srcdir)/src/system-settings \
+ -I$(top_srcdir)/src/settings \
-I${top_srcdir}/libnm-util \
- -I${top_srcdir}/libnm-glib \
-I${top_srcdir}/callouts
-INCLUDES += -I${top_srcdir}/libnm-glib
-
+ if WITH_WIMAX
+ INCLUDES += -I$(top_srcdir)/src/wimax
+ endif
+
###########################################
# Test libraries
###########################################
./ppp-manager/libppp-manager.la \
./modem-manager/libmodem-manager.la \
./bluez-manager/libbluez-manager.la \
- ./system-settings/libsystem-settings.la \
+ ./settings/libsettings.la \
+ $(WIMAX_LIBS) \
./backends/libnmbackend.la \
$(top_builddir)/libnm-util/libnm-util.la \
$(DBUS_LIBS) \
static guint32 log_domains = \
LOGD_HW | LOGD_RFKILL | LOGD_ETHER | LOGD_WIFI | LOGD_BT | LOGD_MB | \
LOGD_DHCP4 | LOGD_DHCP6 | LOGD_PPP | LOGD_IP4 | LOGD_IP6 | LOGD_AUTOIP4 | \
- LOGD_DNS | LOGD_VPN | LOGD_SHARING | LOGD_SUPPLICANT | LOGD_USER_SET | \
- LOGD_SYS_SET | LOGD_SUSPEND | LOGD_CORE | LOGD_DEVICE | LOGD_OLPC_MESH | \
+ LOGD_DNS | LOGD_VPN | LOGD_SHARING | LOGD_SUPPLICANT | LOGD_AGENTS | \
- LOGD_SETTINGS | LOGD_SUSPEND | LOGD_CORE | LOGD_DEVICE | LOGD_OLPC_MESH;
++ LOGD_SETTINGS | LOGD_SUSPEND | LOGD_CORE | LOGD_DEVICE | LOGD_OLPC_MESH | \
+ LOGD_WIMAX;
typedef struct {
guint32 num;
device_cleanup (self);
- manager = nm_manager_get (NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE, NULL);
- manager = nm_manager_get (NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
++ manager = nm_manager_get (NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
if (priv->device_added_id)
g_signal_handler_disconnect (manager, priv->device_added_id);
g_object_unref (manager);
priv->companion = other;
/* When we've found the companion, stop listening for other devices */
- manager = nm_manager_get (NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE, NULL);
- manager = nm_manager_get (NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
++ manager = nm_manager_get (NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
if (priv->device_added_id) {
g_signal_handler_disconnect (manager, priv->device_added_id);
priv->device_added_id = 0;
if (priv->device_added_id != 0)
return FALSE;
- manager = nm_manager_get (NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE, NULL);
- manager = nm_manager_get (NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
++ manager = nm_manager_get (NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL);
priv->device_added_id = g_signal_connect (manager, "device-added",
G_CALLBACK (device_added_cb), self);
return TRUE;
}
+/*****************************************************************/
+
+ /*
+ * wireless_qual_to_percent
+ *
+ * Convert an iw_quality structure from SIOCGIWSTATS into a magical signal
+ * strength percentage.
+ *
+ */
+ static int
+ wireless_qual_to_percent (const struct iw_quality *qual,
+ const struct iw_quality *max_qual)
+ {
+ int percent = -1;
+ int level_percent = -1;
+
+ g_return_val_if_fail (qual != NULL, -1);
+ g_return_val_if_fail (max_qual != NULL, -1);
+
+ nm_log_dbg (LOGD_WIFI,
+ "QL: qual %d/%u/0x%X, level %d/%u/0x%X, noise %d/%u/0x%X, updated: 0x%X ** MAX: qual %d/%u/0x%X, level %d/%u/0x%X, noise %d/%u/0x%X, updated: 0x%X",
+ (__s8) qual->qual, qual->qual, qual->qual,
+ (__s8) qual->level, qual->level, qual->level,
+ (__s8) qual->noise, qual->noise, qual->noise,
+ qual->updated,
+ (__s8) max_qual->qual, max_qual->qual, max_qual->qual,
+ (__s8) max_qual->level, max_qual->level, max_qual->level,
+ (__s8) max_qual->noise, max_qual->noise, max_qual->noise,
+ max_qual->updated);
+
+ /* Try using the card's idea of the signal quality first as long as it tells us what the max quality is.
+ * Drivers that fill in quality values MUST treat them as percentages, ie the "Link Quality" MUST be
+ * bounded by 0 and max_qual->qual, and MUST change in a linear fashion. Within those bounds, drivers
+ * are free to use whatever they want to calculate "Link Quality".
+ */
+ if ((max_qual->qual != 0) && !(max_qual->updated & IW_QUAL_QUAL_INVALID) && !(qual->updated & IW_QUAL_QUAL_INVALID))
+ percent = (int)(100 * ((double)qual->qual / (double)max_qual->qual));
+
+ /* If the driver doesn't specify a complete and valid quality, we have two options:
+ *
+ * 1) dBm: driver must specify max_qual->level = 0, and have valid values for
+ * qual->level and (qual->noise OR max_qual->noise)
+ * 2) raw RSSI: driver must specify max_qual->level > 0, and have valid values for
+ * qual->level and max_qual->level
+ *
+ * This is the WEXT spec. If this interpretation is wrong, I'll fix it. Otherwise,
+ * If drivers don't conform to it, they are wrong and need to be fixed.
+ */
+
+ if ( (max_qual->level == 0) && !(max_qual->updated & IW_QUAL_LEVEL_INVALID) /* Valid max_qual->level == 0 */
+ && !(qual->updated & IW_QUAL_LEVEL_INVALID) /* Must have valid qual->level */
+ && ( ((max_qual->noise > 0) && !(max_qual->updated & IW_QUAL_NOISE_INVALID)) /* Must have valid max_qual->noise */
+ || ((qual->noise > 0) && !(qual->updated & IW_QUAL_NOISE_INVALID))) /* OR valid qual->noise */
+ ) {
+ /* Absolute power values (dBm) */
+
+ /* Reasonable fallbacks for dumb drivers that don't specify either level. */
+ #define FALLBACK_NOISE_FLOOR_DBM -90
+ #define FALLBACK_SIGNAL_MAX_DBM -20
+ int max_level = FALLBACK_SIGNAL_MAX_DBM;
+ int noise = FALLBACK_NOISE_FLOOR_DBM;
+ int level = qual->level - 0x100;
+
+ level = CLAMP (level, FALLBACK_NOISE_FLOOR_DBM, FALLBACK_SIGNAL_MAX_DBM);
+
+ if ((qual->noise > 0) && !(qual->updated & IW_QUAL_NOISE_INVALID))
+ noise = qual->noise - 0x100;
+ else if ((max_qual->noise > 0) && !(max_qual->updated & IW_QUAL_NOISE_INVALID))
+ noise = max_qual->noise - 0x100;
+ noise = CLAMP (noise, FALLBACK_NOISE_FLOOR_DBM, FALLBACK_SIGNAL_MAX_DBM);
+
+ /* A sort of signal-to-noise ratio calculation */
+ level_percent = (int)(100 - 70 *(
+ ((double)max_level - (double)level) /
+ ((double)max_level - (double)noise)));
+ nm_log_dbg (LOGD_WIFI, "QL1: level_percent is %d. max_level %d, level %d, noise_floor %d.",
+ level_percent, max_level, level, noise);
+ } else if ( (max_qual->level != 0)
+ && !(max_qual->updated & IW_QUAL_LEVEL_INVALID) /* Valid max_qual->level as upper bound */
+ && !(qual->updated & IW_QUAL_LEVEL_INVALID)) {
+ /* Relative power values (RSSI) */
+
+ int level = qual->level;
+
+ /* Signal level is relavtive (0 -> max_qual->level) */
+ level = CLAMP (level, 0, max_qual->level);
+ level_percent = (int)(100 * ((double)level / (double)max_qual->level));
+ nm_log_dbg (LOGD_WIFI, "QL2: level_percent is %d. max_level %d, level %d.",
+ level_percent, max_qual->level, level);
+ } else if (percent == -1) {
+ nm_log_dbg (LOGD_WIFI, "QL: Could not get quality %% value from driver. Driver is probably buggy.");
+ }
+
+ /* If the quality percent was 0 or doesn't exist, then try to use signal levels instead */
+ if ((percent < 1) && (level_percent >= 0))
+ percent = level_percent;
+
+ nm_log_dbg (LOGD_WIFI, "QL: Final quality percent is %d (%d).",
+ percent, CLAMP (percent, 0, 100));
+ return (CLAMP (percent, 0, 100));
+ }
+
+
/*
* nm_device_wifi_update_signal_strength
*
#include <glib.h>
#include <dbus/dbus-glib.h>
+#include <nm-connection.h>
#include "nm-dbus-manager.h"
+#include "nm-session-monitor.h"
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK "org.freedesktop.NetworkManager.enable-disable-network"
-#define NM_AUTH_PERMISSION_SLEEP_WAKE "org.freedesktop.NetworkManager.sleep-wake"
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI "org.freedesktop.NetworkManager.enable-disable-wifi"
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN "org.freedesktop.NetworkManager.enable-disable-wwan"
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX "org.freedesktop.NetworkManager.enable-disable-wimax"
-#define NM_AUTH_PERMISSION_USE_USER_CONNECTIONS "org.freedesktop.NetworkManager.use-user-connections"
-#define NM_AUTH_PERMISSION_NETWORK_CONTROL "org.freedesktop.NetworkManager.network-control"
+#define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK "org.freedesktop.NetworkManager.enable-disable-network"
+#define NM_AUTH_PERMISSION_SLEEP_WAKE "org.freedesktop.NetworkManager.sleep-wake"
+#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI "org.freedesktop.NetworkManager.enable-disable-wifi"
+#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN "org.freedesktop.NetworkManager.enable-disable-wwan"
++#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX "org.freedesktop.NetworkManager.enable-disable-wimax"
+#define NM_AUTH_PERMISSION_NETWORK_CONTROL "org.freedesktop.NetworkManager.network-control"
+#define NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED "org.freedesktop.NetworkManager.wifi.share.protected"
+#define NM_AUTH_PERMISSION_WIFI_SHARE_OPEN "org.freedesktop.NetworkManager.wifi.share.open"
+#define NM_AUTH_PERMISSION_SETTINGS_CONNECTION_MODIFY "org.freedesktop.NetworkManager.settings.modify"
+#define NM_AUTH_PERMISSION_SETTINGS_HOSTNAME_MODIFY "org.freedesktop.NetworkManager.settings.hostname.modify"
typedef struct NMAuthChain NMAuthChain;
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_SLEEP_WAKE);
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI);
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN);
- get_perm_add_result (chain, results, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS);
+ get_perm_add_result (chain, results, NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX);
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_NETWORK_CONTROL);
+ get_perm_add_result (chain, results, NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED);
+ get_perm_add_result (chain, results, NM_AUTH_PERMISSION_WIFI_SHARE_OPEN);
+ get_perm_add_result (chain, results, NM_AUTH_PERMISSION_SETTINGS_CONNECTION_MODIFY);
+ get_perm_add_result (chain, results, NM_AUTH_PERMISSION_SETTINGS_HOSTNAME_MODIFY);
dbus_g_method_return (context, results);
g_hash_table_destroy (results);
}
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_SLEEP_WAKE, FALSE);
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI, FALSE);
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN, FALSE);
- nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS, FALSE);
+ nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX, FALSE);
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, FALSE);
+ nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED, FALSE);
+ nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_WIFI_SHARE_OPEN, FALSE);
+ nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_SETTINGS_CONNECTION_MODIFY, FALSE);
+ nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_SETTINGS_HOSTNAME_MODIFY, FALSE);
}
/* Legacy 0.6 compatibility interface */
gboolean initial_net_enabled,
gboolean initial_wifi_enabled,
gboolean initial_wwan_enabled,
- gboolean initial_wimax_enabled,
++ gboolean initial_wimax_enabled,
GError **error)
{
static NMManager *singleton = NULL;
priv->radio_states[RFKILL_TYPE_WLAN].user_enabled = initial_wifi_enabled;
priv->radio_states[RFKILL_TYPE_WWAN].user_enabled = initial_wwan_enabled;
+ priv->radio_states[RFKILL_TYPE_WIMAX].user_enabled = initial_wimax_enabled;
- g_signal_connect (priv->sys_settings, "notify::" NM_SYSCONFIG_SETTINGS_UNMANAGED_SPECS,
+ g_signal_connect (priv->settings, "notify::" NM_SETTINGS_UNMANAGED_SPECS,
G_CALLBACK (system_unmanaged_devices_changed_cb), singleton);
- g_signal_connect (priv->sys_settings, "notify::" NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME,
+ g_signal_connect (priv->settings, "notify::" NM_SETTINGS_HOSTNAME,
G_CALLBACK (system_hostname_changed_cb), singleton);
- g_signal_connect (priv->sys_settings, "new-connection",
- G_CALLBACK (system_new_connection_cb), singleton);
-
- dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (priv->dbus_mgr),
- NM_DBUS_PATH,
- G_OBJECT (singleton));
+ g_signal_connect (priv->settings, NM_SETTINGS_CONNECTION_ADDED,
+ G_CALLBACK (connections_changed), singleton);
+ g_signal_connect (priv->settings, NM_SETTINGS_CONNECTION_UPDATED,
+ G_CALLBACK (connections_changed), singleton);
+ g_signal_connect (priv->settings, NM_SETTINGS_CONNECTION_REMOVED,
+ G_CALLBACK (connections_changed), singleton);
+ g_signal_connect (priv->settings, NM_SETTINGS_CONNECTION_VISIBILITY_CHANGED,
+ G_CALLBACK (connections_changed), singleton);
- g_signal_connect (priv->dbus_mgr,
- "name-owner-changed",
- G_CALLBACK (nm_manager_name_owner_changed),
- singleton);
+ dbus_g_connection_register_g_object (bus, NM_DBUS_PATH, G_OBJECT (singleton));
priv->udev_mgr = nm_udev_manager_new ();
g_signal_connect (priv->udev_mgr,
device_added (NMManager *manager, NMDevice *device, gpointer user_data)
{
NMPolicy *policy = (NMPolicy *) user_data;
- gulong id;
-
- id = g_signal_connect (device, "state-changed",
- G_CALLBACK (device_state_changed),
- policy);
- policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device);
- id = g_signal_connect (device, "notify::" NM_DEVICE_INTERFACE_IP4_CONFIG,
- G_CALLBACK (device_ip_config_changed),
- policy);
- policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device);
-
- id = g_signal_connect (device, "notify::" NM_DEVICE_INTERFACE_IP6_CONFIG,
- G_CALLBACK (device_ip_config_changed),
- policy);
- policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device);
+ _connect_device_signal (policy, device, "state-changed", device_state_changed);
+ _connect_device_signal (policy, device, "notify::" NM_DEVICE_INTERFACE_IP4_CONFIG, device_ip_config_changed);
+ _connect_device_signal (policy, device, "notify::" NM_DEVICE_INTERFACE_IP6_CONFIG, device_ip_config_changed);
if (NM_IS_DEVICE_WIFI (device)) {
- id = g_signal_connect (device, "access-point-added",
- G_CALLBACK (wireless_networks_changed),
- policy);
- policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device);
-
- id = g_signal_connect (device, "access-point-removed",
- G_CALLBACK (wireless_networks_changed),
- policy);
- policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device);
+ _connect_device_signal (policy, device, "access-point-added", wireless_networks_changed);
+ _connect_device_signal (policy, device, "access-point-removed", wireless_networks_changed);
+ #if WITH_WIMAX
+ } else if (NM_IS_DEVICE_WIMAX (device)) {
- id = g_signal_connect (device, "nsp-added",
- G_CALLBACK (nsps_changed),
- policy);
- policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device);
-
- id = g_signal_connect (device, "nsp-removed",
- G_CALLBACK (nsps_changed),
- policy);
- policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device);
++ _connect_device_signal (policy, device, "nsp-added", nsps_changed);
++ _connect_device_signal (policy, device, "nsp-removed", nsps_changed);
+ #endif
}
}
g_signal_handler_disconnect (policy->vpn_manager, policy->vpn_deactivated_id);
g_object_unref (policy->vpn_manager);
- for (iter = policy->signal_ids; iter; iter = g_slist_next (iter))
- g_signal_handler_disconnect (policy->manager, (gulong) iter->data);
- g_slist_free (policy->signal_ids);
+ for (iter = policy->manager_ids; iter; iter = g_slist_next (iter))
+ g_signal_handler_disconnect (policy->manager, GPOINTER_TO_UINT (iter->data));
+ g_slist_free (policy->manager_ids);
+
+ for (iter = policy->settings_ids; iter; iter = g_slist_next (iter))
+ g_signal_handler_disconnect (policy->settings, GPOINTER_TO_UINT (iter->data));
+ g_slist_free (policy->settings_ids);
- for (iter = policy->dev_signal_ids; iter; iter = g_slist_next (iter)) {
- DeviceSignalID *data = (DeviceSignalID *) iter->data;
+ for (iter = policy->dev_ids; iter; iter = g_slist_next (iter)) {
+ DeviceSignalId *data = iter->data;
g_signal_handler_disconnect (data->device, data->id);
- g_free (data);
+ g_slice_free (DeviceSignalId, data);
}
- g_slist_free (policy->dev_signal_ids);
+ g_slist_free (policy->dev_ids);
- /* Rewrite /etc/hosts on exit to ensure we don't leave stale IP addresses
- * lying around. FIXME: this will take out a valid IP address of an
- * ethernet device we're leaving active (ie, a connection we can "assume"
- * when NM starts again).
- */
- policy->default_device4 = NULL;
- policy->default_device6 = NULL;
- update_system_hostname (policy, NULL, NULL);
-
g_free (policy->orig_hostname);
g_free (policy->cur_hostname);
#include "wireless-helper.h"
#include <string.h>
+ #include <stdlib.h>
#include "nm-wifi-ap.h"
+#include "nm-wifi-ap-utils.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-logging.h"
}
static NMIfcfgConnection *
-read_one_connection (SCPluginIfcfg *plugin, const char *filename)
+_internal_new_connection (SCPluginIfcfg *self,
+ const char *path,
+ NMConnection *source,
+ GError **error)
{
- SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
+ SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self);
NMIfcfgConnection *connection;
- GError *error = NULL;
+ NMSettingConnection *s_con;
+ const char *cid;
+ GError *local = NULL;
gboolean ignore_error = FALSE;
- PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "parsing %s ... ", filename);
-
- connection = nm_ifcfg_connection_new (filename, &error, &ignore_error);
- if (connection) {
- NMSettingConnection *s_con;
- const char *cid;
-
- s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION);
- g_assert (s_con);
-
- cid = nm_setting_connection_get_id (s_con);
- g_assert (cid);
-
- g_hash_table_insert (priv->connections,
- (gpointer) nm_ifcfg_connection_get_filename (connection),
- g_object_ref (connection));
- PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " read connection '%s'", cid);
-
- if (nm_ifcfg_connection_get_unmanaged_spec (connection)) {
- PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "Ignoring connection '%s' and its "
- "device due to NM_CONTROLLED/BRIDGE/VLAN.", cid);
- } else {
- /* Wait for the connection to become unmanaged once it knows the
- * UDI of it's device, if/when the device gets plugged in.
- */
- g_signal_connect (G_OBJECT (connection), "notify::unmanaged",
- G_CALLBACK (connection_unmanaged_changed), plugin);
- }
+ if (!source) {
+ PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "parsing %s ... ", path);
+ }
- /* watch changes of ifcfg hardlinks */
- g_signal_connect (G_OBJECT (connection), "ifcfg-changed",
- G_CALLBACK (connection_ifcfg_changed), plugin);
- } else {
+ connection = nm_ifcfg_connection_new (path, source, &local, &ignore_error);
+ if (!connection) {
if (!ignore_error) {
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " error: %s",
- (error && error->message) ? error->message : "(unknown)");
+ (local && local->message) ? local->message : "(unknown)");
}
- g_clear_error (&error);
+ g_propagate_error (error, local);
+ return NULL;
}
- g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
+ s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION);
+ g_assert (s_con);
+ cid = nm_setting_connection_get_id (s_con);
+ g_assert (cid);
+
+ g_hash_table_insert (priv->connections,
+ (gpointer) nm_ifcfg_connection_get_path (connection),
+ connection);
+ PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " read connection '%s'", cid);
+
+ if (nm_ifcfg_connection_get_unmanaged_spec (connection)) {
+ PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "Ignoring connection '%s' and its "
+ "device due to NM_CONTROLLED/BRIDGE/VLAN.", cid);
+ } else {
+ /* Wait for the connection to become unmanaged once it knows the
+ * hardware IDs of its device, if/when the device gets plugged in.
+ */
+ g_signal_connect (G_OBJECT (connection), "notify::" NM_IFCFG_CONNECTION_UNMANAGED,
+ G_CALLBACK (connection_unmanaged_changed), self);
+ }
+
+ /* watch changes of ifcfg hardlinks */
+ g_signal_connect (G_OBJECT (connection), "ifcfg-changed",
+ G_CALLBACK (connection_ifcfg_changed), self);
+
return connection;
}
gboolean ignore_error = FALSE;
const char *new_unmanaged = NULL, *old_unmanaged = NULL;
- g_return_if_fail (plugin != NULL);
+ g_return_if_fail (self != NULL);
g_return_if_fail (path != NULL);
- g_return_if_fail (connection != NULL);
- g_return_if_fail (do_remove != NULL);
- g_return_if_fail (do_new != NULL);
- new = (NMIfcfgConnection *) nm_ifcfg_connection_new (path, &error, &ignore_error);
+ if (!existing) {
+ /* Completely new connection */
+ new = _internal_new_connection (self, path, NULL, NULL);
- if (new && !nm_ifcfg_connection_get_unmanaged_spec (new)) {
- /* Only managed connections are announced to the settings service */
- g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, new);
++ if (new) {
++ if (nm_ifcfg_connection_get_unmanaged_spec (new)) {
++ g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
++ } else {
++ /* Only managed connections are announced to the settings service */
++ g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, new);
++ }
+ }
+ return;
+ }
+
+ /* Existing connection that got changed */
+ PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "updating %s", path);
+
+ new = (NMIfcfgConnection *) nm_ifcfg_connection_new (path, NULL, &error, &ignore_error);
if (!new) {
/* errors reading connection; remove it */
if (!ignore_error) {
return error_quark;
}
+ static char *
+ find_default_gateway_str (char *str)
+ {
+ char *tmp;
+
+ if ((tmp = strstr (str, "default via ")) != NULL) {
+ return tmp + strlen ("default via ");
+ } else if ((tmp = strstr (str, "default gw ")) != NULL) {
+ return tmp + strlen ("default gw ");
+ }
+ return NULL;
+ }
+
+ static char *
+ find_gateway_str (char *str)
+ {
+ char *tmp;
+
+ if ((tmp = strstr (str, "via ")) != NULL) {
+ return tmp + strlen ("via ");
+ } else if ((tmp = strstr (str, "gw ")) != NULL) {
+ return tmp + strlen ("gw ");
+ }
+ return NULL;
+ }
+
gboolean
-reload_parsers ()
+reload_parsers (void)
{
ifnet_destroy ();
wpa_parser_destroy ();
}
gboolean
-has_default_route (gchar * conn_name, gboolean (*check_fn) (gchar *))
+has_default_route (const char *conn_name, gboolean (*check_fn) (const char *))
{
- gchar *routes = NULL, *tmp, *end;
+ char *routes = NULL, *end, *tmp;
+ gboolean success = FALSE;
g_return_val_if_fail (conn_name != NULL, FALSE);
- tmp = ifnet_get_data (conn_name, "routes");
- if (!tmp)
+
+ routes = g_strdup (ifnet_get_data (conn_name, "routes"));
+ if (!routes)
return FALSE;
-
- tmp = strstr (routes, "default via ");
- routes = g_strdup (tmp);
+ tmp = find_default_gateway_str (routes);
- if (!tmp) {
- goto error;
- }
- g_strstrip (tmp);
- if ((end = strstr (tmp, "\"")) != NULL)
- *end = '\0';
- if (check_fn (tmp)) {
- g_free (routes);
- return TRUE;
+ if (tmp) {
- tmp += strlen ("default via ");
+ g_strstrip (tmp);
+ if ((end = strstr (tmp, "\"")) != NULL)
+ *end = '\0';
+ if (check_fn (tmp))
+ success = TRUE;
}
- error:
+
g_free (routes);
- return FALSE;
+ return success;
}
static ip_block *
ASSERT (connection != NULL, "get connection",
"get connection failed: %s",
error == NULL ? "None" : (*error)->message);
- ASSERT (ifnet_update_parsers_by_connection
- (connection, "eth0", NULL, "net.generate",
- "wpa_supplicant.conf.generate", error),
- "update connection", "update connection failed %s", "eth0");
+
+ success = ifnet_update_parsers_by_connection (connection, "eth0",
+ "net.generate",
+ "wpa_supplicant.conf.generate",
+ NULL,
+ error);
+ ASSERT (success, "update connection", "update connection failed %s", "eth0");
+ g_object_unref (connection);
- connection =
- ifnet_update_connection_from_config_block ("0xab3ace", error);
- ASSERT (connection != NULL, "get connection",
- "get connection failed: %s",
+
+ connection = ifnet_update_connection_from_config_block ("0xab3ace", error);
- ASSERT (connection != NULL, "get connection",
- "get connection failed: %s",
++ ASSERT (connection != NULL, "get connection", "get connection failed: %s",
error == NULL ? "None" : (*error)->message);
- ASSERT (ifnet_update_parsers_by_connection
- (connection, "0xab3ace", NULL, "net.generate",
- "wpa_supplicant.conf.generate", error),
- "update connection", "update connection failed %s", "0xab3ace");
+
+ success = ifnet_update_parsers_by_connection (connection, "0xab3ace",
+ "net.generate",
+ "wpa_supplicant.conf.generate",
+ NULL,
+ error);
- ASSERT (success, "update connection",
- "update connection failed %s", "0xab3ace");
++ ASSERT (success, "update connection", "update connection failed %s", "0xab3ace");
+ g_object_unref (connection);
}
static void
/* Remove any connection for this block that was previously found */
exported = g_hash_table_lookup (priv->iface_connections, block->name);
if (exported) {
- nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (exported),
- ignore_cb,
- NULL);
+ PLUGIN_PRINT("SCPlugin-Ifupdown", "deleting %s from iface_connections", block->name);
+ nm_sysconfig_connection_delete (NM_SYSCONFIG_CONNECTION (exported),
+ ignore_cb,
+ NULL);
g_hash_table_remove (priv->iface_connections, block->name);
}