[PATCH] Re: dhcp client support broken on karmic with latest NM build



On Saturday 27 of February 2010 00:23:10 Dan Williams wrote:
> On Fri, 2010-02-26 at 14:30 +0300, Andrey Borzenkov wrote:
> > On Thursday 25 of February 2010 22:53:59 Dan Williams wrote:
> > > 3) Set the 'dhcp' property in the [main] section of
> > > nm-system-settings.conf to either "dhclient" or "dhcpcd"
> > 
> > I must be completely stupid but I cannot find it in current sources
> > (upstream GIT, tree corresponds to 0.8 tag). Is it in some distro-
> > specific patches?
> 
> It goes like this:
> 
> Build time: by default configure checks for both dhclient and dhcpcd on
> the build system.  If any exist, they are enabled.  If you don't want to
> hard-dep during build time you can configure with
> --with-dhclient=/path/to/dhclient and --with-dhcpcd=/path/to/dhcpcd.
> 
> Runtime: the runtime client choice is by default dhclient (see
> src/NetworkManager.c) unless overriden.  That should probably be fixed
> such that if dhclient does not exist, but dhcpcd's path is valid,
> default to dhcpcd.
> 

Attached patch that tests if dhclient path is correct. If so it uses dhclient, 
otherwise dhcpcd.

Jirka
diff --git a/src/Makefile.am b/src/Makefile.am
index a150500..b06c337 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -198,6 +198,8 @@ NetworkManager_CPPFLAGS = \
 	-DLOCALSTATEDIR=\"$(localstatedir)\" \
 	-DNM_RUN_DIR=\"$(rundir)\" \
 	-DNMLOCALEDIR=\"$(datadir)/locale\" \
+	-DDHCLIENT_PATH=\"$(DHCLIENT_PATH)\" \
+	-DDHCPCD_PATH=\"$(DHCPCD_PATH)\" \
 	-DARP_DEBUG
 
 NetworkManager_LDADD = \
diff --git a/src/NetworkManager.c b/src/NetworkManager.c
index 17a96a9..7a54246 100644
--- a/src/NetworkManager.c
+++ b/src/NetworkManager.c
@@ -442,6 +442,7 @@ main (int argc, char *argv[])
 	gboolean g_fatal_warnings = FALSE;
 	char *pidfile = NULL, *state_file = NULL, *dhcp = NULL;
 	char *config = NULL, *plugins = NULL, *conf_plugins = NULL;
+	const char *default_dhcp_client;
 	gboolean wifi_enabled = TRUE, net_enabled = TRUE, wwan_enabled = TRUE;
 	gboolean success;
 	NMPolicy *policy = NULL;
@@ -651,7 +652,12 @@ main (int argc, char *argv[])
 		goto done;
 	}
 
-	dhcp_mgr = nm_dhcp_manager_new (dhcp ? dhcp : "dhclient", &error);
+	/* Initialize DHCP manager */
+	if (strlen (DHCLIENT_PATH) && g_file_test (DHCLIENT_PATH, G_FILE_TEST_EXISTS))
+		default_dhcp_client = "dhclient";
+	else
+		default_dhcp_client = "dhcpcd";
+	dhcp_mgr = nm_dhcp_manager_new (dhcp ? dhcp : default_dhcp_client, &error);
 	if (!dhcp_mgr) {
 		nm_warning ("Failed to start the DHCP manager: %s.", error->message);
 		goto done;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]