diff options
Diffstat (limited to 'src/dhcp/nm-dhcp-dhclient.c')
| -rw-r--r-- | src/dhcp/nm-dhcp-dhclient.c | 57 |
1 files changed, 15 insertions, 42 deletions
diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c index 54b50479..869966fb 100644 --- a/src/dhcp/nm-dhcp-dhclient.c +++ b/src/dhcp/nm-dhcp-dhclient.c @@ -1,19 +1,5 @@ -/* nm-dhcp-dhclient.c - dhclient specific hooks for NetworkManager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Copyright (C) 2005 - 2012 Red Hat, Inc. */ @@ -38,7 +24,6 @@ #include "nm-glib-aux/nm-dedup-multi.h" #include "nm-utils.h" -#include "nm-config.h" #include "nm-dhcp-dhclient-utils.h" #include "nm-dhcp-manager.h" #include "NetworkManagerUtils.h" @@ -118,35 +103,14 @@ get_dhclient_leasefile (int addr_family, const char *uuid, char **out_preferred_path) { - gs_free char *rundir_path = NULL; gs_free char *path = NULL; - /* First, see if the lease file is in /run */ - rundir_path = g_strdup_printf (NMRUNDIR "/dhclient%s-%s-%s.lease", - _addr_family_to_path_part (addr_family), - uuid, - iface); - - if (g_file_test (rundir_path, G_FILE_TEST_EXISTS)) { - NM_SET_OUT (out_preferred_path, g_strdup (rundir_path)); - return g_steal_pointer (&rundir_path); - } - - /* /var/lib/NetworkManager is the preferred leasefile path */ - path = g_strdup_printf (NMSTATEDIR "/dhclient%s-%s-%s.lease", - _addr_family_to_path_part (addr_family), - uuid, - iface); - - if (g_file_test (path, G_FILE_TEST_EXISTS)) { + if (nm_dhcp_utils_get_leasefile_path (addr_family, "dhclient", iface, uuid, &path)) { NM_SET_OUT (out_preferred_path, g_strdup (path)); return g_steal_pointer (&path); } - if (nm_config_get_configure_and_quit (nm_config_get ()) == NM_CONFIG_CONFIGURE_AND_QUIT_INITRD) - NM_SET_OUT (out_preferred_path, g_steal_pointer (&rundir_path)); - else - NM_SET_OUT (out_preferred_path, g_steal_pointer (&path)); + NM_SET_OUT (out_preferred_path, g_steal_pointer (&path)); /* If the leasefile we're looking for doesn't exist yet in the new location * (eg, /var/lib/NetworkManager) then look in old locations to maintain @@ -182,6 +146,7 @@ merge_dhclient_config (NMDhcpDhclient *self, const char *hostname, guint32 timeout, gboolean use_fqdn, + NMDhcpHostnameFlags hostname_flags, const char *orig_path, GBytes **out_new_client_id, GError **error) @@ -210,10 +175,11 @@ merge_dhclient_config (NMDhcpDhclient *self, hostname, timeout, use_fqdn, + hostname_flags, orig_path, orig, out_new_client_id); - g_assert (new); + nm_assert (new); return g_file_set_contents (conf_file, new, @@ -301,6 +267,7 @@ create_dhclient_config (NMDhcpDhclient *self, const char *hostname, guint32 timeout, gboolean use_fqdn, + NMDhcpHostnameFlags hostname_flags, GBytes **out_new_client_id) { gs_free char *orig = NULL; @@ -328,6 +295,7 @@ create_dhclient_config (NMDhcpDhclient *self, hostname, timeout, use_fqdn, + hostname_flags, orig, out_new_client_id, &error)) { @@ -527,6 +495,7 @@ ip4_start (NMDhcpClient *client, nm_dhcp_client_get_hostname (client), nm_dhcp_client_get_timeout (client), nm_dhcp_client_get_use_fqdn (client), + nm_dhcp_client_get_hostname_flags (client), &new_client_id); if (!priv->conf_file) { nm_utils_error_set_literal (error, @@ -558,6 +527,9 @@ ip6_start (NMDhcpClient *client, NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client); NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self); + if (nm_dhcp_client_get_iaid_explicit (client)) + _LOGW ("dhclient does not support specifying an IAID for DHCPv6, it will be ignored"); + priv->conf_file = create_dhclient_config (self, AF_INET6, nm_dhcp_client_get_iface (client), @@ -567,6 +539,7 @@ ip6_start (NMDhcpClient *client, nm_dhcp_client_get_hostname (client), nm_dhcp_client_get_timeout (client), TRUE, + nm_dhcp_client_get_hostname_flags (client), NULL); if (!priv->conf_file) { nm_utils_error_set_literal (error, @@ -723,7 +696,7 @@ nm_dhcp_dhclient_class_init (NMDhcpDhclientClass *dhclient_class) } const NMDhcpClientFactory _nm_dhcp_client_factory_dhclient = { - .name = "dhclient", + .name = "dhclient", .get_type = nm_dhcp_dhclient_get_type, .get_path = nm_dhcp_dhclient_get_path, }; |