2008-11-03 04:13:42 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
/* NetworkManager -- Network link manager
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2009-05-20 12:02:18 -04:00
|
|
|
* Copyright (C) 2007 - 2009 Novell, Inc.
|
2012-02-05 23:18:32 -06:00
|
|
|
* Copyright (C) 2007 - 2012 Red Hat, Inc.
|
2008-11-03 04:13:42 +00:00
|
|
|
*/
|
2007-08-15 07:52:25 +00:00
|
|
|
|
2010-08-13 13:18:58 -05:00
|
|
|
#include <config.h>
|
|
|
|
|
|
2013-05-27 20:35:33 +02:00
|
|
|
#include <stdlib.h>
|
2007-10-09 08:57:35 +00:00
|
|
|
#include <netinet/ether.h>
|
2011-04-22 14:56:31 -05:00
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <errno.h>
|
2007-02-08 15:34:26 +00:00
|
|
|
#include <string.h>
|
2012-02-22 16:52:41 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/types.h>
|
2012-02-05 23:18:32 -06:00
|
|
|
#include <sys/stat.h>
|
2008-11-21 18:11:15 +00:00
|
|
|
#include <dbus/dbus-glib-lowlevel.h>
|
|
|
|
|
#include <dbus/dbus-glib.h>
|
2011-05-18 22:20:24 -05:00
|
|
|
#include <gio/gio.h>
|
2011-01-13 13:30:30 -06:00
|
|
|
#include <glib/gi18n.h>
|
2007-02-08 15:34:26 +00:00
|
|
|
|
2008-12-31 18:57:36 -05:00
|
|
|
#include "nm-glib-compat.h"
|
2007-02-08 15:34:26 +00:00
|
|
|
#include "nm-manager.h"
|
2010-04-06 16:20:11 -07:00
|
|
|
#include "nm-logging.h"
|
2007-02-08 15:34:26 +00:00
|
|
|
#include "nm-dbus-manager.h"
|
2008-03-26 13:43:01 +00:00
|
|
|
#include "nm-vpn-manager.h"
|
2009-01-19 11:01:00 +02:00
|
|
|
#include "nm-modem-manager.h"
|
2009-05-14 13:59:03 -04:00
|
|
|
#include "nm-device-bt.h"
|
2011-11-17 22:39:34 -06:00
|
|
|
#include "nm-device.h"
|
2009-02-16 18:47:03 -05:00
|
|
|
#include "nm-device-ethernet.h"
|
2008-06-10 16:32:39 +00:00
|
|
|
#include "nm-device-wifi.h"
|
2009-08-05 16:34:02 -04:00
|
|
|
#include "nm-device-olpc-mesh.h"
|
2011-02-25 10:16:17 -06:00
|
|
|
#include "nm-device-modem.h"
|
2012-02-05 23:18:32 -06:00
|
|
|
#include "nm-device-infiniband.h"
|
2012-02-15 17:31:37 -06:00
|
|
|
#include "nm-device-bond.h"
|
2012-10-29 19:02:45 -05:00
|
|
|
#include "nm-device-bridge.h"
|
2012-02-22 23:59:50 -06:00
|
|
|
#include "nm-device-vlan.h"
|
2011-05-17 21:03:18 +03:00
|
|
|
#include "nm-device-adsl.h"
|
2013-04-17 10:41:15 -04:00
|
|
|
#include "nm-device-generic.h"
|
2013-05-03 13:55:51 -04:00
|
|
|
#include "nm-device-veth.h"
|
2013-04-25 15:46:39 -04:00
|
|
|
#include "nm-device-tun.h"
|
2013-05-06 09:16:17 -04:00
|
|
|
#include "nm-device-macvlan.h"
|
2013-05-21 12:49:24 -03:00
|
|
|
#include "nm-device-gre.h"
|
2010-03-02 15:06:14 -08:00
|
|
|
#include "nm-system.h"
|
2009-05-14 13:59:03 -04:00
|
|
|
#include "nm-setting-bluetooth.h"
|
2007-11-07 16:06:43 +00:00
|
|
|
#include "nm-setting-connection.h"
|
|
|
|
|
#include "nm-setting-wireless.h"
|
2008-03-26 13:43:01 +00:00
|
|
|
#include "nm-setting-vpn.h"
|
2008-03-29 21:35:41 +00:00
|
|
|
#include "nm-dbus-glib-types.h"
|
2013-01-21 15:12:24 +01:00
|
|
|
#include "nm-platform.h"
|
2013-05-24 17:30:31 -03:00
|
|
|
#include "nm-atm-manager.h"
|
2013-05-09 10:24:08 -04:00
|
|
|
#include "nm-rfkill-manager.h"
|
2009-03-16 14:31:28 +02:00
|
|
|
#include "nm-hostname-provider.h"
|
2009-05-13 21:32:56 -04:00
|
|
|
#include "nm-bluez-manager.h"
|
|
|
|
|
#include "nm-bluez-common.h"
|
2010-10-27 20:05:23 -05:00
|
|
|
#include "nm-settings.h"
|
2011-01-26 11:38:12 -06:00
|
|
|
#include "nm-settings-connection.h"
|
2010-05-28 18:23:00 -07:00
|
|
|
#include "nm-manager-auth.h"
|
2011-01-13 13:30:30 -06:00
|
|
|
#include "NetworkManagerUtils.h"
|
2011-05-27 17:32:40 +02:00
|
|
|
#include "nm-utils.h"
|
2012-02-05 23:18:32 -06:00
|
|
|
#include "nm-device-factory.h"
|
2012-02-08 12:56:52 -05:00
|
|
|
#include "nm-enum-types.h"
|
2012-10-09 00:36:35 -04:00
|
|
|
#include "nm-sleep-monitor.h"
|
2013-04-25 15:46:39 -04:00
|
|
|
#include "nm-platform.h"
|
2011-12-05 15:11:13 -06:00
|
|
|
|
|
|
|
|
#if WITH_CONCHECK
|
2011-10-21 21:21:30 +02:00
|
|
|
#include "nm-connectivity.h"
|
2011-12-05 15:11:13 -06:00
|
|
|
#endif
|
2011-10-21 21:21:30 +02:00
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
|
2008-07-09 14:05:49 +00:00
|
|
|
#define NM_AUTOIP_DBUS_SERVICE "org.freedesktop.nm_avahi_autoipd"
|
|
|
|
|
#define NM_AUTOIP_DBUS_IFACE "org.freedesktop.nm_avahi_autoipd"
|
|
|
|
|
|
2011-04-22 12:27:55 -05:00
|
|
|
static gboolean impl_manager_get_devices (NMManager *manager,
|
|
|
|
|
GPtrArray **devices,
|
|
|
|
|
GError **err);
|
|
|
|
|
|
|
|
|
|
static gboolean impl_manager_get_device_by_ip_iface (NMManager *self,
|
|
|
|
|
const char *iface,
|
|
|
|
|
char **out_object_path,
|
|
|
|
|
GError **error);
|
|
|
|
|
|
2008-03-19 20:58:21 +00:00
|
|
|
static void impl_manager_activate_connection (NMManager *manager,
|
2010-06-03 23:20:11 -07:00
|
|
|
const char *connection_path,
|
|
|
|
|
const char *device_path,
|
|
|
|
|
const char *specific_object_path,
|
|
|
|
|
DBusGMethodInvocation *context);
|
2007-10-01 15:38:39 +00:00
|
|
|
|
2011-01-10 23:39:12 -06:00
|
|
|
static void impl_manager_add_and_activate_connection (NMManager *manager,
|
|
|
|
|
GHashTable *settings,
|
|
|
|
|
const char *device_path,
|
|
|
|
|
const char *specific_object_path,
|
|
|
|
|
DBusGMethodInvocation *context);
|
|
|
|
|
|
2010-06-04 00:42:10 -07:00
|
|
|
static void impl_manager_deactivate_connection (NMManager *manager,
|
|
|
|
|
const char *connection_path,
|
|
|
|
|
DBusGMethodInvocation *context);
|
2007-10-03 14:48:25 +00:00
|
|
|
|
2010-05-29 23:11:45 -07:00
|
|
|
static void impl_manager_sleep (NMManager *manager,
|
|
|
|
|
gboolean do_sleep,
|
|
|
|
|
DBusGMethodInvocation *context);
|
2007-02-12 09:23:43 +00:00
|
|
|
|
2010-05-29 23:00:46 -07:00
|
|
|
static void impl_manager_enable (NMManager *manager,
|
|
|
|
|
gboolean enable,
|
|
|
|
|
DBusGMethodInvocation *context);
|
2010-05-22 08:55:30 -07:00
|
|
|
|
2010-05-28 18:23:00 -07:00
|
|
|
static void impl_manager_get_permissions (NMManager *manager,
|
|
|
|
|
DBusGMethodInvocation *context);
|
|
|
|
|
|
2011-03-08 12:57:35 -06:00
|
|
|
static gboolean impl_manager_get_state (NMManager *manager,
|
|
|
|
|
guint32 *state,
|
|
|
|
|
GError **error);
|
|
|
|
|
|
2010-04-08 08:56:17 -07:00
|
|
|
static gboolean impl_manager_set_logging (NMManager *manager,
|
|
|
|
|
const char *level,
|
|
|
|
|
const char *domains,
|
|
|
|
|
GError **error);
|
|
|
|
|
|
2012-12-12 14:21:40 +01:00
|
|
|
static void impl_manager_get_logging (NMManager *manager,
|
|
|
|
|
char **level,
|
|
|
|
|
char **domains);
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
#include "nm-manager-glue.h"
|
|
|
|
|
|
2009-05-13 21:32:56 -04:00
|
|
|
static void bluez_manager_bdaddr_added_cb (NMBluezManager *bluez_mgr,
|
2012-05-11 11:17:18 -05:00
|
|
|
const char *bdaddr,
|
|
|
|
|
const char *name,
|
|
|
|
|
const char *object_path,
|
|
|
|
|
guint32 uuids,
|
|
|
|
|
NMManager *manager);
|
2009-05-13 21:32:56 -04:00
|
|
|
|
|
|
|
|
static void bluez_manager_bdaddr_removed_cb (NMBluezManager *bluez_mgr,
|
2012-05-11 11:17:18 -05:00
|
|
|
const char *bdaddr,
|
|
|
|
|
const char *object_path,
|
|
|
|
|
gpointer user_data);
|
2009-05-20 12:02:18 -04:00
|
|
|
|
2009-02-16 18:47:03 -05:00
|
|
|
static void add_device (NMManager *self, NMDevice *device);
|
2009-01-19 11:01:00 +02:00
|
|
|
|
2009-03-16 14:31:28 +02:00
|
|
|
static void hostname_provider_init (NMHostnameProvider *provider_class);
|
|
|
|
|
|
2012-02-23 10:00:08 -06:00
|
|
|
static NMActiveConnection *internal_activate_device (NMManager *manager,
|
|
|
|
|
NMDevice *device,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
const char *specific_object,
|
|
|
|
|
gboolean user_requested,
|
|
|
|
|
gulong sender_uid,
|
2012-08-28 13:38:23 +02:00
|
|
|
const char *dbus_sender,
|
2012-02-23 10:00:08 -06:00
|
|
|
gboolean assumed,
|
|
|
|
|
NMActiveConnection *master,
|
|
|
|
|
GError **error);
|
2009-08-05 18:03:09 -04:00
|
|
|
|
2011-04-22 12:27:55 -05:00
|
|
|
static NMDevice *find_device_by_ip_iface (NMManager *self, const gchar *iface);
|
2009-09-04 16:55:48 +02:00
|
|
|
|
2009-10-04 23:59:20 -07:00
|
|
|
static GSList * remove_one_device (NMManager *manager,
|
|
|
|
|
GSList *list,
|
|
|
|
|
NMDevice *device,
|
2010-08-11 17:26:33 -05:00
|
|
|
gboolean quitting);
|
2009-09-04 16:55:48 +02:00
|
|
|
|
2013-02-06 12:59:50 -06:00
|
|
|
static void rfkill_change_wifi (const char *desc, gboolean enabled);
|
|
|
|
|
|
2008-12-31 18:57:36 -05:00
|
|
|
#define SSD_POKE_INTERVAL 120
|
2009-02-16 18:47:03 -05:00
|
|
|
#define ORIGDEV_TAG "originating-device"
|
2007-10-01 15:38:39 +00:00
|
|
|
|
2010-06-03 23:20:11 -07:00
|
|
|
typedef struct PendingActivation PendingActivation;
|
|
|
|
|
typedef void (*PendingActivationFunc) (PendingActivation *pending,
|
|
|
|
|
GError *error);
|
|
|
|
|
|
|
|
|
|
struct PendingActivation {
|
2010-06-01 00:36:46 -07:00
|
|
|
NMManager *manager;
|
|
|
|
|
|
2010-06-03 23:20:11 -07:00
|
|
|
DBusGMethodInvocation *context;
|
|
|
|
|
PendingActivationFunc callback;
|
|
|
|
|
NMAuthChain *chain;
|
2011-07-01 14:59:56 -05:00
|
|
|
const char *wifi_shared_permission;
|
2010-06-03 23:20:11 -07:00
|
|
|
|
2007-10-01 15:38:39 +00:00
|
|
|
char *connection_path;
|
2011-01-10 23:39:12 -06:00
|
|
|
NMConnection *connection;
|
2007-10-01 15:38:39 +00:00
|
|
|
char *specific_object_path;
|
2008-03-26 13:43:01 +00:00
|
|
|
char *device_path;
|
2010-06-03 23:20:11 -07:00
|
|
|
};
|
2007-10-01 15:38:39 +00:00
|
|
|
|
2009-12-23 00:03:45 -08:00
|
|
|
typedef struct {
|
2010-09-01 17:08:10 -05:00
|
|
|
gboolean user_enabled;
|
2011-04-13 21:58:25 -05:00
|
|
|
gboolean daemon_enabled;
|
2010-09-01 17:08:10 -05:00
|
|
|
gboolean sw_enabled;
|
2009-12-23 00:03:45 -08:00
|
|
|
gboolean hw_enabled;
|
2010-03-25 11:36:19 -07:00
|
|
|
RfKillType rtype;
|
2009-12-23 00:03:45 -08:00
|
|
|
const char *desc;
|
|
|
|
|
const char *key;
|
|
|
|
|
const char *prop;
|
|
|
|
|
const char *hw_prop;
|
|
|
|
|
RfKillState (*other_enabled_func) (NMManager *);
|
2011-04-13 21:58:25 -05:00
|
|
|
RfKillState (*daemon_enabled_func) (NMManager *);
|
2009-12-23 00:03:45 -08:00
|
|
|
} RadioState;
|
|
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
typedef struct {
|
2009-11-02 17:29:53 -08:00
|
|
|
char *state_file;
|
2009-07-09 11:06:31 -04:00
|
|
|
|
2012-08-22 17:11:31 -05:00
|
|
|
GSList *active_connections;
|
|
|
|
|
guint ac_cleanup_id;
|
|
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
GSList *devices;
|
2007-09-25 16:47:53 +00:00
|
|
|
NMState state;
|
2011-12-05 15:11:13 -06:00
|
|
|
#if WITH_CONCHECK
|
2011-10-21 21:21:30 +02:00
|
|
|
NMConnectivity *connectivity;
|
2011-12-05 15:11:13 -06:00
|
|
|
#endif
|
2007-09-09 22:18:42 +00:00
|
|
|
|
2008-01-02 13:42:52 +00:00
|
|
|
NMDBusManager *dbus_mgr;
|
2013-03-20 08:51:08 -05:00
|
|
|
guint dbus_connection_changed_id;
|
2013-05-24 17:30:31 -03:00
|
|
|
NMAtmManager *atm_mgr;
|
2013-05-09 10:24:08 -04:00
|
|
|
NMRfkillManager *rfkill_mgr;
|
2009-05-13 21:32:56 -04:00
|
|
|
NMBluezManager *bluez_mgr;
|
2008-01-02 13:42:52 +00:00
|
|
|
|
2012-02-05 23:18:32 -06:00
|
|
|
/* List of NMDeviceFactoryFunc pointers sorted in priority order */
|
|
|
|
|
GSList *factories;
|
|
|
|
|
|
2010-10-27 20:05:23 -05:00
|
|
|
NMSettings *settings;
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
char *hostname;
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2009-12-23 00:03:45 -08:00
|
|
|
RadioState radio_states[RFKILL_TYPE_MAX];
|
2007-02-08 15:34:26 +00:00
|
|
|
gboolean sleeping;
|
2010-05-22 08:55:30 -07:00
|
|
|
gboolean net_enabled;
|
2008-02-06 16:50:43 +00:00
|
|
|
|
2008-03-26 13:43:01 +00:00
|
|
|
NMVPNManager *vpn_manager;
|
|
|
|
|
|
2009-01-19 11:01:00 +02:00
|
|
|
NMModemManager *modem_manager;
|
|
|
|
|
guint modem_added_id;
|
|
|
|
|
guint modem_removed_id;
|
|
|
|
|
|
2008-07-09 14:05:49 +00:00
|
|
|
DBusGProxy *aipd_proxy;
|
2012-10-09 00:36:35 -04:00
|
|
|
NMSleepMonitor *sleep_monitor;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
2010-05-28 18:23:00 -07:00
|
|
|
GSList *auth_chains;
|
|
|
|
|
|
2010-07-01 10:32:11 -07:00
|
|
|
/* Firmware dir monitor */
|
|
|
|
|
GFileMonitor *fw_monitor;
|
|
|
|
|
guint fw_monitor_id;
|
|
|
|
|
guint fw_changed_id;
|
|
|
|
|
|
2010-10-19 11:10:17 +02:00
|
|
|
guint timestamp_update_id;
|
|
|
|
|
|
core: only manage those bridges created by NetworkManager (rh #905035)
Until we handle bridges non-destructively, only manage bridges
created by NM. When quitting write out a file listing all
bridges created by NM and a timestamp, and when starting read
that file and if the timestamp is within 30 minutes, manage
any bridge that was listed in that file. This scheme, while
not foolproof (eg, if NM crashes), should ensure that NM can
recognize bridges it created if it's restarted. The file
is stored in /run or /var/run, which is cleaned each restart,
ensuring that the state does not persist across reboots.
If an automatic or user-initiated activation request for
a bridge NM does not manage is received, that request is
denied. Only if the bridge interface does not yet exist, or
was present in the managed bridges file, will an
NMDeviceBridge be created and activation be possible.
2013-02-01 18:03:11 -06:00
|
|
|
GHashTable *nm_bridges;
|
|
|
|
|
|
2008-03-26 13:43:01 +00:00
|
|
|
gboolean disposed;
|
2007-02-08 15:34:26 +00:00
|
|
|
} NMManagerPrivate;
|
|
|
|
|
|
|
|
|
|
#define NM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MANAGER, NMManagerPrivate))
|
|
|
|
|
|
2009-03-16 14:31:28 +02:00
|
|
|
G_DEFINE_TYPE_EXTENDED (NMManager, nm_manager, G_TYPE_OBJECT, 0,
|
|
|
|
|
G_IMPLEMENT_INTERFACE (NM_TYPE_HOSTNAME_PROVIDER,
|
|
|
|
|
hostname_provider_init))
|
2007-02-08 15:34:26 +00:00
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
DEVICE_ADDED,
|
|
|
|
|
DEVICE_REMOVED,
|
2008-03-07 23:17:48 +00:00
|
|
|
STATE_CHANGED,
|
2010-05-28 18:23:00 -07:00
|
|
|
CHECK_PERMISSIONS,
|
2010-06-04 13:05:27 -07:00
|
|
|
USER_PERMISSIONS_CHANGED,
|
2012-08-22 18:33:17 -05:00
|
|
|
ACTIVE_CONNECTION_ADDED,
|
|
|
|
|
ACTIVE_CONNECTION_REMOVED,
|
2007-02-08 15:34:26 +00:00
|
|
|
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
2010-09-27 10:34:56 +02:00
|
|
|
PROP_VERSION,
|
2007-02-08 15:34:26 +00:00
|
|
|
PROP_STATE,
|
2010-05-22 08:55:30 -07:00
|
|
|
PROP_NETWORKING_ENABLED,
|
2007-02-08 15:34:26 +00:00
|
|
|
PROP_WIRELESS_ENABLED,
|
2007-10-15 14:46:37 +00:00
|
|
|
PROP_WIRELESS_HARDWARE_ENABLED,
|
2009-12-23 00:18:18 -08:00
|
|
|
PROP_WWAN_ENABLED,
|
|
|
|
|
PROP_WWAN_HARDWARE_ENABLED,
|
2009-12-29 11:27:10 +02:00
|
|
|
PROP_WIMAX_ENABLED,
|
|
|
|
|
PROP_WIMAX_HARDWARE_ENABLED,
|
2008-03-20 19:56:12 +00:00
|
|
|
PROP_ACTIVE_CONNECTIONS,
|
2007-02-08 15:34:26 +00:00
|
|
|
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
/* Not exported */
|
|
|
|
|
PROP_HOSTNAME,
|
2009-10-20 15:25:04 -07:00
|
|
|
PROP_SLEEPING,
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
LAST_PROP
|
|
|
|
|
};
|
|
|
|
|
|
2011-01-10 23:39:12 -06:00
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
2007-12-27 08:06:27 +00:00
|
|
|
#define NM_MANAGER_ERROR (nm_manager_error_quark ())
|
|
|
|
|
|
|
|
|
|
static GQuark
|
|
|
|
|
nm_manager_error_quark (void)
|
|
|
|
|
{
|
|
|
|
|
static GQuark quark = 0;
|
|
|
|
|
if (!quark)
|
|
|
|
|
quark = g_quark_from_static_string ("nm-manager-error");
|
|
|
|
|
return quark;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-10 23:39:12 -06:00
|
|
|
/************************************************************************/
|
|
|
|
|
|
2012-08-22 17:11:31 -05:00
|
|
|
static void active_connection_state_changed (NMActiveConnection *active,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
NMManager *self);
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
_active_connection_cleanup (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GSList *iter;
|
|
|
|
|
gboolean changed = FALSE;
|
|
|
|
|
|
|
|
|
|
priv->ac_cleanup_id = 0;
|
|
|
|
|
|
|
|
|
|
iter = priv->active_connections;
|
|
|
|
|
while (iter) {
|
|
|
|
|
NMActiveConnection *ac = iter->data;
|
|
|
|
|
|
|
|
|
|
iter = iter->next;
|
|
|
|
|
if (nm_active_connection_get_state (ac) == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) {
|
|
|
|
|
priv->active_connections = g_slist_remove (priv->active_connections, ac);
|
2012-08-22 18:33:17 -05:00
|
|
|
g_signal_emit (self, signals[ACTIVE_CONNECTION_REMOVED], 0, ac);
|
2012-08-22 17:11:31 -05:00
|
|
|
g_signal_handlers_disconnect_by_func (ac, active_connection_state_changed, self);
|
|
|
|
|
g_object_unref (ac);
|
|
|
|
|
changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (changed)
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_MANAGER_ACTIVE_CONNECTIONS);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
active_connection_state_changed (NMActiveConnection *active,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
NMManager *self)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
NMActiveConnectionState state;
|
|
|
|
|
|
|
|
|
|
state = nm_active_connection_get_state (active);
|
|
|
|
|
if (state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) {
|
|
|
|
|
/* Destroy active connections from an idle handler to ensure that
|
|
|
|
|
* their last property change notifications go out, which wouldn't
|
|
|
|
|
* happen if we destroyed them immediately when their state was set
|
|
|
|
|
* to DEACTIVATED.
|
|
|
|
|
*/
|
|
|
|
|
if (!priv->ac_cleanup_id)
|
|
|
|
|
priv->ac_cleanup_id = g_idle_add (_active_connection_cleanup, self);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
active_connection_add (NMManager *self, NMActiveConnection *active)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (g_slist_find (priv->active_connections, active) == FALSE);
|
|
|
|
|
|
|
|
|
|
priv->active_connections = g_slist_prepend (priv->active_connections, active);
|
|
|
|
|
g_signal_connect (active, "notify::" NM_ACTIVE_CONNECTION_STATE,
|
|
|
|
|
G_CALLBACK (active_connection_state_changed),
|
|
|
|
|
self);
|
2012-08-22 18:33:17 -05:00
|
|
|
|
|
|
|
|
g_signal_emit (self, signals[ACTIVE_CONNECTION_ADDED], 0, active);
|
2012-08-22 17:11:31 -05:00
|
|
|
g_object_notify (G_OBJECT (self), NM_MANAGER_ACTIVE_CONNECTIONS);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:21:56 -05:00
|
|
|
const GSList *
|
|
|
|
|
nm_manager_get_active_connections (NMManager *manager)
|
|
|
|
|
{
|
|
|
|
|
return NM_MANAGER_GET_PRIVATE (manager)->active_connections;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-14 15:21:29 -05:00
|
|
|
static NMActiveConnection *
|
|
|
|
|
active_connection_get_by_path (NMManager *manager, const char *path)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (manager != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (path != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
for (iter = priv->active_connections; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMActiveConnection *candidate = iter->data;
|
|
|
|
|
|
|
|
|
|
if (strcmp (path, nm_active_connection_get_path (candidate)) == 0)
|
|
|
|
|
return candidate;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:11:31 -05:00
|
|
|
/************************************************************************/
|
|
|
|
|
|
2011-01-10 23:39:12 -06:00
|
|
|
static NMDevice *
|
|
|
|
|
nm_manager_get_device_by_udi (NMManager *manager, const char *udi)
|
|
|
|
|
{
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
2011-03-15 17:04:35 -05:00
|
|
|
g_return_val_if_fail (udi != NULL, NULL);
|
|
|
|
|
|
2011-01-10 23:39:12 -06:00
|
|
|
for (iter = NM_MANAGER_GET_PRIVATE (manager)->devices; iter; iter = iter->next) {
|
|
|
|
|
if (!strcmp (nm_device_get_udi (NM_DEVICE (iter->data)), udi))
|
|
|
|
|
return NM_DEVICE (iter->data);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NMDevice *
|
|
|
|
|
nm_manager_get_device_by_path (NMManager *manager, const char *path)
|
|
|
|
|
{
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
2011-03-15 17:04:35 -05:00
|
|
|
g_return_val_if_fail (path != NULL, NULL);
|
|
|
|
|
|
2011-01-10 23:39:12 -06:00
|
|
|
for (iter = NM_MANAGER_GET_PRIVATE (manager)->devices; iter; iter = iter->next) {
|
|
|
|
|
if (!strcmp (nm_device_get_path (NM_DEVICE (iter->data)), path))
|
|
|
|
|
return NM_DEVICE (iter->data);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-18 13:48:47 +02:00
|
|
|
NMDevice *
|
|
|
|
|
nm_manager_get_device_by_master (NMManager *manager, const char *master, const char *driver)
|
|
|
|
|
{
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (master != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
for (iter = NM_MANAGER_GET_PRIVATE (manager)->devices; iter; iter = iter->next) {
|
|
|
|
|
NMDevice *device = NM_DEVICE (iter->data);
|
|
|
|
|
|
|
|
|
|
if (!strcmp (nm_device_get_iface (device), master) &&
|
|
|
|
|
(!driver || !strcmp (nm_device_get_driver (device), driver)))
|
|
|
|
|
return device;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-03 13:55:51 -04:00
|
|
|
NMDevice *
|
|
|
|
|
nm_manager_get_device_by_ifindex (NMManager *manager, int ifindex)
|
|
|
|
|
{
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
for (iter = NM_MANAGER_GET_PRIVATE (manager)->devices; iter; iter = iter->next) {
|
|
|
|
|
NMDevice *device = NM_DEVICE (iter->data);
|
|
|
|
|
|
|
|
|
|
if (nm_device_get_ifindex (device) == ifindex)
|
|
|
|
|
return device;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-22 08:55:30 -07:00
|
|
|
static gboolean
|
|
|
|
|
manager_sleeping (NMManager *self)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->sleeping || !priv->net_enabled)
|
|
|
|
|
return TRUE;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-19 11:01:00 +02:00
|
|
|
static void
|
|
|
|
|
modem_added (NMModemManager *modem_manager,
|
2009-10-04 23:35:20 -07:00
|
|
|
NMModem *modem,
|
|
|
|
|
const char *driver,
|
2009-01-19 11:01:00 +02:00
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2009-10-04 23:35:20 -07:00
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
NMDevice *replace_device, *device = NULL;
|
2012-11-07 15:40:38 +01:00
|
|
|
const char *modem_iface;
|
2010-01-28 11:21:53 -08:00
|
|
|
GSList *iter;
|
2009-09-04 16:55:48 +02:00
|
|
|
|
2012-11-07 15:40:38 +01:00
|
|
|
/* Don't rely only on the data port; use the control port if available */
|
|
|
|
|
modem_iface = nm_modem_get_data_port (modem);
|
|
|
|
|
if (!modem_iface)
|
|
|
|
|
modem_iface = nm_modem_get_control_port (modem);
|
|
|
|
|
g_return_if_fail (modem_iface);
|
2009-09-04 16:55:48 +02:00
|
|
|
|
2012-11-07 15:40:38 +01:00
|
|
|
replace_device = find_device_by_ip_iface (NM_MANAGER (user_data), modem_iface);
|
2009-09-04 16:55:48 +02:00
|
|
|
if (replace_device) {
|
2009-09-10 17:49:11 -07:00
|
|
|
priv->devices = remove_one_device (NM_MANAGER (user_data),
|
|
|
|
|
priv->devices,
|
|
|
|
|
replace_device,
|
2010-08-11 17:26:33 -05:00
|
|
|
FALSE);
|
2009-09-04 16:55:48 +02:00
|
|
|
}
|
|
|
|
|
|
2010-01-28 11:21:53 -08:00
|
|
|
/* Give Bluetooth DUN devices first chance to claim the modem */
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
2011-11-18 12:34:27 -06:00
|
|
|
if (nm_device_get_device_type (iter->data) == NM_DEVICE_TYPE_BT) {
|
2010-01-28 11:21:53 -08:00
|
|
|
if (nm_device_bt_modem_added (NM_DEVICE_BT (iter->data), modem, driver))
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If it was a Bluetooth modem and no bluetooth device claimed it, ignore
|
|
|
|
|
* it. The rfcomm port (and thus the modem) gets created automatically
|
|
|
|
|
* by the Bluetooth code during the connection process.
|
|
|
|
|
*/
|
|
|
|
|
if (driver && !strcmp (driver, "bluetooth")) {
|
2012-11-07 15:40:38 +01:00
|
|
|
nm_log_info (LOGD_MB, "ignoring modem '%s' (no associated Bluetooth device)", modem_iface);
|
2010-01-28 11:21:53 -08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-25 10:16:17 -06:00
|
|
|
/* Make the new modem device */
|
|
|
|
|
device = nm_device_modem_new (modem, driver);
|
2009-10-04 23:35:20 -07:00
|
|
|
if (device)
|
|
|
|
|
add_device (self, device);
|
2009-01-19 11:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
2009-05-20 12:02:18 -04:00
|
|
|
static void
|
|
|
|
|
nm_manager_update_state (NMManager *manager)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv;
|
|
|
|
|
NMState new_state = NM_STATE_DISCONNECTED;
|
2011-02-14 17:55:27 -06:00
|
|
|
GSList *iter;
|
2009-05-20 12:02:18 -04:00
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_MANAGER (manager));
|
|
|
|
|
|
|
|
|
|
priv = NM_MANAGER_GET_PRIVATE (manager);
|
|
|
|
|
|
2010-05-22 08:55:30 -07:00
|
|
|
if (manager_sleeping (manager))
|
2009-05-20 12:02:18 -04:00
|
|
|
new_state = NM_STATE_ASLEEP;
|
2010-05-22 08:55:30 -07:00
|
|
|
else {
|
2011-12-13 17:35:36 -06:00
|
|
|
for (iter = priv->devices; iter; iter = iter->next) {
|
|
|
|
|
NMDevice *dev = NM_DEVICE (iter->data);
|
|
|
|
|
NMDeviceState state = nm_device_get_state (dev);
|
2009-05-20 12:02:18 -04:00
|
|
|
|
2011-12-13 17:35:36 -06:00
|
|
|
if (state == NM_DEVICE_STATE_ACTIVATED) {
|
|
|
|
|
new_state = NM_STATE_CONNECTED_GLOBAL;
|
|
|
|
|
#if WITH_CONCHECK
|
|
|
|
|
/* Connectivity check might have a better idea */
|
|
|
|
|
if (nm_connectivity_get_connected (priv->connectivity) == FALSE)
|
2011-10-21 21:21:30 +02:00
|
|
|
new_state = NM_STATE_CONNECTED_SITE;
|
2011-12-13 17:35:36 -06:00
|
|
|
#endif
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-02-14 17:55:27 -06:00
|
|
|
|
2011-12-13 17:35:36 -06:00
|
|
|
if (nm_device_is_activating (dev))
|
|
|
|
|
new_state = NM_STATE_CONNECTING;
|
|
|
|
|
else if (new_state != NM_STATE_CONNECTING) {
|
|
|
|
|
if (state == NM_DEVICE_STATE_DEACTIVATING)
|
|
|
|
|
new_state = NM_STATE_DISCONNECTING;
|
2009-05-20 12:02:18 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->state != new_state) {
|
|
|
|
|
priv->state = new_state;
|
|
|
|
|
g_object_notify (G_OBJECT (manager), NM_MANAGER_STATE);
|
|
|
|
|
|
|
|
|
|
g_signal_emit (manager, signals[STATE_CHANGED], 0, priv->state);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
manager_device_state_changed (NMDevice *device,
|
|
|
|
|
NMDeviceState new_state,
|
|
|
|
|
NMDeviceState old_state,
|
|
|
|
|
NMDeviceStateReason reason,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2011-12-14 13:41:57 -06:00
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
2012-02-29 15:04:16 +01:00
|
|
|
#if WITH_CONCHECK
|
2011-12-14 13:41:57 -06:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2012-02-29 15:04:16 +01:00
|
|
|
#endif
|
2009-05-20 12:02:18 -04:00
|
|
|
|
|
|
|
|
switch (new_state) {
|
|
|
|
|
case NM_DEVICE_STATE_UNMANAGED:
|
|
|
|
|
case NM_DEVICE_STATE_UNAVAILABLE:
|
|
|
|
|
case NM_DEVICE_STATE_DISCONNECTED:
|
|
|
|
|
case NM_DEVICE_STATE_PREPARE:
|
|
|
|
|
case NM_DEVICE_STATE_FAILED:
|
2011-12-14 13:41:57 -06:00
|
|
|
g_object_notify (G_OBJECT (self), NM_MANAGER_ACTIVE_CONNECTIONS);
|
2009-05-20 12:02:18 -04:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-14 13:41:57 -06:00
|
|
|
nm_manager_update_state (self);
|
2011-10-21 21:21:30 +02:00
|
|
|
|
2011-12-05 15:11:13 -06:00
|
|
|
#if WITH_CONCHECK
|
2011-12-14 13:41:57 -06:00
|
|
|
if (priv->state >= NM_STATE_CONNECTED_LOCAL) {
|
|
|
|
|
if (old_state == NM_DEVICE_STATE_ACTIVATED || new_state == NM_DEVICE_STATE_ACTIVATED) {
|
|
|
|
|
/* Still connected, but a device activated or deactivated; make sure
|
|
|
|
|
* we still have connectivity on the other activated devices.
|
|
|
|
|
*/
|
2011-12-15 10:13:31 -06:00
|
|
|
nm_log_dbg (LOGD_CORE, "(%s): triggered connectivity check due to state change",
|
|
|
|
|
nm_device_get_iface (device));
|
2011-12-14 13:41:57 -06:00
|
|
|
nm_connectivity_start_check (priv->connectivity);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* Cannot be connected if no devices are activated */
|
2011-12-15 10:13:31 -06:00
|
|
|
nm_log_dbg (LOGD_CORE, "stopping connectivity checks");
|
2011-12-14 13:41:57 -06:00
|
|
|
nm_connectivity_stop_check (priv->connectivity);
|
|
|
|
|
}
|
2011-12-05 15:11:13 -06:00
|
|
|
#endif
|
2009-05-20 12:02:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Removes a device from a device list; returns the start of the new device list */
|
|
|
|
|
static GSList *
|
2009-08-03 17:15:03 -04:00
|
|
|
remove_one_device (NMManager *manager,
|
|
|
|
|
GSList *list,
|
|
|
|
|
NMDevice *device,
|
2010-08-11 17:26:33 -05:00
|
|
|
gboolean quitting)
|
2009-05-20 12:02:18 -04:00
|
|
|
{
|
2009-07-09 11:06:31 -04:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
|
|
|
|
|
2009-08-03 17:15:03 -04:00
|
|
|
if (nm_device_get_managed (device)) {
|
2010-08-11 17:26:33 -05:00
|
|
|
/* When quitting, we want to leave up interfaces & connections
|
|
|
|
|
* that can be taken over again (ie, "assumed") when NM restarts
|
|
|
|
|
* so that '/etc/init.d/NetworkManager restart' will not distrupt
|
|
|
|
|
* networking for interfaces that support connection assumption.
|
|
|
|
|
* All other devices get unmanaged when NM quits so that their
|
|
|
|
|
* connections get torn down and the interface is deactivated.
|
|
|
|
|
*/
|
2009-08-03 17:15:03 -04:00
|
|
|
|
2011-11-17 23:10:11 -06:00
|
|
|
if ( !nm_device_can_assume_connections (device)
|
2010-08-11 17:26:33 -05:00
|
|
|
|| (nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED)
|
|
|
|
|
|| !quitting)
|
2013-04-24 10:40:58 -04:00
|
|
|
nm_device_set_manager_managed (device, FALSE, NM_DEVICE_STATE_REASON_REMOVED);
|
2009-08-03 17:15:03 -04:00
|
|
|
}
|
2009-05-20 12:02:18 -04:00
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (device, manager_device_state_changed, manager);
|
|
|
|
|
|
2010-10-27 20:05:23 -05:00
|
|
|
nm_settings_device_removed (priv->settings, device);
|
2009-05-20 12:02:18 -04:00
|
|
|
g_signal_emit (manager, signals[DEVICE_REMOVED], 0, device);
|
|
|
|
|
g_object_unref (device);
|
|
|
|
|
|
|
|
|
|
return g_slist_remove (list, device);
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-19 11:01:00 +02:00
|
|
|
static void
|
|
|
|
|
modem_removed (NMModemManager *modem_manager,
|
2009-10-04 23:35:20 -07:00
|
|
|
NMModem *modem,
|
2009-01-19 11:01:00 +02:00
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2009-05-20 12:02:18 -04:00
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2009-10-04 23:35:20 -07:00
|
|
|
NMDevice *found;
|
2010-01-28 11:21:53 -08:00
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
/* Give Bluetooth DUN devices first chance to handle the modem removal */
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
2011-11-18 12:34:27 -06:00
|
|
|
if (nm_device_get_device_type (iter->data) == NM_DEVICE_TYPE_BT) {
|
2010-01-28 11:21:53 -08:00
|
|
|
if (nm_device_bt_modem_removed (NM_DEVICE_BT (iter->data), modem))
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-01-19 11:01:00 +02:00
|
|
|
|
2010-01-28 11:21:53 -08:00
|
|
|
/* Otherwise remove the standalone modem */
|
2009-10-04 23:35:20 -07:00
|
|
|
found = nm_manager_get_device_by_udi (self, nm_modem_get_path (modem));
|
|
|
|
|
if (found)
|
2010-08-11 17:26:33 -05:00
|
|
|
priv->devices = remove_one_device (self, priv->devices, found, FALSE);
|
2009-01-19 11:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
2008-07-09 14:05:49 +00:00
|
|
|
static void
|
|
|
|
|
aipd_handle_event (DBusGProxy *proxy,
|
|
|
|
|
const char *event,
|
|
|
|
|
const char *iface,
|
|
|
|
|
const char *address,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *manager = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
|
|
|
|
GSList *iter;
|
2009-12-23 11:10:11 -08:00
|
|
|
gboolean handled = FALSE;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
if (!event || !iface) {
|
2010-04-06 16:20:11 -07:00
|
|
|
nm_log_warn (LOGD_AUTOIP4, "incomplete message received from avahi-autoipd");
|
2008-07-09 14:05:49 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (strcmp (event, "BIND") != 0)
|
|
|
|
|
&& (strcmp (event, "CONFLICT") != 0)
|
|
|
|
|
&& (strcmp (event, "UNBIND") != 0)
|
|
|
|
|
&& (strcmp (event, "STOP") != 0)) {
|
2010-04-06 16:20:11 -07:00
|
|
|
nm_log_warn (LOGD_AUTOIP4, "unknown event '%s' received from avahi-autoipd", event);
|
2008-07-09 14:05:49 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMDevice *candidate = NM_DEVICE (iter->data);
|
|
|
|
|
|
|
|
|
|
if (!strcmp (nm_device_get_iface (candidate), iface)) {
|
|
|
|
|
nm_device_handle_autoip4_event (candidate, event, address);
|
|
|
|
|
handled = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!handled)
|
2010-04-06 16:20:11 -07:00
|
|
|
nm_log_warn (LOGD_AUTOIP4, "(%s): unhandled avahi-autoipd event", iface);
|
2008-07-09 14:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
2009-03-16 14:31:28 +02:00
|
|
|
static const char *
|
|
|
|
|
hostname_provider_get_hostname (NMHostnameProvider *provider)
|
|
|
|
|
{
|
|
|
|
|
return NM_MANAGER_GET_PRIVATE (provider)->hostname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
hostname_provider_init (NMHostnameProvider *provider_class)
|
|
|
|
|
{
|
|
|
|
|
provider_class->get_hostname = hostname_provider_get_hostname;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-25 16:47:53 +00:00
|
|
|
NMState
|
|
|
|
|
nm_manager_get_state (NMManager *manager)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_MANAGER (manager), NM_STATE_UNKNOWN);
|
|
|
|
|
|
|
|
|
|
return NM_MANAGER_GET_PRIVATE (manager)->state;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-13 13:30:30 -06:00
|
|
|
static gboolean
|
|
|
|
|
might_be_vpn (NMConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
NMSettingConnection *s_con;
|
|
|
|
|
const char *ctype = NULL;
|
|
|
|
|
|
2011-12-05 12:27:47 +01:00
|
|
|
if (nm_connection_get_setting_vpn (connection))
|
2011-01-13 13:30:30 -06:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
/* Make sure it's not a VPN, which we can't autocomplete yet */
|
2011-12-05 12:27:47 +01:00
|
|
|
s_con = nm_connection_get_setting_connection (connection);
|
2011-01-13 13:30:30 -06:00
|
|
|
if (s_con)
|
|
|
|
|
ctype = nm_setting_connection_get_connection_type (s_con);
|
|
|
|
|
|
|
|
|
|
return (g_strcmp0 (ctype, NM_SETTING_VPN_SETTING_NAME) == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
try_complete_vpn (NMConnection *connection, GSList *existing, GError **error)
|
|
|
|
|
{
|
|
|
|
|
g_assert (might_be_vpn (connection) == TRUE);
|
|
|
|
|
|
2011-12-05 12:27:47 +01:00
|
|
|
if (!nm_connection_get_setting_vpn (connection)) {
|
2011-01-13 13:30:30 -06:00
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_UNSUPPORTED_CONNECTION_TYPE,
|
|
|
|
|
"VPN connections require a 'vpn' setting");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nm_utils_complete_generic (connection,
|
|
|
|
|
NM_SETTING_VPN_SETTING_NAME,
|
|
|
|
|
existing,
|
|
|
|
|
_("VPN connection %d"),
|
2011-02-25 11:58:16 -06:00
|
|
|
NULL,
|
|
|
|
|
FALSE); /* No IPv6 by default for now */
|
|
|
|
|
|
2011-01-13 13:30:30 -06:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-01 00:36:46 -07:00
|
|
|
static PendingActivation *
|
|
|
|
|
pending_activation_new (NMManager *manager,
|
2010-06-03 23:20:11 -07:00
|
|
|
DBusGMethodInvocation *context,
|
2010-06-01 00:36:46 -07:00
|
|
|
const char *device_path,
|
|
|
|
|
const char *connection_path,
|
2011-01-10 23:39:12 -06:00
|
|
|
GHashTable *settings,
|
2010-06-03 23:20:11 -07:00
|
|
|
const char *specific_object_path,
|
2011-01-10 23:39:12 -06:00
|
|
|
PendingActivationFunc callback,
|
|
|
|
|
GError **error)
|
2010-06-01 00:36:46 -07:00
|
|
|
{
|
2011-01-10 23:39:12 -06:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
2010-06-01 00:36:46 -07:00
|
|
|
PendingActivation *pending;
|
2011-03-15 17:04:35 -05:00
|
|
|
NMDevice *device = NULL;
|
2011-01-10 23:39:12 -06:00
|
|
|
NMConnection *connection = NULL;
|
|
|
|
|
GSList *all_connections = NULL;
|
|
|
|
|
gboolean success;
|
2010-06-01 00:36:46 -07:00
|
|
|
|
2010-06-03 23:20:11 -07:00
|
|
|
g_return_val_if_fail (manager != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (context != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (device_path != NULL, NULL);
|
|
|
|
|
|
2011-03-15 17:04:35 -05:00
|
|
|
/* A object path of "/" means NULL */
|
2011-03-15 11:45:47 -05:00
|
|
|
if (g_strcmp0 (specific_object_path, "/") == 0)
|
|
|
|
|
specific_object_path = NULL;
|
2011-03-15 17:04:35 -05:00
|
|
|
if (g_strcmp0 (device_path, "/") == 0)
|
|
|
|
|
device_path = NULL;
|
2011-03-15 11:45:47 -05:00
|
|
|
|
2011-01-10 23:39:12 -06:00
|
|
|
/* Create the partial connection from the given settings */
|
|
|
|
|
if (settings) {
|
2011-03-15 17:04:35 -05:00
|
|
|
if (device_path)
|
|
|
|
|
device = nm_manager_get_device_by_path (manager, device_path);
|
2011-01-10 23:39:12 -06:00
|
|
|
if (!device) {
|
|
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
|
|
|
|
"Device not found");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connection = nm_connection_new ();
|
|
|
|
|
nm_connection_replace_settings (connection, settings, NULL);
|
|
|
|
|
|
|
|
|
|
all_connections = nm_settings_get_connections (priv->settings);
|
2011-01-13 13:30:30 -06:00
|
|
|
|
|
|
|
|
if (might_be_vpn (connection)) {
|
|
|
|
|
/* Try to fill the VPN's connection setting and name at least */
|
|
|
|
|
success = try_complete_vpn (connection, all_connections, error);
|
|
|
|
|
} else {
|
|
|
|
|
/* Let each device subclass complete the connection */
|
|
|
|
|
success = nm_device_complete_connection (device,
|
|
|
|
|
connection,
|
|
|
|
|
specific_object_path,
|
|
|
|
|
all_connections,
|
|
|
|
|
error);
|
|
|
|
|
}
|
2011-01-10 23:39:12 -06:00
|
|
|
g_slist_free (all_connections);
|
|
|
|
|
|
|
|
|
|
if (success == FALSE) {
|
|
|
|
|
g_object_unref (connection);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-01 00:36:46 -07:00
|
|
|
pending = g_slice_new0 (PendingActivation);
|
|
|
|
|
pending->manager = manager;
|
2010-06-03 23:20:11 -07:00
|
|
|
pending->context = context;
|
|
|
|
|
pending->callback = callback;
|
|
|
|
|
|
2010-06-01 00:36:46 -07:00
|
|
|
pending->connection_path = g_strdup (connection_path);
|
2011-01-10 23:39:12 -06:00
|
|
|
pending->connection = connection;
|
2007-10-01 15:38:39 +00:00
|
|
|
|
2010-06-03 23:20:11 -07:00
|
|
|
/* "/" is special-cased to NULL to get through D-Bus */
|
|
|
|
|
if (specific_object_path && strcmp (specific_object_path, "/"))
|
|
|
|
|
pending->specific_object_path = g_strdup (specific_object_path);
|
2012-03-06 12:00:41 -06:00
|
|
|
if (device_path && strcmp (device_path, "/"))
|
|
|
|
|
pending->device_path = g_strdup (device_path);
|
2010-06-01 00:36:46 -07:00
|
|
|
|
|
|
|
|
return pending;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-03 23:20:11 -07:00
|
|
|
static void
|
2011-07-01 14:59:56 -05:00
|
|
|
pending_auth_done (NMAuthChain *chain,
|
|
|
|
|
GError *error,
|
|
|
|
|
DBusGMethodInvocation *context,
|
|
|
|
|
gpointer user_data)
|
2010-06-03 23:20:11 -07:00
|
|
|
{
|
|
|
|
|
PendingActivation *pending = user_data;
|
|
|
|
|
NMAuthCallResult result;
|
2011-05-18 22:20:24 -05:00
|
|
|
GError *tmp_error = NULL;
|
2010-06-03 23:20:11 -07:00
|
|
|
|
|
|
|
|
/* Caller has had a chance to obtain authorization, so we only need to
|
|
|
|
|
* check for 'yes' here.
|
|
|
|
|
*/
|
2012-10-08 12:52:15 -05:00
|
|
|
result = nm_auth_chain_get_result (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL);
|
|
|
|
|
if (error)
|
|
|
|
|
tmp_error = g_error_copy (error);
|
|
|
|
|
else if (result != NM_AUTH_CALL_RESULT_YES) {
|
2011-05-18 22:20:24 -05:00
|
|
|
tmp_error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"Not authorized to control networking.");
|
2012-10-08 12:52:15 -05:00
|
|
|
} else if (pending->wifi_shared_permission) {
|
2011-07-01 14:59:56 -05:00
|
|
|
result = nm_auth_chain_get_result (chain, pending->wifi_shared_permission);
|
|
|
|
|
if (result != NM_AUTH_CALL_RESULT_YES) {
|
|
|
|
|
tmp_error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"Not authorized to share connections via wifi.");
|
|
|
|
|
}
|
2010-06-03 23:20:11 -07:00
|
|
|
}
|
|
|
|
|
|
2011-05-18 22:20:24 -05:00
|
|
|
pending->callback (pending, tmp_error);
|
|
|
|
|
g_clear_error (&tmp_error);
|
2010-06-03 23:20:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2012-12-16 12:30:41 -06:00
|
|
|
pending_activation_check_authorized (PendingActivation *pending)
|
2010-06-01 00:36:46 -07:00
|
|
|
{
|
2010-06-03 23:20:11 -07:00
|
|
|
GError *error;
|
2011-07-01 14:59:56 -05:00
|
|
|
const char *wifi_permission = NULL;
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSettings *settings;
|
2012-12-16 12:30:41 -06:00
|
|
|
const char *error_desc = NULL;
|
2010-06-03 23:20:11 -07:00
|
|
|
|
|
|
|
|
g_return_if_fail (pending != NULL);
|
|
|
|
|
|
2011-07-01 14:59:56 -05:00
|
|
|
/* By this point we have an auto-completed connection (for AddAndActivate)
|
|
|
|
|
* or an existing connection (for Activate).
|
|
|
|
|
*/
|
|
|
|
|
connection = pending->connection;
|
|
|
|
|
if (!connection) {
|
|
|
|
|
settings = NM_MANAGER_GET_PRIVATE (pending->manager)->settings;
|
|
|
|
|
connection = (NMConnection *) nm_settings_get_connection_by_path (settings, pending->connection_path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!connection) {
|
|
|
|
|
error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_UNKNOWN_CONNECTION,
|
|
|
|
|
"Connection could not be found.");
|
|
|
|
|
pending->callback (pending, error);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-03 23:20:11 -07:00
|
|
|
/* First check if the user is allowed to use networking at all, giving
|
|
|
|
|
* the user a chance to authenticate to gain the permission.
|
|
|
|
|
*/
|
2011-05-18 22:20:24 -05:00
|
|
|
pending->chain = nm_auth_chain_new (pending->context,
|
2011-07-01 14:59:56 -05:00
|
|
|
pending_auth_done,
|
2012-12-16 12:30:41 -06:00
|
|
|
pending,
|
|
|
|
|
&error_desc);
|
|
|
|
|
if (pending->chain) {
|
|
|
|
|
nm_auth_chain_add_call (pending->chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, TRUE);
|
|
|
|
|
|
|
|
|
|
/* Shared wifi connections require special permissions too */
|
|
|
|
|
wifi_permission = nm_utils_get_shared_wifi_permission (connection);
|
|
|
|
|
if (wifi_permission) {
|
|
|
|
|
pending->wifi_shared_permission = wifi_permission;
|
|
|
|
|
nm_auth_chain_add_call (pending->chain, wifi_permission, TRUE);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
error_desc);
|
|
|
|
|
pending->callback (pending, error);
|
|
|
|
|
g_error_free (error);
|
2011-07-01 14:59:56 -05:00
|
|
|
}
|
2010-06-01 00:36:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
pending_activation_destroy (PendingActivation *pending,
|
|
|
|
|
GError *error,
|
2012-02-23 10:00:08 -06:00
|
|
|
NMActiveConnection *ac)
|
2010-06-01 00:36:46 -07:00
|
|
|
{
|
|
|
|
|
g_return_if_fail (pending != NULL);
|
|
|
|
|
|
2011-01-10 23:39:12 -06:00
|
|
|
if (error)
|
|
|
|
|
dbus_g_method_return_error (pending->context, error);
|
2012-02-23 10:00:08 -06:00
|
|
|
else if (ac) {
|
2011-01-10 23:39:12 -06:00
|
|
|
if (pending->connection) {
|
|
|
|
|
dbus_g_method_return (pending->context,
|
|
|
|
|
pending->connection_path,
|
2012-02-23 10:00:08 -06:00
|
|
|
nm_active_connection_get_path (ac));
|
|
|
|
|
} else {
|
|
|
|
|
dbus_g_method_return (pending->context,
|
|
|
|
|
nm_active_connection_get_path (ac));
|
|
|
|
|
}
|
2011-01-10 23:39:12 -06:00
|
|
|
}
|
|
|
|
|
|
2010-06-01 00:36:46 -07:00
|
|
|
g_free (pending->connection_path);
|
|
|
|
|
g_free (pending->specific_object_path);
|
|
|
|
|
g_free (pending->device_path);
|
2011-01-10 23:39:12 -06:00
|
|
|
if (pending->connection)
|
|
|
|
|
g_object_unref (pending->connection);
|
2010-06-01 00:36:46 -07:00
|
|
|
|
2010-06-03 23:20:11 -07:00
|
|
|
if (pending->chain)
|
|
|
|
|
nm_auth_chain_unref (pending->chain);
|
2010-06-01 00:36:46 -07:00
|
|
|
|
|
|
|
|
memset (pending, 0, sizeof (PendingActivation));
|
|
|
|
|
g_slice_free (PendingActivation, pending);
|
2007-10-01 15:38:39 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
/*******************************************************************/
|
2010-10-27 20:05:23 -05:00
|
|
|
/* Settings stuff via NMSettings */
|
2009-06-11 00:39:12 -04:00
|
|
|
/*******************************************************************/
|
|
|
|
|
|
2012-02-22 23:59:50 -06:00
|
|
|
static NMDevice *
|
|
|
|
|
get_device_from_hwaddr (NMManager *self, NMConnection *connection)
|
2012-02-12 14:48:44 -06:00
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
2012-02-22 23:59:50 -06:00
|
|
|
if (nm_device_hwaddr_matches (NM_DEVICE (iter->data), connection, NULL, 0, TRUE))
|
|
|
|
|
return iter->data;
|
2012-02-12 14:48:44 -06:00
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 23:59:50 -06:00
|
|
|
static NMDevice*
|
|
|
|
|
find_vlan_parent (NMManager *self,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
gboolean check_hwaddr)
|
2012-02-12 14:48:44 -06:00
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2012-02-21 13:46:04 -06:00
|
|
|
NMSettingVlan *s_vlan;
|
|
|
|
|
NMConnection *parent_connection;
|
2012-02-22 23:59:50 -06:00
|
|
|
const char *parent_iface;
|
|
|
|
|
NMDevice *parent = NULL;
|
2012-02-12 14:48:44 -06:00
|
|
|
GSList *iter;
|
|
|
|
|
|
2012-02-21 13:46:04 -06:00
|
|
|
/* The 'parent' property could be either an interface name, a connection
|
2012-08-27 13:23:40 -04:00
|
|
|
* UUID, or even given by the MAC address of the connection's ethernet
|
|
|
|
|
* or WiFi setting.
|
2012-02-12 14:48:44 -06:00
|
|
|
*/
|
2012-02-21 13:46:04 -06:00
|
|
|
s_vlan = nm_connection_get_setting_vlan (connection);
|
|
|
|
|
g_return_val_if_fail (s_vlan != NULL, NULL);
|
|
|
|
|
|
2012-02-22 23:59:50 -06:00
|
|
|
parent_iface = nm_setting_vlan_get_parent (s_vlan);
|
|
|
|
|
if (parent_iface) {
|
|
|
|
|
parent = find_device_by_ip_iface (self, parent_iface);
|
|
|
|
|
if (parent)
|
2012-02-21 13:46:04 -06:00
|
|
|
return parent;
|
2012-02-12 14:48:44 -06:00
|
|
|
|
2012-02-22 23:59:50 -06:00
|
|
|
if (nm_utils_is_uuid (parent_iface)) {
|
2012-02-21 13:46:04 -06:00
|
|
|
/* Try as a connection UUID */
|
2012-02-22 23:59:50 -06:00
|
|
|
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (priv->settings, parent_iface);
|
2012-02-21 13:46:04 -06:00
|
|
|
if (parent_connection) {
|
|
|
|
|
/* Check if the parent connection is activated on some device already */
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
2012-02-22 23:59:50 -06:00
|
|
|
NMActRequest *req;
|
|
|
|
|
NMConnection *candidate;
|
|
|
|
|
|
|
|
|
|
req = nm_device_get_act_request (NM_DEVICE (iter->data));
|
|
|
|
|
if (req) {
|
|
|
|
|
candidate = nm_active_connection_get_connection (NM_ACTIVE_CONNECTION (req));
|
|
|
|
|
if (candidate == parent_connection)
|
2013-03-12 18:01:11 +01:00
|
|
|
return NM_DEVICE (iter->data);
|
2012-02-21 13:46:04 -06:00
|
|
|
}
|
2012-02-12 14:48:44 -06:00
|
|
|
}
|
|
|
|
|
|
2012-02-21 13:46:04 -06:00
|
|
|
/* Check the hardware address of the parent connection */
|
|
|
|
|
if (check_hwaddr)
|
2012-02-22 23:59:50 -06:00
|
|
|
return get_device_from_hwaddr (self, parent_connection);
|
2012-02-21 13:46:04 -06:00
|
|
|
}
|
|
|
|
|
return NULL;
|
2012-02-12 14:48:44 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Try the hardware address from the VLAN connection's hardware setting */
|
|
|
|
|
if (check_hwaddr)
|
2012-02-22 23:59:50 -06:00
|
|
|
return get_device_from_hwaddr (self, connection);
|
2012-02-12 14:48:44 -06:00
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-10 13:25:39 -06:00
|
|
|
/**
|
|
|
|
|
* get_virtual_iface_name:
|
|
|
|
|
* @self: the #NMManager
|
|
|
|
|
* @connection: the #NMConnection representing a virtual interface
|
2012-02-22 23:59:50 -06:00
|
|
|
* @out_parent: on success, the parent device if any
|
2012-02-10 13:25:39 -06:00
|
|
|
*
|
|
|
|
|
* Given @connection, returns the interface name that the connection
|
|
|
|
|
* would represent. If the interface name is not given by the connection,
|
|
|
|
|
* this may require constructing it based on information in the connection
|
|
|
|
|
* and existing network interfaces.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the expected interface name (caller takes ownership), or %NULL
|
|
|
|
|
*/
|
|
|
|
|
static char *
|
2012-02-12 14:48:44 -06:00
|
|
|
get_virtual_iface_name (NMManager *self,
|
|
|
|
|
NMConnection *connection,
|
2012-02-22 23:59:50 -06:00
|
|
|
NMDevice **out_parent)
|
2012-02-10 13:25:39 -06:00
|
|
|
{
|
2012-02-12 14:48:44 -06:00
|
|
|
char *vname = NULL;
|
2012-02-22 23:59:50 -06:00
|
|
|
NMDevice *parent = NULL;
|
2012-02-12 14:48:44 -06:00
|
|
|
|
2012-02-22 23:59:50 -06:00
|
|
|
if (out_parent)
|
|
|
|
|
*out_parent = NULL;
|
2012-02-12 14:48:44 -06:00
|
|
|
|
2012-02-10 13:25:39 -06:00
|
|
|
if (nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME))
|
|
|
|
|
return g_strdup (nm_connection_get_virtual_iface_name (connection));
|
|
|
|
|
|
2012-10-29 19:02:45 -05:00
|
|
|
if (nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME))
|
|
|
|
|
return g_strdup (nm_connection_get_virtual_iface_name (connection));
|
|
|
|
|
|
2012-02-12 14:48:44 -06:00
|
|
|
if (nm_connection_is_type (connection, NM_SETTING_VLAN_SETTING_NAME)) {
|
|
|
|
|
NMSettingVlan *s_vlan;
|
2012-02-22 23:59:50 -06:00
|
|
|
const char *ifname;
|
2012-02-12 14:48:44 -06:00
|
|
|
|
|
|
|
|
s_vlan = nm_connection_get_setting_vlan (connection);
|
|
|
|
|
g_return_val_if_fail (s_vlan != NULL, NULL);
|
|
|
|
|
|
2012-02-22 23:59:50 -06:00
|
|
|
parent = find_vlan_parent (self, connection, TRUE);
|
2012-02-21 13:46:04 -06:00
|
|
|
if (parent) {
|
2012-09-19 10:56:30 -04:00
|
|
|
ifname = nm_connection_get_virtual_iface_name (connection);
|
|
|
|
|
|
|
|
|
|
if (!nm_device_supports_vlans (parent)) {
|
|
|
|
|
nm_log_warn (LOGD_DEVICE, "(%s): No support for VLANs on interface %s of type %s",
|
|
|
|
|
ifname ? ifname : nm_connection_get_id (connection),
|
|
|
|
|
nm_device_get_ip_iface (parent),
|
|
|
|
|
nm_device_get_type_desc (parent));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-12 14:48:44 -06:00
|
|
|
/* If the connection doesn't specify the interface name for the VLAN
|
2012-02-21 13:46:04 -06:00
|
|
|
* device, we create one for it using the VLAN ID and the parent
|
2012-02-12 14:48:44 -06:00
|
|
|
* interface's name.
|
|
|
|
|
*/
|
|
|
|
|
if (ifname)
|
|
|
|
|
vname = g_strdup (ifname);
|
2012-02-22 23:59:50 -06:00
|
|
|
else {
|
|
|
|
|
vname = nm_utils_new_vlan_name (nm_device_get_ip_iface (parent),
|
|
|
|
|
nm_setting_vlan_get_id (s_vlan));
|
|
|
|
|
}
|
|
|
|
|
if (out_parent)
|
|
|
|
|
*out_parent = parent;
|
2012-02-12 14:48:44 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return vname;
|
2012-02-10 13:25:39 -06:00
|
|
|
}
|
|
|
|
|
|
2011-10-18 13:48:44 +02:00
|
|
|
static gboolean
|
|
|
|
|
connection_needs_virtual_device (NMConnection *connection)
|
|
|
|
|
{
|
2012-10-29 19:02:45 -05:00
|
|
|
if ( nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)
|
|
|
|
|
|| nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)
|
|
|
|
|
|| nm_connection_is_type (connection, NM_SETTING_VLAN_SETTING_NAME))
|
2012-02-12 14:48:44 -06:00
|
|
|
return TRUE;
|
2011-10-18 13:48:44 +02:00
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-10 13:25:39 -06:00
|
|
|
static char *
|
|
|
|
|
get_virtual_iface_placeholder_udi (void)
|
2011-10-18 13:48:44 +02:00
|
|
|
{
|
2012-02-10 13:25:39 -06:00
|
|
|
static guint32 id = 0;
|
2011-10-18 13:48:44 +02:00
|
|
|
|
2012-02-10 13:25:39 -06:00
|
|
|
return g_strdup_printf ("/virtual/device/placeholder/%d", id++);
|
|
|
|
|
}
|
2011-10-18 13:48:44 +02:00
|
|
|
|
core: only manage those bridges created by NetworkManager (rh #905035)
Until we handle bridges non-destructively, only manage bridges
created by NM. When quitting write out a file listing all
bridges created by NM and a timestamp, and when starting read
that file and if the timestamp is within 30 minutes, manage
any bridge that was listed in that file. This scheme, while
not foolproof (eg, if NM crashes), should ensure that NM can
recognize bridges it created if it's restarted. The file
is stored in /run or /var/run, which is cleaned each restart,
ensuring that the state does not persist across reboots.
If an automatic or user-initiated activation request for
a bridge NM does not manage is received, that request is
denied. Only if the bridge interface does not yet exist, or
was present in the managed bridges file, will an
NMDeviceBridge be created and activation be possible.
2013-02-01 18:03:11 -06:00
|
|
|
/***************************/
|
|
|
|
|
|
|
|
|
|
/* FIXME: remove when we handle bridges non-destructively */
|
|
|
|
|
|
|
|
|
|
#define NM_BRIDGE_FILE NMRUNDIR "/nm-bridges"
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
read_nm_created_bridges (NMManager *self)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
char *contents;
|
|
|
|
|
char **lines, **iter;
|
|
|
|
|
GTimeVal tv;
|
|
|
|
|
glong ts;
|
|
|
|
|
|
|
|
|
|
if (!g_file_get_contents (NM_BRIDGE_FILE, &contents, NULL, NULL))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
g_get_current_time (&tv);
|
|
|
|
|
|
|
|
|
|
lines = g_strsplit_set (contents, "\n", 0);
|
|
|
|
|
g_free (contents);
|
|
|
|
|
|
|
|
|
|
for (iter = lines; iter && *iter; iter++) {
|
|
|
|
|
if (g_str_has_prefix (*iter, "ts=")) {
|
|
|
|
|
errno = 0;
|
|
|
|
|
ts = strtol (*iter + 3, NULL, 10);
|
|
|
|
|
/* allow 30 minutes time difference before we ignore the file */
|
|
|
|
|
if (errno || ABS (tv.tv_sec - ts) > 1800)
|
|
|
|
|
goto out;
|
|
|
|
|
} else if (g_str_has_prefix (*iter, "iface="))
|
|
|
|
|
g_hash_table_insert (priv->nm_bridges, g_strdup (*iter + 6), GUINT_TO_POINTER (1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
g_strfreev (lines);
|
|
|
|
|
unlink (NM_BRIDGE_FILE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
write_nm_created_bridges (NMManager *self)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GString *br_list;
|
|
|
|
|
GSList *iter;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
GTimeVal tv;
|
|
|
|
|
gboolean found = FALSE;
|
|
|
|
|
|
|
|
|
|
/* write out nm-created bridges list */
|
|
|
|
|
br_list = g_string_sized_new (50);
|
|
|
|
|
|
|
|
|
|
/* Timestamp is first line */
|
|
|
|
|
g_get_current_time (&tv);
|
|
|
|
|
g_string_append_printf (br_list, "ts=%ld\n", tv.tv_sec);
|
|
|
|
|
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMDevice *device = iter->data;
|
|
|
|
|
|
|
|
|
|
if (nm_device_get_device_type (device) == NM_DEVICE_TYPE_BRIDGE) {
|
|
|
|
|
g_string_append_printf (br_list, "iface=%s\n", nm_device_get_iface (device));
|
|
|
|
|
found = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found) {
|
|
|
|
|
if (!g_file_set_contents (NM_BRIDGE_FILE, br_list->str, -1, &error)) {
|
|
|
|
|
nm_log_warn (LOGD_BRIDGE, "Failed to write NetworkManager-created bridge list; "
|
|
|
|
|
"on restart bridges may not be recognized. (%s)",
|
|
|
|
|
error ? error->message : "unknown");
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_string_free (br_list, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
bridge_created_by_nm (NMManager *self, const char *iface)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
return (priv->nm_bridges && g_hash_table_lookup (priv->nm_bridges, iface));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***************************/
|
|
|
|
|
|
2012-02-10 13:25:39 -06:00
|
|
|
/**
|
|
|
|
|
* system_create_virtual_device:
|
|
|
|
|
* @self: the #NMManager
|
|
|
|
|
* @connection: the connection which might require a virtual device
|
|
|
|
|
*
|
|
|
|
|
* If @connection requires a virtual device and one does not yet exist for it,
|
|
|
|
|
* creates that device.
|
|
|
|
|
*
|
2013-04-19 15:48:01 +02:00
|
|
|
* Returns: the #NMDevice if successfully created, %NULL if not
|
2012-02-10 13:25:39 -06:00
|
|
|
*/
|
|
|
|
|
static NMDevice *
|
|
|
|
|
system_create_virtual_device (NMManager *self, NMConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GSList *iter;
|
|
|
|
|
char *iface = NULL, *udi;
|
2012-02-22 23:59:50 -06:00
|
|
|
NMDevice *device = NULL, *parent = NULL;
|
2012-02-10 13:25:39 -06:00
|
|
|
|
2012-02-22 23:59:50 -06:00
|
|
|
iface = get_virtual_iface_name (self, connection, &parent);
|
2012-02-10 13:25:39 -06:00
|
|
|
if (!iface) {
|
|
|
|
|
nm_log_warn (LOGD_DEVICE, "(%s) failed to determine virtual interface name",
|
|
|
|
|
nm_connection_get_id (connection));
|
|
|
|
|
return NULL;
|
2011-10-18 13:48:44 +02:00
|
|
|
}
|
|
|
|
|
|
2012-02-10 13:25:39 -06:00
|
|
|
/* Make sure we didn't create a device for this connection already */
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMDevice *candidate = iter->data;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
if ( g_strcmp0 (nm_device_get_iface (candidate), iface) == 0
|
|
|
|
|
|| nm_device_check_connection_compatible (candidate, connection, &error)) {
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)) {
|
2013-01-21 15:12:24 +01:00
|
|
|
if (!nm_platform_bond_add (iface)) {
|
2012-02-10 13:25:39 -06:00
|
|
|
nm_log_warn (LOGD_DEVICE, "(%s): failed to add bonding master interface for '%s'",
|
|
|
|
|
iface, nm_connection_get_id (connection));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2012-02-15 17:31:37 -06:00
|
|
|
|
|
|
|
|
udi = get_virtual_iface_placeholder_udi ();
|
|
|
|
|
device = nm_device_bond_new (udi, iface);
|
|
|
|
|
g_free (udi);
|
2012-10-29 19:02:45 -05:00
|
|
|
} else if (nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) {
|
2013-01-21 15:12:24 +01:00
|
|
|
gboolean result;
|
core: only manage those bridges created by NetworkManager (rh #905035)
Until we handle bridges non-destructively, only manage bridges
created by NM. When quitting write out a file listing all
bridges created by NM and a timestamp, and when starting read
that file and if the timestamp is within 30 minutes, manage
any bridge that was listed in that file. This scheme, while
not foolproof (eg, if NM crashes), should ensure that NM can
recognize bridges it created if it's restarted. The file
is stored in /run or /var/run, which is cleaned each restart,
ensuring that the state does not persist across reboots.
If an automatic or user-initiated activation request for
a bridge NM does not manage is received, that request is
denied. Only if the bridge interface does not yet exist, or
was present in the managed bridges file, will an
NMDeviceBridge be created and activation be possible.
2013-02-01 18:03:11 -06:00
|
|
|
|
2013-01-21 15:12:24 +01:00
|
|
|
result = nm_platform_bridge_add (iface);
|
|
|
|
|
if (!result && nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
|
2012-10-29 19:02:45 -05:00
|
|
|
nm_log_warn (LOGD_DEVICE, "(%s): failed to add bridging interface for '%s'",
|
|
|
|
|
iface, nm_connection_get_id (connection));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
core: only manage those bridges created by NetworkManager (rh #905035)
Until we handle bridges non-destructively, only manage bridges
created by NM. When quitting write out a file listing all
bridges created by NM and a timestamp, and when starting read
that file and if the timestamp is within 30 minutes, manage
any bridge that was listed in that file. This scheme, while
not foolproof (eg, if NM crashes), should ensure that NM can
recognize bridges it created if it's restarted. The file
is stored in /run or /var/run, which is cleaned each restart,
ensuring that the state does not persist across reboots.
If an automatic or user-initiated activation request for
a bridge NM does not manage is received, that request is
denied. Only if the bridge interface does not yet exist, or
was present in the managed bridges file, will an
NMDeviceBridge be created and activation be possible.
2013-02-01 18:03:11 -06:00
|
|
|
/* FIXME: remove when we handle bridges non-destructively */
|
2013-01-21 15:12:24 +01:00
|
|
|
if (!result && !bridge_created_by_nm (self, iface)) {
|
core: only manage those bridges created by NetworkManager (rh #905035)
Until we handle bridges non-destructively, only manage bridges
created by NM. When quitting write out a file listing all
bridges created by NM and a timestamp, and when starting read
that file and if the timestamp is within 30 minutes, manage
any bridge that was listed in that file. This scheme, while
not foolproof (eg, if NM crashes), should ensure that NM can
recognize bridges it created if it's restarted. The file
is stored in /run or /var/run, which is cleaned each restart,
ensuring that the state does not persist across reboots.
If an automatic or user-initiated activation request for
a bridge NM does not manage is received, that request is
denied. Only if the bridge interface does not yet exist, or
was present in the managed bridges file, will an
NMDeviceBridge be created and activation be possible.
2013-02-01 18:03:11 -06:00
|
|
|
nm_log_warn (LOGD_DEVICE, "(%s): cannot use existing bridge for '%s'",
|
|
|
|
|
iface, nm_connection_get_id (connection));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-29 19:02:45 -05:00
|
|
|
udi = get_virtual_iface_placeholder_udi ();
|
|
|
|
|
device = nm_device_bridge_new (udi, iface);
|
|
|
|
|
g_free (udi);
|
2012-02-12 14:48:44 -06:00
|
|
|
} else if (nm_connection_is_type (connection, NM_SETTING_VLAN_SETTING_NAME)) {
|
2013-01-21 15:12:24 +01:00
|
|
|
NMSettingVlan *s_vlan = nm_connection_get_setting_vlan (connection);
|
|
|
|
|
int ifindex = nm_device_get_ip_ifindex (parent);
|
|
|
|
|
int num, i;
|
|
|
|
|
guint32 from, to;
|
|
|
|
|
|
|
|
|
|
if (!nm_platform_vlan_add (iface, ifindex,
|
|
|
|
|
nm_setting_vlan_get_id (s_vlan),
|
|
|
|
|
nm_setting_vlan_get_flags (s_vlan))) {
|
2012-02-12 14:48:44 -06:00
|
|
|
nm_log_warn (LOGD_DEVICE, "(%s): failed to add VLAN interface for '%s'",
|
|
|
|
|
iface, nm_connection_get_id (connection));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2013-01-21 15:12:24 +01:00
|
|
|
num = nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_INGRESS_MAP);
|
|
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
|
if (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_INGRESS_MAP, i, &from, &to))
|
|
|
|
|
nm_platform_vlan_set_ingress_map (ifindex, from, to);
|
|
|
|
|
}
|
|
|
|
|
num = nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_EGRESS_MAP);
|
|
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
|
if (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, i, &from, &to))
|
|
|
|
|
nm_platform_vlan_set_egress_map (ifindex, from, to);
|
|
|
|
|
}
|
2012-02-10 13:25:39 -06:00
|
|
|
udi = get_virtual_iface_placeholder_udi ();
|
2012-02-22 23:59:50 -06:00
|
|
|
device = nm_device_vlan_new (udi, iface, parent);
|
2012-02-10 13:25:39 -06:00
|
|
|
g_free (udi);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-15 17:31:37 -06:00
|
|
|
if (device)
|
|
|
|
|
add_device (self, device);
|
|
|
|
|
|
2012-02-10 13:25:39 -06:00
|
|
|
out:
|
|
|
|
|
g_free (iface);
|
|
|
|
|
return device;
|
2011-10-18 13:48:44 +02:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
static void
|
2012-02-10 13:25:39 -06:00
|
|
|
system_create_virtual_devices (NMManager *self)
|
2011-10-18 13:48:44 +02:00
|
|
|
{
|
2012-02-10 13:25:39 -06:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2011-10-18 13:48:44 +02:00
|
|
|
GSList *iter, *connections;
|
|
|
|
|
|
2012-02-10 13:25:39 -06:00
|
|
|
nm_log_dbg (LOGD_CORE, "creating virtual devices...");
|
2011-10-18 13:48:44 +02:00
|
|
|
|
2012-02-10 13:25:39 -06:00
|
|
|
connections = nm_settings_get_connections (priv->settings);
|
2011-10-18 13:48:44 +02:00
|
|
|
for (iter = connections; iter; iter = g_slist_next (iter)) {
|
2012-02-10 13:25:39 -06:00
|
|
|
NMConnection *connection = iter->data;
|
|
|
|
|
NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
|
2011-10-18 13:48:44 +02:00
|
|
|
|
2012-02-10 13:25:39 -06:00
|
|
|
g_assert (s_con);
|
|
|
|
|
if (connection_needs_virtual_device (connection)) {
|
|
|
|
|
/* We only create a virtual interface if the connection can autoconnect */
|
|
|
|
|
if (nm_setting_connection_get_autoconnect (s_con))
|
|
|
|
|
system_create_virtual_device (self, connection);
|
|
|
|
|
}
|
2011-10-18 13:48:44 +02:00
|
|
|
}
|
|
|
|
|
g_slist_free (connections);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
connection_added (NMSettings *settings,
|
2012-11-19 15:30:48 -05:00
|
|
|
NMSettingsConnection *settings_connection,
|
2011-10-18 13:48:44 +02:00
|
|
|
NMManager *manager)
|
|
|
|
|
{
|
2012-11-19 15:30:48 -05:00
|
|
|
NMConnection *connection = NM_CONNECTION (settings_connection);
|
|
|
|
|
|
|
|
|
|
if (connection_needs_virtual_device (connection)) {
|
|
|
|
|
NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
|
|
|
|
|
|
|
|
|
|
g_assert (s_con);
|
|
|
|
|
if (nm_setting_connection_get_autoconnect (s_con))
|
|
|
|
|
system_create_virtual_device (manager, connection);
|
|
|
|
|
}
|
2011-10-18 13:48:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
connection_changed (NMSettings *settings,
|
2012-11-19 15:30:48 -05:00
|
|
|
NMSettingsConnection *connection,
|
|
|
|
|
NMManager *manager)
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
{
|
2011-10-18 13:48:44 +02:00
|
|
|
/* FIXME: Some virtual devices may need to be updated in the future. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
connection_removed (NMSettings *settings,
|
|
|
|
|
NMSettingsConnection *connection,
|
|
|
|
|
NMManager *manager)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* Do not delete existing virtual devices to keep connectivity up.
|
|
|
|
|
* Virtual devices are reused when NetworkManager is restarted.
|
|
|
|
|
*/
|
2008-05-22 14:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
static void
|
2010-10-27 20:05:23 -05:00
|
|
|
system_unmanaged_devices_changed_cb (NMSettings *settings,
|
2009-06-11 00:39:12 -04:00
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data)
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
{
|
2010-10-27 20:05:23 -05:00
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2009-06-11 00:39:12 -04:00
|
|
|
const GSList *unmanaged_specs, *iter;
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
|
2010-10-27 20:05:23 -05:00
|
|
|
unmanaged_specs = nm_settings_get_unmanaged_specs (priv->settings);
|
2009-06-11 00:39:12 -04:00
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMDevice *device = NM_DEVICE (iter->data);
|
|
|
|
|
gboolean managed;
|
2008-06-05 13:16:02 +00:00
|
|
|
|
2011-11-17 23:16:50 -06:00
|
|
|
managed = !nm_device_spec_match_list (device, unmanaged_specs);
|
2013-04-24 10:40:58 -04:00
|
|
|
nm_device_set_manager_managed (device,
|
|
|
|
|
managed,
|
|
|
|
|
managed ? NM_DEVICE_STATE_REASON_NOW_MANAGED :
|
|
|
|
|
NM_DEVICE_STATE_REASON_NOW_UNMANAGED);
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-10-27 20:05:23 -05:00
|
|
|
system_hostname_changed_cb (NMSettings *settings,
|
2009-06-11 00:39:12 -04:00
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data)
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
{
|
2010-10-27 20:05:23 -05:00
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2009-06-11 00:39:12 -04:00
|
|
|
char *hostname;
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
|
2010-10-27 20:05:23 -05:00
|
|
|
hostname = nm_settings_get_hostname (priv->settings);
|
2009-06-11 00:39:12 -04:00
|
|
|
if (!hostname && !priv->hostname)
|
|
|
|
|
return;
|
|
|
|
|
if (hostname && priv->hostname && !strcmp (hostname, priv->hostname))
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
return;
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
g_free (priv->hostname);
|
|
|
|
|
priv->hostname = (hostname && strlen (hostname)) ? g_strdup (hostname) : NULL;
|
2010-10-27 20:05:23 -05:00
|
|
|
g_object_notify (G_OBJECT (self), NM_MANAGER_HOSTNAME);
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
g_free (hostname);
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
/*******************************************************************/
|
|
|
|
|
/* General NMManager stuff */
|
|
|
|
|
/*******************************************************************/
|
|
|
|
|
|
2009-11-02 17:29:53 -08:00
|
|
|
/* Store value into key-file; supported types: boolean, int, string */
|
|
|
|
|
static gboolean
|
|
|
|
|
write_value_to_state_file (const char *filename,
|
|
|
|
|
const char *group,
|
|
|
|
|
const char *key,
|
|
|
|
|
GType value_type,
|
|
|
|
|
gpointer value,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GKeyFile *key_file;
|
|
|
|
|
char *data;
|
|
|
|
|
gsize len = 0;
|
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (filename != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (group != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (key != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (value_type == G_TYPE_BOOLEAN ||
|
|
|
|
|
value_type == G_TYPE_INT ||
|
|
|
|
|
value_type == G_TYPE_STRING,
|
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
|
|
key_file = g_key_file_new ();
|
|
|
|
|
|
|
|
|
|
g_key_file_set_list_separator (key_file, ',');
|
|
|
|
|
g_key_file_load_from_file (key_file, filename, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
|
|
|
|
switch (value_type) {
|
|
|
|
|
case G_TYPE_BOOLEAN:
|
|
|
|
|
g_key_file_set_boolean (key_file, group, key, *((gboolean *) value));
|
|
|
|
|
break;
|
|
|
|
|
case G_TYPE_INT:
|
|
|
|
|
g_key_file_set_integer (key_file, group, key, *((gint *) value));
|
|
|
|
|
break;
|
|
|
|
|
case G_TYPE_STRING:
|
|
|
|
|
g_key_file_set_string (key_file, group, key, *((const gchar **) value));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data = g_key_file_to_data (key_file, &len, NULL);
|
|
|
|
|
if (data) {
|
|
|
|
|
ret = g_file_set_contents (filename, data, len, error);
|
|
|
|
|
g_free (data);
|
|
|
|
|
}
|
|
|
|
|
g_key_file_free (key_file);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-01 17:08:10 -05:00
|
|
|
static gboolean
|
2011-04-22 14:56:31 -05:00
|
|
|
radio_enabled_for_rstate (RadioState *rstate, gboolean check_changeable)
|
2010-09-01 17:08:10 -05:00
|
|
|
{
|
2011-04-13 21:58:25 -05:00
|
|
|
gboolean enabled;
|
|
|
|
|
|
2011-04-22 14:56:31 -05:00
|
|
|
enabled = rstate->user_enabled && rstate->hw_enabled;
|
|
|
|
|
if (check_changeable) {
|
|
|
|
|
enabled &= rstate->sw_enabled;
|
|
|
|
|
if (rstate->daemon_enabled_func)
|
|
|
|
|
enabled &= rstate->daemon_enabled;
|
|
|
|
|
}
|
2011-04-13 21:58:25 -05:00
|
|
|
return enabled;
|
2010-09-01 17:08:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2011-04-22 14:56:31 -05:00
|
|
|
radio_enabled_for_type (NMManager *self, RfKillType rtype, gboolean check_changeable)
|
2010-09-01 17:08:10 -05:00
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
2011-04-22 14:56:31 -05:00
|
|
|
return radio_enabled_for_rstate (&priv->radio_states[rtype], check_changeable);
|
2010-09-01 17:08:10 -05:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
static void
|
2011-04-13 21:58:25 -05:00
|
|
|
manager_update_radio_enabled (NMManager *self,
|
|
|
|
|
RadioState *rstate,
|
|
|
|
|
gboolean enabled)
|
2008-02-06 16:50:43 +00:00
|
|
|
{
|
2010-09-01 17:08:10 -05:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2009-06-11 00:39:12 -04:00
|
|
|
GSList *iter;
|
2008-02-06 16:50:43 +00:00
|
|
|
|
2009-12-23 00:03:45 -08:00
|
|
|
/* Do nothing for radio types not yet implemented */
|
|
|
|
|
if (!rstate->prop)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-09-01 17:08:10 -05:00
|
|
|
g_object_notify (G_OBJECT (self), rstate->prop);
|
2009-11-02 17:29:53 -08:00
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
/* Don't touch devices if asleep/networking disabled */
|
2010-09-01 17:08:10 -05:00
|
|
|
if (manager_sleeping (self))
|
2009-06-11 00:39:12 -04:00
|
|
|
return;
|
2007-09-03 01:12:23 +00:00
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
/* enable/disable wireless devices as required */
|
|
|
|
|
for (iter = priv->devices; iter; iter = iter->next) {
|
2011-11-18 12:02:58 -06:00
|
|
|
NMDevice *device = NM_DEVICE (iter->data);
|
2010-03-25 11:36:19 -07:00
|
|
|
|
2011-11-18 12:02:58 -06:00
|
|
|
if (nm_device_get_rfkill_type (device) == rstate->rtype) {
|
2010-04-07 14:55:43 -07:00
|
|
|
nm_log_dbg (LOGD_RFKILL, "(%s): setting radio %s",
|
2011-11-18 12:02:58 -06:00
|
|
|
nm_device_get_iface (device),
|
2010-04-07 14:55:43 -07:00
|
|
|
enabled ? "enabled" : "disabled");
|
2011-11-18 12:02:58 -06:00
|
|
|
nm_device_set_enabled (device, enabled);
|
2010-04-07 14:55:43 -07:00
|
|
|
}
|
2008-02-06 16:50:43 +00:00
|
|
|
}
|
2007-09-03 01:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-22 14:22:31 +00:00
|
|
|
static void
|
2011-11-18 00:40:31 -06:00
|
|
|
manager_hidden_ap_found (NMDevice *device,
|
2009-06-11 00:39:12 -04:00
|
|
|
NMAccessPoint *ap,
|
|
|
|
|
gpointer user_data)
|
2008-05-22 14:22:31 +00:00
|
|
|
{
|
2009-06-11 00:39:12 -04:00
|
|
|
NMManager *manager = NM_MANAGER (user_data);
|
2010-10-27 15:47:10 -05:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
2011-05-27 17:32:40 +02:00
|
|
|
const struct ether_addr *bssid;
|
2009-06-11 00:39:12 -04:00
|
|
|
GSList *iter;
|
|
|
|
|
GSList *connections;
|
|
|
|
|
gboolean done = FALSE;
|
2008-05-22 14:22:31 +00:00
|
|
|
|
2011-05-27 17:32:40 +02:00
|
|
|
g_return_if_fail (nm_ap_get_ssid (ap) == NULL);
|
2008-05-22 14:22:31 +00:00
|
|
|
|
2011-05-27 17:32:40 +02:00
|
|
|
bssid = nm_ap_get_address (ap);
|
|
|
|
|
g_assert (bssid);
|
2009-03-31 13:10:00 -04:00
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
/* Look for this AP's BSSID in the seen-bssids list of a connection,
|
|
|
|
|
* and if a match is found, copy over the SSID */
|
2010-10-27 20:05:23 -05:00
|
|
|
connections = nm_settings_get_connections (priv->settings);
|
2009-06-11 00:39:12 -04:00
|
|
|
for (iter = connections; iter && !done; iter = g_slist_next (iter)) {
|
|
|
|
|
NMConnection *connection = NM_CONNECTION (iter->data);
|
2011-05-27 17:32:40 +02:00
|
|
|
NMSettingWireless *s_wifi;
|
2008-10-28 19:26:00 +00:00
|
|
|
|
2011-05-27 17:32:40 +02:00
|
|
|
s_wifi = nm_connection_get_setting_wireless (connection);
|
|
|
|
|
if (s_wifi) {
|
|
|
|
|
if (nm_settings_connection_has_seen_bssid (NM_SETTINGS_CONNECTION (connection), bssid))
|
|
|
|
|
nm_ap_set_ssid (ap, nm_setting_wireless_get_ssid (s_wifi));
|
2007-10-08 15:09:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_slist_free (connections);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-24 10:43:43 -08:00
|
|
|
static RfKillState
|
|
|
|
|
nm_manager_get_ipw_rfkill_state (NMManager *self)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GSList *iter;
|
|
|
|
|
RfKillState ipw_state = RFKILL_UNBLOCKED;
|
|
|
|
|
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMDevice *candidate = NM_DEVICE (iter->data);
|
|
|
|
|
RfKillState candidate_state;
|
|
|
|
|
|
2011-11-18 12:34:27 -06:00
|
|
|
if (nm_device_get_device_type (candidate) == NM_DEVICE_TYPE_WIFI) {
|
2009-11-24 10:43:43 -08:00
|
|
|
candidate_state = nm_device_wifi_get_ipw_rfkill_state (NM_DEVICE_WIFI (candidate));
|
|
|
|
|
|
|
|
|
|
if (candidate_state > ipw_state)
|
|
|
|
|
ipw_state = candidate_state;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ipw_state;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-23 00:18:18 -08:00
|
|
|
static RfKillState
|
|
|
|
|
nm_manager_get_modem_enabled_state (NMManager *self)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GSList *iter;
|
|
|
|
|
RfKillState wwan_state = RFKILL_UNBLOCKED;
|
|
|
|
|
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMDevice *candidate = NM_DEVICE (iter->data);
|
|
|
|
|
RfKillState candidate_state = RFKILL_UNBLOCKED;
|
|
|
|
|
|
2011-11-18 12:02:58 -06:00
|
|
|
if (nm_device_get_rfkill_type (candidate) == RFKILL_TYPE_WWAN) {
|
2011-11-17 23:28:30 -06:00
|
|
|
if (!nm_device_get_enabled (candidate))
|
2009-12-23 00:18:18 -08:00
|
|
|
candidate_state = RFKILL_SOFT_BLOCKED;
|
|
|
|
|
|
|
|
|
|
if (candidate_state > wwan_state)
|
|
|
|
|
wwan_state = candidate_state;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return wwan_state;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-01 17:08:10 -05:00
|
|
|
static void
|
|
|
|
|
update_rstate_from_rfkill (RadioState *rstate, RfKillState rfkill)
|
|
|
|
|
{
|
|
|
|
|
if (rfkill == RFKILL_UNBLOCKED) {
|
|
|
|
|
rstate->sw_enabled = TRUE;
|
|
|
|
|
rstate->hw_enabled = TRUE;
|
|
|
|
|
} else if (rfkill == RFKILL_SOFT_BLOCKED) {
|
|
|
|
|
rstate->sw_enabled = FALSE;
|
|
|
|
|
rstate->hw_enabled = TRUE;
|
|
|
|
|
} else if (rfkill == RFKILL_HARD_BLOCKED) {
|
|
|
|
|
rstate->sw_enabled = FALSE;
|
|
|
|
|
rstate->hw_enabled = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-24 10:43:43 -08:00
|
|
|
static void
|
2009-12-23 00:03:45 -08:00
|
|
|
manager_rfkill_update_one_type (NMManager *self,
|
|
|
|
|
RadioState *rstate,
|
|
|
|
|
RfKillType rtype)
|
2009-11-24 10:43:43 -08:00
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2009-12-23 00:03:45 -08:00
|
|
|
RfKillState udev_state = RFKILL_UNBLOCKED;
|
|
|
|
|
RfKillState other_state = RFKILL_UNBLOCKED;
|
|
|
|
|
RfKillState composite;
|
2010-09-01 17:08:10 -05:00
|
|
|
gboolean old_enabled, new_enabled, old_rfkilled, new_rfkilled;
|
2011-04-13 21:58:25 -05:00
|
|
|
gboolean old_hwe, old_daemon_enabled = FALSE;
|
2010-09-01 17:08:10 -05:00
|
|
|
|
2011-04-13 21:58:25 -05:00
|
|
|
old_enabled = radio_enabled_for_rstate (rstate, TRUE);
|
2010-09-01 17:08:10 -05:00
|
|
|
old_rfkilled = rstate->hw_enabled && rstate->sw_enabled;
|
|
|
|
|
old_hwe = rstate->hw_enabled;
|
2009-11-24 10:43:43 -08:00
|
|
|
|
2013-05-09 10:24:08 -04:00
|
|
|
udev_state = nm_rfkill_manager_get_rfkill_state (priv->rfkill_mgr, rtype);
|
2009-11-24 10:43:43 -08:00
|
|
|
|
2009-12-23 00:03:45 -08:00
|
|
|
if (rstate->other_enabled_func)
|
|
|
|
|
other_state = rstate->other_enabled_func (self);
|
2009-11-24 10:43:43 -08:00
|
|
|
|
2009-12-23 00:03:45 -08:00
|
|
|
/* The composite state is the "worst" of either udev or other states */
|
|
|
|
|
if (udev_state == RFKILL_HARD_BLOCKED || other_state == RFKILL_HARD_BLOCKED)
|
2009-11-24 10:43:43 -08:00
|
|
|
composite = RFKILL_HARD_BLOCKED;
|
2009-12-23 00:03:45 -08:00
|
|
|
else if (udev_state == RFKILL_SOFT_BLOCKED || other_state == RFKILL_SOFT_BLOCKED)
|
2009-11-24 10:43:43 -08:00
|
|
|
composite = RFKILL_SOFT_BLOCKED;
|
|
|
|
|
else
|
|
|
|
|
composite = RFKILL_UNBLOCKED;
|
|
|
|
|
|
2010-09-01 17:08:10 -05:00
|
|
|
update_rstate_from_rfkill (rstate, composite);
|
2009-11-24 10:43:43 -08:00
|
|
|
|
2011-04-13 21:58:25 -05:00
|
|
|
/* If the device has a management daemon that can affect enabled state, check that now */
|
|
|
|
|
if (rstate->daemon_enabled_func) {
|
|
|
|
|
old_daemon_enabled = rstate->daemon_enabled;
|
|
|
|
|
rstate->daemon_enabled = (rstate->daemon_enabled_func (self) == RFKILL_UNBLOCKED);
|
|
|
|
|
if (old_daemon_enabled != rstate->daemon_enabled) {
|
|
|
|
|
nm_log_info (LOGD_RFKILL, "%s now %s by management service",
|
|
|
|
|
rstate->desc,
|
|
|
|
|
rstate->daemon_enabled ? "enabled" : "disabled");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print out all states affecting device enablement */
|
2010-04-08 18:23:43 -07:00
|
|
|
if (rstate->desc) {
|
2011-04-13 21:58:25 -05:00
|
|
|
if (rstate->daemon_enabled_func) {
|
|
|
|
|
nm_log_dbg (LOGD_RFKILL, "%s hw-enabled %d sw-enabled %d daemon-enabled %d",
|
|
|
|
|
rstate->desc, rstate->hw_enabled, rstate->sw_enabled, rstate->daemon_enabled);
|
|
|
|
|
} else {
|
|
|
|
|
nm_log_dbg (LOGD_RFKILL, "%s hw-enabled %d sw-enabled %d",
|
|
|
|
|
rstate->desc, rstate->hw_enabled, rstate->sw_enabled);
|
|
|
|
|
}
|
2010-04-08 18:23:43 -07:00
|
|
|
}
|
|
|
|
|
|
2010-09-01 17:08:10 -05:00
|
|
|
/* Log new killswitch state */
|
|
|
|
|
new_rfkilled = rstate->hw_enabled && rstate->sw_enabled;
|
|
|
|
|
if (old_rfkilled != new_rfkilled) {
|
2010-04-06 16:20:11 -07:00
|
|
|
nm_log_info (LOGD_RFKILL, "%s now %s by radio killswitch",
|
|
|
|
|
rstate->desc,
|
2010-09-01 17:08:10 -05:00
|
|
|
new_rfkilled ? "enabled" : "disabled");
|
|
|
|
|
}
|
2009-12-23 00:03:45 -08:00
|
|
|
|
2010-09-01 17:08:10 -05:00
|
|
|
/* Send out property changed signal for HW enabled */
|
|
|
|
|
if (rstate->hw_enabled != old_hwe) {
|
2010-04-08 18:23:43 -07:00
|
|
|
if (rstate->hw_prop)
|
|
|
|
|
g_object_notify (G_OBJECT (self), rstate->hw_prop);
|
2009-11-24 10:43:43 -08:00
|
|
|
}
|
2010-09-01 17:08:10 -05:00
|
|
|
|
2011-04-13 21:58:25 -05:00
|
|
|
/* And finally update the actual device radio state itself; respect the
|
|
|
|
|
* daemon state here because this is never called from user-triggered
|
|
|
|
|
* radio changes and we only want to ignore the daemon enabled state when
|
|
|
|
|
* handling user radio change requests.
|
|
|
|
|
*/
|
|
|
|
|
new_enabled = radio_enabled_for_rstate (rstate, TRUE);
|
2010-09-01 17:08:10 -05:00
|
|
|
if (new_enabled != old_enabled)
|
2011-04-13 21:58:25 -05:00
|
|
|
manager_update_radio_enabled (self, rstate, new_enabled);
|
2009-12-23 00:03:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_manager_rfkill_update (NMManager *self, RfKillType rtype)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
guint i;
|
|
|
|
|
|
2011-04-13 21:58:25 -05:00
|
|
|
if (rtype != RFKILL_TYPE_UNKNOWN)
|
2009-12-23 00:03:45 -08:00
|
|
|
manager_rfkill_update_one_type (self, &priv->radio_states[rtype], rtype);
|
2011-04-13 21:58:25 -05:00
|
|
|
else {
|
|
|
|
|
/* Otherwise sync all radio types */
|
|
|
|
|
for (i = 0; i < RFKILL_TYPE_MAX; i++)
|
|
|
|
|
manager_rfkill_update_one_type (self, &priv->radio_states[i], i);
|
2009-11-24 10:43:43 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
manager_ipw_rfkill_state_changed (NMDeviceWifi *device,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2009-12-23 00:03:45 -08:00
|
|
|
nm_manager_rfkill_update (NM_MANAGER (user_data), RFKILL_TYPE_WLAN);
|
2009-11-24 10:43:43 -08:00
|
|
|
}
|
|
|
|
|
|
2009-12-23 00:18:18 -08:00
|
|
|
static void
|
2012-10-24 19:27:08 +02:00
|
|
|
manager_modem_enabled_changed (NMDevice *device, gpointer user_data)
|
2009-12-23 00:18:18 -08:00
|
|
|
{
|
|
|
|
|
nm_manager_rfkill_update (NM_MANAGER (user_data), RFKILL_TYPE_WWAN);
|
2009-11-24 10:43:43 -08:00
|
|
|
}
|
|
|
|
|
|
2012-06-01 15:27:39 -05:00
|
|
|
static void
|
|
|
|
|
device_auth_done_cb (NMAuthChain *chain,
|
|
|
|
|
GError *auth_error,
|
|
|
|
|
DBusGMethodInvocation *context,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
NMAuthCallResult result;
|
|
|
|
|
NMDevice *device;
|
|
|
|
|
const char *permission;
|
|
|
|
|
NMDeviceAuthRequestFunc callback;
|
|
|
|
|
|
|
|
|
|
priv->auth_chains = g_slist_remove (priv->auth_chains, chain);
|
|
|
|
|
|
|
|
|
|
permission = nm_auth_chain_get_data (chain, "requested-permission");
|
|
|
|
|
g_assert (permission);
|
|
|
|
|
callback = nm_auth_chain_get_data (chain, "callback");
|
|
|
|
|
g_assert (callback);
|
|
|
|
|
device = nm_auth_chain_get_data (chain, "device");
|
|
|
|
|
g_assert (device);
|
|
|
|
|
|
2012-10-08 12:52:15 -05:00
|
|
|
result = nm_auth_chain_get_result (chain, permission);
|
|
|
|
|
|
2012-06-01 15:27:39 -05:00
|
|
|
if (auth_error) {
|
|
|
|
|
/* translate the auth error into a manager permission denied error */
|
|
|
|
|
nm_log_dbg (LOGD_CORE, "%s request failed: %s", permission, auth_error->message);
|
|
|
|
|
error = g_error_new (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"%s request failed: %s",
|
|
|
|
|
permission, auth_error->message);
|
|
|
|
|
} else if (result != NM_AUTH_CALL_RESULT_YES) {
|
|
|
|
|
nm_log_dbg (LOGD_CORE, "%s request failed: not authorized", permission);
|
|
|
|
|
error = g_error_new (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"%s request failed: not authorized",
|
|
|
|
|
permission);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_assert (error || (result == NM_AUTH_CALL_RESULT_YES));
|
|
|
|
|
|
|
|
|
|
callback (device,
|
|
|
|
|
context,
|
|
|
|
|
error,
|
|
|
|
|
nm_auth_chain_get_data (chain, "user-data"));
|
|
|
|
|
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
nm_auth_chain_unref (chain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
device_auth_request_cb (NMDevice *device,
|
|
|
|
|
DBusGMethodInvocation *context,
|
|
|
|
|
const char *permission,
|
|
|
|
|
gboolean allow_interaction,
|
|
|
|
|
NMDeviceAuthRequestFunc callback,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
NMManager *self)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
NMAuthChain *chain;
|
2012-12-16 12:30:41 -06:00
|
|
|
const char *error_desc = NULL;
|
2012-06-01 15:27:39 -05:00
|
|
|
|
2012-12-16 12:30:41 -06:00
|
|
|
/* Validate the request */
|
|
|
|
|
chain = nm_auth_chain_new (context, device_auth_done_cb, self, &error_desc);
|
|
|
|
|
if (chain) {
|
|
|
|
|
priv->auth_chains = g_slist_append (priv->auth_chains, chain);
|
|
|
|
|
|
|
|
|
|
nm_auth_chain_set_data (chain, "device", g_object_ref (device), g_object_unref);
|
|
|
|
|
nm_auth_chain_set_data (chain, "requested-permission", g_strdup (permission), g_free);
|
|
|
|
|
nm_auth_chain_set_data (chain, "callback", callback, NULL);
|
|
|
|
|
nm_auth_chain_set_data (chain, "user-data", user_data, NULL);
|
|
|
|
|
nm_auth_chain_add_call (chain, permission, allow_interaction);
|
|
|
|
|
} else {
|
2012-06-01 15:27:39 -05:00
|
|
|
error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
2012-12-16 12:30:41 -06:00
|
|
|
error_desc);
|
2012-06-01 15:27:39 -05:00
|
|
|
callback (device, context, error, user_data);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
static void
|
2009-02-16 18:47:03 -05:00
|
|
|
add_device (NMManager *self, NMDevice *device)
|
2007-02-08 15:34:26 +00:00
|
|
|
{
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2009-07-07 14:24:12 -04:00
|
|
|
const char *iface, *driver, *type_desc;
|
2009-06-11 00:39:12 -04:00
|
|
|
char *path;
|
|
|
|
|
static guint32 devcount = 0;
|
|
|
|
|
const GSList *unmanaged_specs;
|
2009-08-06 15:15:46 -04:00
|
|
|
NMConnection *existing = NULL;
|
2013-04-24 10:40:58 -04:00
|
|
|
gboolean enabled = FALSE;
|
2011-11-18 12:02:58 -06:00
|
|
|
RfKillType rtype;
|
2011-11-18 12:34:27 -06:00
|
|
|
NMDeviceType devtype;
|
2007-02-08 15:34:26 +00:00
|
|
|
|
2009-09-04 16:55:48 +02:00
|
|
|
iface = nm_device_get_ip_iface (device);
|
|
|
|
|
g_assert (iface);
|
|
|
|
|
|
2011-11-18 12:34:27 -06:00
|
|
|
devtype = nm_device_get_device_type (device);
|
|
|
|
|
|
2011-11-18 12:09:05 -06:00
|
|
|
/* Ignore the device if we already know about it. But some modems will
|
|
|
|
|
* provide pseudo-ethernet devices that NM has already claimed while
|
|
|
|
|
* ModemManager is still detecting the modem's serial ports, so when the
|
|
|
|
|
* MM modem object finally shows up it may have the same IP interface as the
|
|
|
|
|
* ethernet interface we've already detected. In this case we skip the
|
|
|
|
|
* check for an existing device with the same IP interface name and kill
|
|
|
|
|
* the ethernet device later in favor of the modem device.
|
|
|
|
|
*/
|
2011-11-18 12:34:27 -06:00
|
|
|
if ((devtype != NM_DEVICE_TYPE_MODEM) && find_device_by_ip_iface (self, iface)) {
|
2009-09-04 16:55:48 +02:00
|
|
|
g_object_unref (device);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-02 10:28:16 -05:00
|
|
|
nm_device_set_connection_provider (device, NM_CONNECTION_PROVIDER (priv->settings));
|
|
|
|
|
|
2009-10-04 23:36:06 -07:00
|
|
|
priv->devices = g_slist_append (priv->devices, device);
|
|
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
g_signal_connect (device, "state-changed",
|
2009-02-16 18:47:03 -05:00
|
|
|
G_CALLBACK (manager_device_state_changed),
|
|
|
|
|
self);
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
|
2012-06-01 15:27:39 -05:00
|
|
|
g_signal_connect (device, NM_DEVICE_AUTH_REQUEST,
|
|
|
|
|
G_CALLBACK (device_auth_request_cb),
|
|
|
|
|
self);
|
|
|
|
|
|
2011-11-18 12:34:27 -06:00
|
|
|
if (devtype == NM_DEVICE_TYPE_WIFI) {
|
2009-11-24 10:43:43 -08:00
|
|
|
/* Attach to the access-point-added signal so that the manager can fill
|
|
|
|
|
* non-SSID-broadcasting APs with an SSID.
|
|
|
|
|
*/
|
2007-10-08 15:09:33 +00:00
|
|
|
g_signal_connect (device, "hidden-ap-found",
|
2009-02-16 18:47:03 -05:00
|
|
|
G_CALLBACK (manager_hidden_ap_found),
|
|
|
|
|
self);
|
2007-10-08 15:09:33 +00:00
|
|
|
|
2009-11-24 10:43:43 -08:00
|
|
|
/* Hook up rfkill handling for ipw-based cards until they get converted
|
|
|
|
|
* to use the kernel's rfkill subsystem in 2.6.33.
|
|
|
|
|
*/
|
|
|
|
|
g_signal_connect (device, "notify::" NM_DEVICE_WIFI_IPW_RFKILL_STATE,
|
|
|
|
|
G_CALLBACK (manager_ipw_rfkill_state_changed),
|
|
|
|
|
self);
|
2011-11-18 12:34:27 -06:00
|
|
|
} else if (devtype == NM_DEVICE_TYPE_MODEM) {
|
2010-05-24 17:07:46 -07:00
|
|
|
g_signal_connect (device, NM_DEVICE_MODEM_ENABLE_CHANGED,
|
2009-12-23 00:18:18 -08:00
|
|
|
G_CALLBACK (manager_modem_enabled_changed),
|
|
|
|
|
self);
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
}
|
|
|
|
|
|
2011-11-18 12:02:58 -06:00
|
|
|
/* Update global rfkill state for this device type with the device's
|
|
|
|
|
* rfkill state, and then set this device's rfkill state based on the
|
|
|
|
|
* global state.
|
|
|
|
|
*/
|
|
|
|
|
rtype = nm_device_get_rfkill_type (device);
|
2011-04-13 21:58:25 -05:00
|
|
|
if (rtype != RFKILL_TYPE_UNKNOWN) {
|
|
|
|
|
nm_manager_rfkill_update (self, rtype);
|
|
|
|
|
enabled = radio_enabled_for_type (self, rtype, TRUE);
|
2011-11-17 23:38:08 -06:00
|
|
|
nm_device_set_enabled (device, enabled);
|
2011-04-13 21:58:25 -05:00
|
|
|
}
|
|
|
|
|
|
2009-07-07 14:24:12 -04:00
|
|
|
type_desc = nm_device_get_type_desc (device);
|
|
|
|
|
g_assert (type_desc);
|
|
|
|
|
driver = nm_device_get_driver (device);
|
2009-02-18 14:21:02 -05:00
|
|
|
if (!driver)
|
|
|
|
|
driver = "unknown";
|
2010-04-21 14:58:25 -07:00
|
|
|
nm_log_info (LOGD_HW, "(%s): new %s device (driver: '%s' ifindex: %d)",
|
|
|
|
|
iface, type_desc, driver, nm_device_get_ifindex (device));
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
path = g_strdup_printf ("/org/freedesktop/NetworkManager/Devices/%d", devcount++);
|
|
|
|
|
nm_device_set_path (device, path);
|
2012-10-04 16:42:03 -05:00
|
|
|
nm_dbus_manager_register_object (priv->dbus_mgr, path, device);
|
2010-04-06 16:20:11 -07:00
|
|
|
nm_log_info (LOGD_CORE, "(%s): exported as %s", iface, path);
|
2009-06-11 00:39:12 -04:00
|
|
|
g_free (path);
|
|
|
|
|
|
2009-08-03 17:15:03 -04:00
|
|
|
/* Check if we should assume the device's active connection by matching its
|
|
|
|
|
* config with an existing system connection.
|
|
|
|
|
*/
|
2013-03-19 09:17:41 -04:00
|
|
|
if (nm_device_can_assume_connections (device)) {
|
2009-08-05 18:03:09 -04:00
|
|
|
GSList *connections = NULL;
|
|
|
|
|
|
2010-10-27 20:05:23 -05:00
|
|
|
connections = nm_settings_get_connections (priv->settings);
|
2013-03-06 14:58:03 -05:00
|
|
|
existing = nm_device_find_assumable_connection (device, connections);
|
2009-08-05 18:03:09 -04:00
|
|
|
g_slist_free (connections);
|
2010-04-07 14:55:43 -07:00
|
|
|
|
2011-03-08 13:41:28 +01:00
|
|
|
if (existing)
|
2010-04-07 14:55:43 -07:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): found existing device connection '%s'",
|
|
|
|
|
nm_device_get_iface (device),
|
2011-03-08 13:41:28 +01:00
|
|
|
nm_connection_get_id (existing));
|
2009-08-05 18:03:09 -04:00
|
|
|
}
|
2009-08-03 17:15:03 -04:00
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
/* Start the device if it's supposed to be managed */
|
2010-10-27 20:05:23 -05:00
|
|
|
unmanaged_specs = nm_settings_get_unmanaged_specs (priv->settings);
|
2010-05-22 08:55:30 -07:00
|
|
|
if ( !manager_sleeping (self)
|
2011-11-17 23:16:50 -06:00
|
|
|
&& !nm_device_spec_match_list (device, unmanaged_specs)) {
|
2013-04-24 10:40:58 -04:00
|
|
|
nm_device_set_manager_managed (device,
|
|
|
|
|
TRUE,
|
|
|
|
|
existing ? NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED :
|
|
|
|
|
NM_DEVICE_STATE_REASON_NOW_MANAGED);
|
2009-08-05 18:03:09 -04:00
|
|
|
}
|
2008-01-02 13:42:52 +00:00
|
|
|
|
2010-10-27 20:05:23 -05:00
|
|
|
nm_settings_device_added (priv->settings, device);
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
g_signal_emit (self, signals[DEVICE_ADDED], 0, device);
|
2009-08-05 18:03:09 -04:00
|
|
|
|
2012-02-10 13:25:39 -06:00
|
|
|
/* New devices might be master interfaces for virtual interfaces; so we may
|
|
|
|
|
* need to create new virtual interfaces now.
|
|
|
|
|
*/
|
|
|
|
|
system_create_virtual_devices (self);
|
|
|
|
|
|
2009-08-05 18:03:09 -04:00
|
|
|
/* If the device has a connection it can assume, do that now */
|
2013-04-24 10:40:58 -04:00
|
|
|
if (existing && nm_device_can_activate (device)) {
|
2012-02-23 10:00:08 -06:00
|
|
|
NMActiveConnection *ac;
|
2009-08-05 18:03:09 -04:00
|
|
|
GError *error = NULL;
|
|
|
|
|
|
2010-04-07 14:55:43 -07:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): will attempt to assume existing connection",
|
|
|
|
|
nm_device_get_iface (device));
|
|
|
|
|
|
2012-08-28 13:38:23 +02:00
|
|
|
ac = internal_activate_device (self, device, existing, NULL, FALSE, 0, NULL, TRUE, NULL, &error);
|
2012-02-23 10:00:08 -06:00
|
|
|
if (ac)
|
2012-08-22 17:11:31 -05:00
|
|
|
active_connection_add (self, ac);
|
2009-08-05 18:03:09 -04:00
|
|
|
else {
|
2010-07-13 18:09:56 -04:00
|
|
|
nm_log_warn (LOGD_DEVICE, "assumed connection %s failed to activate: (%d) %s",
|
2010-04-06 16:20:11 -07:00
|
|
|
nm_connection_get_path (existing),
|
|
|
|
|
error ? error->code : -1,
|
|
|
|
|
error && error->message ? error->message : "(unknown)");
|
2009-08-05 18:03:09 -04:00
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-02-08 15:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
2009-05-13 21:32:56 -04:00
|
|
|
static void
|
|
|
|
|
bluez_manager_bdaddr_added_cb (NMBluezManager *bluez_mgr,
|
2009-06-11 00:39:12 -04:00
|
|
|
const char *bdaddr,
|
|
|
|
|
const char *name,
|
|
|
|
|
const char *object_path,
|
|
|
|
|
guint32 capabilities,
|
|
|
|
|
NMManager *manager)
|
2009-05-13 21:32:56 -04:00
|
|
|
{
|
2009-07-07 14:57:05 -04:00
|
|
|
NMDevice *device;
|
2009-05-14 13:59:03 -04:00
|
|
|
gboolean has_dun = (capabilities & NM_BT_CAPABILITY_DUN);
|
|
|
|
|
gboolean has_nap = (capabilities & NM_BT_CAPABILITY_NAP);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (bdaddr != NULL);
|
|
|
|
|
g_return_if_fail (name != NULL);
|
|
|
|
|
g_return_if_fail (object_path != NULL);
|
|
|
|
|
g_return_if_fail (capabilities != NM_BT_CAPABILITY_NONE);
|
2009-05-13 21:32:56 -04:00
|
|
|
|
2009-05-14 13:59:03 -04:00
|
|
|
/* Make sure the device is not already in the device list */
|
|
|
|
|
if (nm_manager_get_device_by_udi (manager, object_path))
|
|
|
|
|
return;
|
|
|
|
|
|
2013-06-06 09:05:59 -03:00
|
|
|
device = nm_device_bt_new (object_path, bdaddr, name, capabilities);
|
2009-07-07 14:57:05 -04:00
|
|
|
if (device) {
|
2010-04-06 16:20:11 -07:00
|
|
|
nm_log_info (LOGD_HW, "BT device %s (%s) added (%s%s%s)",
|
|
|
|
|
name,
|
|
|
|
|
bdaddr,
|
|
|
|
|
has_dun ? "DUN" : "",
|
|
|
|
|
has_dun && has_nap ? " " : "",
|
|
|
|
|
has_nap ? "NAP" : "");
|
2009-07-07 14:57:05 -04:00
|
|
|
|
|
|
|
|
add_device (manager, device);
|
|
|
|
|
}
|
2009-05-13 21:32:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
bluez_manager_bdaddr_removed_cb (NMBluezManager *bluez_mgr,
|
2009-05-14 13:59:03 -04:00
|
|
|
const char *bdaddr,
|
2009-05-20 12:02:18 -04:00
|
|
|
const char *object_path,
|
|
|
|
|
gpointer user_data)
|
2009-05-13 21:32:56 -04:00
|
|
|
{
|
2009-05-14 13:59:03 -04:00
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2012-05-11 11:17:18 -05:00
|
|
|
NMDevice *device;
|
2009-05-14 13:59:03 -04:00
|
|
|
|
|
|
|
|
g_return_if_fail (bdaddr != NULL);
|
|
|
|
|
g_return_if_fail (object_path != NULL);
|
|
|
|
|
|
2012-05-11 11:17:18 -05:00
|
|
|
device = nm_manager_get_device_by_udi (self, object_path);
|
|
|
|
|
if (device) {
|
|
|
|
|
nm_log_info (LOGD_HW, "BT device %s removed", bdaddr);
|
|
|
|
|
priv->devices = remove_one_device (self, priv->devices, device, FALSE);
|
2009-05-14 13:59:03 -04:00
|
|
|
}
|
2009-05-13 21:32:56 -04:00
|
|
|
}
|
|
|
|
|
|
2009-09-04 16:55:48 +02:00
|
|
|
static NMDevice *
|
2011-04-22 12:27:55 -05:00
|
|
|
find_device_by_ip_iface (NMManager *self, const gchar *iface)
|
2009-09-04 16:55:48 +02:00
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GSList *iter;
|
2010-01-28 11:21:53 -08:00
|
|
|
|
2009-09-04 16:55:48 +02:00
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
2011-04-22 12:27:55 -05:00
|
|
|
NMDevice *candidate = iter->data;
|
2010-01-28 11:21:53 -08:00
|
|
|
|
2011-04-22 12:27:55 -05:00
|
|
|
if (g_strcmp0 (nm_device_get_ip_iface (candidate), iface) == 0)
|
|
|
|
|
return candidate;
|
|
|
|
|
}
|
2009-09-04 16:55:48 +02:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-24 17:30:31 -03:00
|
|
|
static NMDevice *
|
|
|
|
|
find_device_by_iface (NMManager *self, const gchar *iface)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMDevice *candidate = iter->data;
|
|
|
|
|
|
|
|
|
|
if (g_strcmp0 (nm_device_get_iface (candidate), iface) == 0)
|
|
|
|
|
return candidate;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
static NMDevice *
|
|
|
|
|
find_device_by_ifindex (NMManager *self, guint32 ifindex)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
2010-04-21 14:58:25 -07:00
|
|
|
NMDevice *candidate = NM_DEVICE (iter->data);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2010-04-21 14:58:25 -07:00
|
|
|
if (ifindex == nm_device_get_ifindex (candidate))
|
|
|
|
|
return candidate;
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-05 23:18:32 -06:00
|
|
|
#define PLUGIN_PREFIX "libnm-device-plugin-"
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
NMDeviceType t;
|
|
|
|
|
guint priority;
|
|
|
|
|
NMDeviceFactoryCreateFunc create_func;
|
|
|
|
|
} PluginInfo;
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
|
plugin_sort (PluginInfo *a, PluginInfo *b)
|
|
|
|
|
{
|
|
|
|
|
/* Higher priority means sort earlier in the list (ie, return -1) */
|
|
|
|
|
if (a->priority > b->priority)
|
|
|
|
|
return -1;
|
|
|
|
|
else if (a->priority < b->priority)
|
|
|
|
|
return 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
load_device_factories (NMManager *self)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GDir *dir;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
const char *item;
|
|
|
|
|
char *path;
|
|
|
|
|
GSList *list = NULL, *iter;
|
|
|
|
|
|
|
|
|
|
dir = g_dir_open (NMPLUGINDIR, 0, &error);
|
|
|
|
|
if (!dir) {
|
|
|
|
|
nm_log_warn (LOGD_HW, "Failed to open plugin directory %s: %s",
|
|
|
|
|
NMPLUGINDIR,
|
|
|
|
|
(error && error->message) ? error->message : "(unknown)");
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while ((item = g_dir_read_name (dir))) {
|
|
|
|
|
GModule *plugin;
|
|
|
|
|
NMDeviceFactoryCreateFunc create_func;
|
|
|
|
|
NMDeviceFactoryPriorityFunc priority_func;
|
|
|
|
|
NMDeviceFactoryTypeFunc type_func;
|
|
|
|
|
PluginInfo *info = NULL;
|
|
|
|
|
NMDeviceType plugin_type;
|
|
|
|
|
|
|
|
|
|
if (!g_str_has_prefix (item, PLUGIN_PREFIX))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
path = g_module_build_path (NMPLUGINDIR, item);
|
|
|
|
|
g_assert (path);
|
|
|
|
|
plugin = g_module_open (path, G_MODULE_BIND_LOCAL);
|
|
|
|
|
g_free (path);
|
|
|
|
|
|
|
|
|
|
if (!plugin) {
|
|
|
|
|
nm_log_warn (LOGD_HW, "(%s): failed to load plugin: %s", item, g_module_error ());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!g_module_symbol (plugin, "nm_device_factory_get_type", (gpointer) (&type_func))) {
|
|
|
|
|
nm_log_warn (LOGD_HW, "(%s): failed to find device factory: %s", item, g_module_error ());
|
|
|
|
|
g_module_close (plugin);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make sure we don't double-load plugins */
|
|
|
|
|
plugin_type = type_func ();
|
|
|
|
|
for (iter = list; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
PluginInfo *candidate = iter->data;
|
|
|
|
|
|
|
|
|
|
if (plugin_type == candidate->t) {
|
|
|
|
|
info = candidate;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (info) {
|
|
|
|
|
g_module_close (plugin);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!g_module_symbol (plugin, "nm_device_factory_create_device", (gpointer) (&create_func))) {
|
|
|
|
|
nm_log_warn (LOGD_HW, "(%s): failed to find device creator: %s", item, g_module_error ());
|
|
|
|
|
g_module_close (plugin);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info = g_malloc0 (sizeof (*info));
|
|
|
|
|
info->create_func = create_func;
|
|
|
|
|
info->t = plugin_type;
|
|
|
|
|
|
|
|
|
|
/* Grab priority; higher number equals higher priority */
|
|
|
|
|
if (g_module_symbol (plugin, "nm_device_factory_get_priority", (gpointer) (&priority_func)))
|
|
|
|
|
info->priority = priority_func ();
|
|
|
|
|
else {
|
|
|
|
|
nm_log_dbg (LOGD_HW, "(%s): failed to find device factory priority func: %s",
|
|
|
|
|
item, g_module_error ());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_module_make_resident (plugin);
|
|
|
|
|
list = g_slist_insert_sorted (list, info, (GCompareFunc) plugin_sort);
|
|
|
|
|
|
|
|
|
|
nm_log_info (LOGD_HW, "Loaded device factory: %s", g_module_name (plugin));
|
|
|
|
|
};
|
|
|
|
|
g_dir_close (dir);
|
|
|
|
|
|
|
|
|
|
/* Ditch the priority info and copy the factory functions to our private data */
|
|
|
|
|
for (iter = list; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
PluginInfo *info = iter->data;
|
|
|
|
|
|
|
|
|
|
priv->factories = g_slist_append (priv->factories, info->create_func);
|
|
|
|
|
g_free (info);
|
|
|
|
|
}
|
|
|
|
|
g_slist_free (list);
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-19 11:01:00 +02:00
|
|
|
static void
|
2013-05-29 12:00:50 -03:00
|
|
|
platform_link_added_cb (NMPlatform *platform,
|
|
|
|
|
int ifindex,
|
|
|
|
|
NMPlatformLink *link,
|
|
|
|
|
gpointer user_data)
|
2009-01-19 11:01:00 +02:00
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
2012-02-05 23:18:32 -06:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2012-02-10 12:21:10 -06:00
|
|
|
NMDevice *device = NULL;
|
2012-02-05 23:18:32 -06:00
|
|
|
GSList *iter;
|
|
|
|
|
GError *error = NULL;
|
2009-01-19 11:01:00 +02:00
|
|
|
|
2013-05-24 17:30:31 -03:00
|
|
|
g_return_if_fail (ifindex > 0);
|
2012-03-06 11:38:03 -06:00
|
|
|
|
2013-05-24 17:30:31 -03:00
|
|
|
device = find_device_by_ifindex (self, ifindex);
|
|
|
|
|
if (device) {
|
|
|
|
|
/* If it's a virtual device we may need to update its UDI */
|
2013-05-29 12:00:50 -03:00
|
|
|
g_object_set (G_OBJECT (device), NM_DEVICE_UDI, link->udi, NULL);
|
2013-05-24 17:30:31 -03:00
|
|
|
return;
|
2012-02-10 13:25:39 -06:00
|
|
|
}
|
2009-01-19 11:01:00 +02:00
|
|
|
|
2012-02-05 23:18:32 -06:00
|
|
|
/* Try registered device factories */
|
|
|
|
|
for (iter = priv->factories; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMDeviceFactoryCreateFunc create_func = iter->data;
|
|
|
|
|
|
|
|
|
|
g_clear_error (&error);
|
2013-05-29 12:57:13 -03:00
|
|
|
device = (NMDevice *) create_func (link, &error);
|
2012-02-10 12:21:10 -06:00
|
|
|
if (device && NM_IS_DEVICE (device)) {
|
2012-02-05 23:18:32 -06:00
|
|
|
g_assert_no_error (error);
|
|
|
|
|
break; /* success! */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
nm_log_warn (LOGD_HW, "%s: factory failed to create device: (%d) %s",
|
2013-05-29 12:00:50 -03:00
|
|
|
link->udi,
|
2012-02-10 12:21:10 -06:00
|
|
|
error ? error->code : -1,
|
|
|
|
|
error ? error->message : "(unknown)");
|
2012-02-05 23:18:32 -06:00
|
|
|
g_clear_error (&error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (device == NULL) {
|
2013-04-25 15:46:39 -04:00
|
|
|
int parent_ifindex = -1;
|
|
|
|
|
NMDevice *parent;
|
|
|
|
|
|
2013-05-29 12:00:50 -03:00
|
|
|
switch (link->type) {
|
2013-04-25 15:46:39 -04:00
|
|
|
case NM_LINK_TYPE_ETHERNET:
|
2013-05-29 12:57:13 -03:00
|
|
|
device = nm_device_ethernet_new (link);
|
2013-04-25 15:46:39 -04:00
|
|
|
break;
|
|
|
|
|
case NM_LINK_TYPE_INFINIBAND:
|
2013-05-29 12:57:13 -03:00
|
|
|
device = nm_device_infiniband_new (link);
|
2013-05-29 12:00:50 -03:00
|
|
|
break;
|
|
|
|
|
case NM_LINK_TYPE_OLPC_MESH:
|
2013-05-29 12:57:13 -03:00
|
|
|
device = nm_device_olpc_mesh_new (link);
|
2013-05-29 12:00:50 -03:00
|
|
|
break;
|
|
|
|
|
case NM_LINK_TYPE_WIFI:
|
2013-05-29 12:57:13 -03:00
|
|
|
device = nm_device_wifi_new (link);
|
2013-04-25 15:46:39 -04:00
|
|
|
break;
|
|
|
|
|
case NM_LINK_TYPE_BOND:
|
2013-05-29 12:00:50 -03:00
|
|
|
device = nm_device_bond_new (link->udi, link->name);
|
2013-04-25 15:46:39 -04:00
|
|
|
break;
|
|
|
|
|
case NM_LINK_TYPE_BRIDGE:
|
core: only manage those bridges created by NetworkManager (rh #905035)
Until we handle bridges non-destructively, only manage bridges
created by NM. When quitting write out a file listing all
bridges created by NM and a timestamp, and when starting read
that file and if the timestamp is within 30 minutes, manage
any bridge that was listed in that file. This scheme, while
not foolproof (eg, if NM crashes), should ensure that NM can
recognize bridges it created if it's restarted. The file
is stored in /run or /var/run, which is cleaned each restart,
ensuring that the state does not persist across reboots.
If an automatic or user-initiated activation request for
a bridge NM does not manage is received, that request is
denied. Only if the bridge interface does not yet exist, or
was present in the managed bridges file, will an
NMDeviceBridge be created and activation be possible.
2013-02-01 18:03:11 -06:00
|
|
|
/* FIXME: always create device when we handle bridges non-destructively */
|
2013-05-29 12:00:50 -03:00
|
|
|
if (bridge_created_by_nm (self, link->name))
|
|
|
|
|
device = nm_device_bridge_new (link->udi, link->name);
|
core: only manage those bridges created by NetworkManager (rh #905035)
Until we handle bridges non-destructively, only manage bridges
created by NM. When quitting write out a file listing all
bridges created by NM and a timestamp, and when starting read
that file and if the timestamp is within 30 minutes, manage
any bridge that was listed in that file. This scheme, while
not foolproof (eg, if NM crashes), should ensure that NM can
recognize bridges it created if it's restarted. The file
is stored in /run or /var/run, which is cleaned each restart,
ensuring that the state does not persist across reboots.
If an automatic or user-initiated activation request for
a bridge NM does not manage is received, that request is
denied. Only if the bridge interface does not yet exist, or
was present in the managed bridges file, will an
NMDeviceBridge be created and activation be possible.
2013-02-01 18:03:11 -06:00
|
|
|
else
|
2013-05-29 12:00:50 -03:00
|
|
|
nm_log_info (LOGD_BRIDGE, "(%s): ignoring bridge not created by NetworkManager", link->name);
|
2013-04-25 15:46:39 -04:00
|
|
|
break;
|
|
|
|
|
case NM_LINK_TYPE_VLAN:
|
2012-03-06 11:05:24 -06:00
|
|
|
/* Have to find the parent device */
|
2013-01-21 15:12:24 +01:00
|
|
|
if (nm_platform_vlan_get_info (ifindex, &parent_ifindex, NULL)) {
|
2012-03-06 11:05:24 -06:00
|
|
|
parent = find_device_by_ifindex (self, parent_ifindex);
|
|
|
|
|
if (parent)
|
2013-05-29 12:00:50 -03:00
|
|
|
device = nm_device_vlan_new (link->udi, link->name, parent);
|
2012-03-06 11:05:24 -06:00
|
|
|
else {
|
|
|
|
|
/* If udev signaled the VLAN interface before it signaled
|
|
|
|
|
* the VLAN's parent at startup we may not know about the
|
|
|
|
|
* parent device yet. But we'll find it on the second pass
|
|
|
|
|
* from nm_manager_start().
|
|
|
|
|
*/
|
2013-05-29 12:00:50 -03:00
|
|
|
nm_log_dbg (LOGD_HW, "(%s): VLAN parent interface unknown", link->name);
|
2012-03-06 11:05:24 -06:00
|
|
|
}
|
|
|
|
|
} else
|
2013-05-29 12:00:50 -03:00
|
|
|
nm_log_err (LOGD_HW, "(%s): failed to get VLAN parent ifindex", link->name);
|
2013-04-25 15:46:39 -04:00
|
|
|
break;
|
2013-05-03 13:55:51 -04:00
|
|
|
case NM_LINK_TYPE_VETH:
|
2013-05-29 12:57:13 -03:00
|
|
|
device = nm_device_veth_new (link);
|
2013-05-03 13:55:51 -04:00
|
|
|
break;
|
2013-04-25 15:46:39 -04:00
|
|
|
case NM_LINK_TYPE_TUN:
|
|
|
|
|
case NM_LINK_TYPE_TAP:
|
2013-05-29 12:57:13 -03:00
|
|
|
device = nm_device_tun_new (link);
|
2013-04-25 15:46:39 -04:00
|
|
|
break;
|
2013-05-06 09:16:17 -04:00
|
|
|
case NM_LINK_TYPE_MACVLAN:
|
|
|
|
|
case NM_LINK_TYPE_MACVTAP:
|
2013-05-29 12:57:13 -03:00
|
|
|
device = nm_device_macvlan_new (link);
|
2013-05-06 09:16:17 -04:00
|
|
|
break;
|
2013-05-21 12:49:24 -03:00
|
|
|
case NM_LINK_TYPE_GRE:
|
|
|
|
|
case NM_LINK_TYPE_GRETAP:
|
2013-05-29 12:57:13 -03:00
|
|
|
device = nm_device_gre_new (link);
|
2013-05-21 12:49:24 -03:00
|
|
|
break;
|
2013-04-17 10:41:15 -04:00
|
|
|
|
2013-04-25 15:46:39 -04:00
|
|
|
default:
|
2013-05-29 12:57:13 -03:00
|
|
|
device = nm_device_generic_new (link);
|
2013-04-25 15:46:39 -04:00
|
|
|
break;
|
2013-04-17 10:41:15 -04:00
|
|
|
}
|
2012-02-05 23:18:32 -06:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
if (device)
|
2012-02-10 12:21:10 -06:00
|
|
|
add_device (self, device);
|
2009-01-19 11:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
static void
|
2013-05-29 12:00:50 -03:00
|
|
|
platform_link_removed_cb (NMPlatform *platform,
|
|
|
|
|
int ifindex,
|
|
|
|
|
NMPlatformLink *link,
|
|
|
|
|
gpointer user_data)
|
2007-02-08 15:34:26 +00:00
|
|
|
{
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2009-06-11 00:39:12 -04:00
|
|
|
NMDevice *device;
|
2007-02-08 15:34:26 +00:00
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
device = find_device_by_ifindex (self, ifindex);
|
|
|
|
|
if (device)
|
2010-08-11 17:26:33 -05:00
|
|
|
priv->devices = remove_one_device (self, priv->devices, device, FALSE);
|
2007-02-08 15:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-24 17:30:31 -03:00
|
|
|
static void
|
|
|
|
|
atm_device_added_cb (NMAtmManager *atm_mgr,
|
|
|
|
|
const char *iface,
|
|
|
|
|
const char *sysfs_path,
|
|
|
|
|
const char *driver,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMDevice *device;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (iface != NULL);
|
|
|
|
|
g_return_if_fail (sysfs_path != NULL);
|
|
|
|
|
|
|
|
|
|
device = find_device_by_iface (self, iface);
|
|
|
|
|
if (device)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
device = nm_device_adsl_new (sysfs_path, iface, driver);
|
|
|
|
|
if (device)
|
|
|
|
|
add_device (self, device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
atm_device_removed_cb (NMAtmManager *manager,
|
|
|
|
|
const char *iface,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
NMDevice *device = NULL;
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
if (g_strcmp0 (nm_device_get_iface (NM_DEVICE (iter->data)), iface) == 0) {
|
|
|
|
|
device = iter->data;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (device)
|
|
|
|
|
priv->devices = remove_one_device (self, priv->devices, device, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
static void
|
2013-05-09 10:24:08 -04:00
|
|
|
rfkill_manager_rfkill_changed_cb (NMRfkillManager *rfkill_mgr,
|
|
|
|
|
RfKillType rtype,
|
|
|
|
|
RfKillState udev_state,
|
|
|
|
|
gpointer user_data)
|
2007-02-08 15:34:26 +00:00
|
|
|
{
|
2009-12-23 00:03:45 -08:00
|
|
|
nm_manager_rfkill_update (NM_MANAGER (user_data), rtype);
|
2007-02-08 15:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
GSList *
|
|
|
|
|
nm_manager_get_devices (NMManager *manager)
|
2007-02-08 15:34:26 +00:00
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_MANAGER (manager), NULL);
|
|
|
|
|
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
return NM_MANAGER_GET_PRIVATE (manager)->devices;
|
2007-02-08 15:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
static gboolean
|
|
|
|
|
impl_manager_get_devices (NMManager *manager, GPtrArray **devices, GError **err)
|
2007-08-26 15:55:27 +00:00
|
|
|
{
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
2007-08-26 15:55:27 +00:00
|
|
|
GSList *iter;
|
|
|
|
|
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
*devices = g_ptr_array_sized_new (g_slist_length (priv->devices));
|
2007-08-26 15:55:27 +00:00
|
|
|
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
for (iter = priv->devices; iter; iter = iter->next)
|
2009-06-11 00:39:12 -04:00
|
|
|
g_ptr_array_add (*devices, g_strdup (nm_device_get_path (NM_DEVICE (iter->data))));
|
2007-08-26 15:55:27 +00:00
|
|
|
|
2008-04-29 Dan Williams <dcbw@redhat.com>
Handle HAL dropouts better; allow NM to start up even if HAL isn't up yet.
* marshallers/nm-marshal.list
- Add marshaller
* src/NetworkManager.c
- (main): let the NMManager handle the NMHalManager
* src/nm-hal-manager.c
src/nm-hal-manager.h
- convert to a GObject, and emit singals when stuff changes. Let the
NMManager handle the signals, instead of the NMHalManager calling
into the NMManager.
* src/nm-manager.c
src/nm-manager.h
- (remove_one_device): consolidate device removals here
- (dispose): use remove_one_device()
- (nm_manager_get_device_by_udi): make static
- (deferred_hal_manager_query_devices): idle handler to query the HAL
manager for devices at startup or wakeup time
- (nm_manager_new): create and monitor the HAL manager
- (hal_manager_udi_added_cb): new function; do what
nm_manager_add_device() used to do when signalled by the hal manager
- (hal_manager_udi_removed_cb): new function; do what
nm_manager_remove_device() used to do when signalled by the hal
manager
- (hal_manager_rfkill_changed_cb): handle rfkill changes from the
hal manager
- (hal_manager_hal_reappeared_cb): when HAL comes back, remove devices
in our device list that aren't known to HAL
- (impl_manager_sleep): on wakeup, re-add devices from an idle handler;
see comments on nm-hal-manager.c::nm_manager_state_changed() a few
commits ago
- (nm_manager_get_device_by_path, nm_manager_is_udi_managed,
nm_manager_activation_pending, nm_manager_wireless_enabled,
nm_manager_wireless_hardware_enabled,
nm_manager_set_wireless_hardware_enabled): remove, unused
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 23:03:00 +00:00
|
|
|
return TRUE;
|
2007-08-26 15:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-22 12:27:55 -05:00
|
|
|
static gboolean
|
|
|
|
|
impl_manager_get_device_by_ip_iface (NMManager *self,
|
|
|
|
|
const char *iface,
|
|
|
|
|
char **out_object_path,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *device;
|
|
|
|
|
const char *path = NULL;
|
|
|
|
|
|
|
|
|
|
device = find_device_by_ip_iface (self, iface);
|
|
|
|
|
if (device) {
|
|
|
|
|
path = nm_device_get_path (device);
|
|
|
|
|
if (path)
|
|
|
|
|
*out_object_path = g_strdup (path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (path == NULL) {
|
|
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
|
|
|
|
"No device found for the requested iface.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return path ? TRUE : FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 10:00:08 -06:00
|
|
|
static NMActiveConnection *
|
2009-06-11 00:39:12 -04:00
|
|
|
internal_activate_device (NMManager *manager,
|
|
|
|
|
NMDevice *device,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
const char *specific_object,
|
|
|
|
|
gboolean user_requested,
|
2011-01-26 18:36:08 -06:00
|
|
|
gulong sender_uid,
|
2012-08-28 13:38:23 +02:00
|
|
|
const char *dbus_sender,
|
2009-08-05 18:03:09 -04:00
|
|
|
gboolean assumed,
|
2012-02-23 10:00:08 -06:00
|
|
|
NMActiveConnection *master,
|
2009-06-11 00:39:12 -04:00
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMActRequest *req;
|
2012-11-14 14:05:30 -06:00
|
|
|
NMDevice *master_device = NULL;
|
2009-06-11 00:39:12 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_MANAGER (manager), NULL);
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
|
|
|
|
|
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
|
|
|
|
|
|
|
|
|
/* Ensure the requested connection is compatible with the device */
|
2011-11-17 23:04:47 -06:00
|
|
|
if (!nm_device_check_connection_compatible (device, connection, error))
|
2009-06-11 00:39:12 -04:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* Tear down any existing connection */
|
|
|
|
|
if (nm_device_get_act_request (device)) {
|
2011-06-02 09:06:48 -05:00
|
|
|
nm_log_info (LOGD_DEVICE, "(%s): disconnecting for new activation request.",
|
|
|
|
|
nm_device_get_iface (device));
|
2009-06-11 00:39:12 -04:00
|
|
|
nm_device_state_changed (device,
|
|
|
|
|
NM_DEVICE_STATE_DISCONNECTED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
if (master)
|
2012-08-22 09:38:01 -05:00
|
|
|
master_device = nm_active_connection_get_device (master);
|
2012-11-14 14:05:30 -06:00
|
|
|
|
2010-12-13 13:11:51 -06:00
|
|
|
req = nm_act_request_new (connection,
|
|
|
|
|
specific_object,
|
|
|
|
|
user_requested,
|
2011-01-26 18:36:08 -06:00
|
|
|
sender_uid,
|
2012-08-28 13:38:23 +02:00
|
|
|
dbus_sender,
|
2010-12-13 13:11:51 -06:00
|
|
|
assumed,
|
2012-08-22 09:38:01 -05:00
|
|
|
device,
|
|
|
|
|
master_device);
|
2012-12-18 21:06:02 -06:00
|
|
|
g_assert (req);
|
2012-11-13 17:36:39 -06:00
|
|
|
nm_device_activate (device, req);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2012-11-13 17:36:39 -06:00
|
|
|
return NM_ACTIVE_CONNECTION (req);
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
|
|
|
|
|
2012-02-26 17:27:42 -06:00
|
|
|
/**
|
|
|
|
|
* find_master:
|
|
|
|
|
* @self: #NMManager object
|
|
|
|
|
* @connection: the #NMConnection to find the master connection and device for
|
|
|
|
|
* @device: the #NMDevice, if any, which will activate @connection
|
|
|
|
|
* @out_master_connection: on success, the master connection of @connection if
|
|
|
|
|
* that master connection was found
|
|
|
|
|
* @out_master_device: on success, the master device of @connection if that
|
|
|
|
|
* master device was found
|
|
|
|
|
*
|
|
|
|
|
* Given an #NMConnection, attempts to find its master connection and/or its
|
|
|
|
|
* master device. This function may return a master connection, a master device,
|
|
|
|
|
* or both. If only a connection is returned, that master connection is not
|
|
|
|
|
* currently active on any device. If only a device is returned, that device
|
|
|
|
|
* is not currently activated with any connection. If both are returned, then
|
|
|
|
|
* the device is currently activated or activating with the returned master
|
|
|
|
|
* connection.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the master device and/or connection could be found or if
|
|
|
|
|
* the connection did not require a master, %FALSE otherwise
|
|
|
|
|
**/
|
|
|
|
|
static gboolean
|
|
|
|
|
find_master (NMManager *self,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
NMDevice *device,
|
|
|
|
|
NMConnection **out_master_connection,
|
|
|
|
|
NMDevice **out_master_device)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
NMSettingConnection *s_con;
|
|
|
|
|
const char *master;
|
|
|
|
|
NMDevice *master_device = NULL;
|
|
|
|
|
NMConnection *master_connection = NULL;
|
|
|
|
|
GSList *iter, *connections = NULL;
|
|
|
|
|
|
|
|
|
|
s_con = nm_connection_get_setting_connection (connection);
|
|
|
|
|
g_assert (s_con);
|
|
|
|
|
master = nm_setting_connection_get_master (s_con);
|
|
|
|
|
|
|
|
|
|
if (master == NULL)
|
|
|
|
|
return TRUE; /* success, but no master */
|
|
|
|
|
|
|
|
|
|
/* Try as an interface name first */
|
|
|
|
|
master_device = find_device_by_ip_iface (self, master);
|
|
|
|
|
if (master_device) {
|
|
|
|
|
/* A device obviously can't be its own master */
|
|
|
|
|
if (master_device == device)
|
|
|
|
|
return FALSE;
|
|
|
|
|
} else {
|
|
|
|
|
/* Try master as a connection UUID */
|
|
|
|
|
master_connection = (NMConnection *) nm_settings_get_connection_by_uuid (priv->settings, master);
|
|
|
|
|
if (master_connection) {
|
|
|
|
|
/* Check if the master connection is activated on some device already */
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMDevice *candidate = NM_DEVICE (iter->data);
|
|
|
|
|
|
|
|
|
|
if (candidate == device)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (nm_device_get_connection (candidate) == master_connection) {
|
|
|
|
|
master_device = candidate;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* Might be a virtual interface that hasn't been created yet, so
|
|
|
|
|
* look through the interface names of connections that require
|
|
|
|
|
* virtual interfaces and see if one of their virtual interface
|
|
|
|
|
* names matches the master.
|
|
|
|
|
*/
|
|
|
|
|
connections = nm_settings_get_connections (priv->settings);
|
|
|
|
|
for (iter = connections; iter && !master_connection; iter = g_slist_next (iter)) {
|
|
|
|
|
NMConnection *candidate = iter->data;
|
|
|
|
|
char *vname;
|
|
|
|
|
|
|
|
|
|
if (connection_needs_virtual_device (candidate)) {
|
|
|
|
|
vname = get_virtual_iface_name (self, candidate, NULL);
|
|
|
|
|
if (g_strcmp0 (master, vname) == 0)
|
|
|
|
|
master_connection = candidate;
|
|
|
|
|
g_free (vname);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_slist_free (connections);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (out_master_connection)
|
|
|
|
|
*out_master_connection = master_connection;
|
|
|
|
|
if (out_master_device)
|
|
|
|
|
*out_master_device = master_device;
|
|
|
|
|
|
|
|
|
|
return master_device || master_connection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
is_compatible_with_slave (NMConnection *master, NMConnection *slave)
|
|
|
|
|
{
|
|
|
|
|
NMSettingConnection *s_con;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (master, FALSE);
|
|
|
|
|
g_return_val_if_fail (slave, FALSE);
|
|
|
|
|
|
|
|
|
|
s_con = nm_connection_get_setting_connection (slave);
|
|
|
|
|
g_assert (s_con);
|
|
|
|
|
|
|
|
|
|
return nm_connection_is_type (master, nm_setting_connection_get_slave_type (s_con));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ensure_master_active_connection:
|
|
|
|
|
*
|
|
|
|
|
* @self: the #NMManager
|
|
|
|
|
* @dbus_sender: if the request was initiated by a user via D-Bus, the
|
|
|
|
|
* dbus sender name of the client that requested the activation; for auto
|
|
|
|
|
* activated connections use %NULL
|
|
|
|
|
* @connection: the connection that should depend on @master_connection
|
|
|
|
|
* @device: the #NMDevice, if any, which will activate @connection
|
|
|
|
|
* @master_connection: the master connection
|
|
|
|
|
* @master_device: the master device
|
|
|
|
|
* @error: the error, if an error occurred
|
|
|
|
|
*
|
|
|
|
|
* Determines whether a given #NMConnection depends on another connection to
|
|
|
|
|
* be activated, and if so, finds that master connection or creates it.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the master #NMActiveConnection that the caller should depend on, or
|
|
|
|
|
* %NULL if an error occurred
|
|
|
|
|
*/
|
|
|
|
|
static NMActiveConnection *
|
|
|
|
|
ensure_master_active_connection (NMManager *self,
|
|
|
|
|
const char *dbus_sender,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
NMDevice *device,
|
|
|
|
|
NMConnection *master_connection,
|
|
|
|
|
NMDevice *master_device,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
NMActiveConnection *master_ac = NULL;
|
|
|
|
|
NMDeviceState master_state;
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
g_assert (master_connection || master_device);
|
|
|
|
|
|
|
|
|
|
/* If the master device isn't activated then we need to activate it using
|
|
|
|
|
* compatible connection. If it's already activating we can just proceed.
|
|
|
|
|
*/
|
|
|
|
|
if (master_device) {
|
|
|
|
|
/* If we're passed a connection and a device, we require that connection
|
|
|
|
|
* be already activated on the device, eg returned from find_master().
|
|
|
|
|
*/
|
|
|
|
|
if (master_connection)
|
|
|
|
|
g_assert (nm_device_get_connection (master_device) == master_connection);
|
|
|
|
|
|
|
|
|
|
master_state = nm_device_get_state (master_device);
|
|
|
|
|
if ( (master_state == NM_DEVICE_STATE_ACTIVATED)
|
|
|
|
|
|| nm_device_is_activating (master_device)) {
|
|
|
|
|
/* Device already using master_connection */
|
|
|
|
|
return NM_ACTIVE_CONNECTION (nm_device_get_act_request (master_device));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the device is disconnected, find a compabile connection and
|
|
|
|
|
* activate it on the device.
|
|
|
|
|
*/
|
|
|
|
|
if (master_state == NM_DEVICE_STATE_DISCONNECTED) {
|
|
|
|
|
GSList *connections;
|
|
|
|
|
|
|
|
|
|
g_assert (master_connection == NULL);
|
|
|
|
|
|
|
|
|
|
/* Find a compatible connection and activate this device using it */
|
|
|
|
|
connections = nm_settings_get_connections (priv->settings);
|
|
|
|
|
for (iter = connections; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMConnection *candidate = NM_CONNECTION (iter->data);
|
|
|
|
|
|
|
|
|
|
/* Ensure eg bond slave and the candidate master is a bond master */
|
|
|
|
|
if (!is_compatible_with_slave (candidate, connection))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (nm_device_check_connection_compatible (master_device, candidate, NULL)) {
|
|
|
|
|
master_ac = nm_manager_activate_connection (self,
|
|
|
|
|
candidate,
|
|
|
|
|
NULL,
|
|
|
|
|
nm_device_get_path (master_device),
|
|
|
|
|
dbus_sender,
|
|
|
|
|
error);
|
2013-01-30 12:52:42 -06:00
|
|
|
if (!master_ac)
|
|
|
|
|
g_prefix_error (error, "%s", "Master device activation failed: ");
|
2012-02-26 17:27:42 -06:00
|
|
|
g_slist_free (connections);
|
|
|
|
|
return master_ac;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_slist_free (connections);
|
|
|
|
|
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_UNKNOWN_CONNECTION,
|
|
|
|
|
"No compatible connection found for master device %s.",
|
|
|
|
|
nm_device_get_iface (master_device));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Otherwise, the device is unmanaged, unavailable, or disconnecting */
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_UNMANAGED_DEVICE,
|
|
|
|
|
"Master device %s unmanaged or not available for activation",
|
|
|
|
|
nm_device_get_iface (master_device));
|
|
|
|
|
} else if (master_connection) {
|
|
|
|
|
gboolean found_device = FALSE;
|
|
|
|
|
|
|
|
|
|
/* Find a compatible device and activate it using this connection */
|
|
|
|
|
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMDevice *candidate = NM_DEVICE (iter->data);
|
|
|
|
|
|
|
|
|
|
if (candidate == device) {
|
|
|
|
|
/* A device obviously can't be its own master */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!nm_device_check_connection_compatible (candidate, master_connection, NULL))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
found_device = TRUE;
|
|
|
|
|
master_state = nm_device_get_state (candidate);
|
|
|
|
|
if (master_state != NM_DEVICE_STATE_DISCONNECTED)
|
|
|
|
|
continue;
|
|
|
|
|
|
2013-01-30 12:52:42 -06:00
|
|
|
master_ac = nm_manager_activate_connection (self,
|
|
|
|
|
master_connection,
|
|
|
|
|
NULL,
|
|
|
|
|
nm_device_get_path (candidate),
|
|
|
|
|
dbus_sender,
|
|
|
|
|
error);
|
|
|
|
|
if (!master_ac)
|
|
|
|
|
g_prefix_error (error, "%s", "Master device activation failed: ");
|
|
|
|
|
return master_ac;
|
2012-02-26 17:27:42 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Device described by master_connection may be a virtual one that's
|
|
|
|
|
* not created yet.
|
|
|
|
|
*/
|
|
|
|
|
if (!found_device && connection_needs_virtual_device (master_connection)) {
|
2013-01-30 12:52:42 -06:00
|
|
|
master_ac = nm_manager_activate_connection (self,
|
|
|
|
|
master_connection,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
dbus_sender,
|
|
|
|
|
error);
|
|
|
|
|
if (!master_ac)
|
|
|
|
|
g_prefix_error (error, "%s", "Master device activation failed: ");
|
|
|
|
|
return master_ac;
|
2012-02-26 17:27:42 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
|
|
|
|
"No compatible disconnected device found for master connection %s.",
|
|
|
|
|
nm_connection_get_uuid (master_connection));
|
|
|
|
|
} else
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 10:04:41 -06:00
|
|
|
static NMActiveConnection *
|
|
|
|
|
activate_vpn_connection (NMManager *self,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
const char *specific_object,
|
|
|
|
|
gulong sender_uid,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2012-09-14 15:21:29 -05:00
|
|
|
NMActiveConnection *parent = NULL;
|
2012-02-23 10:04:41 -06:00
|
|
|
NMDevice *device = NULL;
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
if (specific_object) {
|
|
|
|
|
/* Find the specifc connection the client requested we use */
|
2012-09-14 15:21:29 -05:00
|
|
|
parent = active_connection_get_by_path (self, specific_object);
|
|
|
|
|
if (!parent) {
|
2012-02-23 10:04:41 -06:00
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE,
|
|
|
|
|
"Base connection for VPN connection not active.");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2012-09-14 15:21:29 -05:00
|
|
|
for (iter = priv->active_connections; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMActiveConnection *candidate = iter->data;
|
2012-02-23 10:04:41 -06:00
|
|
|
|
2012-09-14 15:21:29 -05:00
|
|
|
if (nm_active_connection_get_default (candidate)) {
|
|
|
|
|
parent = candidate;
|
2012-02-23 10:04:41 -06:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-14 15:21:29 -05:00
|
|
|
if (!parent) {
|
|
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_CONNECTION,
|
|
|
|
|
"Could not find source connection.");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
device = nm_active_connection_get_device (parent);
|
|
|
|
|
if (!device) {
|
2012-02-23 10:04:41 -06:00
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
2012-09-14 15:21:29 -05:00
|
|
|
"Source connection had no active device.");
|
2012-02-23 10:04:41 -06:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nm_vpn_manager_activate_connection (priv->vpn_manager,
|
|
|
|
|
connection,
|
|
|
|
|
device,
|
2012-09-14 15:21:29 -05:00
|
|
|
nm_active_connection_get_path (parent),
|
2012-02-23 10:04:41 -06:00
|
|
|
TRUE,
|
|
|
|
|
sender_uid,
|
|
|
|
|
error);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 10:00:08 -06:00
|
|
|
NMActiveConnection *
|
2008-03-26 13:43:01 +00:00
|
|
|
nm_manager_activate_connection (NMManager *manager,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
const char *specific_object,
|
|
|
|
|
const char *device_path,
|
2011-01-26 18:36:08 -06:00
|
|
|
const char *dbus_sender,
|
2008-03-26 13:43:01 +00:00
|
|
|
GError **error)
|
|
|
|
|
{
|
2009-10-16 11:52:27 -07:00
|
|
|
NMManagerPrivate *priv;
|
2008-03-26 13:43:01 +00:00
|
|
|
NMDevice *device = NULL;
|
2013-03-04 16:25:40 -06:00
|
|
|
gulong sender_uid = G_MAXULONG;
|
2012-02-23 10:04:41 -06:00
|
|
|
char *iface;
|
2012-02-26 17:27:42 -06:00
|
|
|
NMDevice *master_device = NULL;
|
|
|
|
|
NMConnection *master_connection = NULL;
|
2012-08-22 17:11:31 -05:00
|
|
|
NMActiveConnection *master_ac = NULL, *ac = NULL;
|
2013-04-23 14:01:24 -05:00
|
|
|
gboolean matched;
|
2008-03-26 13:43:01 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (manager != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (connection != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (error != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (*error == NULL, NULL);
|
|
|
|
|
|
2009-10-16 11:52:27 -07:00
|
|
|
priv = NM_MANAGER_GET_PRIVATE (manager);
|
|
|
|
|
|
2011-01-26 18:36:08 -06:00
|
|
|
/* Get the UID of the user that originated the request, if any */
|
|
|
|
|
if (dbus_sender) {
|
2013-03-04 16:25:40 -06:00
|
|
|
if (!nm_dbus_manager_get_unix_user (priv->dbus_mgr, dbus_sender, &sender_uid)) {
|
2011-01-26 18:36:08 -06:00
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_MANAGER_ERROR, NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"Failed to get unix user for dbus sender");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2013-03-04 16:25:40 -06:00
|
|
|
} else {
|
|
|
|
|
/* No sender means an internal/automatic activation request */
|
|
|
|
|
sender_uid = 0;
|
2011-01-26 18:36:08 -06:00
|
|
|
}
|
|
|
|
|
|
2012-02-23 10:04:41 -06:00
|
|
|
/* VPN ? */
|
2012-08-22 17:11:31 -05:00
|
|
|
if (nm_connection_is_type (connection, NM_SETTING_VPN_SETTING_NAME)) {
|
2012-09-14 15:50:19 -05:00
|
|
|
ac = activate_vpn_connection (manager, connection, specific_object, sender_uid, error);
|
2012-08-22 17:11:31 -05:00
|
|
|
goto activated;
|
|
|
|
|
}
|
2008-03-26 13:43:01 +00:00
|
|
|
|
2012-02-23 10:04:41 -06:00
|
|
|
/* Device-based connection */
|
|
|
|
|
if (device_path) {
|
|
|
|
|
device = nm_manager_get_device_by_path (manager, device_path);
|
|
|
|
|
if (!device) {
|
|
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
|
|
|
|
"Device not found");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2009-10-16 11:52:27 -07:00
|
|
|
|
2012-02-23 10:04:41 -06:00
|
|
|
/* If it's a virtual interface make sure the device given by the
|
|
|
|
|
* path matches the connection's interface details.
|
|
|
|
|
*/
|
|
|
|
|
if (connection_needs_virtual_device (connection)) {
|
|
|
|
|
iface = get_virtual_iface_name (manager, connection, NULL);
|
|
|
|
|
if (!iface) {
|
|
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
|
|
|
|
"Failed to determine connection's virtual interface name");
|
|
|
|
|
return NULL;
|
2013-04-23 14:01:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
matched = g_str_equal (iface, nm_device_get_ip_iface (device));
|
|
|
|
|
g_free (iface);
|
|
|
|
|
if (!matched) {
|
2012-02-23 10:04:41 -06:00
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
|
|
|
|
"Device given by path did not match connection's virtual interface name");
|
2009-10-16 11:52:27 -07:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2008-03-26 13:43:01 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2012-02-23 10:04:41 -06:00
|
|
|
/* Virtual connections (VLAN, bond, etc) may not specify a device
|
|
|
|
|
* path because the device may not be created yet, or it be given
|
|
|
|
|
* by the connection's properties instead. Find the device the
|
|
|
|
|
* connection refers to, or create it if needed.
|
|
|
|
|
*/
|
|
|
|
|
if (!connection_needs_virtual_device (connection)) {
|
|
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
|
|
|
|
"This connection requires an existing device.");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2012-02-12 16:13:17 -06:00
|
|
|
|
2012-02-26 17:27:42 -06:00
|
|
|
iface = get_virtual_iface_name (manager, connection, NULL);
|
2012-02-23 10:04:41 -06:00
|
|
|
if (!iface) {
|
|
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
|
|
|
|
"Failed to determine connection's virtual interface name");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2012-02-12 16:13:17 -06:00
|
|
|
|
2012-02-23 10:04:41 -06:00
|
|
|
device = find_device_by_ip_iface (manager, iface);
|
2013-04-23 14:01:24 -05:00
|
|
|
g_free (iface);
|
2012-02-23 10:04:41 -06:00
|
|
|
if (!device) {
|
|
|
|
|
/* Create it */
|
|
|
|
|
device = system_create_virtual_device (manager, connection);
|
|
|
|
|
if (!device) {
|
2012-02-12 16:13:17 -06:00
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
2012-02-23 10:04:41 -06:00
|
|
|
"Failed to create virtual interface");
|
2012-02-12 16:13:17 -06:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2013-05-15 14:56:36 -05:00
|
|
|
|
|
|
|
|
/* A newly created device, if allowed to be managed by NM, will be
|
|
|
|
|
* in the UNAVAILABLE state here. To ensure it can be activated
|
|
|
|
|
* immediately, we transition it to DISCONNECTED so it passes the
|
|
|
|
|
* nm_device_can_activate() check below.
|
|
|
|
|
*/
|
|
|
|
|
if ( nm_device_is_available (device)
|
|
|
|
|
&& (nm_device_get_state (device) == NM_DEVICE_STATE_UNAVAILABLE)) {
|
|
|
|
|
nm_device_state_changed (device,
|
|
|
|
|
NM_DEVICE_STATE_DISCONNECTED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
}
|
2012-02-26 17:27:42 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-24 10:40:58 -04:00
|
|
|
if (!nm_device_can_activate (device)) {
|
2013-03-19 09:17:41 -04:00
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNMANAGED_DEVICE,
|
|
|
|
|
"Device not managed by NetworkManager or unavailable");
|
|
|
|
|
return NULL;
|
2012-02-26 17:27:42 -06:00
|
|
|
}
|
|
|
|
|
|
2013-01-30 12:52:42 -06:00
|
|
|
/* If this is an autoconnect request, but the device isn't allowing autoconnect
|
|
|
|
|
* right now, we reject it.
|
|
|
|
|
*/
|
|
|
|
|
if (!dbus_sender && !nm_device_autoconnect_allowed (device)) {
|
|
|
|
|
g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_AUTOCONNECT_NOT_ALLOWED,
|
|
|
|
|
"%s does not allow automatic connections at this time",
|
|
|
|
|
nm_device_get_iface (device));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-26 17:27:42 -06:00
|
|
|
/* Try to find the master connection/device if the connection has a dependency */
|
|
|
|
|
if (!find_master (manager, connection, device, &master_connection, &master_device)) {
|
|
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
|
|
|
|
"Master connection not found or invalid");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Ensure there's a master active connection the new connection we're
|
|
|
|
|
* activating can depend on.
|
|
|
|
|
*/
|
|
|
|
|
if (master_connection || master_device) {
|
|
|
|
|
if (master_connection) {
|
|
|
|
|
nm_log_dbg (LOGD_CORE, "Activation of '%s' requires master connection '%s'",
|
|
|
|
|
nm_connection_get_id (connection),
|
|
|
|
|
nm_connection_get_id (master_connection));
|
|
|
|
|
}
|
|
|
|
|
if (master_device) {
|
|
|
|
|
nm_log_dbg (LOGD_CORE, "Activation of '%s' requires master device '%s'",
|
|
|
|
|
nm_connection_get_id (connection),
|
|
|
|
|
nm_device_get_ip_iface (master_device));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Ensure eg bond slave and the candidate master is a bond master */
|
|
|
|
|
if (master_connection && !is_compatible_with_slave (master_connection, connection)) {
|
|
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_DEPENDENCY_FAILED,
|
|
|
|
|
"The master connection was not compatible");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
master_ac = ensure_master_active_connection (manager,
|
|
|
|
|
dbus_sender,
|
|
|
|
|
connection,
|
|
|
|
|
device,
|
|
|
|
|
master_connection,
|
|
|
|
|
master_device,
|
|
|
|
|
error);
|
|
|
|
|
if (!master_ac) {
|
|
|
|
|
if (error)
|
|
|
|
|
g_assert (*error);
|
|
|
|
|
return NULL;
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
}
|
2012-02-26 17:27:42 -06:00
|
|
|
|
|
|
|
|
nm_log_dbg (LOGD_CORE, "Activation of '%s' depends on active connection %s",
|
|
|
|
|
nm_connection_get_id (connection),
|
|
|
|
|
nm_active_connection_get_path (master_ac));
|
2008-03-26 13:43:01 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:11:31 -05:00
|
|
|
ac = internal_activate_device (manager,
|
|
|
|
|
device,
|
|
|
|
|
connection,
|
|
|
|
|
specific_object,
|
|
|
|
|
dbus_sender ? TRUE : FALSE,
|
|
|
|
|
dbus_sender ? sender_uid : 0,
|
|
|
|
|
dbus_sender,
|
|
|
|
|
FALSE,
|
|
|
|
|
master_ac,
|
|
|
|
|
error);
|
|
|
|
|
|
|
|
|
|
activated:
|
|
|
|
|
if (ac)
|
|
|
|
|
active_connection_add (manager, ac);
|
|
|
|
|
|
|
|
|
|
return ac;
|
2008-03-26 13:43:01 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-13 18:09:56 -04:00
|
|
|
/*
|
|
|
|
|
* TODO this function was created and named in the era of user settings, where
|
|
|
|
|
* we could get activation requests for a connection before we got the settings
|
|
|
|
|
* data of that connection. Now that user settings are gone, flatten or rename
|
|
|
|
|
* it.
|
|
|
|
|
*/
|
2007-10-01 15:38:39 +00:00
|
|
|
static void
|
2011-01-10 23:39:12 -06:00
|
|
|
pending_activate (NMManager *self, PendingActivation *pending)
|
2007-10-01 15:38:39 +00:00
|
|
|
{
|
2010-10-27 15:47:10 -05:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2011-01-26 11:38:12 -06:00
|
|
|
NMSettingsConnection *connection;
|
2012-02-23 10:00:08 -06:00
|
|
|
NMActiveConnection *ac = NULL;
|
2007-12-27 08:06:27 +00:00
|
|
|
GError *error = NULL;
|
2012-12-15 10:48:11 -06:00
|
|
|
char *sender = NULL;
|
2007-10-01 15:38:39 +00:00
|
|
|
|
2010-07-13 18:09:56 -04:00
|
|
|
/* Ok, we're authorized */
|
2010-06-03 23:20:11 -07:00
|
|
|
|
2010-10-27 20:05:23 -05:00
|
|
|
connection = nm_settings_get_connection_by_path (priv->settings, pending->connection_path);
|
2010-06-03 23:20:11 -07:00
|
|
|
if (!connection) {
|
|
|
|
|
error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_UNKNOWN_CONNECTION,
|
|
|
|
|
"Connection could not be found.");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-15 10:48:11 -06:00
|
|
|
if (!nm_dbus_manager_get_caller_info (priv->dbus_mgr,
|
|
|
|
|
pending->context,
|
|
|
|
|
&sender,
|
|
|
|
|
NULL)) {
|
|
|
|
|
error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"D-Bus sendder could not be determined.");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-26 18:36:08 -06:00
|
|
|
g_assert (sender);
|
2012-02-23 10:00:08 -06:00
|
|
|
ac = nm_manager_activate_connection (self,
|
|
|
|
|
NM_CONNECTION (connection),
|
|
|
|
|
pending->specific_object_path,
|
|
|
|
|
pending->device_path,
|
|
|
|
|
sender,
|
|
|
|
|
&error);
|
2011-01-26 18:36:08 -06:00
|
|
|
g_free (sender);
|
|
|
|
|
|
2012-08-22 17:11:31 -05:00
|
|
|
if (!ac) {
|
2010-07-13 18:09:56 -04:00
|
|
|
nm_log_warn (LOGD_CORE, "connection %s failed to activate: (%d) %s",
|
2011-06-30 12:54:18 +02:00
|
|
|
pending->connection_path,
|
|
|
|
|
error ? error->code : -1,
|
|
|
|
|
error && error->message ? error->message : "(unknown)");
|
2012-02-23 10:00:08 -06:00
|
|
|
}
|
2007-02-08 15:34:26 +00:00
|
|
|
|
2010-06-03 23:20:11 -07:00
|
|
|
out:
|
2012-02-23 10:00:08 -06:00
|
|
|
pending_activation_destroy (pending, error, ac);
|
2010-06-01 00:36:46 -07:00
|
|
|
g_clear_error (&error);
|
2007-10-01 15:38:39 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-03 23:20:11 -07:00
|
|
|
static void
|
|
|
|
|
activation_auth_done (PendingActivation *pending, GError *error)
|
|
|
|
|
{
|
2011-01-10 23:39:12 -06:00
|
|
|
if (error)
|
2010-06-03 23:20:11 -07:00
|
|
|
pending_activation_destroy (pending, error, NULL);
|
2011-01-10 23:39:12 -06:00
|
|
|
else
|
|
|
|
|
pending_activate (pending->manager, pending);
|
2008-11-21 18:11:15 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-01 15:38:39 +00:00
|
|
|
static void
|
2010-06-03 23:20:11 -07:00
|
|
|
impl_manager_activate_connection (NMManager *self,
|
2008-11-21 18:11:15 +00:00
|
|
|
const char *connection_path,
|
|
|
|
|
const char *device_path,
|
|
|
|
|
const char *specific_object_path,
|
|
|
|
|
DBusGMethodInvocation *context)
|
2007-10-01 15:38:39 +00:00
|
|
|
{
|
2010-06-03 23:20:11 -07:00
|
|
|
PendingActivation *pending;
|
2011-01-10 23:39:12 -06:00
|
|
|
GError *error = NULL;
|
2007-10-16 18:59:36 +00:00
|
|
|
|
2010-06-03 23:20:11 -07:00
|
|
|
/* Need to check the caller's permissions and stuff before we can
|
|
|
|
|
* activate the connection.
|
|
|
|
|
*/
|
|
|
|
|
pending = pending_activation_new (self,
|
|
|
|
|
context,
|
|
|
|
|
device_path,
|
|
|
|
|
connection_path,
|
2011-01-10 23:39:12 -06:00
|
|
|
NULL,
|
2010-06-03 23:20:11 -07:00
|
|
|
specific_object_path,
|
2011-01-10 23:39:12 -06:00
|
|
|
activation_auth_done,
|
|
|
|
|
&error);
|
|
|
|
|
if (pending)
|
2012-12-16 12:30:41 -06:00
|
|
|
pending_activation_check_authorized (pending);
|
2011-01-10 23:39:12 -06:00
|
|
|
else {
|
|
|
|
|
g_assert (error);
|
|
|
|
|
dbus_g_method_return_error (context, error);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
activation_add_done (NMSettings *self,
|
2011-01-26 11:38:12 -06:00
|
|
|
NMSettingsConnection *connection,
|
2011-01-10 23:39:12 -06:00
|
|
|
GError *error,
|
|
|
|
|
DBusGMethodInvocation *context,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
PendingActivation *pending = user_data;
|
|
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
|
pending_activation_destroy (pending, error, NULL);
|
|
|
|
|
else {
|
|
|
|
|
/* Save the new connection's D-Bus path */
|
|
|
|
|
pending->connection_path = g_strdup (nm_connection_get_path (NM_CONNECTION (connection)));
|
|
|
|
|
|
|
|
|
|
/* And activate it */
|
|
|
|
|
pending_activate (pending->manager, pending);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_and_activate_auth_done (PendingActivation *pending, GError *error)
|
|
|
|
|
{
|
|
|
|
|
if (error)
|
|
|
|
|
pending_activation_destroy (pending, error, NULL);
|
|
|
|
|
else {
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (pending->manager);
|
|
|
|
|
|
|
|
|
|
/* Basic sender auth checks performed; try to add the connection */
|
|
|
|
|
nm_settings_add_connection (priv->settings,
|
|
|
|
|
pending->connection,
|
2013-04-12 16:09:29 -05:00
|
|
|
TRUE,
|
2011-01-10 23:39:12 -06:00
|
|
|
pending->context,
|
|
|
|
|
activation_add_done,
|
|
|
|
|
pending);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
impl_manager_add_and_activate_connection (NMManager *self,
|
|
|
|
|
GHashTable *settings,
|
|
|
|
|
const char *device_path,
|
|
|
|
|
const char *specific_object_path,
|
|
|
|
|
DBusGMethodInvocation *context)
|
|
|
|
|
{
|
|
|
|
|
PendingActivation *pending;
|
|
|
|
|
GError *error = NULL;
|
2010-06-03 23:20:11 -07:00
|
|
|
|
2011-01-10 23:39:12 -06:00
|
|
|
/* Need to check the caller's permissions and stuff before we can
|
|
|
|
|
* activate the connection.
|
|
|
|
|
*/
|
|
|
|
|
pending = pending_activation_new (self,
|
|
|
|
|
context,
|
|
|
|
|
device_path,
|
|
|
|
|
NULL,
|
|
|
|
|
settings,
|
|
|
|
|
specific_object_path,
|
|
|
|
|
add_and_activate_auth_done,
|
|
|
|
|
&error);
|
|
|
|
|
if (pending)
|
2012-12-16 12:30:41 -06:00
|
|
|
pending_activation_check_authorized (pending);
|
2011-01-10 23:39:12 -06:00
|
|
|
else {
|
|
|
|
|
g_assert (error);
|
|
|
|
|
dbus_g_method_return_error (context, error);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
2007-02-08 15:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
2008-03-26 13:43:01 +00:00
|
|
|
gboolean
|
|
|
|
|
nm_manager_deactivate_connection (NMManager *manager,
|
|
|
|
|
const char *connection_path,
|
2008-10-11 19:57:45 +00:00
|
|
|
NMDeviceStateReason reason,
|
2008-03-26 13:43:01 +00:00
|
|
|
GError **error)
|
2007-10-03 14:48:25 +00:00
|
|
|
{
|
2008-03-20 19:56:12 +00:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
2012-09-14 15:21:29 -05:00
|
|
|
NMActiveConnection *active;
|
2008-03-26 13:43:01 +00:00
|
|
|
gboolean success = FALSE;
|
2007-10-03 14:48:25 +00:00
|
|
|
|
2012-09-14 15:21:29 -05:00
|
|
|
active = active_connection_get_by_path (manager, connection_path);
|
|
|
|
|
if (!active) {
|
|
|
|
|
g_set_error_literal (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE,
|
|
|
|
|
"The connection was not active.");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2007-10-03 14:48:25 +00:00
|
|
|
|
2012-09-14 15:21:29 -05:00
|
|
|
if (NM_IS_VPN_CONNECTION (active)) {
|
|
|
|
|
NMVPNConnectionStateReason vpn_reason = NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED;
|
2007-10-03 14:48:25 +00:00
|
|
|
|
2012-09-14 15:21:29 -05:00
|
|
|
if (reason == NM_DEVICE_STATE_REASON_CONNECTION_REMOVED)
|
|
|
|
|
vpn_reason = NM_VPN_CONNECTION_STATE_REASON_CONNECTION_REMOVED;
|
2012-09-14 15:31:32 -05:00
|
|
|
if (nm_vpn_manager_deactivate_connection (priv->vpn_manager, NM_VPN_CONNECTION (active), vpn_reason))
|
2008-03-26 13:43:01 +00:00
|
|
|
success = TRUE;
|
|
|
|
|
} else {
|
2012-09-14 15:21:29 -05:00
|
|
|
g_assert (NM_IS_ACT_REQUEST (active));
|
|
|
|
|
/* FIXME: use DEACTIVATING state */
|
|
|
|
|
nm_device_state_changed (nm_active_connection_get_device (active),
|
|
|
|
|
NM_DEVICE_STATE_DISCONNECTED,
|
|
|
|
|
reason);
|
|
|
|
|
success = TRUE;
|
2008-03-26 13:43:01 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-14 15:21:29 -05:00
|
|
|
if (success)
|
|
|
|
|
g_object_notify (G_OBJECT (manager), NM_MANAGER_ACTIVE_CONNECTIONS);
|
|
|
|
|
|
2008-03-26 13:43:01 +00:00
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-04 00:42:10 -07:00
|
|
|
static void
|
|
|
|
|
deactivate_net_auth_done_cb (NMAuthChain *chain,
|
2011-05-18 22:20:24 -05:00
|
|
|
GError *auth_error,
|
2010-06-04 00:42:10 -07:00
|
|
|
DBusGMethodInvocation *context,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2011-05-18 22:20:24 -05:00
|
|
|
GError *error = NULL;
|
2010-06-04 00:42:10 -07:00
|
|
|
NMAuthCallResult result;
|
|
|
|
|
|
|
|
|
|
priv->auth_chains = g_slist_remove (priv->auth_chains, chain);
|
|
|
|
|
|
2012-10-08 12:52:15 -05:00
|
|
|
result = nm_auth_chain_get_result (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL);
|
|
|
|
|
|
2012-06-01 16:53:23 -05:00
|
|
|
if (auth_error) {
|
|
|
|
|
nm_log_dbg (LOGD_CORE, "Disconnect request failed: %s", auth_error->message);
|
|
|
|
|
error = g_error_new (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"Deactivate request failed: %s",
|
|
|
|
|
auth_error->message);
|
|
|
|
|
} else if (result != NM_AUTH_CALL_RESULT_YES) {
|
|
|
|
|
error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"Not authorized to deactivate connections");
|
|
|
|
|
} else {
|
|
|
|
|
/* success; deactivation allowed */
|
2011-05-18 22:20:24 -05:00
|
|
|
if (!nm_manager_deactivate_connection (self,
|
2012-10-08 12:52:15 -05:00
|
|
|
nm_auth_chain_get_data (chain, "path"),
|
2011-05-18 22:20:24 -05:00
|
|
|
NM_DEVICE_STATE_REASON_USER_REQUESTED,
|
|
|
|
|
&error))
|
|
|
|
|
g_assert (error);
|
2010-06-04 00:42:10 -07:00
|
|
|
}
|
|
|
|
|
|
2011-05-18 22:20:24 -05:00
|
|
|
if (error)
|
|
|
|
|
dbus_g_method_return_error (context, error);
|
|
|
|
|
else
|
2010-07-13 18:09:56 -04:00
|
|
|
dbus_g_method_return (context);
|
2010-06-04 00:42:10 -07:00
|
|
|
|
2011-05-18 22:20:24 -05:00
|
|
|
g_clear_error (&error);
|
2010-06-04 00:42:10 -07:00
|
|
|
nm_auth_chain_unref (chain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
impl_manager_deactivate_connection (NMManager *self,
|
|
|
|
|
const char *active_path,
|
|
|
|
|
DBusGMethodInvocation *context)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
NMConnection *connection = NULL;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
GSList *iter;
|
|
|
|
|
NMAuthChain *chain;
|
2012-12-16 12:30:41 -06:00
|
|
|
const char *error_desc = NULL;
|
2010-06-04 00:42:10 -07:00
|
|
|
|
2012-08-22 17:11:31 -05:00
|
|
|
/* Find the connection by its object path */
|
|
|
|
|
for (iter = priv->active_connections; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMActiveConnection *ac = iter->data;
|
2010-06-04 00:42:10 -07:00
|
|
|
|
2012-08-22 17:11:31 -05:00
|
|
|
if (g_strcmp0 (nm_active_connection_get_path (ac), active_path) == 0) {
|
|
|
|
|
connection = nm_active_connection_get_connection (ac);
|
2010-06-04 00:42:10 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!connection) {
|
|
|
|
|
error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE,
|
|
|
|
|
"The connection was not active.");
|
|
|
|
|
dbus_g_method_return_error (context, error);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-16 12:30:41 -06:00
|
|
|
/* Validate the user request */
|
|
|
|
|
chain = nm_auth_chain_new (context, deactivate_net_auth_done_cb, self, &error_desc);
|
|
|
|
|
if (chain) {
|
|
|
|
|
priv->auth_chains = g_slist_append (priv->auth_chains, chain);
|
|
|
|
|
|
|
|
|
|
nm_auth_chain_set_data (chain, "path", g_strdup (active_path), g_free);
|
|
|
|
|
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, TRUE);
|
|
|
|
|
} else {
|
2010-06-04 00:42:10 -07:00
|
|
|
error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
2012-12-16 12:30:41 -06:00
|
|
|
error_desc);
|
2010-06-04 00:42:10 -07:00
|
|
|
dbus_g_method_return_error (context, error);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
2007-10-03 14:48:25 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-22 08:55:30 -07:00
|
|
|
static void
|
|
|
|
|
do_sleep_wake (NMManager *self)
|
2007-02-08 15:34:26 +00:00
|
|
|
{
|
2010-05-22 08:55:30 -07:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
const GSList *unmanaged_specs;
|
2009-06-11 00:39:12 -04:00
|
|
|
GSList *iter;
|
2007-02-08 15:34:26 +00:00
|
|
|
|
2010-05-22 08:55:30 -07:00
|
|
|
if (manager_sleeping (self)) {
|
|
|
|
|
nm_log_info (LOGD_SUSPEND, "sleeping or disabling...");
|
2007-02-08 15:34:26 +00:00
|
|
|
|
|
|
|
|
/* Just deactivate and down all devices from the device list,
|
2010-05-22 08:55:30 -07:00
|
|
|
* to keep things fast the device list will get resynced when
|
|
|
|
|
* the manager wakes up.
|
2007-02-08 15:34:26 +00:00
|
|
|
*/
|
2008-04-29 15:19:31 +00:00
|
|
|
for (iter = priv->devices; iter; iter = iter->next)
|
2013-04-24 10:40:58 -04:00
|
|
|
nm_device_set_manager_managed (NM_DEVICE (iter->data), FALSE, NM_DEVICE_STATE_REASON_SLEEPING);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2010-05-22 08:55:30 -07:00
|
|
|
} else {
|
|
|
|
|
nm_log_info (LOGD_SUSPEND, "waking up and re-enabling...");
|
2007-02-08 15:34:26 +00:00
|
|
|
|
2010-10-27 20:05:23 -05:00
|
|
|
unmanaged_specs = nm_settings_get_unmanaged_specs (priv->settings);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2009-11-24 10:43:43 -08:00
|
|
|
/* Ensure rfkill state is up-to-date since we don't respond to state
|
|
|
|
|
* changes during sleep.
|
|
|
|
|
*/
|
2009-12-23 00:03:45 -08:00
|
|
|
nm_manager_rfkill_update (self, RFKILL_TYPE_UNKNOWN);
|
2009-11-24 10:43:43 -08:00
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
/* Re-manage managed devices */
|
|
|
|
|
for (iter = priv->devices; iter; iter = iter->next) {
|
|
|
|
|
NMDevice *device = NM_DEVICE (iter->data);
|
2009-12-23 00:03:45 -08:00
|
|
|
guint i;
|
2009-11-20 09:11:46 -08:00
|
|
|
|
|
|
|
|
/* enable/disable wireless devices since that we don't respond
|
|
|
|
|
* to killswitch changes during sleep.
|
|
|
|
|
*/
|
2009-12-23 00:03:45 -08:00
|
|
|
for (i = 0; i < RFKILL_TYPE_MAX; i++) {
|
|
|
|
|
RadioState *rstate = &priv->radio_states[i];
|
2011-04-13 21:58:25 -05:00
|
|
|
gboolean enabled = radio_enabled_for_rstate (rstate, TRUE);
|
2009-12-23 00:03:45 -08:00
|
|
|
|
2010-04-08 18:23:43 -07:00
|
|
|
if (rstate->desc) {
|
2010-09-01 17:08:10 -05:00
|
|
|
nm_log_dbg (LOGD_RFKILL, "%s %s devices (hw_enabled %d, sw_enabled %d, user_enabled %d)",
|
2010-04-08 18:23:43 -07:00
|
|
|
enabled ? "enabling" : "disabling",
|
2010-09-01 17:08:10 -05:00
|
|
|
rstate->desc, rstate->hw_enabled, rstate->sw_enabled, rstate->user_enabled);
|
2010-04-08 18:23:43 -07:00
|
|
|
}
|
|
|
|
|
|
2011-11-18 12:02:58 -06:00
|
|
|
if (nm_device_get_rfkill_type (device) == rstate->rtype)
|
2011-11-17 23:38:08 -06:00
|
|
|
nm_device_set_enabled (device, enabled);
|
2009-12-23 00:03:45 -08:00
|
|
|
}
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2012-05-14 15:32:54 +02:00
|
|
|
g_object_set (G_OBJECT (device), NM_DEVICE_AUTOCONNECT, TRUE, NULL);
|
|
|
|
|
|
2011-11-17 23:16:50 -06:00
|
|
|
if (nm_device_spec_match_list (device, unmanaged_specs))
|
2013-04-24 10:40:58 -04:00
|
|
|
nm_device_set_manager_managed (device, FALSE, NM_DEVICE_STATE_REASON_NOW_UNMANAGED);
|
2009-06-11 00:39:12 -04:00
|
|
|
else
|
2013-04-24 10:40:58 -04:00
|
|
|
nm_device_set_manager_managed (device, TRUE, NM_DEVICE_STATE_REASON_NOW_MANAGED);
|
2008-05-22 14:27:40 +00:00
|
|
|
}
|
2007-02-08 15:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
nm_manager_update_state (self);
|
2010-05-22 08:55:30 -07:00
|
|
|
}
|
|
|
|
|
|
2010-05-29 23:11:45 -07:00
|
|
|
static void
|
|
|
|
|
_internal_sleep (NMManager *self, gboolean do_sleep)
|
2010-05-22 08:55:30 -07:00
|
|
|
{
|
2010-05-29 23:11:45 -07:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2010-05-22 08:55:30 -07:00
|
|
|
|
2010-08-31 15:45:55 -05:00
|
|
|
if (priv->sleeping == do_sleep)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-05-22 08:55:30 -07:00
|
|
|
nm_log_info (LOGD_SUSPEND, "%s requested (sleeping: %s enabled: %s)",
|
2010-05-28 13:06:14 -07:00
|
|
|
do_sleep ? "sleep" : "wake",
|
2010-05-22 08:55:30 -07:00
|
|
|
priv->sleeping ? "yes" : "no",
|
|
|
|
|
priv->net_enabled ? "yes" : "no");
|
|
|
|
|
|
2010-05-28 13:06:14 -07:00
|
|
|
priv->sleeping = do_sleep;
|
2010-05-22 08:55:30 -07:00
|
|
|
|
|
|
|
|
do_sleep_wake (self);
|
2009-10-20 15:25:04 -07:00
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_MANAGER_SLEEPING);
|
2010-05-29 23:11:45 -07:00
|
|
|
}
|
|
|
|
|
|
2010-10-15 10:28:38 -05:00
|
|
|
#if 0
|
2010-05-29 23:11:45 -07:00
|
|
|
static void
|
|
|
|
|
sleep_auth_done_cb (NMAuthChain *chain,
|
|
|
|
|
GError *error,
|
|
|
|
|
DBusGMethodInvocation *context,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GError *ret_error;
|
|
|
|
|
NMAuthCallResult result;
|
|
|
|
|
gboolean do_sleep;
|
|
|
|
|
|
|
|
|
|
priv->auth_chains = g_slist_remove (priv->auth_chains, chain);
|
2010-06-02 02:16:14 -07:00
|
|
|
|
2012-10-08 12:52:15 -05:00
|
|
|
result = nm_auth_chain_get_result (chain, NM_AUTH_PERMISSION_SLEEP_WAKE);
|
2010-05-29 23:11:45 -07:00
|
|
|
if (error) {
|
2010-08-31 15:45:55 -05:00
|
|
|
nm_log_dbg (LOGD_SUSPEND, "Sleep/wake request failed: %s", error->message);
|
2010-05-29 23:11:45 -07:00
|
|
|
ret_error = g_error_new (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"Sleep/wake request failed: %s",
|
|
|
|
|
error->message);
|
|
|
|
|
dbus_g_method_return_error (context, ret_error);
|
|
|
|
|
g_error_free (ret_error);
|
|
|
|
|
} else if (result != NM_AUTH_CALL_RESULT_YES) {
|
|
|
|
|
ret_error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"Not authorized to sleep/wake");
|
|
|
|
|
dbus_g_method_return_error (context, ret_error);
|
|
|
|
|
g_error_free (ret_error);
|
|
|
|
|
} else {
|
2010-06-02 02:16:14 -07:00
|
|
|
/* Auth success */
|
|
|
|
|
do_sleep = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, "sleep"));
|
2010-05-29 23:11:45 -07:00
|
|
|
_internal_sleep (self, do_sleep);
|
|
|
|
|
dbus_g_method_return (context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nm_auth_chain_unref (chain);
|
|
|
|
|
}
|
2010-10-15 10:28:38 -05:00
|
|
|
#endif
|
2010-05-29 23:11:45 -07:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
impl_manager_sleep (NMManager *self,
|
|
|
|
|
gboolean do_sleep,
|
|
|
|
|
DBusGMethodInvocation *context)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv;
|
2010-05-30 08:30:37 -07:00
|
|
|
GError *error = NULL;
|
2010-10-15 10:28:38 -05:00
|
|
|
#if 0
|
|
|
|
|
NMAuthChain *chain;
|
2010-05-30 08:30:37 -07:00
|
|
|
const char *error_desc = NULL;
|
2010-10-15 10:28:38 -05:00
|
|
|
#endif
|
2010-05-29 23:11:45 -07:00
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_MANAGER (self));
|
|
|
|
|
|
|
|
|
|
priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->sleeping == do_sleep) {
|
|
|
|
|
error = g_error_new (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_ALREADY_ASLEEP_OR_AWAKE,
|
|
|
|
|
"Already %s", do_sleep ? "asleep" : "awake");
|
|
|
|
|
dbus_g_method_return_error (context, error);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-15 10:28:38 -05:00
|
|
|
/* Unconditionally allow the request. Previously it was polkit protected
|
|
|
|
|
* but unfortunately that doesn't work for short-lived processes like
|
|
|
|
|
* pm-utils. It uses dbus-send without --print-reply, which quits
|
|
|
|
|
* immediately after sending the request, and NM is unable to obtain the
|
|
|
|
|
* sender's UID as dbus-send has already dropped off the bus. Thus NM
|
|
|
|
|
* fails the request. Instead, don't validate the request, but rely on
|
|
|
|
|
* D-Bus permissions to restrict the call to root.
|
|
|
|
|
*/
|
|
|
|
|
_internal_sleep (self, do_sleep);
|
|
|
|
|
dbus_g_method_return (context);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
#if 0
|
2012-12-16 12:30:41 -06:00
|
|
|
chain = nm_auth_chain_new (context, sleep_auth_done_cb, self, &error_desc);
|
|
|
|
|
if (chain) {
|
|
|
|
|
priv->auth_chains = g_slist_append (priv->auth_chains, chain);
|
|
|
|
|
nm_auth_chain_set_data (chain, "sleep", GUINT_TO_POINTER (do_sleep), NULL);
|
|
|
|
|
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_SLEEP_WAKE, TRUE);
|
|
|
|
|
} else {
|
2010-05-30 08:30:37 -07:00
|
|
|
error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
error_desc);
|
|
|
|
|
dbus_g_method_return_error (context, error);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
2010-10-15 10:28:38 -05:00
|
|
|
#endif
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-31 15:45:55 -05:00
|
|
|
static void
|
2012-10-09 00:36:35 -04:00
|
|
|
sleeping_cb (DBusGProxy *proxy, gpointer user_data)
|
2010-08-31 15:45:55 -05:00
|
|
|
{
|
2012-10-09 00:36:35 -04:00
|
|
|
nm_log_dbg (LOGD_SUSPEND, "Received sleeping signal");
|
2010-08-31 15:45:55 -05:00
|
|
|
_internal_sleep (NM_MANAGER (user_data), TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2012-10-09 00:36:35 -04:00
|
|
|
resuming_cb (DBusGProxy *proxy, gpointer user_data)
|
2010-08-31 15:45:55 -05:00
|
|
|
{
|
2012-10-09 00:36:35 -04:00
|
|
|
nm_log_dbg (LOGD_SUSPEND, "Received resuming signal");
|
2010-08-31 15:45:55 -05:00
|
|
|
_internal_sleep (NM_MANAGER (user_data), FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-29 23:00:46 -07:00
|
|
|
static void
|
|
|
|
|
_internal_enable (NMManager *self, gboolean enable)
|
2010-05-22 08:55:30 -07:00
|
|
|
{
|
2010-05-29 23:00:46 -07:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GError *err = NULL;
|
2010-05-22 08:55:30 -07:00
|
|
|
|
|
|
|
|
/* Update "NetworkingEnabled" key in state file */
|
|
|
|
|
if (priv->state_file) {
|
|
|
|
|
if (!write_value_to_state_file (priv->state_file,
|
|
|
|
|
"main", "NetworkingEnabled",
|
|
|
|
|
G_TYPE_BOOLEAN, (gpointer) &enable,
|
|
|
|
|
&err)) {
|
|
|
|
|
/* Not a hard error */
|
|
|
|
|
nm_log_warn (LOGD_SUSPEND, "writing to state file %s failed: (%d) %s.",
|
|
|
|
|
priv->state_file,
|
|
|
|
|
err ? err->code : -1,
|
|
|
|
|
(err && err->message) ? err->message : "unknown");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nm_log_info (LOGD_SUSPEND, "%s requested (sleeping: %s enabled: %s)",
|
|
|
|
|
enable ? "enable" : "disable",
|
|
|
|
|
priv->sleeping ? "yes" : "no",
|
|
|
|
|
priv->net_enabled ? "yes" : "no");
|
|
|
|
|
|
|
|
|
|
priv->net_enabled = enable;
|
|
|
|
|
|
|
|
|
|
do_sleep_wake (self);
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_MANAGER_NETWORKING_ENABLED);
|
2010-05-29 23:00:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
enable_net_done_cb (NMAuthChain *chain,
|
|
|
|
|
GError *error,
|
|
|
|
|
DBusGMethodInvocation *context,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2012-10-08 12:52:15 -05:00
|
|
|
GError *ret_error = NULL;
|
2010-05-29 23:00:46 -07:00
|
|
|
NMAuthCallResult result;
|
|
|
|
|
gboolean enable;
|
|
|
|
|
|
|
|
|
|
priv->auth_chains = g_slist_remove (priv->auth_chains, chain);
|
2010-06-02 02:16:14 -07:00
|
|
|
|
2012-10-08 12:52:15 -05:00
|
|
|
result = nm_auth_chain_get_result (chain, NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK);
|
2010-05-29 23:00:46 -07:00
|
|
|
if (error) {
|
|
|
|
|
nm_log_dbg (LOGD_CORE, "Enable request failed: %s", error->message);
|
|
|
|
|
ret_error = g_error_new (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"Enable request failed: %s",
|
|
|
|
|
error->message);
|
|
|
|
|
} else if (result != NM_AUTH_CALL_RESULT_YES) {
|
|
|
|
|
ret_error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"Not authorized to enable/disable networking");
|
|
|
|
|
} else {
|
2010-06-02 02:16:14 -07:00
|
|
|
/* Auth success */
|
|
|
|
|
enable = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, "enable"));
|
2010-05-29 23:00:46 -07:00
|
|
|
_internal_enable (self, enable);
|
|
|
|
|
dbus_g_method_return (context);
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-08 12:52:15 -05:00
|
|
|
if (ret_error) {
|
|
|
|
|
dbus_g_method_return_error (context, ret_error);
|
|
|
|
|
g_error_free (ret_error);
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-29 23:00:46 -07:00
|
|
|
nm_auth_chain_unref (chain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
impl_manager_enable (NMManager *self,
|
|
|
|
|
gboolean enable,
|
|
|
|
|
DBusGMethodInvocation *context)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv;
|
|
|
|
|
NMAuthChain *chain;
|
2010-05-30 08:30:37 -07:00
|
|
|
GError *error = NULL;
|
2012-12-16 12:30:41 -06:00
|
|
|
const char *error_desc;
|
2010-05-29 23:00:46 -07:00
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_MANAGER (self));
|
|
|
|
|
|
|
|
|
|
priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->net_enabled == enable) {
|
|
|
|
|
error = g_error_new (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_ALREADY_ENABLED_OR_DISABLED,
|
|
|
|
|
"Already %s", enable ? "enabled" : "disabled");
|
|
|
|
|
dbus_g_method_return_error (context, error);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-16 12:30:41 -06:00
|
|
|
chain = nm_auth_chain_new (context, enable_net_done_cb, self, &error_desc);
|
|
|
|
|
if (chain) {
|
|
|
|
|
priv->auth_chains = g_slist_append (priv->auth_chains, chain);
|
|
|
|
|
|
|
|
|
|
nm_auth_chain_set_data (chain, "enable", GUINT_TO_POINTER (enable), NULL);
|
|
|
|
|
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK, TRUE);
|
|
|
|
|
} else {
|
2010-05-30 08:30:37 -07:00
|
|
|
error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
2012-12-16 12:30:41 -06:00
|
|
|
error_desc);
|
2010-05-30 08:30:37 -07:00
|
|
|
dbus_g_method_return_error (context, error);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
2010-05-22 08:55:30 -07:00
|
|
|
}
|
|
|
|
|
|
2010-05-28 18:23:00 -07:00
|
|
|
/* Permissions */
|
|
|
|
|
|
2010-06-02 02:16:14 -07:00
|
|
|
static void
|
|
|
|
|
get_perm_add_result (NMAuthChain *chain, GHashTable *results, const char *permission)
|
|
|
|
|
{
|
|
|
|
|
NMAuthCallResult result;
|
|
|
|
|
|
2012-10-08 12:52:15 -05:00
|
|
|
result = nm_auth_chain_get_result (chain, permission);
|
2010-06-02 02:16:14 -07:00
|
|
|
if (result == NM_AUTH_CALL_RESULT_YES)
|
|
|
|
|
g_hash_table_insert (results, (char *) permission, "yes");
|
|
|
|
|
else if (result == NM_AUTH_CALL_RESULT_NO)
|
|
|
|
|
g_hash_table_insert (results, (char *) permission, "no");
|
|
|
|
|
else if (result == NM_AUTH_CALL_RESULT_AUTH)
|
|
|
|
|
g_hash_table_insert (results, (char *) permission, "auth");
|
|
|
|
|
else {
|
|
|
|
|
nm_log_dbg (LOGD_CORE, "unknown auth chain result %d", result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-28 18:23:00 -07:00
|
|
|
static void
|
|
|
|
|
get_permissions_done_cb (NMAuthChain *chain,
|
|
|
|
|
GError *error,
|
|
|
|
|
DBusGMethodInvocation *context,
|
2010-05-29 23:00:46 -07:00
|
|
|
gpointer user_data)
|
2010-05-28 18:23:00 -07:00
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GError *ret_error;
|
2010-06-02 02:16:14 -07:00
|
|
|
GHashTable *results;
|
2010-05-28 18:23:00 -07:00
|
|
|
|
|
|
|
|
priv->auth_chains = g_slist_remove (priv->auth_chains, chain);
|
|
|
|
|
if (error) {
|
|
|
|
|
nm_log_dbg (LOGD_CORE, "Permissions request failed: %s", error->message);
|
|
|
|
|
ret_error = g_error_new (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
"Permissions request failed: %s",
|
|
|
|
|
error->message);
|
|
|
|
|
dbus_g_method_return_error (context, ret_error);
|
|
|
|
|
g_error_free (ret_error);
|
|
|
|
|
} else {
|
2010-06-02 02:16:14 -07:00
|
|
|
results = g_hash_table_new (g_str_hash, g_str_equal);
|
2012-10-08 12:52:15 -05:00
|
|
|
|
2010-06-02 02:16:14 -07:00
|
|
|
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK);
|
|
|
|
|
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);
|
2011-01-02 17:34:23 -06:00
|
|
|
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX);
|
2010-06-02 02:23:51 -07:00
|
|
|
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_NETWORK_CONTROL);
|
2010-08-26 14:26:12 -05:00
|
|
|
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED);
|
|
|
|
|
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_WIFI_SHARE_OPEN);
|
2011-02-11 11:19:02 -06:00
|
|
|
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_SETTINGS_MODIFY_SYSTEM);
|
2011-02-11 11:27:08 -06:00
|
|
|
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_SETTINGS_MODIFY_OWN);
|
2011-02-11 11:32:57 -06:00
|
|
|
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_SETTINGS_MODIFY_HOSTNAME);
|
2012-10-08 12:52:15 -05:00
|
|
|
|
2010-06-02 02:16:14 -07:00
|
|
|
dbus_g_method_return (context, results);
|
|
|
|
|
g_hash_table_destroy (results);
|
2010-05-28 18:23:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nm_auth_chain_unref (chain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
impl_manager_get_permissions (NMManager *self,
|
|
|
|
|
DBusGMethodInvocation *context)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
NMAuthChain *chain;
|
2012-12-16 12:30:41 -06:00
|
|
|
const char *error_desc = NULL;
|
2012-10-08 12:52:15 -05:00
|
|
|
GError *error;
|
2010-05-28 18:23:00 -07:00
|
|
|
|
2012-12-16 12:30:41 -06:00
|
|
|
chain = nm_auth_chain_new (context, get_permissions_done_cb, self, &error_desc);
|
|
|
|
|
if (chain) {
|
2012-10-08 12:52:15 -05:00
|
|
|
priv->auth_chains = g_slist_append (priv->auth_chains, chain);
|
2010-05-28 18:23:00 -07:00
|
|
|
|
2012-10-08 12:52:15 -05:00
|
|
|
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK, FALSE);
|
|
|
|
|
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_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_MODIFY_SYSTEM, FALSE);
|
|
|
|
|
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_SETTINGS_MODIFY_OWN, FALSE);
|
|
|
|
|
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_SETTINGS_MODIFY_HOSTNAME, FALSE);
|
2012-12-16 12:30:41 -06:00
|
|
|
} else {
|
|
|
|
|
error = g_error_new_literal (NM_MANAGER_ERROR,
|
|
|
|
|
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
|
|
|
|
error_desc);
|
|
|
|
|
dbus_g_method_return_error (context, error);
|
|
|
|
|
g_error_free (error);
|
2012-10-08 12:52:15 -05:00
|
|
|
}
|
2010-05-28 18:23:00 -07:00
|
|
|
}
|
|
|
|
|
|
2011-03-08 12:57:35 -06:00
|
|
|
static gboolean
|
|
|
|
|
impl_manager_get_state (NMManager *manager, guint32 *state, GError **error)
|
|
|
|
|
{
|
|
|
|
|
nm_manager_update_state (manager);
|
|
|
|
|
*state = NM_MANAGER_GET_PRIVATE (manager)->state;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-08 08:56:17 -07:00
|
|
|
static gboolean
|
|
|
|
|
impl_manager_set_logging (NMManager *manager,
|
|
|
|
|
const char *level,
|
|
|
|
|
const char *domains,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
if (nm_logging_setup (level, domains, error)) {
|
2010-05-04 12:06:00 -07:00
|
|
|
char *new_domains = nm_logging_domains_to_string ();
|
|
|
|
|
|
|
|
|
|
nm_log_info (LOGD_CORE, "logging: level '%s' domains '%s'",
|
|
|
|
|
nm_logging_level_to_string (),
|
|
|
|
|
new_domains);
|
|
|
|
|
g_free (new_domains);
|
2010-04-08 08:56:17 -07:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2007-08-15 07:52:25 +00:00
|
|
|
|
2012-12-12 14:21:40 +01:00
|
|
|
static void
|
|
|
|
|
impl_manager_get_logging (NMManager *manager,
|
|
|
|
|
char **level,
|
|
|
|
|
char **domains)
|
|
|
|
|
{
|
|
|
|
|
*level = g_strdup (nm_logging_level_to_string ());
|
|
|
|
|
*domains = g_strdup (nm_logging_domains_to_string ());
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
void
|
|
|
|
|
nm_manager_start (NMManager *self)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2009-12-23 00:03:45 -08:00
|
|
|
guint i;
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2009-12-23 00:03:45 -08:00
|
|
|
/* Set initial radio enabled/disabled state */
|
|
|
|
|
for (i = 0; i < RFKILL_TYPE_MAX; i++) {
|
|
|
|
|
RadioState *rstate = &priv->radio_states[i];
|
2010-09-01 17:08:10 -05:00
|
|
|
RfKillState udev_state;
|
2011-04-13 21:58:25 -05:00
|
|
|
gboolean enabled;
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2009-12-23 00:03:45 -08:00
|
|
|
if (!rstate->desc)
|
|
|
|
|
continue;
|
|
|
|
|
|
2013-05-09 10:24:08 -04:00
|
|
|
udev_state = nm_rfkill_manager_get_rfkill_state (priv->rfkill_mgr, i);
|
2010-09-01 17:08:10 -05:00
|
|
|
update_rstate_from_rfkill (rstate, udev_state);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2010-09-01 17:08:10 -05:00
|
|
|
if (rstate->desc) {
|
|
|
|
|
nm_log_info (LOGD_RFKILL, "%s %s by radio killswitch; %s by state file",
|
|
|
|
|
rstate->desc,
|
|
|
|
|
(rstate->hw_enabled && rstate->sw_enabled) ? "enabled" : "disabled",
|
|
|
|
|
rstate->user_enabled ? "enabled" : "disabled");
|
|
|
|
|
}
|
2011-04-13 21:58:25 -05:00
|
|
|
enabled = radio_enabled_for_rstate (rstate, TRUE);
|
|
|
|
|
manager_update_radio_enabled (self, rstate, enabled);
|
2009-12-23 00:03:45 -08:00
|
|
|
}
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2010-05-22 08:55:30 -07:00
|
|
|
/* Log overall networking status - enabled/disabled */
|
2010-04-08 18:23:43 -07:00
|
|
|
nm_log_info (LOGD_CORE, "Networking is %s by state file",
|
2010-05-22 08:55:30 -07:00
|
|
|
priv->net_enabled ? "enabled" : "disabled");
|
2010-04-08 18:23:43 -07:00
|
|
|
|
2010-10-27 15:47:10 -05:00
|
|
|
system_unmanaged_devices_changed_cb (priv->settings, NULL, self);
|
|
|
|
|
system_hostname_changed_cb (priv->settings, NULL, self);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
core: only manage those bridges created by NetworkManager (rh #905035)
Until we handle bridges non-destructively, only manage bridges
created by NM. When quitting write out a file listing all
bridges created by NM and a timestamp, and when starting read
that file and if the timestamp is within 30 minutes, manage
any bridge that was listed in that file. This scheme, while
not foolproof (eg, if NM crashes), should ensure that NM can
recognize bridges it created if it's restarted. The file
is stored in /run or /var/run, which is cleaned each restart,
ensuring that the state does not persist across reboots.
If an automatic or user-initiated activation request for
a bridge NM does not manage is received, that request is
denied. Only if the bridge interface does not yet exist, or
was present in the managed bridges file, will an
NMDeviceBridge be created and activation be possible.
2013-02-01 18:03:11 -06:00
|
|
|
/* FIXME: remove when we handle bridges non-destructively */
|
|
|
|
|
/* Read a list of bridges NM managed when it last quit, and only
|
|
|
|
|
* manage those bridges to avoid conflicts with external tools.
|
|
|
|
|
*/
|
|
|
|
|
priv->nm_bridges = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
|
|
|
|
read_nm_created_bridges (self);
|
|
|
|
|
|
2013-05-29 12:00:50 -03:00
|
|
|
nm_platform_query_devices ();
|
2013-05-24 17:30:31 -03:00
|
|
|
nm_atm_manager_query_devices (priv->atm_mgr);
|
2012-05-11 11:17:18 -05:00
|
|
|
nm_bluez_manager_query_devices (priv->bluez_mgr);
|
2011-10-18 13:48:44 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Connections added before the manager is started do not emit
|
|
|
|
|
* connection-added signals thus devices have to be created manually.
|
|
|
|
|
*/
|
2012-02-10 13:25:39 -06:00
|
|
|
system_create_virtual_devices (self);
|
core: only manage those bridges created by NetworkManager (rh #905035)
Until we handle bridges non-destructively, only manage bridges
created by NM. When quitting write out a file listing all
bridges created by NM and a timestamp, and when starting read
that file and if the timestamp is within 30 minutes, manage
any bridge that was listed in that file. This scheme, while
not foolproof (eg, if NM crashes), should ensure that NM can
recognize bridges it created if it's restarted. The file
is stored in /run or /var/run, which is cleaned each restart,
ensuring that the state does not persist across reboots.
If an automatic or user-initiated activation request for
a bridge NM does not manage is received, that request is
denied. Only if the bridge interface does not yet exist, or
was present in the managed bridges file, will an
NMDeviceBridge be created and activation be possible.
2013-02-01 18:03:11 -06:00
|
|
|
|
|
|
|
|
/* FIXME: remove when we handle bridges non-destructively */
|
|
|
|
|
g_hash_table_unref (priv->nm_bridges);
|
|
|
|
|
priv->nm_bridges = NULL;
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
|
|
|
|
|
2010-07-01 10:32:11 -07:00
|
|
|
static gboolean
|
|
|
|
|
handle_firmware_changed (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
priv->fw_changed_id = 0;
|
|
|
|
|
|
|
|
|
|
if (manager_sleeping (self))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Try to re-enable devices with missing firmware */
|
|
|
|
|
for (iter = priv->devices; iter; iter = iter->next) {
|
|
|
|
|
NMDevice *candidate = NM_DEVICE (iter->data);
|
|
|
|
|
NMDeviceState state = nm_device_get_state (candidate);
|
|
|
|
|
|
|
|
|
|
if ( nm_device_get_firmware_missing (candidate)
|
|
|
|
|
&& (state == NM_DEVICE_STATE_UNAVAILABLE)) {
|
|
|
|
|
nm_log_info (LOGD_CORE, "(%s): firmware may now be available",
|
|
|
|
|
nm_device_get_iface (candidate));
|
|
|
|
|
|
|
|
|
|
/* Re-set unavailable state to try bringing the device up again */
|
|
|
|
|
nm_device_state_changed (candidate,
|
|
|
|
|
NM_DEVICE_STATE_UNAVAILABLE,
|
|
|
|
|
NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-05 15:11:13 -06:00
|
|
|
#if WITH_CONCHECK
|
2011-10-21 21:21:30 +02:00
|
|
|
static void
|
2011-12-13 17:35:36 -06:00
|
|
|
connectivity_changed (NMConnectivity *connectivity,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data)
|
2011-10-21 21:21:30 +02:00
|
|
|
{
|
2011-12-13 17:35:36 -06:00
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
gboolean connected;
|
2011-10-21 21:21:30 +02:00
|
|
|
|
2011-12-13 17:35:36 -06:00
|
|
|
connected = nm_connectivity_get_connected (connectivity);
|
2011-12-15 10:13:31 -06:00
|
|
|
nm_log_dbg (LOGD_CORE, "connectivity checking indicates %s",
|
2011-12-13 17:35:36 -06:00
|
|
|
connected ? "CONNECTED" : "NOT CONNECTED");
|
2011-10-21 21:21:30 +02:00
|
|
|
|
2011-12-13 17:35:36 -06:00
|
|
|
nm_manager_update_state (self);
|
2011-10-21 21:21:30 +02:00
|
|
|
}
|
2011-12-05 15:11:13 -06:00
|
|
|
#endif /* WITH_CONCHECK */
|
2011-10-21 21:21:30 +02:00
|
|
|
|
2010-07-01 10:32:11 -07:00
|
|
|
static void
|
|
|
|
|
firmware_dir_changed (GFileMonitor *monitor,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GFile *other_file,
|
|
|
|
|
GFileMonitorEvent event_type,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
switch (event_type) {
|
|
|
|
|
case G_FILE_MONITOR_EVENT_CREATED:
|
|
|
|
|
case G_FILE_MONITOR_EVENT_CHANGED:
|
|
|
|
|
case G_FILE_MONITOR_EVENT_MOVED:
|
|
|
|
|
case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
|
|
|
|
|
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
|
|
|
|
|
if (!priv->fw_changed_id) {
|
|
|
|
|
priv->fw_changed_id = g_timeout_add_seconds (4, handle_firmware_changed, self);
|
|
|
|
|
nm_log_info (LOGD_CORE, "kernel firmware directory '%s' changed",
|
|
|
|
|
KERNEL_FIRMWARE_DIR);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-17 17:01:10 +02:00
|
|
|
#define NM_PERM_DENIED_ERROR "org.freedesktop.NetworkManager.PermissionDenied"
|
|
|
|
|
#define DEV_PERM_DENIED_ERROR "org.freedesktop.NetworkManager.Device.PermissionDenied"
|
2010-08-25 15:12:32 -05:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
prop_set_auth_done_cb (NMAuthChain *chain,
|
|
|
|
|
GError *error,
|
|
|
|
|
DBusGMethodInvocation *context,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2012-10-07 16:45:41 -05:00
|
|
|
DBusConnection *connection;
|
2010-08-25 15:12:32 -05:00
|
|
|
NMAuthCallResult result;
|
2012-10-07 16:45:41 -05:00
|
|
|
DBusMessage *reply = NULL, *message;
|
|
|
|
|
const char *permission, *prop;
|
|
|
|
|
GObject *obj;
|
2010-08-25 15:12:32 -05:00
|
|
|
gboolean set_enabled = TRUE;
|
|
|
|
|
|
|
|
|
|
priv->auth_chains = g_slist_remove (priv->auth_chains, chain);
|
|
|
|
|
|
2012-10-07 16:45:41 -05:00
|
|
|
message = nm_auth_chain_get_data (chain, "message");
|
2010-08-25 15:12:32 -05:00
|
|
|
permission = nm_auth_chain_get_data (chain, "permission");
|
|
|
|
|
prop = nm_auth_chain_get_data (chain, "prop");
|
|
|
|
|
set_enabled = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, "enabled"));
|
2012-10-07 16:45:41 -05:00
|
|
|
obj = nm_auth_chain_get_data (chain, "object");
|
2010-08-25 15:12:32 -05:00
|
|
|
|
2012-10-08 12:52:15 -05:00
|
|
|
result = nm_auth_chain_get_result (chain, permission);
|
|
|
|
|
if (error || (result != NM_AUTH_CALL_RESULT_YES)) {
|
|
|
|
|
reply = dbus_message_new_error (message,
|
|
|
|
|
NM_IS_DEVICE (obj) ? DEV_PERM_DENIED_ERROR : NM_PERM_DENIED_ERROR,
|
2010-08-25 15:12:32 -05:00
|
|
|
"Not authorized to perform this operation");
|
|
|
|
|
} else {
|
2012-10-08 12:52:15 -05:00
|
|
|
g_object_set (obj, prop, set_enabled, NULL);
|
|
|
|
|
reply = dbus_message_new_method_return (message);
|
2010-08-25 15:12:32 -05:00
|
|
|
}
|
|
|
|
|
|
2012-10-08 12:52:15 -05:00
|
|
|
g_assert (reply);
|
|
|
|
|
connection = nm_auth_chain_get_data (chain, "connection");
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
dbus_connection_send (connection, reply, NULL);
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
|
2010-08-25 15:12:32 -05:00
|
|
|
nm_auth_chain_unref (chain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static DBusHandlerResult
|
|
|
|
|
prop_filter (DBusConnection *connection,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
void *user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
DBusMessageIter iter;
|
|
|
|
|
DBusMessageIter sub;
|
|
|
|
|
const char *propiface = NULL;
|
|
|
|
|
const char *propname = NULL;
|
|
|
|
|
const char *glib_propname = NULL, *permission = NULL;
|
2012-10-07 16:45:41 -05:00
|
|
|
gulong caller_uid = G_MAXULONG;
|
2010-08-25 15:12:32 -05:00
|
|
|
DBusMessage *reply = NULL;
|
|
|
|
|
gboolean set_enabled = FALSE;
|
|
|
|
|
NMAuthChain *chain;
|
2012-10-07 16:45:41 -05:00
|
|
|
GObject *obj;
|
2010-08-25 15:12:32 -05:00
|
|
|
|
|
|
|
|
/* The sole purpose of this function is to validate property accesses
|
|
|
|
|
* on the NMManager object since dbus-glib doesn't yet give us this
|
|
|
|
|
* functionality.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_is_method_call (message, DBUS_INTERFACE_PROPERTIES, "Set"))
|
|
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
|
|
|
|
|
|
|
dbus_message_iter_init (message, &iter);
|
|
|
|
|
|
|
|
|
|
/* Get the D-Bus interface of the property to set */
|
|
|
|
|
if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
|
|
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
|
|
dbus_message_iter_get_basic (&iter, &propiface);
|
2012-05-17 17:01:10 +02:00
|
|
|
if (!propiface || (strcmp (propiface, NM_DBUS_INTERFACE) && strcmp (propiface, NM_DBUS_INTERFACE_DEVICE)))
|
2010-08-25 15:12:32 -05:00
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
|
|
dbus_message_iter_next (&iter);
|
|
|
|
|
|
|
|
|
|
/* Get the property name that's going to be set */
|
|
|
|
|
if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
|
|
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
|
|
dbus_message_iter_get_basic (&iter, &propname);
|
|
|
|
|
dbus_message_iter_next (&iter);
|
|
|
|
|
|
|
|
|
|
if (!strcmp (propname, "WirelessEnabled")) {
|
|
|
|
|
glib_propname = NM_MANAGER_WIRELESS_ENABLED;
|
|
|
|
|
permission = NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI;
|
|
|
|
|
} else if (!strcmp (propname, "WwanEnabled")) {
|
|
|
|
|
glib_propname = NM_MANAGER_WWAN_ENABLED;
|
|
|
|
|
permission = NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN;
|
2011-01-02 17:34:23 -06:00
|
|
|
} else if (!strcmp (propname, "WimaxEnabled")) {
|
|
|
|
|
glib_propname = NM_MANAGER_WIMAX_ENABLED;
|
|
|
|
|
permission = NM_AUTH_PERMISSION_ENABLE_DISABLE_WIMAX;
|
2012-05-17 17:01:10 +02:00
|
|
|
} else if (!strcmp (propname, "Autoconnect")) {
|
|
|
|
|
glib_propname = NM_DEVICE_AUTOCONNECT;
|
|
|
|
|
permission = NM_AUTH_PERMISSION_NETWORK_CONTROL;
|
2010-08-25 15:12:32 -05:00
|
|
|
} else
|
|
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
|
|
|
|
|
|
|
/* Get the new value for the property */
|
|
|
|
|
if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_VARIANT)
|
|
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
|
|
dbus_message_iter_recurse (&iter, &sub);
|
|
|
|
|
if (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_BOOLEAN)
|
|
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
|
|
dbus_message_iter_get_basic (&sub, &set_enabled);
|
|
|
|
|
|
2012-10-07 16:45:41 -05:00
|
|
|
/* Make sure the object exists */
|
|
|
|
|
obj = dbus_g_connection_lookup_g_object (dbus_connection_get_g_connection (connection),
|
|
|
|
|
dbus_message_get_path (message));
|
|
|
|
|
if (!obj) {
|
2012-05-17 17:01:10 +02:00
|
|
|
reply = dbus_message_new_error (message, NM_PERM_DENIED_ERROR,
|
2012-10-07 16:45:41 -05:00
|
|
|
"Object does not exist");
|
2012-05-17 17:01:10 +02:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-07 16:45:41 -05:00
|
|
|
if (!nm_dbus_manager_get_caller_info_from_message (priv->dbus_mgr,
|
|
|
|
|
connection,
|
|
|
|
|
message,
|
|
|
|
|
NULL,
|
|
|
|
|
&caller_uid)) {
|
2012-05-17 17:01:10 +02:00
|
|
|
reply = dbus_message_new_error (message, NM_PERM_DENIED_ERROR,
|
2012-10-07 16:45:41 -05:00
|
|
|
"Could not determine request UID.");
|
2010-08-25 15:12:32 -05:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-16 12:30:41 -06:00
|
|
|
/* Validate the user request */
|
2012-10-08 12:52:15 -05:00
|
|
|
chain = nm_auth_chain_new_raw_message (message, caller_uid, prop_set_auth_done_cb, self);
|
|
|
|
|
g_assert (chain);
|
|
|
|
|
priv->auth_chains = g_slist_append (priv->auth_chains, chain);
|
|
|
|
|
nm_auth_chain_set_data (chain, "prop", g_strdup (glib_propname), g_free);
|
|
|
|
|
nm_auth_chain_set_data (chain, "permission", g_strdup (permission), g_free);
|
|
|
|
|
nm_auth_chain_set_data (chain, "enabled", GUINT_TO_POINTER (set_enabled), NULL);
|
|
|
|
|
nm_auth_chain_set_data (chain, "message", dbus_message_ref (message), (GDestroyNotify) dbus_message_unref);
|
|
|
|
|
nm_auth_chain_set_data (chain, "connection", dbus_connection_ref (connection), (GDestroyNotify) dbus_connection_unref);
|
|
|
|
|
nm_auth_chain_set_data (chain, "object", g_object_ref (obj), (GDestroyNotify) g_object_unref);
|
|
|
|
|
nm_auth_chain_add_call (chain, permission, TRUE);
|
2010-08-25 15:12:32 -05:00
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (reply) {
|
|
|
|
|
dbus_connection_send (connection, reply, NULL);
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
}
|
|
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-26 11:30:24 -05:00
|
|
|
static NMManager *singleton = NULL;
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
NMManager *
|
2011-09-26 11:30:24 -05:00
|
|
|
nm_manager_get (void)
|
|
|
|
|
{
|
|
|
|
|
g_assert (singleton);
|
|
|
|
|
return g_object_ref (singleton);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NMManager *
|
|
|
|
|
nm_manager_new (NMSettings *settings,
|
2009-11-02 17:29:53 -08:00
|
|
|
const char *state_file,
|
|
|
|
|
gboolean initial_net_enabled,
|
|
|
|
|
gboolean initial_wifi_enabled,
|
2009-12-22 23:51:08 -08:00
|
|
|
gboolean initial_wwan_enabled,
|
2011-01-12 15:46:37 -06:00
|
|
|
gboolean initial_wimax_enabled,
|
2009-11-02 17:29:53 -08:00
|
|
|
GError **error)
|
2009-06-11 00:39:12 -04:00
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv;
|
2009-08-10 23:25:11 -05:00
|
|
|
DBusGConnection *bus;
|
2010-08-25 15:12:32 -05:00
|
|
|
DBusConnection *dbus_connection;
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2010-10-27 15:47:10 -05:00
|
|
|
g_assert (settings);
|
|
|
|
|
|
2011-09-26 11:30:24 -05:00
|
|
|
/* Can only be called once */
|
|
|
|
|
g_assert (singleton == NULL);
|
2009-06-11 00:39:12 -04:00
|
|
|
singleton = (NMManager *) g_object_new (NM_TYPE_MANAGER, NULL);
|
|
|
|
|
g_assert (singleton);
|
|
|
|
|
|
|
|
|
|
priv = NM_MANAGER_GET_PRIVATE (singleton);
|
|
|
|
|
|
2011-12-05 15:11:13 -06:00
|
|
|
#if WITH_CONCHECK
|
2013-02-01 08:46:16 -06:00
|
|
|
priv->connectivity = nm_connectivity_new ();
|
2011-10-21 21:21:30 +02:00
|
|
|
|
2011-12-13 17:35:36 -06:00
|
|
|
g_signal_connect (priv->connectivity, "notify::" NM_CONNECTIVITY_CONNECTED,
|
|
|
|
|
G_CALLBACK (connectivity_changed), singleton);
|
2011-12-05 15:11:13 -06:00
|
|
|
#endif
|
2011-10-21 21:21:30 +02:00
|
|
|
|
2009-08-10 23:25:11 -05:00
|
|
|
bus = nm_dbus_manager_get_connection (priv->dbus_mgr);
|
|
|
|
|
g_assert (bus);
|
2010-08-25 15:12:32 -05:00
|
|
|
dbus_connection = dbus_g_connection_get_connection (bus);
|
|
|
|
|
g_assert (dbus_connection);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_add_filter (dbus_connection, prop_filter, singleton, NULL)) {
|
|
|
|
|
nm_log_err (LOGD_CORE, "failed to register DBus connection filter");
|
|
|
|
|
g_object_unref (singleton);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2009-08-10 23:25:11 -05:00
|
|
|
|
2010-10-27 16:50:57 -05:00
|
|
|
priv->settings = g_object_ref (settings);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2009-11-02 17:29:53 -08:00
|
|
|
priv->state_file = g_strdup (state_file);
|
|
|
|
|
|
2010-05-22 08:55:30 -07:00
|
|
|
priv->net_enabled = initial_net_enabled;
|
2009-11-02 17:29:53 -08:00
|
|
|
|
2010-09-01 17:08:10 -05:00
|
|
|
priv->radio_states[RFKILL_TYPE_WLAN].user_enabled = initial_wifi_enabled;
|
|
|
|
|
priv->radio_states[RFKILL_TYPE_WWAN].user_enabled = initial_wwan_enabled;
|
2011-01-02 17:24:23 -06:00
|
|
|
priv->radio_states[RFKILL_TYPE_WIMAX].user_enabled = initial_wimax_enabled;
|
2009-11-02 17:29:53 -08:00
|
|
|
|
2010-10-27 20:05:23 -05:00
|
|
|
g_signal_connect (priv->settings, "notify::" NM_SETTINGS_UNMANAGED_SPECS,
|
2009-06-11 00:39:12 -04:00
|
|
|
G_CALLBACK (system_unmanaged_devices_changed_cb), singleton);
|
2010-10-27 20:05:23 -05:00
|
|
|
g_signal_connect (priv->settings, "notify::" NM_SETTINGS_HOSTNAME,
|
2009-06-11 00:39:12 -04:00
|
|
|
G_CALLBACK (system_hostname_changed_cb), singleton);
|
2011-01-26 11:38:12 -06:00
|
|
|
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_ADDED,
|
2011-10-18 13:48:44 +02:00
|
|
|
G_CALLBACK (connection_added), singleton);
|
2011-01-26 11:38:12 -06:00
|
|
|
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_UPDATED,
|
2011-10-18 13:48:44 +02:00
|
|
|
G_CALLBACK (connection_changed), singleton);
|
2011-01-26 11:38:12 -06:00
|
|
|
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_REMOVED,
|
2011-10-18 13:48:44 +02:00
|
|
|
G_CALLBACK (connection_removed), singleton);
|
2011-01-26 11:38:12 -06:00
|
|
|
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_VISIBILITY_CHANGED,
|
2011-10-18 13:48:44 +02:00
|
|
|
G_CALLBACK (connection_changed), singleton);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2012-10-04 16:42:03 -05:00
|
|
|
nm_dbus_manager_register_object (priv->dbus_mgr, NM_DBUS_PATH, singleton);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2013-05-29 12:00:50 -03:00
|
|
|
g_signal_connect (nm_platform_get (),
|
|
|
|
|
"link-added",
|
|
|
|
|
G_CALLBACK (platform_link_added_cb),
|
2009-06-11 00:39:12 -04:00
|
|
|
singleton);
|
2013-05-29 12:00:50 -03:00
|
|
|
g_signal_connect (nm_platform_get (),
|
|
|
|
|
"link-removed",
|
|
|
|
|
G_CALLBACK (platform_link_removed_cb),
|
2009-06-11 00:39:12 -04:00
|
|
|
singleton);
|
2013-05-09 10:24:08 -04:00
|
|
|
|
2013-05-24 17:30:31 -03:00
|
|
|
priv->atm_mgr = nm_atm_manager_new ();
|
|
|
|
|
g_signal_connect (priv->atm_mgr,
|
|
|
|
|
"device-added",
|
|
|
|
|
G_CALLBACK (atm_device_added_cb),
|
|
|
|
|
singleton);
|
|
|
|
|
g_signal_connect (priv->atm_mgr,
|
|
|
|
|
"device-removed",
|
|
|
|
|
G_CALLBACK (atm_device_removed_cb),
|
|
|
|
|
singleton);
|
|
|
|
|
|
2013-05-09 10:24:08 -04:00
|
|
|
priv->rfkill_mgr = nm_rfkill_manager_new ();
|
|
|
|
|
g_signal_connect (priv->rfkill_mgr,
|
2009-06-11 00:39:12 -04:00
|
|
|
"rfkill-changed",
|
2013-05-09 10:24:08 -04:00
|
|
|
G_CALLBACK (rfkill_manager_rfkill_changed_cb),
|
2009-06-11 00:39:12 -04:00
|
|
|
singleton);
|
|
|
|
|
|
2012-05-11 11:17:18 -05:00
|
|
|
priv->bluez_mgr = nm_bluez_manager_get (NM_CONNECTION_PROVIDER (priv->settings));
|
2009-06-11 00:39:12 -04:00
|
|
|
|
|
|
|
|
g_signal_connect (priv->bluez_mgr,
|
2012-05-11 11:17:18 -05:00
|
|
|
NM_BLUEZ_MANAGER_BDADDR_ADDED,
|
|
|
|
|
G_CALLBACK (bluez_manager_bdaddr_added_cb),
|
|
|
|
|
singleton);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
|
|
|
|
g_signal_connect (priv->bluez_mgr,
|
2012-05-11 11:17:18 -05:00
|
|
|
NM_BLUEZ_MANAGER_BDADDR_REMOVED,
|
|
|
|
|
G_CALLBACK (bluez_manager_bdaddr_removed_cb),
|
|
|
|
|
singleton);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2013-02-06 12:59:50 -06:00
|
|
|
/* Force kernel WiFi rfkill state to follow NM saved wifi state in case
|
|
|
|
|
* the BIOS doesn't save rfkill state, and to be consistent with user
|
|
|
|
|
* changes to the WirelessEnabled property which toggles kernel rfkill.
|
|
|
|
|
*/
|
|
|
|
|
rfkill_change_wifi (priv->radio_states[RFKILL_TYPE_WLAN].desc, initial_wifi_enabled);
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
return singleton;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-01 14:16:52 -05:00
|
|
|
static void
|
|
|
|
|
authority_changed_cb (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
/* Let clients know they should re-check their authorization */
|
|
|
|
|
g_signal_emit (NM_MANAGER (user_data), signals[CHECK_PERMISSIONS], 0);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
static void
|
|
|
|
|
dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMManager *manager = NM_MANAGER (object);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
2010-08-25 15:12:32 -05:00
|
|
|
DBusGConnection *bus;
|
|
|
|
|
DBusConnection *dbus_connection;
|
2012-08-22 17:11:31 -05:00
|
|
|
GSList *iter;
|
2009-06-11 00:39:12 -04:00
|
|
|
|
|
|
|
|
if (priv->disposed) {
|
|
|
|
|
G_OBJECT_CLASS (nm_manager_parent_class)->dispose (object);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
priv->disposed = TRUE;
|
|
|
|
|
|
2010-05-28 18:23:00 -07:00
|
|
|
g_slist_foreach (priv->auth_chains, (GFunc) nm_auth_chain_unref, NULL);
|
|
|
|
|
g_slist_free (priv->auth_chains);
|
2011-05-18 22:20:24 -05:00
|
|
|
|
2011-07-01 14:16:52 -05:00
|
|
|
nm_auth_changed_func_unregister (authority_changed_cb, manager);
|
2010-05-28 18:23:00 -07:00
|
|
|
|
core: only manage those bridges created by NetworkManager (rh #905035)
Until we handle bridges non-destructively, only manage bridges
created by NM. When quitting write out a file listing all
bridges created by NM and a timestamp, and when starting read
that file and if the timestamp is within 30 minutes, manage
any bridge that was listed in that file. This scheme, while
not foolproof (eg, if NM crashes), should ensure that NM can
recognize bridges it created if it's restarted. The file
is stored in /run or /var/run, which is cleaned each restart,
ensuring that the state does not persist across reboots.
If an automatic or user-initiated activation request for
a bridge NM does not manage is received, that request is
denied. Only if the bridge interface does not yet exist, or
was present in the managed bridges file, will an
NMDeviceBridge be created and activation be possible.
2013-02-01 18:03:11 -06:00
|
|
|
/* FIXME: remove when we handle bridges non-destructively */
|
|
|
|
|
write_nm_created_bridges (manager);
|
|
|
|
|
|
|
|
|
|
/* Remove all devices */
|
2009-06-11 00:39:12 -04:00
|
|
|
while (g_slist_length (priv->devices)) {
|
2009-09-10 17:49:11 -07:00
|
|
|
priv->devices = remove_one_device (manager,
|
|
|
|
|
priv->devices,
|
|
|
|
|
NM_DEVICE (priv->devices->data),
|
2010-08-11 17:26:33 -05:00
|
|
|
TRUE);
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
|
|
|
|
|
2012-08-22 17:11:31 -05:00
|
|
|
if (priv->ac_cleanup_id) {
|
|
|
|
|
g_source_remove (priv->ac_cleanup_id);
|
|
|
|
|
priv->ac_cleanup_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (iter = priv->active_connections; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
g_signal_handlers_disconnect_by_func (iter->data, active_connection_state_changed, object);
|
|
|
|
|
g_object_unref (iter->data);
|
|
|
|
|
}
|
|
|
|
|
g_slist_free (priv->active_connections);
|
|
|
|
|
|
2011-12-05 15:11:13 -06:00
|
|
|
#if WITH_CONCHECK
|
2011-10-21 21:21:30 +02:00
|
|
|
if (priv->connectivity) {
|
|
|
|
|
g_object_unref (priv->connectivity);
|
|
|
|
|
priv->connectivity = NULL;
|
|
|
|
|
}
|
2011-12-05 15:11:13 -06:00
|
|
|
#endif
|
2011-10-21 21:21:30 +02:00
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
g_free (priv->hostname);
|
|
|
|
|
|
2010-10-27 15:47:10 -05:00
|
|
|
g_object_unref (priv->settings);
|
2009-06-11 00:39:12 -04:00
|
|
|
g_object_unref (priv->vpn_manager);
|
|
|
|
|
|
|
|
|
|
if (priv->modem_added_id) {
|
|
|
|
|
g_source_remove (priv->modem_added_id);
|
|
|
|
|
priv->modem_added_id = 0;
|
|
|
|
|
}
|
|
|
|
|
if (priv->modem_removed_id) {
|
|
|
|
|
g_source_remove (priv->modem_removed_id);
|
|
|
|
|
priv->modem_removed_id = 0;
|
|
|
|
|
}
|
|
|
|
|
g_object_unref (priv->modem_manager);
|
|
|
|
|
|
2010-08-25 15:12:32 -05:00
|
|
|
/* Unregister property filter */
|
|
|
|
|
bus = nm_dbus_manager_get_connection (priv->dbus_mgr);
|
2011-01-02 10:49:36 -06:00
|
|
|
if (bus) {
|
|
|
|
|
dbus_connection = dbus_g_connection_get_connection (bus);
|
|
|
|
|
g_assert (dbus_connection);
|
|
|
|
|
dbus_connection_remove_filter (dbus_connection, prop_filter, manager);
|
|
|
|
|
}
|
2013-03-20 08:51:08 -05:00
|
|
|
g_signal_handler_disconnect (priv->dbus_mgr, priv->dbus_connection_changed_id);
|
2013-04-10 11:37:05 -05:00
|
|
|
priv->dbus_mgr = NULL;
|
2010-08-25 15:12:32 -05:00
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
if (priv->bluez_mgr)
|
|
|
|
|
g_object_unref (priv->bluez_mgr);
|
|
|
|
|
|
2010-08-31 15:47:16 -05:00
|
|
|
if (priv->aipd_proxy)
|
|
|
|
|
g_object_unref (priv->aipd_proxy);
|
|
|
|
|
|
2012-10-09 00:36:35 -04:00
|
|
|
if (priv->sleep_monitor)
|
|
|
|
|
g_object_unref (priv->sleep_monitor);
|
2010-08-31 15:45:55 -05:00
|
|
|
|
2010-07-01 10:32:11 -07:00
|
|
|
if (priv->fw_monitor) {
|
|
|
|
|
if (priv->fw_monitor_id)
|
|
|
|
|
g_signal_handler_disconnect (priv->fw_monitor, priv->fw_monitor_id);
|
|
|
|
|
|
|
|
|
|
if (priv->fw_changed_id)
|
|
|
|
|
g_source_remove (priv->fw_changed_id);
|
|
|
|
|
|
|
|
|
|
g_file_monitor_cancel (priv->fw_monitor);
|
|
|
|
|
g_object_unref (priv->fw_monitor);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-05 23:18:32 -06:00
|
|
|
g_slist_free (priv->factories);
|
|
|
|
|
|
2010-10-19 11:10:17 +02:00
|
|
|
if (priv->timestamp_update_id) {
|
|
|
|
|
g_source_remove (priv->timestamp_update_id);
|
|
|
|
|
priv->timestamp_update_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
G_OBJECT_CLASS (nm_manager_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-22 14:56:31 -05:00
|
|
|
#define KERN_RFKILL_OP_CHANGE_ALL 3
|
|
|
|
|
#define KERN_RFKILL_TYPE_WLAN 1
|
|
|
|
|
struct rfkill_event {
|
|
|
|
|
__u32 idx;
|
|
|
|
|
__u8 type;
|
|
|
|
|
__u8 op;
|
|
|
|
|
__u8 soft, hard;
|
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
rfkill_change_wifi (const char *desc, gboolean enabled)
|
|
|
|
|
{
|
|
|
|
|
int fd;
|
|
|
|
|
struct rfkill_event event;
|
|
|
|
|
ssize_t len;
|
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
fd = open ("/dev/rfkill", O_RDWR);
|
|
|
|
|
if (fd < 0) {
|
|
|
|
|
if (errno == EACCES)
|
|
|
|
|
nm_log_warn (LOGD_RFKILL, "(%s): failed to open killswitch device "
|
|
|
|
|
"for WiFi radio control", desc);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fcntl (fd, F_SETFL, O_NONBLOCK) < 0) {
|
|
|
|
|
nm_log_warn (LOGD_RFKILL, "(%s): failed to set killswitch device for "
|
|
|
|
|
"non-blocking operation", desc);
|
|
|
|
|
close (fd);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset (&event, 0, sizeof (event));
|
|
|
|
|
event.op = KERN_RFKILL_OP_CHANGE_ALL;
|
|
|
|
|
event.type = KERN_RFKILL_TYPE_WLAN;
|
|
|
|
|
event.soft = enabled ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
len = write (fd, &event, sizeof (event));
|
|
|
|
|
if (len < 0) {
|
|
|
|
|
nm_log_warn (LOGD_RFKILL, "(%s): failed to change WiFi killswitch state: (%d) %s",
|
|
|
|
|
desc, errno, g_strerror (errno));
|
|
|
|
|
} else if (len == sizeof (event)) {
|
|
|
|
|
nm_log_info (LOGD_RFKILL, "%s hardware radio set %s",
|
|
|
|
|
desc, enabled ? "enabled" : "disabled");
|
|
|
|
|
} else {
|
|
|
|
|
/* Failed to write full structure */
|
|
|
|
|
nm_log_warn (LOGD_RFKILL, "(%s): failed to change WiFi killswitch state", desc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
close (fd);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-01 17:08:10 -05:00
|
|
|
static void
|
|
|
|
|
manager_radio_user_toggled (NMManager *self,
|
|
|
|
|
RadioState *rstate,
|
|
|
|
|
gboolean enabled)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
gboolean old_enabled, new_enabled;
|
|
|
|
|
|
|
|
|
|
if (rstate->desc) {
|
|
|
|
|
nm_log_dbg (LOGD_RFKILL, "(%s): setting radio %s by user",
|
|
|
|
|
rstate->desc,
|
|
|
|
|
enabled ? "enabled" : "disabled");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Update enabled key in state file */
|
|
|
|
|
if (priv->state_file) {
|
|
|
|
|
if (!write_value_to_state_file (priv->state_file,
|
|
|
|
|
"main", rstate->key,
|
|
|
|
|
G_TYPE_BOOLEAN, (gpointer) &enabled,
|
|
|
|
|
&error)) {
|
|
|
|
|
nm_log_warn (LOGD_CORE, "writing to state file %s failed: (%d) %s.",
|
|
|
|
|
priv->state_file,
|
|
|
|
|
error ? error->code : -1,
|
|
|
|
|
(error && error->message) ? error->message : "unknown");
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-13 21:58:25 -05:00
|
|
|
/* When the user toggles the radio, their request should override any
|
|
|
|
|
* daemon (like ModemManager) enabled state that can be changed. For WWAN
|
|
|
|
|
* for example, we want the WwanEnabled property to reflect the daemon state
|
|
|
|
|
* too so that users can toggle the modem powered, but we don't want that
|
|
|
|
|
* daemon state to affect whether or not the user *can* turn it on, which is
|
|
|
|
|
* what the kernel rfkill state does. So we ignore daemon enabled state
|
|
|
|
|
* when determining what the new state should be since it shouldn't block
|
|
|
|
|
* the user's request.
|
|
|
|
|
*/
|
|
|
|
|
old_enabled = radio_enabled_for_rstate (rstate, TRUE);
|
2010-09-01 17:08:10 -05:00
|
|
|
rstate->user_enabled = enabled;
|
2011-04-13 21:58:25 -05:00
|
|
|
new_enabled = radio_enabled_for_rstate (rstate, FALSE);
|
2011-04-22 14:56:31 -05:00
|
|
|
if (new_enabled != old_enabled) {
|
2011-04-13 21:58:25 -05:00
|
|
|
manager_update_radio_enabled (self, rstate, new_enabled);
|
2011-04-22 14:56:31 -05:00
|
|
|
|
|
|
|
|
/* For WiFi only (for now) set the actual kernel rfkill state */
|
|
|
|
|
if (rstate->rtype == RFKILL_TYPE_WLAN)
|
|
|
|
|
rfkill_change_wifi (rstate->desc, new_enabled);
|
|
|
|
|
}
|
2010-09-01 17:08:10 -05:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
static void
|
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
2009-12-23 00:03:45 -08:00
|
|
|
NMManager *self = NM_MANAGER (object);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
switch (prop_id) {
|
2010-05-22 08:55:30 -07:00
|
|
|
case PROP_NETWORKING_ENABLED:
|
|
|
|
|
/* Construct only for now */
|
|
|
|
|
priv->net_enabled = g_value_get_boolean (value);
|
|
|
|
|
break;
|
2009-06-11 00:39:12 -04:00
|
|
|
case PROP_WIRELESS_ENABLED:
|
2010-09-01 17:08:10 -05:00
|
|
|
manager_radio_user_toggled (NM_MANAGER (object),
|
|
|
|
|
&priv->radio_states[RFKILL_TYPE_WLAN],
|
|
|
|
|
g_value_get_boolean (value));
|
2009-06-11 00:39:12 -04:00
|
|
|
break;
|
2009-12-23 00:18:18 -08:00
|
|
|
case PROP_WWAN_ENABLED:
|
2010-09-01 17:08:10 -05:00
|
|
|
manager_radio_user_toggled (NM_MANAGER (object),
|
|
|
|
|
&priv->radio_states[RFKILL_TYPE_WWAN],
|
|
|
|
|
g_value_get_boolean (value));
|
2009-06-11 00:39:12 -04:00
|
|
|
break;
|
2009-12-29 11:27:10 +02:00
|
|
|
case PROP_WIMAX_ENABLED:
|
2011-01-02 17:34:23 -06:00
|
|
|
manager_radio_user_toggled (NM_MANAGER (object),
|
|
|
|
|
&priv->radio_states[RFKILL_TYPE_WIMAX],
|
|
|
|
|
g_value_get_boolean (value));
|
2009-12-29 11:27:10 +02:00
|
|
|
break;
|
2009-06-11 00:39:12 -04:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (object);
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
2012-08-22 17:21:56 -05:00
|
|
|
GSList *iter;
|
|
|
|
|
GPtrArray *active;
|
|
|
|
|
const char *path;
|
2009-06-11 00:39:12 -04:00
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2010-09-27 10:34:56 +02:00
|
|
|
case PROP_VERSION:
|
|
|
|
|
g_value_set_string (value, VERSION);
|
|
|
|
|
break;
|
2009-06-11 00:39:12 -04:00
|
|
|
case PROP_STATE:
|
|
|
|
|
nm_manager_update_state (self);
|
|
|
|
|
g_value_set_uint (value, priv->state);
|
|
|
|
|
break;
|
2010-05-22 08:55:30 -07:00
|
|
|
case PROP_NETWORKING_ENABLED:
|
|
|
|
|
g_value_set_boolean (value, priv->net_enabled);
|
|
|
|
|
break;
|
2009-06-11 00:39:12 -04:00
|
|
|
case PROP_WIRELESS_ENABLED:
|
2011-04-13 21:58:25 -05:00
|
|
|
g_value_set_boolean (value, radio_enabled_for_type (self, RFKILL_TYPE_WLAN, TRUE));
|
2009-06-11 00:39:12 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_WIRELESS_HARDWARE_ENABLED:
|
2009-12-23 00:03:45 -08:00
|
|
|
g_value_set_boolean (value, priv->radio_states[RFKILL_TYPE_WLAN].hw_enabled);
|
2009-06-11 00:39:12 -04:00
|
|
|
break;
|
2009-12-23 00:18:18 -08:00
|
|
|
case PROP_WWAN_ENABLED:
|
2011-04-13 21:58:25 -05:00
|
|
|
g_value_set_boolean (value, radio_enabled_for_type (self, RFKILL_TYPE_WWAN, TRUE));
|
2009-12-23 00:18:18 -08:00
|
|
|
break;
|
|
|
|
|
case PROP_WWAN_HARDWARE_ENABLED:
|
|
|
|
|
g_value_set_boolean (value, priv->radio_states[RFKILL_TYPE_WWAN].hw_enabled);
|
2009-06-11 00:39:12 -04:00
|
|
|
break;
|
2009-12-29 11:27:10 +02:00
|
|
|
case PROP_WIMAX_ENABLED:
|
2011-04-13 21:58:25 -05:00
|
|
|
g_value_set_boolean (value, radio_enabled_for_type (self, RFKILL_TYPE_WIMAX, TRUE));
|
2009-12-29 11:27:10 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_WIMAX_HARDWARE_ENABLED:
|
|
|
|
|
g_value_set_boolean (value, priv->radio_states[RFKILL_TYPE_WIMAX].hw_enabled);
|
|
|
|
|
break;
|
2009-06-11 00:39:12 -04:00
|
|
|
case PROP_ACTIVE_CONNECTIONS:
|
2012-08-22 17:21:56 -05:00
|
|
|
active = g_ptr_array_sized_new (3);
|
|
|
|
|
for (iter = priv->active_connections; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
path = nm_active_connection_get_path (NM_ACTIVE_CONNECTION (iter->data));
|
|
|
|
|
g_ptr_array_add (active, g_strdup (path));
|
|
|
|
|
}
|
|
|
|
|
g_value_take_boxed (value, active);
|
2009-06-11 00:39:12 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_HOSTNAME:
|
|
|
|
|
g_value_set_string (value, priv->hostname);
|
|
|
|
|
break;
|
2009-10-20 15:25:04 -07:00
|
|
|
case PROP_SLEEPING:
|
|
|
|
|
g_value_set_boolean (value, priv->sleeping);
|
|
|
|
|
break;
|
2009-06-11 00:39:12 -04:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 11:10:17 +02:00
|
|
|
static gboolean
|
|
|
|
|
periodic_update_active_connection_timestamps (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *manager = NM_MANAGER (user_data);
|
2011-09-15 14:21:45 +02:00
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
2012-08-22 17:25:10 -05:00
|
|
|
GSList *iter;
|
2010-10-19 11:10:17 +02:00
|
|
|
|
2012-08-22 17:25:10 -05:00
|
|
|
for (iter = priv->active_connections; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMActiveConnection *ac = iter->data;
|
|
|
|
|
NMSettingsConnection *connection;
|
2011-09-15 14:21:45 +02:00
|
|
|
|
2012-08-22 17:25:10 -05:00
|
|
|
if (nm_active_connection_get_state (ac) == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
|
|
|
|
connection = NM_SETTINGS_CONNECTION (nm_active_connection_get_connection (ac));
|
|
|
|
|
nm_settings_connection_update_timestamp (connection, (guint64) time (NULL), FALSE);
|
2011-09-15 14:21:45 +02:00
|
|
|
}
|
2010-10-19 11:10:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-20 08:51:08 -05:00
|
|
|
static void
|
|
|
|
|
dbus_connection_changed_cb (NMDBusManager *dbus_mgr,
|
|
|
|
|
DBusGConnection *connection,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMManager *self = NM_MANAGER (user_data);
|
|
|
|
|
DBusConnection *dbus_connection;
|
|
|
|
|
|
|
|
|
|
if (connection) {
|
|
|
|
|
dbus_connection = dbus_g_connection_get_connection (connection);
|
|
|
|
|
g_assert (dbus_connection);
|
|
|
|
|
|
|
|
|
|
/* Register property filter on new connection; there's no reason this
|
|
|
|
|
* should fail except out-of-memory or program error; if it does fail
|
|
|
|
|
* then there's no Manager property access control, which is bad.
|
|
|
|
|
*/
|
|
|
|
|
g_assert (dbus_connection_add_filter (dbus_connection, prop_filter, self, NULL));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
static void
|
|
|
|
|
nm_manager_init (NMManager *manager)
|
|
|
|
|
{
|
|
|
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
|
|
|
|
DBusGConnection *g_connection;
|
2011-09-15 14:21:45 +02:00
|
|
|
guint i;
|
2010-07-01 10:32:11 -07:00
|
|
|
GFile *file;
|
2009-12-23 00:03:45 -08:00
|
|
|
|
|
|
|
|
/* Initialize rfkill structures and states */
|
|
|
|
|
memset (priv->radio_states, 0, sizeof (priv->radio_states));
|
|
|
|
|
|
2010-09-01 17:08:10 -05:00
|
|
|
priv->radio_states[RFKILL_TYPE_WLAN].user_enabled = TRUE;
|
2009-12-23 00:03:45 -08:00
|
|
|
priv->radio_states[RFKILL_TYPE_WLAN].key = "WirelessEnabled";
|
|
|
|
|
priv->radio_states[RFKILL_TYPE_WLAN].prop = NM_MANAGER_WIRELESS_ENABLED;
|
|
|
|
|
priv->radio_states[RFKILL_TYPE_WLAN].hw_prop = NM_MANAGER_WIRELESS_HARDWARE_ENABLED;
|
|
|
|
|
priv->radio_states[RFKILL_TYPE_WLAN].desc = "WiFi";
|
|
|
|
|
priv->radio_states[RFKILL_TYPE_WLAN].other_enabled_func = nm_manager_get_ipw_rfkill_state;
|
2010-03-25 11:36:19 -07:00
|
|
|
priv->radio_states[RFKILL_TYPE_WLAN].rtype = RFKILL_TYPE_WLAN;
|
2009-12-23 00:03:45 -08:00
|
|
|
|
2010-09-01 17:08:10 -05:00
|
|
|
priv->radio_states[RFKILL_TYPE_WWAN].user_enabled = TRUE;
|
2009-12-23 00:18:18 -08:00
|
|
|
priv->radio_states[RFKILL_TYPE_WWAN].key = "WWANEnabled";
|
|
|
|
|
priv->radio_states[RFKILL_TYPE_WWAN].prop = NM_MANAGER_WWAN_ENABLED;
|
|
|
|
|
priv->radio_states[RFKILL_TYPE_WWAN].hw_prop = NM_MANAGER_WWAN_HARDWARE_ENABLED;
|
|
|
|
|
priv->radio_states[RFKILL_TYPE_WWAN].desc = "WWAN";
|
2011-04-13 21:58:25 -05:00
|
|
|
priv->radio_states[RFKILL_TYPE_WWAN].daemon_enabled_func = nm_manager_get_modem_enabled_state;
|
2010-03-25 11:36:19 -07:00
|
|
|
priv->radio_states[RFKILL_TYPE_WWAN].rtype = RFKILL_TYPE_WWAN;
|
2009-12-23 00:18:18 -08:00
|
|
|
|
2010-09-01 17:08:10 -05:00
|
|
|
priv->radio_states[RFKILL_TYPE_WIMAX].user_enabled = TRUE;
|
2010-04-08 18:23:43 -07:00
|
|
|
priv->radio_states[RFKILL_TYPE_WIMAX].key = "WiMAXEnabled";
|
2009-12-29 11:27:10 +02:00
|
|
|
priv->radio_states[RFKILL_TYPE_WIMAX].prop = NM_MANAGER_WIMAX_ENABLED;
|
|
|
|
|
priv->radio_states[RFKILL_TYPE_WIMAX].hw_prop = NM_MANAGER_WIMAX_HARDWARE_ENABLED;
|
2010-04-08 18:23:43 -07:00
|
|
|
priv->radio_states[RFKILL_TYPE_WIMAX].desc = "WiMAX";
|
|
|
|
|
priv->radio_states[RFKILL_TYPE_WIMAX].other_enabled_func = NULL;
|
|
|
|
|
priv->radio_states[RFKILL_TYPE_WIMAX].rtype = RFKILL_TYPE_WIMAX;
|
|
|
|
|
|
2009-12-23 00:03:45 -08:00
|
|
|
for (i = 0; i < RFKILL_TYPE_MAX; i++)
|
|
|
|
|
priv->radio_states[i].hw_enabled = TRUE;
|
2009-06-11 00:39:12 -04:00
|
|
|
|
|
|
|
|
priv->sleeping = FALSE;
|
|
|
|
|
priv->state = NM_STATE_DISCONNECTED;
|
|
|
|
|
|
|
|
|
|
priv->dbus_mgr = nm_dbus_manager_get ();
|
2013-03-20 08:51:08 -05:00
|
|
|
priv->dbus_connection_changed_id = g_signal_connect (priv->dbus_mgr,
|
|
|
|
|
NM_DBUS_MANAGER_DBUS_CONNECTION_CHANGED,
|
|
|
|
|
G_CALLBACK (dbus_connection_changed_cb),
|
|
|
|
|
manager);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
|
|
|
|
priv->modem_manager = nm_modem_manager_get ();
|
2009-10-04 23:35:20 -07:00
|
|
|
priv->modem_added_id = g_signal_connect (priv->modem_manager, "modem-added",
|
2009-06-11 00:39:12 -04:00
|
|
|
G_CALLBACK (modem_added), manager);
|
2009-10-04 23:35:20 -07:00
|
|
|
priv->modem_removed_id = g_signal_connect (priv->modem_manager, "modem-removed",
|
2009-06-11 00:39:12 -04:00
|
|
|
G_CALLBACK (modem_removed), manager);
|
|
|
|
|
|
|
|
|
|
priv->vpn_manager = nm_vpn_manager_get ();
|
|
|
|
|
|
|
|
|
|
g_connection = nm_dbus_manager_get_connection (priv->dbus_mgr);
|
|
|
|
|
|
|
|
|
|
/* avahi-autoipd stuff */
|
|
|
|
|
priv->aipd_proxy = dbus_g_proxy_new_for_name (g_connection,
|
|
|
|
|
NM_AUTOIP_DBUS_SERVICE,
|
|
|
|
|
"/",
|
|
|
|
|
NM_AUTOIP_DBUS_IFACE);
|
|
|
|
|
if (priv->aipd_proxy) {
|
2013-05-06 13:37:25 -04:00
|
|
|
dbus_g_object_register_marshaller (g_cclosure_marshal_generic,
|
2009-06-11 00:39:12 -04:00
|
|
|
G_TYPE_NONE,
|
|
|
|
|
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (priv->aipd_proxy,
|
|
|
|
|
"Event",
|
|
|
|
|
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_connect_signal (priv->aipd_proxy, "Event",
|
|
|
|
|
G_CALLBACK (aipd_handle_event),
|
|
|
|
|
manager,
|
|
|
|
|
NULL);
|
|
|
|
|
} else
|
2010-04-06 16:20:11 -07:00
|
|
|
nm_log_warn (LOGD_AUTOIP4, "could not initialize avahi-autoipd D-Bus proxy");
|
2010-05-28 18:23:00 -07:00
|
|
|
|
2012-10-09 00:36:35 -04:00
|
|
|
/* sleep/wake handling */
|
|
|
|
|
priv->sleep_monitor = nm_sleep_monitor_get ();
|
2012-10-14 10:44:34 -05:00
|
|
|
g_signal_connect (priv->sleep_monitor, "sleeping",
|
|
|
|
|
G_CALLBACK (sleeping_cb), manager);
|
|
|
|
|
g_signal_connect (priv->sleep_monitor, "resuming",
|
|
|
|
|
G_CALLBACK (resuming_cb), manager);
|
2010-08-31 15:45:55 -05:00
|
|
|
|
2011-05-18 22:20:24 -05:00
|
|
|
/* Listen for authorization changes */
|
2011-07-01 14:16:52 -05:00
|
|
|
nm_auth_changed_func_register (authority_changed_cb, manager);
|
2010-07-01 10:32:11 -07:00
|
|
|
|
|
|
|
|
/* Monitor the firmware directory */
|
|
|
|
|
if (strlen (KERNEL_FIRMWARE_DIR)) {
|
|
|
|
|
file = g_file_new_for_path (KERNEL_FIRMWARE_DIR "/");
|
|
|
|
|
priv->fw_monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL);
|
|
|
|
|
g_object_unref (file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->fw_monitor) {
|
|
|
|
|
priv->fw_monitor_id = g_signal_connect (priv->fw_monitor, "changed",
|
|
|
|
|
G_CALLBACK (firmware_dir_changed),
|
|
|
|
|
manager);
|
|
|
|
|
nm_log_info (LOGD_CORE, "monitoring kernel firmware directory '%s'.",
|
|
|
|
|
KERNEL_FIRMWARE_DIR);
|
|
|
|
|
} else {
|
|
|
|
|
nm_log_warn (LOGD_CORE, "failed to monitor kernel firmware directory '%s'.",
|
|
|
|
|
KERNEL_FIRMWARE_DIR);
|
|
|
|
|
}
|
2010-10-19 11:10:17 +02:00
|
|
|
|
2012-02-05 23:18:32 -06:00
|
|
|
load_device_factories (manager);
|
|
|
|
|
|
2010-10-19 11:10:17 +02:00
|
|
|
/* Update timestamps in active connections */
|
|
|
|
|
priv->timestamp_update_id = g_timeout_add_seconds (300, (GSourceFunc) periodic_update_active_connection_timestamps, manager);
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_manager_class_init (NMManagerClass *manager_class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (manager_class);
|
|
|
|
|
|
|
|
|
|
g_type_class_add_private (manager_class, sizeof (NMManagerPrivate));
|
|
|
|
|
|
|
|
|
|
/* virtual methods */
|
|
|
|
|
object_class->set_property = set_property;
|
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
|
object_class->dispose = dispose;
|
|
|
|
|
|
|
|
|
|
/* properties */
|
2010-09-27 10:34:56 +02:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_VERSION,
|
|
|
|
|
g_param_spec_string (NM_MANAGER_VERSION,
|
|
|
|
|
"Version",
|
|
|
|
|
"NetworkManager version",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_STATE,
|
|
|
|
|
g_param_spec_uint (NM_MANAGER_STATE,
|
|
|
|
|
"State",
|
|
|
|
|
"Current state",
|
|
|
|
|
0, NM_STATE_DISCONNECTED, 0,
|
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
2010-05-22 08:55:30 -07:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_NETWORKING_ENABLED,
|
|
|
|
|
g_param_spec_boolean (NM_MANAGER_NETWORKING_ENABLED,
|
|
|
|
|
"NetworkingEnabled",
|
|
|
|
|
"Is networking enabled",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_WIRELESS_ENABLED,
|
|
|
|
|
g_param_spec_boolean (NM_MANAGER_WIRELESS_ENABLED,
|
|
|
|
|
"WirelessEnabled",
|
|
|
|
|
"Is wireless enabled",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_WIRELESS_HARDWARE_ENABLED,
|
|
|
|
|
g_param_spec_boolean (NM_MANAGER_WIRELESS_HARDWARE_ENABLED,
|
|
|
|
|
"WirelessHardwareEnabled",
|
|
|
|
|
"RF kill state",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
2009-12-23 00:18:18 -08:00
|
|
|
(object_class, PROP_WWAN_ENABLED,
|
|
|
|
|
g_param_spec_boolean (NM_MANAGER_WWAN_ENABLED,
|
|
|
|
|
"WwanEnabled",
|
|
|
|
|
"Is mobile broadband enabled",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_WWAN_HARDWARE_ENABLED,
|
|
|
|
|
g_param_spec_boolean (NM_MANAGER_WWAN_HARDWARE_ENABLED,
|
|
|
|
|
"WwanHardwareEnabled",
|
|
|
|
|
"Whether WWAN is disabled by a hardware switch or not",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
2009-12-29 11:27:10 +02:00
|
|
|
(object_class, PROP_WIMAX_ENABLED,
|
|
|
|
|
g_param_spec_boolean (NM_MANAGER_WIMAX_ENABLED,
|
|
|
|
|
"WimaxEnabled",
|
|
|
|
|
"Is WiMAX enabled",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_WIMAX_HARDWARE_ENABLED,
|
|
|
|
|
g_param_spec_boolean (NM_MANAGER_WIMAX_HARDWARE_ENABLED,
|
|
|
|
|
"WimaxHardwareEnabled",
|
|
|
|
|
"Whether WiMAX is disabled by a hardware switch or not",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
2009-12-23 00:18:18 -08:00
|
|
|
g_object_class_install_property
|
2009-06-11 00:39:12 -04:00
|
|
|
(object_class, PROP_ACTIVE_CONNECTIONS,
|
|
|
|
|
g_param_spec_boxed (NM_MANAGER_ACTIVE_CONNECTIONS,
|
|
|
|
|
"Active connections",
|
|
|
|
|
"Active connections",
|
|
|
|
|
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
|
|
|
|
/* Hostname is not exported over D-Bus */
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_HOSTNAME,
|
|
|
|
|
g_param_spec_string (NM_MANAGER_HOSTNAME,
|
|
|
|
|
"Hostname",
|
|
|
|
|
"Hostname",
|
|
|
|
|
NULL,
|
2013-05-07 12:18:41 -04:00
|
|
|
G_PARAM_READABLE));
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2010-05-22 08:55:30 -07:00
|
|
|
/* Sleeping is not exported over D-Bus */
|
2009-10-20 15:25:04 -07:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_SLEEPING,
|
|
|
|
|
g_param_spec_boolean (NM_MANAGER_SLEEPING,
|
|
|
|
|
"Sleeping",
|
|
|
|
|
"Sleeping",
|
|
|
|
|
FALSE,
|
2013-05-07 12:18:41 -04:00
|
|
|
G_PARAM_READABLE));
|
2009-10-20 15:25:04 -07:00
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
/* signals */
|
|
|
|
|
signals[DEVICE_ADDED] =
|
|
|
|
|
g_signal_new ("device-added",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMManagerClass, device_added),
|
2013-05-06 13:37:25 -04:00
|
|
|
NULL, NULL, NULL,
|
2009-06-11 00:39:12 -04:00
|
|
|
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
|
|
signals[DEVICE_REMOVED] =
|
|
|
|
|
g_signal_new ("device-removed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMManagerClass, device_removed),
|
2013-05-06 13:37:25 -04:00
|
|
|
NULL, NULL, NULL,
|
2009-06-11 00:39:12 -04:00
|
|
|
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
|
|
signals[STATE_CHANGED] =
|
|
|
|
|
g_signal_new ("state-changed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMManagerClass, state_changed),
|
2013-05-06 13:37:25 -04:00
|
|
|
NULL, NULL, NULL,
|
2009-06-11 00:39:12 -04:00
|
|
|
G_TYPE_NONE, 1, G_TYPE_UINT);
|
|
|
|
|
|
2010-05-28 18:23:00 -07:00
|
|
|
signals[CHECK_PERMISSIONS] =
|
|
|
|
|
g_signal_new ("check-permissions",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2013-05-06 13:37:25 -04:00
|
|
|
0, NULL, NULL, NULL,
|
2010-05-28 18:23:00 -07:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
2010-06-04 13:05:27 -07:00
|
|
|
signals[USER_PERMISSIONS_CHANGED] =
|
|
|
|
|
g_signal_new ("user-permissions-changed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2013-05-06 13:37:25 -04:00
|
|
|
0, NULL, NULL, NULL,
|
2010-06-04 13:05:27 -07:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
2012-08-22 18:33:17 -05:00
|
|
|
signals[ACTIVE_CONNECTION_ADDED] =
|
|
|
|
|
g_signal_new (NM_MANAGER_ACTIVE_CONNECTION_ADDED,
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2013-05-06 13:37:25 -04:00
|
|
|
0, NULL, NULL, NULL,
|
2012-08-22 18:33:17 -05:00
|
|
|
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
|
|
signals[ACTIVE_CONNECTION_REMOVED] =
|
|
|
|
|
g_signal_new (NM_MANAGER_ACTIVE_CONNECTION_REMOVED,
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2013-05-06 13:37:25 -04:00
|
|
|
0, NULL, NULL, NULL,
|
2012-08-22 18:33:17 -05:00
|
|
|
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
|
|
|
|
|
2013-05-07 12:18:41 -04:00
|
|
|
nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
|
|
|
|
|
G_TYPE_FROM_CLASS (manager_class),
|
|
|
|
|
&dbus_glib_nm_manager_object_info);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
|
|
|
|
dbus_g_error_domain_register (NM_MANAGER_ERROR, NULL, NM_TYPE_MANAGER_ERROR);
|
2010-04-08 08:56:17 -07:00
|
|
|
dbus_g_error_domain_register (NM_LOGGING_ERROR, "org.freedesktop.NetworkManager.Logging", NM_TYPE_LOGGING_ERROR);
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
|
|
|
|
|