mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 07:40:28 +01:00
dhcp: more intelligent default DHCP client detection
This commit is contained in:
parent
dbacb05d2a
commit
798d68caa4
2 changed files with 16 additions and 1 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue