+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
+
2008-10-08 Dan Williams <dcbw@redhat.com>
* src/NetworkManagerSystem.c
if (debug) {
char **p;
- g_message ("-----------------------------------------");
+ g_message ("------------ Script Environment ------------");
for (p = envp; *p; p++)
g_message (" %s", *p);
g_message ("\n");
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)) {
*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)) {
ip4_config = nm_device_get_ip4_config (device);
}
+dispatch:
dispatch_scripts (action, iface, parent_iface, type, ip4_config, dhcp4_config);
if (device)
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);
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)));
+ /* 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)));
+ /* 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,