diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c index 241199f401..374c663681 100644 --- a/src/dhcp-manager/nm-dhcp-manager.c +++ b/src/dhcp-manager/nm-dhcp-manager.c @@ -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); diff --git a/src/main.c b/src/main.c index 7b881b1471..c705cb8d50 100644 --- a/src/main.c +++ b/src/main.c @@ -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;