NetworkManager r4158 - in trunk: . callouts src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r4158 - in trunk: . callouts src
- Date: Wed, 8 Oct 2008 22:40:42 +0000 (UTC)
Author: dcbw
Date: Wed Oct 8 22:40:42 2008
New Revision: 4158
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=4158&view=rev
Log:
2008-10-08 Dan Williams <dcbw redhat com>
Add a 'hostname' dispatcher action triggered on hostname changes (bgo #552983)
* src/NetworkManagerUtils.c
- (nm_utils_call_dispatcher): add a 'hostname' action
* src/NetworkManagerPolicy.c
- (set_system_hostname): dispatch hostname changes
* callouts/nm-dispatcher-action.c
- (nm_dispatcher_action): handle 'hostname' actions
Modified:
trunk/ChangeLog
trunk/callouts/nm-dispatcher-action.c
trunk/src/NetworkManagerPolicy.c
trunk/src/NetworkManagerUtils.c
Modified: trunk/callouts/nm-dispatcher-action.c
==============================================================================
--- trunk/callouts/nm-dispatcher-action.c (original)
+++ trunk/callouts/nm-dispatcher-action.c Wed Oct 8 22:40:42 2008
@@ -361,7 +361,7 @@
if (debug) {
char **p;
- g_message ("-----------------------------------------");
+ g_message ("------------ Script Environment ------------");
for (p = envp; *p; p++)
g_message (" %s", *p);
g_message ("\n");
@@ -427,10 +427,13 @@
gint status = -1;
argv[0] = (char *) iter->data;
- argv[1] = (char *) iface;
+ argv[1] = iface ? (char *) iface : "none";
argv[2] = (char *) action;
argv[3] = NULL;
+ if (debug)
+ g_message ("Script: %s %s %s", (char *) iter->data, iface ? (char *) iface : "(none)", (char *) action);
+
error = NULL;
if (g_spawn_sync ("/", argv, envp, 0, child_setup, NULL, NULL, NULL, &status, &error)) {
if (WIFEXITED (status)) {
@@ -488,6 +491,10 @@
*error = NULL;
}
+ /* Hostname changes don't require a device */
+ if (!strcmp (action, "hostname"))
+ goto dispatch;
+
/* interface name */
value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_INTERFACE);
if (!value || !G_VALUE_HOLDS_STRING (value)) {
@@ -537,6 +544,7 @@
ip4_config = nm_device_get_ip4_config (device);
}
+dispatch:
dispatch_scripts (action, iface, parent_iface, type, ip4_config, dhcp4_config);
if (device)
Modified: trunk/src/NetworkManagerPolicy.c
==============================================================================
--- trunk/src/NetworkManagerPolicy.c (original)
+++ trunk/src/NetworkManagerPolicy.c Wed Oct 8 22:40:42 2008
@@ -351,6 +351,7 @@
__func__, FALLBACK_HOSTNAME, errno, strerror (errno));
}
}
+ nm_utils_call_dispatcher ("hostname", NULL, NULL, NULL);
} else {
nm_warning ("%s: couldn't set the system hostname to '%s': (%d) %s",
__func__, name, errno, strerror (errno));
Modified: trunk/src/NetworkManagerUtils.c
==============================================================================
--- trunk/src/NetworkManagerUtils.c (original)
+++ trunk/src/NetworkManagerUtils.c Wed Oct 8 22:40:42 2008
@@ -427,7 +427,10 @@
GHashTable *device_props;
g_return_if_fail (action != NULL);
- g_return_if_fail (NM_IS_DEVICE (device));
+
+ /* All actions except 'hostname' require a device */
+ if (strcmp (action, "hostname"))
+ g_return_if_fail (NM_IS_DEVICE (device));
dbus_mgr = nm_dbus_manager_get ();
g_connection = nm_dbus_manager_get_connection (dbus_mgr);
@@ -470,29 +473,32 @@
device_props = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL, nm_gvalue_destroy);
- /* interface */
- g_hash_table_insert (device_props, NMD_DEVICE_PROPS_INTERFACE,
- str_to_gvalue (nm_device_get_iface (device)));
-
- /* IP interface */
- if (vpn_iface) {
- g_hash_table_insert (device_props, NMD_DEVICE_PROPS_IP_INTERFACE,
- str_to_gvalue (vpn_iface));
- } else if (nm_device_get_ip_iface (device)) {
- g_hash_table_insert (device_props, NMD_DEVICE_PROPS_IP_INTERFACE,
- str_to_gvalue (nm_device_get_ip_iface (device)));
- }
+ /* Hostname actions do not require a device */
+ if (strcmp (action, "hostname")) {
+ /* interface */
+ g_hash_table_insert (device_props, NMD_DEVICE_PROPS_INTERFACE,
+ str_to_gvalue (nm_device_get_iface (device)));
+
+ /* IP interface */
+ if (vpn_iface) {
+ g_hash_table_insert (device_props, NMD_DEVICE_PROPS_IP_INTERFACE,
+ str_to_gvalue (vpn_iface));
+ } else if (nm_device_get_ip_iface (device)) {
+ g_hash_table_insert (device_props, NMD_DEVICE_PROPS_IP_INTERFACE,
+ str_to_gvalue (nm_device_get_ip_iface (device)));
+ }
- /* type */
- g_hash_table_insert (device_props, NMD_DEVICE_PROPS_TYPE,
- uint_to_gvalue (nm_device_get_device_type (device)));
-
- /* state */
- g_hash_table_insert (device_props, NMD_DEVICE_PROPS_STATE,
- uint_to_gvalue (nm_device_get_state (device)));
+ /* type */
+ g_hash_table_insert (device_props, NMD_DEVICE_PROPS_TYPE,
+ uint_to_gvalue (nm_device_get_device_type (device)));
+
+ /* state */
+ g_hash_table_insert (device_props, NMD_DEVICE_PROPS_STATE,
+ uint_to_gvalue (nm_device_get_state (device)));
- g_hash_table_insert (device_props, NMD_DEVICE_PROPS_PATH,
- op_to_gvalue (nm_device_get_udi (device)));
+ g_hash_table_insert (device_props, NMD_DEVICE_PROPS_PATH,
+ op_to_gvalue (nm_device_get_udi (device)));
+ }
dbus_g_proxy_call_no_reply (proxy, "Action",
G_TYPE_STRING, action,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]