2007-11-26 03:47:30 +00:00
|
|
|
/* NetworkManager system settings service
|
|
|
|
|
*
|
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
|
|
|
* Dan Williams <dcbw@redhat.com>
|
2007-11-26 03:47:30 +00:00
|
|
|
* Søren Sandmann <sandmann@daimi.au.dk>
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2008-06-26 18:31:52 +00:00
|
|
|
* 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.
|
2007-11-26 03:47:30 +00:00
|
|
|
*
|
2008-05-11 20:20:52 +00:00
|
|
|
* (C) Copyright 2008 Red Hat, Inc.
|
2007-11-26 03:47:30 +00:00
|
|
|
*/
|
|
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
#include <config.h>
|
2007-11-26 03:47:30 +00:00
|
|
|
#include <gmodule.h>
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
#include <string.h>
|
2007-11-29 14:40:24 +00:00
|
|
|
#include <unistd.h>
|
2008-02-07 Dan Williams <dcbw@redhat.com>
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (add_one_secret_to_hash): copy secrets out of the plugin-returned hash
table of secrets
- (connection_settings_get_secrets): consolidate error returns into
one place; use the new get_secrets() plugin interface function to
get secrets from the plugin itself rather than using GObject data
magic
* system-settings/src/main.c
- (connection_added_cb, connection_removed_cb, free_plugin_connections,
load_connections): keep a private list of the plugin-returned
connections, don't use the plugin's GSList
* system-settings/plugins/ifcfg-fedora/plugin.c
- (watch_path): watch the path, not the filename (duh)
- (reload_all_connections): use the direct hash/equal functions; the
ones for int aren't appropriate here
- (get_secrets, system_config_interface_init): implement the
get_secrets() function
- (build_one_connection, find_connection_by_path): ifcfg file path is
now in the connection's ConnectionData instead of being a GObject
data property
- (handle_profile_item_changed): ifcfg file path is now in the
connection's ConnectionData instead of being a GObject data property;
be sure to copy secrets over from the new connection to the existing
connection when updating the connection's settings
- (init): sc_plugin_inotify_init() returns success/fail, not the inotify
file descriptor
* system-settings/plugins/ifcfg-fedora/parser.c
system-settings/plugins/ifcfg-fedora/parser.h
- (connection_data_get, copy_one_cdata_secret, clear_one_cdata_secret,
connection_data_copy_secrets, connection_data_free,
connection_data_add): new functions; connection data manipulation
- (make_wireless_security_setting): stuff secrets into the
connection data, not as GObject data items; make sure to close
the keys ifcfg file
- (wireless_connection_from_ifcfg, wired_connection_from_ifcfg): add
connection data to the connection
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3299 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-02-07 20:11:31 +00:00
|
|
|
#include <errno.h>
|
2008-04-08 01:36:39 +00:00
|
|
|
#include <net/ethernet.h>
|
|
|
|
|
#include <netinet/ether.h>
|
|
|
|
|
|
|
|
|
|
#include <dbus/dbus-glib.h>
|
2007-11-26 03:47:30 +00:00
|
|
|
|
|
|
|
|
#include <nm-setting-connection.h>
|
|
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
#ifndef NO_GIO
|
|
|
|
|
#include <gio/gio.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <gfilemonitor/gfilemonitor.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "common.h"
|
2008-04-08 01:36:39 +00:00
|
|
|
#include "nm-dbus-glib-types.h"
|
2007-11-26 03:47:30 +00:00
|
|
|
#include "plugin.h"
|
|
|
|
|
#include "nm-system-config-interface.h"
|
2008-05-11 20:20:52 +00:00
|
|
|
#include "nm-ifcfg-connection.h"
|
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
|
|
|
#include "nm-inotify-helper.h"
|
|
|
|
|
#include "shvar.h"
|
2007-11-26 03:47:30 +00:00
|
|
|
|
2008-03-19 03:08:32 +00:00
|
|
|
#define IFCFG_DIR SYSCONFDIR"/sysconfig/network-scripts/"
|
|
|
|
|
|
2007-11-26 03:47:30 +00:00
|
|
|
static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class);
|
|
|
|
|
|
2008-05-13 16:53:50 +00:00
|
|
|
static void connection_changed_handler (SCPluginIfcfg *plugin,
|
|
|
|
|
const char *path,
|
|
|
|
|
NMIfcfgConnection *connection,
|
|
|
|
|
gboolean *do_remove,
|
|
|
|
|
gboolean *do_new);
|
|
|
|
|
|
|
|
|
|
static void handle_connection_remove_or_new (SCPluginIfcfg *plugin,
|
|
|
|
|
const char *path,
|
|
|
|
|
NMIfcfgConnection *connection,
|
|
|
|
|
gboolean do_remove,
|
|
|
|
|
gboolean do_new);
|
|
|
|
|
|
2007-11-26 03:47:30 +00:00
|
|
|
G_DEFINE_TYPE_EXTENDED (SCPluginIfcfg, sc_plugin_ifcfg, G_TYPE_OBJECT, 0,
|
|
|
|
|
G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE,
|
|
|
|
|
system_config_interface_init))
|
|
|
|
|
|
|
|
|
|
#define SC_PLUGIN_IFCFG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgPrivate))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2008-04-08 01:36:39 +00:00
|
|
|
DBusGConnection *g_connection;
|
|
|
|
|
NMSystemConfigHalManager *hal_mgr;
|
|
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
GHashTable *connections;
|
2007-11-29 14:40:24 +00:00
|
|
|
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
gulong ih_event_id;
|
|
|
|
|
int sc_network_wd;
|
|
|
|
|
char *hostname;
|
|
|
|
|
|
2008-08-12 22:37:08 +00:00
|
|
|
GFileMonitor *monitor;
|
|
|
|
|
guint monitor_id;
|
2007-11-26 03:47:30 +00:00
|
|
|
} SCPluginIfcfgPrivate;
|
|
|
|
|
|
|
|
|
|
|
2007-11-29 14:40:24 +00:00
|
|
|
GQuark
|
|
|
|
|
ifcfg_plugin_error_quark (void)
|
2007-11-26 03:47:30 +00:00
|
|
|
{
|
2007-11-29 14:40:24 +00:00
|
|
|
static GQuark error_quark = 0;
|
|
|
|
|
|
|
|
|
|
if (G_UNLIKELY (error_quark == 0))
|
|
|
|
|
error_quark = g_quark_from_static_string ("ifcfg-plugin-error-quark");
|
|
|
|
|
|
|
|
|
|
return error_quark;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-12 18:32:46 +00:00
|
|
|
static void
|
2008-05-11 20:20:52 +00:00
|
|
|
check_unmanaged (gpointer key, gpointer data, gpointer user_data)
|
2008-03-12 18:32:46 +00:00
|
|
|
{
|
2008-05-11 20:20:52 +00:00
|
|
|
GSList **list = (GSList **) user_data;
|
|
|
|
|
NMIfcfgConnection *connection = NM_IFCFG_CONNECTION (data);
|
|
|
|
|
const char *udi;
|
2008-04-08 01:36:39 +00:00
|
|
|
GSList *iter;
|
2008-03-12 18:32:46 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
if (!nm_ifcfg_connection_get_unmanaged (connection))
|
|
|
|
|
return;
|
2008-03-12 18:32:46 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
udi = nm_ifcfg_connection_get_udi (connection);
|
|
|
|
|
if (!udi)
|
|
|
|
|
return;
|
2008-04-08 01:36:39 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
/* Just return if the UDI is already in the list */
|
|
|
|
|
for (iter = *list; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
if (!strcmp ((char *) iter->data, udi))
|
|
|
|
|
return;
|
2008-04-08 01:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
*list = g_slist_prepend (*list, g_strdup (udi));
|
2008-04-08 01:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GSList *
|
|
|
|
|
get_unmanaged_devices (NMSystemConfigInterface *config)
|
|
|
|
|
{
|
2008-05-11 20:20:52 +00:00
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (config);
|
|
|
|
|
GSList *list = NULL;
|
2007-12-01 16:00:17 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
g_hash_table_foreach (priv->connections, check_unmanaged, &list);
|
|
|
|
|
return list;
|
2007-12-01 16:00:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-05-11 20:20:52 +00:00
|
|
|
connection_unmanaged_changed (NMIfcfgConnection *connection,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data)
|
2007-12-01 16:00:17 +00:00
|
|
|
{
|
2008-05-11 20:20:52 +00:00
|
|
|
g_signal_emit_by_name (SC_PLUGIN_IFCFG (user_data), "unmanaged-devices-changed");
|
2007-12-01 16:00:17 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-13 16:53:50 +00:00
|
|
|
static void
|
|
|
|
|
connection_ifcfg_changed (NMIfcfgConnection *connection, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data);
|
|
|
|
|
gboolean do_remove = FALSE, do_new = FALSE;
|
|
|
|
|
const char *path;
|
|
|
|
|
|
|
|
|
|
path = nm_ifcfg_connection_get_filename (connection);
|
|
|
|
|
g_return_if_fail (path != NULL);
|
|
|
|
|
|
|
|
|
|
connection_changed_handler (plugin, path, connection, &do_remove, &do_new);
|
|
|
|
|
handle_connection_remove_or_new (plugin, path, connection, do_remove, do_new);
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
static NMIfcfgConnection *
|
|
|
|
|
read_one_connection (SCPluginIfcfg *plugin, const char *filename)
|
2007-12-01 16:00:17 +00:00
|
|
|
{
|
2008-05-11 20:20:52 +00:00
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
|
|
|
|
NMIfcfgConnection *connection;
|
2007-12-01 16:00:17 +00:00
|
|
|
GError *error = NULL;
|
|
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "parsing %s ... ", filename);
|
2007-12-01 16:00:17 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
connection = nm_ifcfg_connection_new (filename, priv->g_connection, priv->hal_mgr, &error);
|
2007-12-01 16:00:17 +00:00
|
|
|
if (connection) {
|
2008-05-11 20:20:52 +00:00
|
|
|
NMConnection *wrapped;
|
2007-12-01 16:00:17 +00:00
|
|
|
NMSettingConnection *s_con;
|
2008-10-26 17:41:37 +00:00
|
|
|
const char *cid;
|
2007-12-01 16:00:17 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
wrapped = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (connection));
|
|
|
|
|
g_assert (wrapped);
|
|
|
|
|
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (wrapped, NM_TYPE_SETTING_CONNECTION));
|
2007-12-01 16:00:17 +00:00
|
|
|
g_assert (s_con);
|
2008-10-26 17:41:37 +00:00
|
|
|
|
|
|
|
|
cid = nm_setting_connection_get_id (s_con);
|
|
|
|
|
g_assert (cid);
|
2008-05-11 20:20:52 +00:00
|
|
|
|
|
|
|
|
g_hash_table_insert (priv->connections,
|
|
|
|
|
(gpointer) nm_ifcfg_connection_get_filename (connection),
|
|
|
|
|
g_object_ref (connection));
|
2008-10-26 17:41:37 +00:00
|
|
|
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " read connection '%s'", cid);
|
2008-05-11 20:20:52 +00:00
|
|
|
|
|
|
|
|
if (nm_ifcfg_connection_get_unmanaged (connection)) {
|
|
|
|
|
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "Ignoring connection '%s' and its "
|
2008-10-26 17:41:37 +00:00
|
|
|
"device because NM_CONTROLLED was false.", cid);
|
2008-05-11 20:20:52 +00:00
|
|
|
g_signal_emit_by_name (plugin, "unmanaged-devices-changed");
|
|
|
|
|
} else {
|
|
|
|
|
/* Wait for the connection to become unmanaged once it knows the
|
|
|
|
|
* UDI of it's device, if/when the device gets plugged in.
|
|
|
|
|
*/
|
|
|
|
|
g_signal_connect (G_OBJECT (connection), "notify::unmanaged",
|
|
|
|
|
G_CALLBACK (connection_unmanaged_changed), plugin);
|
|
|
|
|
}
|
2008-05-13 16:53:50 +00:00
|
|
|
|
|
|
|
|
/* watch changes of ifcfg hardlinks */
|
|
|
|
|
g_signal_connect (G_OBJECT (connection), "ifcfg-changed",
|
|
|
|
|
G_CALLBACK (connection_ifcfg_changed), plugin);
|
2007-12-01 16:00:17 +00:00
|
|
|
} else {
|
2008-02-04 19:31:20 +00:00
|
|
|
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " error: %s",
|
2007-12-01 16:00:17 +00:00
|
|
|
error->message ? error->message : "(unknown)");
|
2008-05-11 20:20:52 +00:00
|
|
|
g_error_free (error);
|
2008-02-12 19:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return connection;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
static gboolean
|
2008-05-13 16:53:50 +00:00
|
|
|
check_suffix (const char *basename, const char *tag)
|
2008-04-08 01:36:39 +00:00
|
|
|
{
|
2008-05-11 20:20:52 +00:00
|
|
|
int len, tag_len;
|
2008-04-08 01:36:39 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
g_return_val_if_fail (basename != NULL, TRUE);
|
|
|
|
|
g_return_val_if_fail (tag != NULL, TRUE);
|
2008-04-08 01:36:39 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
len = strlen (basename);
|
|
|
|
|
tag_len = strlen (tag);
|
|
|
|
|
if ((len > tag_len) && !strcasecmp (basename + len - tag_len, tag))
|
|
|
|
|
return TRUE;
|
|
|
|
|
return FALSE;
|
2008-04-08 01:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-13 16:53:50 +00:00
|
|
|
static gboolean
|
|
|
|
|
should_ignore_file (const char *filename)
|
|
|
|
|
{
|
|
|
|
|
char *basename;
|
|
|
|
|
gboolean ignore = TRUE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (filename != NULL, TRUE);
|
|
|
|
|
|
|
|
|
|
basename = g_path_get_basename (filename);
|
|
|
|
|
g_return_val_if_fail (basename != NULL, TRUE);
|
|
|
|
|
|
|
|
|
|
if ( !strncmp (basename, IFCFG_TAG, strlen (IFCFG_TAG))
|
|
|
|
|
&& !check_suffix (basename, BAK_TAG)
|
|
|
|
|
&& !check_suffix (basename, TILDE_TAG)
|
|
|
|
|
&& !check_suffix (basename, ORIG_TAG)
|
|
|
|
|
&& !check_suffix (basename, REJ_TAG))
|
|
|
|
|
ignore = FALSE;
|
|
|
|
|
|
|
|
|
|
g_free (basename);
|
|
|
|
|
return ignore;
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-01 16:00:17 +00:00
|
|
|
static void
|
2008-05-11 20:20:52 +00:00
|
|
|
read_connections (SCPluginIfcfg *plugin)
|
2007-12-01 16:00:17 +00:00
|
|
|
{
|
2008-03-19 03:08:32 +00:00
|
|
|
GDir *dir;
|
2008-05-11 20:20:52 +00:00
|
|
|
GError *err = NULL;
|
2007-12-01 16:00:17 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
dir = g_dir_open (IFCFG_DIR, 0, &err);
|
2008-03-19 03:08:32 +00:00
|
|
|
if (dir) {
|
2008-05-11 20:20:52 +00:00
|
|
|
const char *item;
|
|
|
|
|
|
2008-03-19 03:08:32 +00:00
|
|
|
while ((item = g_dir_read_name (dir))) {
|
2008-05-11 20:20:52 +00:00
|
|
|
char *full_path;
|
2008-03-19 03:08:32 +00:00
|
|
|
|
2008-05-13 16:53:50 +00:00
|
|
|
if (should_ignore_file (item))
|
2008-05-11 20:20:52 +00:00
|
|
|
continue;
|
2008-02-12 19:20:18 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
full_path = g_build_filename (IFCFG_DIR, item, NULL);
|
|
|
|
|
read_one_connection (plugin, full_path);
|
|
|
|
|
g_free (full_path);
|
2008-02-12 19:20:18 +00:00
|
|
|
}
|
2008-03-18 15:30:50 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
g_dir_close (dir);
|
|
|
|
|
} else {
|
|
|
|
|
PLUGIN_WARN (IFCFG_PLUGIN_NAME, "Can not read directory '%s': %s", IFCFG_DIR, err->message);
|
|
|
|
|
g_error_free (err);
|
2008-03-18 15:30:50 +00:00
|
|
|
}
|
2008-02-07 Dan Williams <dcbw@redhat.com>
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (add_one_secret_to_hash): copy secrets out of the plugin-returned hash
table of secrets
- (connection_settings_get_secrets): consolidate error returns into
one place; use the new get_secrets() plugin interface function to
get secrets from the plugin itself rather than using GObject data
magic
* system-settings/src/main.c
- (connection_added_cb, connection_removed_cb, free_plugin_connections,
load_connections): keep a private list of the plugin-returned
connections, don't use the plugin's GSList
* system-settings/plugins/ifcfg-fedora/plugin.c
- (watch_path): watch the path, not the filename (duh)
- (reload_all_connections): use the direct hash/equal functions; the
ones for int aren't appropriate here
- (get_secrets, system_config_interface_init): implement the
get_secrets() function
- (build_one_connection, find_connection_by_path): ifcfg file path is
now in the connection's ConnectionData instead of being a GObject
data property
- (handle_profile_item_changed): ifcfg file path is now in the
connection's ConnectionData instead of being a GObject data property;
be sure to copy secrets over from the new connection to the existing
connection when updating the connection's settings
- (init): sc_plugin_inotify_init() returns success/fail, not the inotify
file descriptor
* system-settings/plugins/ifcfg-fedora/parser.c
system-settings/plugins/ifcfg-fedora/parser.h
- (connection_data_get, copy_one_cdata_secret, clear_one_cdata_secret,
connection_data_copy_secrets, connection_data_free,
connection_data_add): new functions; connection data manipulation
- (make_wireless_security_setting): stuff secrets into the
connection data, not as GObject data items; make sure to close
the keys ifcfg file
- (wireless_connection_from_ifcfg, wired_connection_from_ifcfg): add
connection data to the connection
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3299 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-02-07 20:11:31 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
/* Monitoring */
|
2007-12-01 16:00:17 +00:00
|
|
|
|
|
|
|
|
static void
|
2008-05-13 16:53:50 +00:00
|
|
|
connection_changed_handler (SCPluginIfcfg *plugin,
|
|
|
|
|
const char *path,
|
|
|
|
|
NMIfcfgConnection *connection,
|
|
|
|
|
gboolean *do_remove,
|
|
|
|
|
gboolean *do_new)
|
2007-12-01 16:00:17 +00:00
|
|
|
{
|
|
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
2008-05-13 16:53:50 +00:00
|
|
|
NMIfcfgConnection *tmp;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
GHashTable *settings;
|
|
|
|
|
gboolean new_unmanaged, old_unmanaged;
|
2008-05-11 20:20:52 +00:00
|
|
|
|
2008-05-13 16:53:50 +00:00
|
|
|
g_return_if_fail (plugin != NULL);
|
|
|
|
|
g_return_if_fail (path != NULL);
|
|
|
|
|
g_return_if_fail (connection != NULL);
|
|
|
|
|
g_return_if_fail (do_remove != NULL);
|
|
|
|
|
g_return_if_fail (do_new != NULL);
|
2008-05-11 20:20:52 +00:00
|
|
|
|
2008-05-13 16:53:50 +00:00
|
|
|
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "updating %s", path);
|
|
|
|
|
|
|
|
|
|
tmp = (NMIfcfgConnection *) nm_ifcfg_connection_new (path, priv->g_connection, priv->hal_mgr, &error);
|
|
|
|
|
if (!tmp) {
|
|
|
|
|
/* couldn't read connection; remove it */
|
|
|
|
|
|
|
|
|
|
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " error: %s",
|
|
|
|
|
error->message ? error->message : "(unknown)");
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
|
|
|
|
|
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "removed %s.", path);
|
|
|
|
|
*do_remove = TRUE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Successfully read connection changes */
|
|
|
|
|
|
|
|
|
|
old_unmanaged = nm_ifcfg_connection_get_unmanaged (NM_IFCFG_CONNECTION (connection));
|
|
|
|
|
new_unmanaged = nm_ifcfg_connection_get_unmanaged (NM_IFCFG_CONNECTION (tmp));
|
|
|
|
|
|
|
|
|
|
if (new_unmanaged) {
|
|
|
|
|
if (!old_unmanaged) {
|
|
|
|
|
/* Unexport the connection by destroying it, then re-creating it as unmanaged */
|
|
|
|
|
*do_remove = *do_new = TRUE;
|
2008-05-11 20:20:52 +00:00
|
|
|
}
|
2008-05-13 16:53:50 +00:00
|
|
|
} else {
|
|
|
|
|
NMConnection *old_wrapped, *new_wrapped;
|
|
|
|
|
|
|
|
|
|
new_wrapped = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (tmp));
|
|
|
|
|
old_wrapped = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (connection));
|
|
|
|
|
|
2008-05-13 17:48:01 +00:00
|
|
|
if (old_unmanaged) { /* no longer unmanaged */
|
|
|
|
|
NMSettingConnection *s_con;
|
2008-10-26 17:41:37 +00:00
|
|
|
const char *cid;
|
2008-05-13 17:48:01 +00:00
|
|
|
|
|
|
|
|
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (new_wrapped, NM_TYPE_SETTING_CONNECTION));
|
|
|
|
|
g_assert (s_con);
|
2008-10-26 17:41:37 +00:00
|
|
|
|
|
|
|
|
cid = nm_setting_connection_get_id (s_con);
|
|
|
|
|
g_assert (cid);
|
2008-05-13 17:48:01 +00:00
|
|
|
|
|
|
|
|
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "Managing connection '%s' and its "
|
2008-10-26 17:41:37 +00:00
|
|
|
"device because NM_CONTROLLED was true.", cid);
|
2008-05-13 17:48:01 +00:00
|
|
|
g_signal_emit_by_name (plugin, "connection-added", connection);
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-13 16:53:50 +00:00
|
|
|
/* Only update if different */
|
|
|
|
|
if (!nm_connection_compare (new_wrapped, old_wrapped, COMPARE_FLAGS_EXACT)) {
|
|
|
|
|
settings = nm_connection_to_hash (new_wrapped);
|
|
|
|
|
nm_exported_connection_update (NM_EXPORTED_CONNECTION (connection), settings, NULL);
|
|
|
|
|
g_hash_table_destroy (settings);
|
2008-02-12 19:20:18 +00:00
|
|
|
}
|
2008-05-13 16:53:50 +00:00
|
|
|
|
|
|
|
|
/* Update unmanaged status */
|
|
|
|
|
g_object_set (connection, "unmanaged", new_unmanaged, NULL);
|
|
|
|
|
g_signal_emit_by_name (plugin, "unmanaged-devices-changed");
|
2008-02-12 19:20:18 +00:00
|
|
|
}
|
2008-05-13 16:53:50 +00:00
|
|
|
g_object_unref (tmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
handle_connection_remove_or_new (SCPluginIfcfg *plugin,
|
|
|
|
|
const char *path,
|
|
|
|
|
NMIfcfgConnection *connection,
|
|
|
|
|
gboolean do_remove,
|
|
|
|
|
gboolean do_new)
|
|
|
|
|
{
|
|
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (plugin != NULL);
|
|
|
|
|
g_return_if_fail (path != NULL);
|
2008-02-12 19:20:18 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
if (do_remove) {
|
2008-05-13 16:53:50 +00:00
|
|
|
gboolean unmanaged;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (connection != NULL);
|
2008-05-11 20:20:52 +00:00
|
|
|
|
2008-05-13 16:53:50 +00:00
|
|
|
unmanaged = nm_ifcfg_connection_get_unmanaged (connection);
|
|
|
|
|
g_hash_table_remove (priv->connections, path);
|
2008-05-11 20:20:52 +00:00
|
|
|
nm_exported_connection_signal_removed (NM_EXPORTED_CONNECTION (connection));
|
|
|
|
|
|
|
|
|
|
/* Emit unmanaged changes _after_ removing the connection */
|
|
|
|
|
if (unmanaged)
|
|
|
|
|
g_signal_emit_by_name (plugin, "unmanaged-devices-changed");
|
2008-02-12 19:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
if (do_new) {
|
2008-05-13 16:53:50 +00:00
|
|
|
connection = read_one_connection (plugin, path);
|
2008-05-11 20:20:52 +00:00
|
|
|
if (connection) {
|
|
|
|
|
if (!nm_ifcfg_connection_get_unmanaged (NM_IFCFG_CONNECTION (connection)))
|
|
|
|
|
g_signal_emit_by_name (plugin, "connection-added", connection);
|
2008-04-08 01:36:39 +00:00
|
|
|
}
|
2008-02-12 19:20:18 +00:00
|
|
|
}
|
2008-05-13 16:53:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dir_changed (GFileMonitor *monitor,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GFile *other_file,
|
|
|
|
|
GFileMonitorEvent event_type,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data);
|
|
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
|
|
|
|
char *name;
|
|
|
|
|
NMIfcfgConnection *connection;
|
|
|
|
|
gboolean do_remove = FALSE, do_new = FALSE;
|
|
|
|
|
|
|
|
|
|
name = g_file_get_path (file);
|
|
|
|
|
if (should_ignore_file (name)) {
|
|
|
|
|
g_free (name);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connection = g_hash_table_lookup (priv->connections, name);
|
|
|
|
|
if (!connection) {
|
|
|
|
|
do_new = TRUE;
|
|
|
|
|
} else {
|
|
|
|
|
switch (event_type) {
|
|
|
|
|
case G_FILE_MONITOR_EVENT_DELETED:
|
|
|
|
|
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "removed %s.", name);
|
|
|
|
|
do_remove = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case G_FILE_MONITOR_EVENT_CREATED:
|
|
|
|
|
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
|
|
|
|
|
/* Update */
|
|
|
|
|
connection_changed_handler (plugin, name, connection, &do_remove, &do_new);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handle_connection_remove_or_new (plugin, name, connection, do_remove, do_new);
|
2008-02-12 19:20:18 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
g_free (name);
|
2008-02-12 19:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
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
|
|
|
setup_ifcfg_monitoring (SCPluginIfcfg *plugin)
|
2008-02-12 19:20:18 +00:00
|
|
|
{
|
|
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
2008-05-11 20:20:52 +00:00
|
|
|
GFile *file;
|
|
|
|
|
GFileMonitor *monitor;
|
2007-12-01 16:00:17 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
|
2007-12-01 16:00:17 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
file = g_file_new_for_path (IFCFG_DIR);
|
2008-08-12 22:37:08 +00:00
|
|
|
monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL);
|
2008-05-11 20:20:52 +00:00
|
|
|
g_object_unref (file);
|
2008-02-12 19:20:18 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
if (monitor) {
|
2008-08-12 22:37:08 +00:00
|
|
|
priv->monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (dir_changed), plugin);
|
|
|
|
|
priv->monitor = monitor;
|
2007-12-01 16:00:17 +00:00
|
|
|
}
|
2008-02-12 20:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
static void
|
|
|
|
|
hash_to_slist (gpointer key, gpointer value, gpointer user_data)
|
2008-02-12 20:25:12 +00:00
|
|
|
{
|
2008-05-11 20:20:52 +00:00
|
|
|
NMIfcfgConnection *exported = NM_IFCFG_CONNECTION (value);
|
|
|
|
|
GSList **list = (GSList **) user_data;
|
2008-03-19 03:08:32 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
if (!nm_ifcfg_connection_get_unmanaged (exported))
|
|
|
|
|
*list = g_slist_prepend (*list, value);
|
2008-02-12 20:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
static GSList *
|
|
|
|
|
get_connections (NMSystemConfigInterface *config)
|
2007-11-29 14:40:24 +00:00
|
|
|
{
|
2008-05-11 20:20:52 +00:00
|
|
|
SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (config);
|
2007-11-29 14:40:24 +00:00
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
2008-05-11 20:20:52 +00:00
|
|
|
GSList *list = NULL;
|
2007-11-29 14:40:24 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
if (!priv->connections) {
|
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
|
|
|
setup_ifcfg_monitoring (plugin);
|
2008-05-11 20:20:52 +00:00
|
|
|
read_connections (plugin);
|
2008-03-19 03:08:32 +00:00
|
|
|
}
|
2007-11-29 14:40:24 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
g_hash_table_foreach (priv->connections, hash_to_slist, &list);
|
2007-11-29 14:40:24 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
return list;
|
2007-11-29 14:40:24 +00:00
|
|
|
}
|
|
|
|
|
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
#define SC_NETWORK_FILE SYSCONFDIR"/sysconfig/network"
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
plugin_get_hostname (SCPluginIfcfg *plugin)
|
|
|
|
|
{
|
|
|
|
|
shvarFile *network;
|
|
|
|
|
char *hostname;
|
|
|
|
|
|
|
|
|
|
network = svNewFile (SC_NETWORK_FILE);
|
|
|
|
|
if (!network) {
|
|
|
|
|
PLUGIN_WARN (IFCFG_PLUGIN_NAME, "Could not get hostname: failed to read " SC_NETWORK_FILE);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hostname = svGetValue (network, "HOSTNAME");
|
|
|
|
|
svCloseFile (network);
|
|
|
|
|
return hostname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname)
|
|
|
|
|
{
|
|
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
|
|
|
|
shvarFile *network;
|
|
|
|
|
|
|
|
|
|
network = svCreateFile (SC_NETWORK_FILE);
|
|
|
|
|
if (!network) {
|
|
|
|
|
PLUGIN_WARN (IFCFG_PLUGIN_NAME, "Could not save hostname: failed to create/open " SC_NETWORK_FILE);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
svSetValue (network, "HOSTNAME", hostname);
|
|
|
|
|
svWriteFile (network, 0644);
|
|
|
|
|
svCloseFile (network);
|
|
|
|
|
|
|
|
|
|
g_free (priv->hostname);
|
|
|
|
|
priv->hostname = hostname ? g_strdup (hostname) : NULL;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
sc_network_changed_cb (NMInotifyHelper *ih,
|
|
|
|
|
struct inotify_event *evt,
|
|
|
|
|
const char *path,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data);
|
|
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
|
|
|
|
char *new_hostname;
|
|
|
|
|
|
|
|
|
|
if (evt->wd != priv->sc_network_wd)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
new_hostname = plugin_get_hostname (plugin);
|
|
|
|
|
if ( (new_hostname && !priv->hostname)
|
|
|
|
|
|| (!new_hostname && priv->hostname)
|
|
|
|
|
|| (priv->hostname && new_hostname && strcmp (priv->hostname, new_hostname))) {
|
|
|
|
|
g_free (priv->hostname);
|
|
|
|
|
priv->hostname = new_hostname;
|
|
|
|
|
g_object_notify (G_OBJECT (plugin), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME);
|
|
|
|
|
} else
|
|
|
|
|
g_free (new_hostname);
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-29 14:40:24 +00:00
|
|
|
static void
|
2008-04-08 01:36:39 +00:00
|
|
|
init (NMSystemConfigInterface *config, NMSystemConfigHalManager *hal_manager)
|
2007-11-29 14:40:24 +00:00
|
|
|
{
|
|
|
|
|
SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (config);
|
2008-04-08 01:36:39 +00:00
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
|
|
|
|
|
|
|
|
|
priv->hal_mgr = g_object_ref (hal_manager);
|
2007-11-26 03:47:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
sc_plugin_ifcfg_init (SCPluginIfcfg *plugin)
|
|
|
|
|
{
|
2008-04-08 01:36:39 +00:00
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
|
|
|
|
GError *error = NULL;
|
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
|
|
|
NMInotifyHelper *ih;
|
2008-04-08 01:36:39 +00:00
|
|
|
|
|
|
|
|
priv->g_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
|
|
|
|
|
if (!priv->g_connection) {
|
|
|
|
|
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " dbus-glib error: %s",
|
|
|
|
|
error->message ? error->message : "(unknown)");
|
2008-04-16 14:33:12 +00:00
|
|
|
g_error_free (error);
|
2008-04-08 01:36:39 +00:00
|
|
|
}
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
|
|
|
|
|
ih = nm_inotify_helper_get ();
|
|
|
|
|
priv->ih_event_id = g_signal_connect (ih, "event", G_CALLBACK (sc_network_changed_cb), plugin);
|
|
|
|
|
priv->sc_network_wd = nm_inotify_helper_add_watch (ih, SC_NETWORK_FILE);
|
|
|
|
|
|
|
|
|
|
priv->hostname = plugin_get_hostname (plugin);
|
2007-11-26 03:47:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dispose (GObject *object)
|
|
|
|
|
{
|
2008-04-08 01:36:39 +00:00
|
|
|
SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (object);
|
|
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
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
|
|
|
NMInotifyHelper *ih;
|
2008-04-08 01:36:39 +00:00
|
|
|
|
|
|
|
|
g_object_unref (priv->hal_mgr);
|
|
|
|
|
|
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
|
|
|
ih = nm_inotify_helper_get ();
|
|
|
|
|
|
|
|
|
|
g_signal_handler_disconnect (ih, priv->ih_event_id);
|
|
|
|
|
|
|
|
|
|
if (priv->sc_network_wd >= 0)
|
|
|
|
|
nm_inotify_helper_remove_watch (ih, priv->sc_network_wd);
|
|
|
|
|
|
|
|
|
|
g_free (priv->hostname);
|
|
|
|
|
|
2008-04-08 01:36:39 +00:00
|
|
|
if (priv->g_connection)
|
2008-05-02 16:22:39 +00:00
|
|
|
dbus_g_connection_unref (priv->g_connection);
|
2008-03-19 03:08:32 +00:00
|
|
|
|
2008-05-11 20:20:52 +00:00
|
|
|
if (priv->connections)
|
|
|
|
|
g_hash_table_destroy (priv->connections);
|
|
|
|
|
|
2008-08-12 22:37:08 +00:00
|
|
|
if (priv->monitor) {
|
|
|
|
|
if (priv->monitor_id)
|
|
|
|
|
g_signal_handler_disconnect (priv->monitor, priv->monitor_id);
|
2008-05-11 20:20:52 +00:00
|
|
|
|
2008-08-12 22:37:08 +00:00
|
|
|
g_file_monitor_cancel (priv->monitor);
|
|
|
|
|
g_object_unref (priv->monitor);
|
2008-05-11 20:20:52 +00:00
|
|
|
}
|
|
|
|
|
|
2007-11-26 03:47:30 +00:00
|
|
|
G_OBJECT_CLASS (sc_plugin_ifcfg_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
G_OBJECT_CLASS (sc_plugin_ifcfg_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
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
|
|
|
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (object);
|
|
|
|
|
|
2007-11-26 03:47:30 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
|
case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME:
|
|
|
|
|
g_value_set_string (value, IFCFG_PLUGIN_NAME);
|
|
|
|
|
break;
|
|
|
|
|
case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO:
|
|
|
|
|
g_value_set_string (value, IFCFG_PLUGIN_INFO);
|
|
|
|
|
break;
|
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
|
|
|
case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES:
|
|
|
|
|
g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME);
|
|
|
|
|
break;
|
|
|
|
|
case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME:
|
|
|
|
|
g_value_set_string (value, priv->hostname);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
const char *hostname;
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME:
|
|
|
|
|
hostname = g_value_get_string (value);
|
2008-09-24 15:03:33 +00:00
|
|
|
if (hostname && strlen (hostname) < 1)
|
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
|
|
|
hostname = NULL;
|
2008-09-24 15:03:33 +00:00
|
|
|
plugin_set_hostname (SC_PLUGIN_IFCFG (object), hostname);
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
break;
|
2007-11-26 03:47:30 +00:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (req_class);
|
|
|
|
|
|
|
|
|
|
g_type_class_add_private (req_class, sizeof (SCPluginIfcfgPrivate));
|
|
|
|
|
|
|
|
|
|
object_class->dispose = dispose;
|
|
|
|
|
object_class->finalize = finalize;
|
|
|
|
|
object_class->get_property = get_property;
|
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
|
|
|
object_class->set_property = set_property;
|
|
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME,
|
|
|
|
|
NM_SYSTEM_CONFIG_INTERFACE_NAME);
|
|
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO,
|
|
|
|
|
NM_SYSTEM_CONFIG_INTERFACE_INFO);
|
2007-11-26 03:47:30 +00:00
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class,
|
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
|
|
|
NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES,
|
|
|
|
|
NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES);
|
2007-11-26 03:47:30 +00:00
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class,
|
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
|
|
|
NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME,
|
|
|
|
|
NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME);
|
2007-11-26 03:47:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
system_config_interface_init (NMSystemConfigInterface *system_config_interface_class)
|
|
|
|
|
{
|
|
|
|
|
/* interface implementation */
|
2007-11-29 14:40:24 +00:00
|
|
|
system_config_interface_class->get_connections = get_connections;
|
2008-04-08 01:36:39 +00:00
|
|
|
system_config_interface_class->get_unmanaged_devices = get_unmanaged_devices;
|
2007-11-29 14:40:24 +00:00
|
|
|
system_config_interface_class->init = init;
|
2007-11-26 03:47:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G_MODULE_EXPORT GObject *
|
|
|
|
|
nm_system_config_factory (void)
|
|
|
|
|
{
|
|
|
|
|
static SCPluginIfcfg *singleton = NULL;
|
|
|
|
|
|
2007-11-29 14:40:24 +00:00
|
|
|
if (!singleton)
|
2007-11-26 03:47:30 +00:00
|
|
|
singleton = SC_PLUGIN_IFCFG (g_object_new (SC_TYPE_PLUGIN_IFCFG, NULL));
|
2008-04-08 21:15:45 +00:00
|
|
|
else
|
|
|
|
|
g_object_ref (singleton);
|
2007-11-26 03:47:30 +00:00
|
|
|
|
|
|
|
|
return G_OBJECT (singleton);
|
|
|
|
|
}
|