summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rothlisberger <david@rothlis.net>2011-11-09 11:17:04 -0600
committerDan Williams <dcbw@redhat.com>2011-11-09 11:17:04 -0600
commitacadb7da8b1e8c0c850423ad2c8d820528bc41d1 (patch)
tree5644b43a3c60644a70fd6ed52a0ed7485346aa3f
parentc25b97b39f5d589cd2f774fdd482e8e4a9ebf43c (diff)
dhclient: pass DBUS_SYSTEM_BUS_ADDRESS environment variable
So that dhclient will, in turn, pass it to the action script (the action script tries to send a DBus signal to NetworkManager over the system bus). Dhclient "execve"s the action script with a hand-constructed environment that only includes specific variables, plus whatever is passed to dhclient with "-e". As far as I know, dhcpcd has no option equivalent to dhclient's "-e".
-rw-r--r--src/dhcp-manager/nm-dhcp-dhclient.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/dhcp-manager/nm-dhcp-dhclient.c b/src/dhcp-manager/nm-dhcp-dhclient.c
index 88136a9008..09321396e8 100644
--- a/src/dhcp-manager/nm-dhcp-dhclient.c
+++ b/src/dhcp-manager/nm-dhcp-dhclient.c
@@ -418,8 +418,8 @@ dhclient_start (NMDHCPClient *client,
GPtrArray *argv = NULL;
GPid pid = -1;
GError *error = NULL;
- const char *iface, *uuid;
- char *binary_name, *cmd_str, *pid_file = NULL;
+ const char *iface, *uuid, *system_bus_address;
+ char *binary_name, *cmd_str, *pid_file = NULL, *system_bus_address_env = NULL;
gboolean ipv6;
guint log_domain;
@@ -503,6 +503,18 @@ dhclient_start (NMDHCPClient *client,
g_ptr_array_add (argv, (gpointer) priv->conf_file);
}
+ /* Usually the system bus address is well-known; but if it's supposed
+ * to be something else, we need to push it to dhclient, since dhclient
+ * sanitizes the environment it gives the action scripts.
+ */
+ system_bus_address = getenv ("DBUS_SYSTEM_BUS_ADDRESS");
+ if (system_bus_address) {
+ system_bus_address_env = g_strdup_printf ("DBUS_SYSTEM_BUS_ADDRESS=%s", system_bus_address);
+ g_ptr_array_add (argv, (gpointer) "-e");
+ g_ptr_array_add (argv, (gpointer) system_bus_address_env);
+ }
+
+
g_ptr_array_add (argv, (gpointer) iface);
g_ptr_array_add (argv, NULL);
@@ -521,6 +533,7 @@ dhclient_start (NMDHCPClient *client,
}
g_ptr_array_free (argv, TRUE);
+ g_free (system_bus_address_env);
return pid;
}