dhcp: more intelligent default DHCP client detection

This commit is contained in:
Jiří Klimeš
2010-03-06 00:07:06 -08:00
committed by Dan Williams
parent dbacb05d2a
commit 798d68caa4
2 changed files with 16 additions and 1 deletions

View File

@@ -251,6 +251,20 @@ nm_dhcp_manager_new (const char *client, GError **error)
NMDHCPManagerPrivate *priv;
DBusGConnection *g_connection;
/* Set some defaults based on build-time options */
if (!client) {
if (strlen (DHCLIENT_PATH) && g_file_test (DHCLIENT_PATH, G_FILE_TEST_EXISTS))
client = "dhclient";
else if (strlen (DHCPCD_PATH) && g_file_test (DHCPCD_PATH, G_FILE_TEST_EXISTS))
client = "dhcpcd";
else {
g_set_error_literal (error, 0, 0,
"no suitable DHCP client; see 'man NetworkManager'"
" to specify one.");
return NULL;
}
}
g_warn_if_fail (singleton == NULL);
g_return_val_if_fail (client != NULL, NULL);

View File

@@ -652,7 +652,8 @@ main (int argc, char *argv[])
goto done;
}
dhcp_mgr = nm_dhcp_manager_new (dhcp ? dhcp : "dhclient", &error);
/* Initialize DHCP manager */
dhcp_mgr = nm_dhcp_manager_new (dhcp, &error);
if (!dhcp_mgr) {
nm_warning ("Failed to start the DHCP manager: %s.", error->message);
goto done;