NetworkManager/system-settings/src/dbus-settings.c

672 lines
20 KiB
C
Raw Normal View History

/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager system settings service
*
* Søren Sandmann <sandmann@daimi.au.dk>
* Dan Williams <dcbw@redhat.com>
* Tambet Ingo <tambet@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2008 Novell, Inc.
*/
#include <unistd.h>
#include <string.h>
#include <NetworkManager.h>
#include <nm-connection.h>
#include <dbus/dbus.h>
#include <nm-setting-connection.h>
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
#include "nm-dbus-glib-types.h"
#include "dbus-settings.h"
2008-05-08 Tambet Ingo <tambet@gmail.com> Use PolicyKit to authorize the system settings' AddConnection method and the system settings connections' Update and Delete methods. * libnm-glib/nm-settings.c (impl_exported_connection_update) (impl_exported_connection_delete, nm_exported_connection_update) (nm_exported_connection_delete): Return boolean and fill GError to notify the callers of the reasons why it might have failed. * libnm-glib/nm-dbus-settings-system.c (nm_dbus_settings_system_add_connection): Return the error from dbus call so that the callers can see why it failed. * libnm-glib/nm-dbus-connection.c (update, delete): Update the signatures. * system-settings/src/nm-polkit-helpers.[ch]: Implement. * system-settings/src/nm-sysconfig-connection.[ch]: Implement. New abstract base class that checks PolicyKit permissions. * system-settings/src/dbus-settings.c: (impl_settings_add_connection): Check the policy before carring out the request. * system-settings/plugins/keyfile/nm-keyfile-connection.c: Inherit from NMSysconfigConnection, check the policies before allowing updating or removing. * system-settings/plugins/ifcfg-suse/nm-suse-connection.c: Inherit from NMSysconfigConnection. * introspection/nm-exported-connection.xml: Annotate "Update" and "Delete" methods with async flag so that the implementations can get access to DBusGMethodInvocation. * system-settings/src/dbus-settings.c (settings_add_connection_check_privileges): Implement. (impl_settings_add_connection): Check the privileges before adding a new connection. Improve error reporting. * introspection/nm-settings-system.xml: Make the 'AddConnection' method async so that the implementation can access DBusGMethodInvocation. * configure.in: Check for PolicyKit. * policy/org.freedesktop.network-manager-settings.system.policy: New file. * policy/Makefile.am: Install the policy file. * configure.in: Add 'policy' subdir. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3646 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-09 06:33:30 +00:00
#include "nm-polkit-helpers.h"
#include "nm-system-config-error.h"
#include "nm-utils.h"
static gboolean
2008-05-08 Tambet Ingo <tambet@gmail.com> Use PolicyKit to authorize the system settings' AddConnection method and the system settings connections' Update and Delete methods. * libnm-glib/nm-settings.c (impl_exported_connection_update) (impl_exported_connection_delete, nm_exported_connection_update) (nm_exported_connection_delete): Return boolean and fill GError to notify the callers of the reasons why it might have failed. * libnm-glib/nm-dbus-settings-system.c (nm_dbus_settings_system_add_connection): Return the error from dbus call so that the callers can see why it failed. * libnm-glib/nm-dbus-connection.c (update, delete): Update the signatures. * system-settings/src/nm-polkit-helpers.[ch]: Implement. * system-settings/src/nm-sysconfig-connection.[ch]: Implement. New abstract base class that checks PolicyKit permissions. * system-settings/src/dbus-settings.c: (impl_settings_add_connection): Check the policy before carring out the request. * system-settings/plugins/keyfile/nm-keyfile-connection.c: Inherit from NMSysconfigConnection, check the policies before allowing updating or removing. * system-settings/plugins/ifcfg-suse/nm-suse-connection.c: Inherit from NMSysconfigConnection. * introspection/nm-exported-connection.xml: Annotate "Update" and "Delete" methods with async flag so that the implementations can get access to DBusGMethodInvocation. * system-settings/src/dbus-settings.c (settings_add_connection_check_privileges): Implement. (impl_settings_add_connection): Check the privileges before adding a new connection. Improve error reporting. * introspection/nm-settings-system.xml: Make the 'AddConnection' method async so that the implementation can access DBusGMethodInvocation. * configure.in: Check for PolicyKit. * policy/org.freedesktop.network-manager-settings.system.policy: New file. * policy/Makefile.am: Install the policy file. * configure.in: Add 'policy' subdir. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3646 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-09 06:33:30 +00:00
impl_settings_add_connection (NMSysconfigSettings *self, GHashTable *hash, DBusGMethodInvocation *context);
static gboolean
impl_settings_save_hostname (NMSysconfigSettings *self, const char *hostname, DBusGMethodInvocation *context);
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
#include "nm-settings-system-glue.h"
static void unmanaged_devices_changed (NMSystemConfigInterface *config, gpointer user_data);
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
typedef struct {
DBusGConnection *g_connection;
2008-05-08 Tambet Ingo <tambet@gmail.com> Use PolicyKit to authorize the system settings' AddConnection method and the system settings connections' Update and Delete methods. * libnm-glib/nm-settings.c (impl_exported_connection_update) (impl_exported_connection_delete, nm_exported_connection_update) (nm_exported_connection_delete): Return boolean and fill GError to notify the callers of the reasons why it might have failed. * libnm-glib/nm-dbus-settings-system.c (nm_dbus_settings_system_add_connection): Return the error from dbus call so that the callers can see why it failed. * libnm-glib/nm-dbus-connection.c (update, delete): Update the signatures. * system-settings/src/nm-polkit-helpers.[ch]: Implement. * system-settings/src/nm-sysconfig-connection.[ch]: Implement. New abstract base class that checks PolicyKit permissions. * system-settings/src/dbus-settings.c: (impl_settings_add_connection): Check the policy before carring out the request. * system-settings/plugins/keyfile/nm-keyfile-connection.c: Inherit from NMSysconfigConnection, check the policies before allowing updating or removing. * system-settings/plugins/ifcfg-suse/nm-suse-connection.c: Inherit from NMSysconfigConnection. * introspection/nm-exported-connection.xml: Annotate "Update" and "Delete" methods with async flag so that the implementations can get access to DBusGMethodInvocation. * system-settings/src/dbus-settings.c (settings_add_connection_check_privileges): Implement. (impl_settings_add_connection): Check the privileges before adding a new connection. Improve error reporting. * introspection/nm-settings-system.xml: Make the 'AddConnection' method async so that the implementation can access DBusGMethodInvocation. * configure.in: Check for PolicyKit. * policy/org.freedesktop.network-manager-settings.system.policy: New file. * policy/Makefile.am: Install the policy file. * configure.in: Add 'policy' subdir. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3646 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-09 06:33:30 +00:00
PolKitContext *pol_ctx;
NMSystemConfigHalManager *hal_mgr;
GSList *plugins;
gboolean connections_loaded;
GHashTable *connections;
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
GHashTable *unmanaged_devices;
char *orig_hostname;
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
} NMSysconfigSettingsPrivate;
G_DEFINE_TYPE (NMSysconfigSettings, nm_sysconfig_settings, NM_TYPE_SETTINGS);
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
#define NM_SYSCONFIG_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettingsPrivate))
enum {
PROPERTIES_CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
enum {
PROP_0,
PROP_UNMANAGED_DEVICES,
PROP_HOSTNAME,
PROP_CAN_MODIFY,
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
LAST_PROP
};
static void
load_connections (NMSysconfigSettings *self)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GSList *iter;
if (priv->connections_loaded)
return;
for (iter = priv->plugins; iter; iter = g_slist_next (iter)) {
NMSystemConfigInterface *plugin = NM_SYSTEM_CONFIG_INTERFACE (iter->data);
GSList *plugin_connections;
GSList *elt;
plugin_connections = nm_system_config_interface_get_connections (plugin);
// FIXME: ensure connections from plugins loaded with a lower priority
// get rejected when they conflict with connections from a higher
// priority plugin.
for (elt = plugin_connections; elt; elt = g_slist_next (elt))
nm_sysconfig_settings_add_connection (self, NM_EXPORTED_CONNECTION (elt->data), TRUE);
g_slist_free (plugin_connections);
}
priv->connections_loaded = TRUE;
/* FIXME: Bad hack */
unmanaged_devices_changed (NULL, self);
}
static void
hash_keys_to_slist (gpointer key, gpointer val, gpointer user_data)
{
GSList **list = (GSList **) user_data;
*list = g_slist_prepend (*list, key);
}
2008-05-05 Tambet Ingo <tambet@gmail.com> * libnm-glib/nm-dbus-settings.c (constructor): Fix the "PropertiesChanged" signal signature. * libnm-glib/nm-dbus-connection.c (constructor): Use the common GType defined in nm-dbus-glib-types.h. Don't register the connection on dbus, we're a proxy class to communicate with an already registered connection over dbus. 2008-04-30 Tambet Ingo <tambet@gmail.com> Implement new subclasses of NMSettings and NMExportedConnection to make it easier for the applet to access and modify system settings. * libnm-glib/nm-dbus-connection.[ch]: * libnm-glib/nm-dbus-settings.[ch]: * libnm-glib/nm-dbus-settings-system.[ch]: Implement. * libnm-glib/Makefile.am: Add the new files to build, generate some more bindings and glue. * include/NetworkManager.h: Define the system settings DBus interface. 2008-04-30 Tambet Ingo <tambet@gmail.com> Implement additional C API for exported connections to make them identical with the DBus API. Change the (list_connections) virtual function to be more usable from C - instead of requiring implementers to return a GPtrArray of dbus paths, return a list of connections. * libnm-glib/nm-settings.c (nm_exported_connection_class_init): Fix a typo. (nm_settings_list_connections): (nm_exported_connection_new): (nm_exported_connection_update): (nm_exported_connection_delete): Implement. (impl_settings_list_connections): (impl_exported_connection_update): (impl_exported_connection_delete): Use the new public functions to make sure the C and dbus interfaces stay in sync. * system-settings/src/dbus-settings.c (list_connections): Return a list of connections. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3630 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-05 07:07:44 +00:00
static GSList *
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
list_connections (NMSettings *settings)
{
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
NMSysconfigSettings *self = NM_SYSCONFIG_SETTINGS (settings);
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GSList *list = NULL;
load_connections (self);
g_hash_table_foreach (priv->connections, hash_keys_to_slist, &list);
return list;
}
static void
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
settings_finalize (GObject *object)
{
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
NMSysconfigSettings *self = NM_SYSCONFIG_SETTINGS (object);
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
g_hash_table_destroy (priv->connections);
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
g_hash_table_destroy (priv->unmanaged_devices);
g_slist_foreach (priv->plugins, (GFunc) g_object_unref, NULL);
g_slist_free (priv->plugins);
2008-05-08 Tambet Ingo <tambet@gmail.com> Use PolicyKit to authorize the system settings' AddConnection method and the system settings connections' Update and Delete methods. * libnm-glib/nm-settings.c (impl_exported_connection_update) (impl_exported_connection_delete, nm_exported_connection_update) (nm_exported_connection_delete): Return boolean and fill GError to notify the callers of the reasons why it might have failed. * libnm-glib/nm-dbus-settings-system.c (nm_dbus_settings_system_add_connection): Return the error from dbus call so that the callers can see why it failed. * libnm-glib/nm-dbus-connection.c (update, delete): Update the signatures. * system-settings/src/nm-polkit-helpers.[ch]: Implement. * system-settings/src/nm-sysconfig-connection.[ch]: Implement. New abstract base class that checks PolicyKit permissions. * system-settings/src/dbus-settings.c: (impl_settings_add_connection): Check the policy before carring out the request. * system-settings/plugins/keyfile/nm-keyfile-connection.c: Inherit from NMSysconfigConnection, check the policies before allowing updating or removing. * system-settings/plugins/ifcfg-suse/nm-suse-connection.c: Inherit from NMSysconfigConnection. * introspection/nm-exported-connection.xml: Annotate "Update" and "Delete" methods with async flag so that the implementations can get access to DBusGMethodInvocation. * system-settings/src/dbus-settings.c (settings_add_connection_check_privileges): Implement. (impl_settings_add_connection): Check the privileges before adding a new connection. Improve error reporting. * introspection/nm-settings-system.xml: Make the 'AddConnection' method async so that the implementation can access DBusGMethodInvocation. * configure.in: Check for PolicyKit. * policy/org.freedesktop.network-manager-settings.system.policy: New file. * policy/Makefile.am: Install the policy file. * configure.in: Add 'policy' subdir. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3646 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-09 06:33:30 +00:00
if (priv->pol_ctx)
polkit_context_unref (priv->pol_ctx);
g_object_unref (priv->hal_mgr);
dbus_g_connection_unref (priv->g_connection);
g_free (priv->orig_hostname);
G_OBJECT_CLASS (nm_sysconfig_settings_parent_class)->finalize (object);
}
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
static void
add_one_unmanaged_device (gpointer key, gpointer data, gpointer user_data)
{
GPtrArray *devices = (GPtrArray *) user_data;
g_ptr_array_add (devices, g_strdup (key));
}
static char*
uscore_to_wincaps (const char *uscore)
{
const char *p;
GString *str;
gboolean last_was_uscore;
last_was_uscore = TRUE;
str = g_string_new (NULL);
p = uscore;
while (p && *p) {
if (*p == '-' || *p == '_')
last_was_uscore = TRUE;
else {
if (last_was_uscore) {
g_string_append_c (str, g_ascii_toupper (*p));
last_was_uscore = FALSE;
} else
g_string_append_c (str, *p);
}
++p;
}
return g_string_free (str, FALSE);
}
static void
notify (GObject *object, GParamSpec *pspec)
{
GValue *value;
GHashTable *hash;
value = g_slice_new0 (GValue);
hash = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
g_value_init (value, pspec->value_type);
g_object_get_property (object, pspec->name, value);
g_hash_table_insert (hash, uscore_to_wincaps (pspec->name), value);
g_signal_emit (object, signals[PROPERTIES_CHANGED], 0, hash);
g_hash_table_destroy (hash);
g_value_unset (value);
g_slice_free (GValue, value);
}
static GPtrArray *
get_unmanaged_devices (NMSysconfigSettings *self)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GPtrArray *devices;
load_connections (self);
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
devices = g_ptr_array_sized_new (3);
g_hash_table_foreach (priv->unmanaged_devices, (GHFunc) add_one_unmanaged_device, devices);
return devices;
}
NMSystemConfigInterface *
nm_sysconfig_settings_get_plugin (NMSysconfigSettings *self,
guint32 capability)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GSList *iter;
g_return_val_if_fail (self != NULL, NULL);
/* Do any of the plugins support setting the hostname? */
for (iter = priv->plugins; iter; iter = iter->next) {
NMSystemConfigInterfaceCapabilities caps = NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE;
g_object_get (G_OBJECT (iter->data), NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES, &caps, NULL);
if (caps & capability)
return NM_SYSTEM_CONFIG_INTERFACE (iter->data);
}
return NULL;
}
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
{
NMSysconfigSettings *self = NM_SYSCONFIG_SETTINGS (object);
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GSList *iter;
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
switch (prop_id) {
case PROP_UNMANAGED_DEVICES:
g_value_take_boxed (value, get_unmanaged_devices (self));
break;
case PROP_HOSTNAME:
/* Hostname returned is the hostname returned from the first plugin
* that provides one.
*/
for (iter = priv->plugins; iter; iter = iter->next) {
NMSystemConfigInterfaceCapabilities caps = NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE;
g_object_get (G_OBJECT (iter->data), NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES, &caps, NULL);
if (caps & NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME) {
char *hostname = NULL;
g_object_get (G_OBJECT (iter->data), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME, &hostname, NULL);
if (hostname && strlen (hostname)) {
g_value_take_string (value, hostname);
break;
}
}
}
/* If no plugin provided a hostname, try the original hostname of the machine */
if (!g_value_get_string (value) && priv->orig_hostname)
g_value_set_string (value, priv->orig_hostname);
/* Don't ever pass NULL through D-Bus */
if (!g_value_get_string (value))
g_value_set_static_string (value, "");
break;
case PROP_CAN_MODIFY:
g_value_set_boolean (value, !!nm_sysconfig_settings_get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS));
break;
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
NMSettingsClass *settings_class = NM_SETTINGS_CLASS (class);
2008-05-08 Tambet Ingo <tambet@gmail.com> Use PolicyKit to authorize the system settings' AddConnection method and the system settings connections' Update and Delete methods. * libnm-glib/nm-settings.c (impl_exported_connection_update) (impl_exported_connection_delete, nm_exported_connection_update) (nm_exported_connection_delete): Return boolean and fill GError to notify the callers of the reasons why it might have failed. * libnm-glib/nm-dbus-settings-system.c (nm_dbus_settings_system_add_connection): Return the error from dbus call so that the callers can see why it failed. * libnm-glib/nm-dbus-connection.c (update, delete): Update the signatures. * system-settings/src/nm-polkit-helpers.[ch]: Implement. * system-settings/src/nm-sysconfig-connection.[ch]: Implement. New abstract base class that checks PolicyKit permissions. * system-settings/src/dbus-settings.c: (impl_settings_add_connection): Check the policy before carring out the request. * system-settings/plugins/keyfile/nm-keyfile-connection.c: Inherit from NMSysconfigConnection, check the policies before allowing updating or removing. * system-settings/plugins/ifcfg-suse/nm-suse-connection.c: Inherit from NMSysconfigConnection. * introspection/nm-exported-connection.xml: Annotate "Update" and "Delete" methods with async flag so that the implementations can get access to DBusGMethodInvocation. * system-settings/src/dbus-settings.c (settings_add_connection_check_privileges): Implement. (impl_settings_add_connection): Check the privileges before adding a new connection. Improve error reporting. * introspection/nm-settings-system.xml: Make the 'AddConnection' method async so that the implementation can access DBusGMethodInvocation. * configure.in: Check for PolicyKit. * policy/org.freedesktop.network-manager-settings.system.policy: New file. * policy/Makefile.am: Install the policy file. * configure.in: Add 'policy' subdir. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3646 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-09 06:33:30 +00:00
g_type_class_add_private (class, sizeof (NMSysconfigSettingsPrivate));
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
/* virtual methods */
object_class->notify = notify;
object_class->get_property = get_property;
object_class->finalize = settings_finalize;
settings_class->list_connections = list_connections;
/* properties */
g_object_class_install_property
(object_class, PROP_UNMANAGED_DEVICES,
g_param_spec_boxed (NM_SYSCONFIG_SETTINGS_UNMANAGED_DEVICES,
"Unamanged devices",
"Unmanaged devices",
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_HOSTNAME,
g_param_spec_string (NM_SYSCONFIG_SETTINGS_HOSTNAME,
"Hostname",
"Hostname",
NULL,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_CAN_MODIFY,
g_param_spec_boolean (NM_SYSCONFIG_SETTINGS_CAN_MODIFY,
"CanModify",
"Can modify",
FALSE,
G_PARAM_READABLE));
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
/* signals */
signals[PROPERTIES_CHANGED] =
g_signal_new ("properties-changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMSysconfigSettingsClass, properties_changed),
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_VARIANT);
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (settings_class),
&dbus_glib_nm_settings_system_object_info);
2008-05-08 Tambet Ingo <tambet@gmail.com> Use PolicyKit to authorize the system settings' AddConnection method and the system settings connections' Update and Delete methods. * libnm-glib/nm-settings.c (impl_exported_connection_update) (impl_exported_connection_delete, nm_exported_connection_update) (nm_exported_connection_delete): Return boolean and fill GError to notify the callers of the reasons why it might have failed. * libnm-glib/nm-dbus-settings-system.c (nm_dbus_settings_system_add_connection): Return the error from dbus call so that the callers can see why it failed. * libnm-glib/nm-dbus-connection.c (update, delete): Update the signatures. * system-settings/src/nm-polkit-helpers.[ch]: Implement. * system-settings/src/nm-sysconfig-connection.[ch]: Implement. New abstract base class that checks PolicyKit permissions. * system-settings/src/dbus-settings.c: (impl_settings_add_connection): Check the policy before carring out the request. * system-settings/plugins/keyfile/nm-keyfile-connection.c: Inherit from NMSysconfigConnection, check the policies before allowing updating or removing. * system-settings/plugins/ifcfg-suse/nm-suse-connection.c: Inherit from NMSysconfigConnection. * introspection/nm-exported-connection.xml: Annotate "Update" and "Delete" methods with async flag so that the implementations can get access to DBusGMethodInvocation. * system-settings/src/dbus-settings.c (settings_add_connection_check_privileges): Implement. (impl_settings_add_connection): Check the privileges before adding a new connection. Improve error reporting. * introspection/nm-settings-system.xml: Make the 'AddConnection' method async so that the implementation can access DBusGMethodInvocation. * configure.in: Check for PolicyKit. * policy/org.freedesktop.network-manager-settings.system.policy: New file. * policy/Makefile.am: Install the policy file. * configure.in: Add 'policy' subdir. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3646 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-09 06:33:30 +00:00
dbus_g_error_domain_register (NM_SYSCONFIG_SETTINGS_ERROR,
NM_DBUS_IFACE_SETTINGS_SYSTEM,
NM_TYPE_SYSCONFIG_SETTINGS_ERROR);
}
static void
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
nm_sysconfig_settings_init (NMSysconfigSettings *self)
{
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
char hostname[HOST_NAME_MAX + 2];
GError *error = NULL;
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
priv->connections = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
priv->unmanaged_devices = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
2008-05-08 Tambet Ingo <tambet@gmail.com> Use PolicyKit to authorize the system settings' AddConnection method and the system settings connections' Update and Delete methods. * libnm-glib/nm-settings.c (impl_exported_connection_update) (impl_exported_connection_delete, nm_exported_connection_update) (nm_exported_connection_delete): Return boolean and fill GError to notify the callers of the reasons why it might have failed. * libnm-glib/nm-dbus-settings-system.c (nm_dbus_settings_system_add_connection): Return the error from dbus call so that the callers can see why it failed. * libnm-glib/nm-dbus-connection.c (update, delete): Update the signatures. * system-settings/src/nm-polkit-helpers.[ch]: Implement. * system-settings/src/nm-sysconfig-connection.[ch]: Implement. New abstract base class that checks PolicyKit permissions. * system-settings/src/dbus-settings.c: (impl_settings_add_connection): Check the policy before carring out the request. * system-settings/plugins/keyfile/nm-keyfile-connection.c: Inherit from NMSysconfigConnection, check the policies before allowing updating or removing. * system-settings/plugins/ifcfg-suse/nm-suse-connection.c: Inherit from NMSysconfigConnection. * introspection/nm-exported-connection.xml: Annotate "Update" and "Delete" methods with async flag so that the implementations can get access to DBusGMethodInvocation. * system-settings/src/dbus-settings.c (settings_add_connection_check_privileges): Implement. (impl_settings_add_connection): Check the privileges before adding a new connection. Improve error reporting. * introspection/nm-settings-system.xml: Make the 'AddConnection' method async so that the implementation can access DBusGMethodInvocation. * configure.in: Check for PolicyKit. * policy/org.freedesktop.network-manager-settings.system.policy: New file. * policy/Makefile.am: Install the policy file. * configure.in: Add 'policy' subdir. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3646 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-09 06:33:30 +00:00
priv->pol_ctx = create_polkit_context (&error);
if (!priv->pol_ctx) {
g_warning ("%s: failed to create PolicyKit context: %s",
__func__,
(error && error->message) ? error->message : "(unknown)");
}
/* Grab hostname on startup and use that if no plugins provide one */
memset (hostname, 0, sizeof (hostname));
if (gethostname (&hostname[0], HOST_NAME_MAX) == 0) {
/* only cache it if it's a valid hostname */
if (strlen (hostname) && strcmp (hostname, "localhost") && strcmp (hostname, "localhost.localdomain"))
priv->orig_hostname = g_strdup (hostname);
}
}
NMSysconfigSettings *
nm_sysconfig_settings_new (DBusGConnection *g_conn, NMSystemConfigHalManager *hal_mgr)
{
NMSysconfigSettings *settings;
NMSysconfigSettingsPrivate *priv;
g_return_val_if_fail (g_conn != NULL, NULL);
g_return_val_if_fail (hal_mgr != NULL, NULL);
settings = g_object_new (NM_TYPE_SYSCONFIG_SETTINGS, NULL);
dbus_g_connection_register_g_object (g_conn, NM_DBUS_PATH_SETTINGS, G_OBJECT (settings));
priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (settings);
priv->g_connection = dbus_g_connection_ref (g_conn);
priv->hal_mgr = g_object_ref (hal_mgr);
return settings;
}
static void
plugin_connection_added (NMSystemConfigInterface *config,
NMExportedConnection *connection,
gpointer user_data)
{
nm_sysconfig_settings_add_connection (NM_SYSCONFIG_SETTINGS (user_data), connection, TRUE);
}
static void
unmanaged_devices_changed (NMSystemConfigInterface *config,
gpointer user_data)
{
NMSysconfigSettings *self = NM_SYSCONFIG_SETTINGS (user_data);
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GSList *iter;
g_hash_table_remove_all (priv->unmanaged_devices);
/* Ask all the plugins for their unmanaged devices */
for (iter = priv->plugins; iter; iter = g_slist_next (iter)) {
GSList *udis = nm_system_config_interface_get_unmanaged_devices (NM_SYSTEM_CONFIG_INTERFACE (iter->data));
GSList *udi_iter;
for (udi_iter = udis; udi_iter; udi_iter = udi_iter->next) {
if (!g_hash_table_lookup (priv->unmanaged_devices, udi_iter->data)) {
g_hash_table_insert (priv->unmanaged_devices,
udi_iter->data,
GUINT_TO_POINTER (1));
} else
g_free (udi_iter->data);
}
g_slist_free (udis);
}
g_object_notify (G_OBJECT (self), NM_SYSCONFIG_SETTINGS_UNMANAGED_DEVICES);
}
static void
hostname_changed (NMSystemConfigInterface *config,
GParamSpec *pspec,
gpointer user_data)
{
g_object_notify (G_OBJECT (user_data), NM_SYSCONFIG_SETTINGS_HOSTNAME);
}
void
nm_sysconfig_settings_add_plugin (NMSysconfigSettings *self,
NMSystemConfigInterface *plugin)
{
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
NMSysconfigSettingsPrivate *priv;
char *pname = NULL;
char *pinfo = NULL;
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (self));
g_return_if_fail (NM_IS_SYSTEM_CONFIG_INTERFACE (plugin));
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
priv->plugins = g_slist_append (priv->plugins, g_object_ref (plugin));
g_signal_connect (plugin, "connection-added", G_CALLBACK (plugin_connection_added), self);
g_signal_connect (plugin, "unmanaged-devices-changed", G_CALLBACK (unmanaged_devices_changed), self);
g_signal_connect (plugin, "notify::hostname", G_CALLBACK (hostname_changed), self);
nm_system_config_interface_init (plugin, priv->hal_mgr);
g_object_get (G_OBJECT (plugin),
NM_SYSTEM_CONFIG_INTERFACE_NAME, &pname,
NM_SYSTEM_CONFIG_INTERFACE_INFO, &pinfo,
NULL);
g_message ("Loaded plugin %s: %s", pname, pinfo);
g_free (pname);
g_free (pinfo);
}
static void
connection_removed (NMExportedConnection *connection,
gpointer user_data)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (user_data);
g_hash_table_remove (priv->connections, connection);
}
void
nm_sysconfig_settings_add_connection (NMSysconfigSettings *self,
NMExportedConnection *connection,
gboolean do_export)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (self));
g_return_if_fail (NM_IS_EXPORTED_CONNECTION (connection));
if (g_hash_table_lookup (priv->connections, connection))
/* A plugin is lying to us. */
return;
g_hash_table_insert (priv->connections, g_object_ref (connection), GINT_TO_POINTER (1));
g_signal_connect (connection, "removed", G_CALLBACK (connection_removed), self);
if (do_export) {
nm_exported_connection_register_object (connection, NM_CONNECTION_SCOPE_SYSTEM, priv->g_connection);
nm_settings_signal_new_connection (NM_SETTINGS (self), connection);
}
}
void
nm_sysconfig_settings_remove_connection (NMSysconfigSettings *self,
NMExportedConnection *connection,
gboolean do_signal)
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (self));
g_return_if_fail (NM_IS_EXPORTED_CONNECTION (connection));
if (g_hash_table_lookup (priv->connections, connection)) {
nm_exported_connection_signal_removed (connection);
g_hash_table_remove (priv->connections, connection);
2008-04-07 Dan Williams <dcbw@redhat.com> * introspection/nm-settings-system.xml introspection/Makefile.am - Define the unmanaged devices interface for the system settings service * system-settings/src/nm-system-config-hal-manager.c system-settings/src/nm-system-config-hal-manager.h system-settings/src/nm-system-config-hal-manager-private.h system-settings/src/Makefile.am - Add a lightweight HAL manager object for tracking network devices for the purpose of determining unmanaged devices and which devices need the default DHCP connections * system-settings/src/nm-system-config-interface.c system-settings/src/nm-system-config-interface.h - (nm_system_config_interface_init): add the HAL manager as an argument - (nm_system_config_interface_get_unmanaged_devices): implement - Define 'unmanaged-devices-changed' signal * system-settings/src/dbus-settings.c system-settings/src/dbus-settings.h - Implement the unmanaged devices interface; some cleanups * system-settings/plugins/ifcfg-suse/plugin.c - Fixup for plugin interface changes * system-settings/plugins/ifcfg-fedora/plugin.c - (get_ether_device_udi): new function; find the device that has a specified MAC address and return its UDI - (get_udi_for_connection): new function; try to find the specific device a connection is locked to, if any - (device_added_cb, device_removed_cb): update unmanaged device list in response to HAL events - (get_unmanaged_devices): new function; return unmanaged device list - (build_one_connection): set the connection's locked device, if any - (write_auto_wired_connection): remove - (kill_old_auto_wired_file): remove the ifcfg-Auto Wired file if found - (handle_connection_changed): alert listeners that the unmanaged device list has changed - (init): fixup for plugin interface changes, implement unmanaged devices * system-settings/plugins/ifcfg-fedora/parser.c system-settings/plugins/ifcfg-fedora/parser.h - (connection_data_free): clean up connection UDI git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3537 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 01:36:39 +00:00
}
}
gboolean
nm_sysconfig_settings_is_device_managed (NMSysconfigSettings *self,
const char *udi)
{
NMSysconfigSettingsPrivate *priv;
g_return_val_if_fail (NM_IS_SYSCONFIG_SETTINGS (self), FALSE);
priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
load_connections (self);
if (g_hash_table_lookup (priv->unmanaged_devices, udi))
return FALSE;
return TRUE;
}
gboolean
nm_sysconfig_settings_add_new_connection (NMSysconfigSettings *self,
GHashTable *hash,
GError **error)
{
2008-05-08 Tambet Ingo <tambet@gmail.com> Use PolicyKit to authorize the system settings' AddConnection method and the system settings connections' Update and Delete methods. * libnm-glib/nm-settings.c (impl_exported_connection_update) (impl_exported_connection_delete, nm_exported_connection_update) (nm_exported_connection_delete): Return boolean and fill GError to notify the callers of the reasons why it might have failed. * libnm-glib/nm-dbus-settings-system.c (nm_dbus_settings_system_add_connection): Return the error from dbus call so that the callers can see why it failed. * libnm-glib/nm-dbus-connection.c (update, delete): Update the signatures. * system-settings/src/nm-polkit-helpers.[ch]: Implement. * system-settings/src/nm-sysconfig-connection.[ch]: Implement. New abstract base class that checks PolicyKit permissions. * system-settings/src/dbus-settings.c: (impl_settings_add_connection): Check the policy before carring out the request. * system-settings/plugins/keyfile/nm-keyfile-connection.c: Inherit from NMSysconfigConnection, check the policies before allowing updating or removing. * system-settings/plugins/ifcfg-suse/nm-suse-connection.c: Inherit from NMSysconfigConnection. * introspection/nm-exported-connection.xml: Annotate "Update" and "Delete" methods with async flag so that the implementations can get access to DBusGMethodInvocation. * system-settings/src/dbus-settings.c (settings_add_connection_check_privileges): Implement. (impl_settings_add_connection): Check the privileges before adding a new connection. Improve error reporting. * introspection/nm-settings-system.xml: Make the 'AddConnection' method async so that the implementation can access DBusGMethodInvocation. * configure.in: Check for PolicyKit. * policy/org.freedesktop.network-manager-settings.system.policy: New file. * policy/Makefile.am: Install the policy file. * configure.in: Add 'policy' subdir. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3646 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-09 06:33:30 +00:00
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
NMConnection *connection;
GError *tmp_error = NULL, *last_error = NULL;
GSList *iter;
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
gboolean success = FALSE;
2008-05-08 Tambet Ingo <tambet@gmail.com> Use PolicyKit to authorize the system settings' AddConnection method and the system settings connections' Update and Delete methods. * libnm-glib/nm-settings.c (impl_exported_connection_update) (impl_exported_connection_delete, nm_exported_connection_update) (nm_exported_connection_delete): Return boolean and fill GError to notify the callers of the reasons why it might have failed. * libnm-glib/nm-dbus-settings-system.c (nm_dbus_settings_system_add_connection): Return the error from dbus call so that the callers can see why it failed. * libnm-glib/nm-dbus-connection.c (update, delete): Update the signatures. * system-settings/src/nm-polkit-helpers.[ch]: Implement. * system-settings/src/nm-sysconfig-connection.[ch]: Implement. New abstract base class that checks PolicyKit permissions. * system-settings/src/dbus-settings.c: (impl_settings_add_connection): Check the policy before carring out the request. * system-settings/plugins/keyfile/nm-keyfile-connection.c: Inherit from NMSysconfigConnection, check the policies before allowing updating or removing. * system-settings/plugins/ifcfg-suse/nm-suse-connection.c: Inherit from NMSysconfigConnection. * introspection/nm-exported-connection.xml: Annotate "Update" and "Delete" methods with async flag so that the implementations can get access to DBusGMethodInvocation. * system-settings/src/dbus-settings.c (settings_add_connection_check_privileges): Implement. (impl_settings_add_connection): Check the privileges before adding a new connection. Improve error reporting. * introspection/nm-settings-system.xml: Make the 'AddConnection' method async so that the implementation can access DBusGMethodInvocation. * configure.in: Check for PolicyKit. * policy/org.freedesktop.network-manager-settings.system.policy: New file. * policy/Makefile.am: Install the policy file. * configure.in: Add 'policy' subdir. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3646 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-09 06:33:30 +00:00
connection = nm_connection_new_from_hash (hash, &tmp_error);
if (!connection) {
/* Invalid connection hash */
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid connection: '%s' / '%s' invalid: %d",
tmp_error ? g_type_name (nm_connection_lookup_setting_type_by_quark (tmp_error->domain)) : "(unknown)",
tmp_error ? tmp_error->message : "(unknown)", tmp_error ? tmp_error->code : -1);
g_clear_error (&tmp_error);
return FALSE;
}
/* Here's how it works:
1) plugin writes a connection.
2) plugin notices that a new connection is available for reading.
3) plugin reads the new connection (the one it wrote in 1) and emits 'connection-added' signal.
4) NMSysconfigSettings receives the signal and adds it to it's connection list.
*/
for (iter = priv->plugins; iter && !success; iter = iter->next) {
success = nm_system_config_interface_add_connection (NM_SYSTEM_CONFIG_INTERFACE (iter->data),
connection, &tmp_error);
g_clear_error (&last_error);
if (!success)
last_error = tmp_error;
}
g_object_unref (connection);
if (!success) {
g_set_error (error, NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_ADD_FAILED,
"Saving connection failed: (%d) %s",
last_error ? last_error->code : -1,
last_error && last_error->message ? last_error->message : "(unknown)");
g_clear_error (&last_error);
}
return success;
}
static gboolean
impl_settings_add_connection (NMSysconfigSettings *self,
GHashTable *hash,
DBusGMethodInvocation *context)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GError *err = NULL;
/* Do any of the plugins support adding? */
if (!nm_sysconfig_settings_get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS)) {
err = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_ADD_NOT_SUPPORTED,
"%s", "None of the registered plugins support add.");
goto out;
2008-05-08 Tambet Ingo <tambet@gmail.com> Use PolicyKit to authorize the system settings' AddConnection method and the system settings connections' Update and Delete methods. * libnm-glib/nm-settings.c (impl_exported_connection_update) (impl_exported_connection_delete, nm_exported_connection_update) (nm_exported_connection_delete): Return boolean and fill GError to notify the callers of the reasons why it might have failed. * libnm-glib/nm-dbus-settings-system.c (nm_dbus_settings_system_add_connection): Return the error from dbus call so that the callers can see why it failed. * libnm-glib/nm-dbus-connection.c (update, delete): Update the signatures. * system-settings/src/nm-polkit-helpers.[ch]: Implement. * system-settings/src/nm-sysconfig-connection.[ch]: Implement. New abstract base class that checks PolicyKit permissions. * system-settings/src/dbus-settings.c: (impl_settings_add_connection): Check the policy before carring out the request. * system-settings/plugins/keyfile/nm-keyfile-connection.c: Inherit from NMSysconfigConnection, check the policies before allowing updating or removing. * system-settings/plugins/ifcfg-suse/nm-suse-connection.c: Inherit from NMSysconfigConnection. * introspection/nm-exported-connection.xml: Annotate "Update" and "Delete" methods with async flag so that the implementations can get access to DBusGMethodInvocation. * system-settings/src/dbus-settings.c (settings_add_connection_check_privileges): Implement. (impl_settings_add_connection): Check the privileges before adding a new connection. Improve error reporting. * introspection/nm-settings-system.xml: Make the 'AddConnection' method async so that the implementation can access DBusGMethodInvocation. * configure.in: Check for PolicyKit. * policy/org.freedesktop.network-manager-settings.system.policy: New file. * policy/Makefile.am: Install the policy file. * configure.in: Add 'policy' subdir. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3646 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-09 06:33:30 +00:00
}
if (!check_polkit_privileges (priv->g_connection, priv->pol_ctx, context, &err))
goto out;
nm_sysconfig_settings_add_new_connection (self, hash, &err);
out:
if (err) {
2008-05-08 Tambet Ingo <tambet@gmail.com> Use PolicyKit to authorize the system settings' AddConnection method and the system settings connections' Update and Delete methods. * libnm-glib/nm-settings.c (impl_exported_connection_update) (impl_exported_connection_delete, nm_exported_connection_update) (nm_exported_connection_delete): Return boolean and fill GError to notify the callers of the reasons why it might have failed. * libnm-glib/nm-dbus-settings-system.c (nm_dbus_settings_system_add_connection): Return the error from dbus call so that the callers can see why it failed. * libnm-glib/nm-dbus-connection.c (update, delete): Update the signatures. * system-settings/src/nm-polkit-helpers.[ch]: Implement. * system-settings/src/nm-sysconfig-connection.[ch]: Implement. New abstract base class that checks PolicyKit permissions. * system-settings/src/dbus-settings.c: (impl_settings_add_connection): Check the policy before carring out the request. * system-settings/plugins/keyfile/nm-keyfile-connection.c: Inherit from NMSysconfigConnection, check the policies before allowing updating or removing. * system-settings/plugins/ifcfg-suse/nm-suse-connection.c: Inherit from NMSysconfigConnection. * introspection/nm-exported-connection.xml: Annotate "Update" and "Delete" methods with async flag so that the implementations can get access to DBusGMethodInvocation. * system-settings/src/dbus-settings.c (settings_add_connection_check_privileges): Implement. (impl_settings_add_connection): Check the privileges before adding a new connection. Improve error reporting. * introspection/nm-settings-system.xml: Make the 'AddConnection' method async so that the implementation can access DBusGMethodInvocation. * configure.in: Check for PolicyKit. * policy/org.freedesktop.network-manager-settings.system.policy: New file. * policy/Makefile.am: Install the policy file. * configure.in: Add 'policy' subdir. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3646 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-09 06:33:30 +00:00
dbus_g_method_return_error (context, err);
g_error_free (err);
return FALSE;
} else {
dbus_g_method_return (context);
return TRUE;
}
}
static gboolean
impl_settings_save_hostname (NMSysconfigSettings *self,
const char *hostname,
DBusGMethodInvocation *context)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GError *err = NULL;
GSList *iter;
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
gboolean success = FALSE;
/* Do any of the plugins support setting the hostname? */
if (!nm_sysconfig_settings_get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME)) {
err = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_SAVE_HOSTNAME_NOT_SUPPORTED,
"%s", "None of the registered plugins support setting the hostname.");
goto out;
}
if (!check_polkit_privileges (priv->g_connection, priv->pol_ctx, context, &err))
goto out;
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
/* Set the hostname in all plugins */
for (iter = priv->plugins; iter; iter = iter->next) {
NMSystemConfigInterfaceCapabilities caps = NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE;
g_object_get (G_OBJECT (iter->data), NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES, &caps, NULL);
if (caps & NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME) {
g_object_set (G_OBJECT (iter->data), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME, hostname, NULL);
success = TRUE;
}
}
if (!success) {
err = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_SAVE_HOSTNAME_FAILED,
"%s", "Saving the hostname failed.");
}
out:
if (err) {
dbus_g_method_return_error (context, err);
g_error_free (err);
return FALSE;
} else {
dbus_g_method_return (context);
return TRUE;
}
}