From 98b124a661f0825bd6d3ffd2a15d3b6a3576261a Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 15 Jan 2025 16:44:37 +0100 Subject: [PATCH] dhcp: drop dhcpcanon support Drop support for the "dhcpcanon" DHCP client. It's unmantained, as the last code change was in 2018: https://github.com/juga0/dhcpcanon/commits There is no need to first deprecate it because it was still marked as "experimental" in NM. Also, it's not packaged by any recent distro, so we can assume that nobody will miss it. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2112 --- NEWS | 1 + config.h.meson | 6 - contrib/fedora/rpm/NetworkManager.spec | 1 - contrib/fedora/rpm/configure-for-system.sh | 1 - contrib/scripts/nm-ci-run.sh | 1 - meson.build | 2 +- meson_options.txt | 3 +- src/core/dhcp/nm-dhcp-client.h | 1 - src/core/dhcp/nm-dhcp-dhcpcanon.c | 239 --------------------- src/core/dhcp/nm-dhcp-listener.c | 3 - src/core/meson.build | 1 - 11 files changed, 3 insertions(+), 256 deletions(-) delete mode 100644 src/core/dhcp/nm-dhcp-dhcpcanon.c diff --git a/NEWS b/NEWS index 9e988da58..6f57b415d 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,7 @@ USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE! DNS over TLS name servers. * The initrd-generator understands the "rd.net.dns" option to configure global name servers. +* Drop support for the "dhcpcanon" DHCP client. ============================================= NetworkManager-1.50 diff --git a/config.h.meson b/config.h.meson index d364f7628..e59160dec 100644 --- a/config.h.meson +++ b/config.h.meson @@ -4,9 +4,6 @@ /* Define to path of dhclient binary */ #mesondefine DHCLIENT_PATH -/* Define to path of dhcpcanon binary */ -#mesondefine DHCPCANON_PATH - /* Define to path of dhcpcd binary */ #mesondefine DHCPCD_PATH @@ -224,9 +221,6 @@ /* Define if you have dhclient */ #mesondefine WITH_DHCLIENT -/* Define if you have dhcpcanon */ -#mesondefine WITH_DHCPCANON - /* Define if you have dhcpcd */ #mesondefine WITH_DHCPCD diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index 62663ee8d..2af0f4460 100644 --- a/contrib/fedora/rpm/NetworkManager.spec +++ b/contrib/fedora/rpm/NetworkManager.spec @@ -602,7 +602,6 @@ Preferably use nmcli instead. %else -Ddhclient=no \ %endif - -Ddhcpcanon=no \ -Ddhcpcd=no \ -Dcrypto=gnutls \ %if %{with debug} diff --git a/contrib/fedora/rpm/configure-for-system.sh b/contrib/fedora/rpm/configure-for-system.sh index 30471cf10..fff426bca 100755 --- a/contrib/fedora/rpm/configure-for-system.sh +++ b/contrib/fedora/rpm/configure-for-system.sh @@ -369,7 +369,6 @@ meson setup\ -Dnft="${D_SBINDIR}/nft" \ -Diptables="${D_SBINDIR}/iptables" \ -Ddhclient="${D_SBINDIR}/dhclient" \ - -Ddhcpcanon=no \ -Ddhcpcd=no \ -Dconfig_dhcp_default="$P_DHCP_DEFAULT" \ "-Dcrypto=$P_CRYPTO" \ diff --git a/contrib/scripts/nm-ci-run.sh b/contrib/scripts/nm-ci-run.sh index 09fdc21b0..3864620f8 100755 --- a/contrib/scripts/nm-ci-run.sh +++ b/contrib/scripts/nm-ci-run.sh @@ -173,7 +173,6 @@ meson setup build \ -D teamdctl=$_WITH_LIBTEAM \ \ -D dhclient=/bin/nowhere/dhclient \ - -D dhcpcanon=/bin/nowhere/dhcpcanon \ -D dhcpcd=/bin/nowhere/dhcpd \ \ -D netconfig=/bin/nowhere/netconfig \ diff --git a/meson.build b/meson.build index 6539e790e..81d83ce84 100644 --- a/meson.build +++ b/meson.build @@ -632,7 +632,7 @@ config_h.set10('WITH_OFONO', enable_ofono) config_dhcp_default = get_option('config_dhcp_default') config_h.set_quoted('NM_CONFIG_DEFAULT_MAIN_DHCP', config_dhcp_default) dhcp_summary = '' -foreach client : [ 'dhclient', 'dhcpcd', 'dhcpcanon' ] +foreach client : [ 'dhclient', 'dhcpcd' ] client_path = get_option(client) client_enable = (client_path != 'no') if client_enable diff --git a/meson_options.txt b/meson_options.txt index 93eeac86b..4bc11aa08 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -58,9 +58,8 @@ option('config_dns_rc_manager_default', type: 'combo', choices: ['auto', 'symlin # dhcp clients option('dhclient', type: 'string', value: 'no', description: 'Enable dhclient support (deprecated)') -option('dhcpcanon', type: 'string', value: '', description: 'Enable dhcpcanon support (experimental)') option('dhcpcd', type: 'string', value: '', description: 'Enable dhcpcd support') -option('config_dhcp_default', type: 'combo', choices: ['dhcpcanon', 'dhclient', 'dhcpcd', 'internal', 'nettools'], value: 'internal', description: 'Default configuration option for main.dhcp setting, used as fallback if the configuration option is unset') +option('config_dhcp_default', type: 'combo', choices: ['dhclient', 'dhcpcd', 'internal', 'nettools'], value: 'internal', description: 'Default configuration option for main.dhcp setting, used as fallback if the configuration option is unset') # miscellaneous option('introspection', type: 'boolean', value: true, description: 'Enable introspection for this build') diff --git a/src/core/dhcp/nm-dhcp-client.h b/src/core/dhcp/nm-dhcp-client.h index f26d88d86..a7b6ae98a 100644 --- a/src/core/dhcp/nm-dhcp-client.h +++ b/src/core/dhcp/nm-dhcp-client.h @@ -311,7 +311,6 @@ typedef struct { GType nm_dhcp_nettools_get_type(void); -extern const NMDhcpClientFactory _nm_dhcp_client_factory_dhcpcanon; extern const NMDhcpClientFactory _nm_dhcp_client_factory_dhclient; extern const NMDhcpClientFactory _nm_dhcp_client_factory_dhcpcd; extern const NMDhcpClientFactory _nm_dhcp_client_factory_internal; diff --git a/src/core/dhcp/nm-dhcp-dhcpcanon.c b/src/core/dhcp/nm-dhcp-dhcpcanon.c deleted file mode 100644 index cd42b692d..000000000 --- a/src/core/dhcp/nm-dhcp-dhcpcanon.c +++ /dev/null @@ -1,239 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2017 juga - */ - -#include "src/core/nm-default-daemon.h" - -#if WITH_DHCPCANON - -#include -#include - -#include "nm-utils.h" -#include "nm-dhcp-manager.h" -#include "NetworkManagerUtils.h" -#include "nm-dhcp-listener.h" -#include "nm-dhcp-client-logging.h" - -#define NM_TYPE_DHCP_DHCPCANON (nm_dhcp_dhcpcanon_get_type()) -#define NM_DHCP_DHCPCANON(obj) \ - (_NM_G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DHCP_DHCPCANON, NMDhcpDhcpcanon)) -#define NM_DHCP_DHCPCANON_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_DHCP_DHCPCANON, NMDhcpDhcpcanonClass)) -#define NM_IS_DHCP_DHCPCANON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_DHCP_DHCPCANON)) -#define NM_IS_DHCP_DHCPCANON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_DHCP_DHCPCANON)) -#define NM_DHCP_DHCPCANON_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_DHCP_DHCPCANON, NMDhcpDhcpcanonClass)) - -typedef struct _NMDhcpDhcpcanon NMDhcpDhcpcanon; -typedef struct _NMDhcpDhcpcanonClass NMDhcpDhcpcanonClass; - -static GType nm_dhcp_dhcpcanon_get_type(void); - -/*****************************************************************************/ - -typedef struct { - char *conf_file; - const char *def_leasefile; - char *lease_file; - char *pid_file; - NMDhcpListener *dhcp_listener; -} NMDhcpDhcpcanonPrivate; - -struct _NMDhcpDhcpcanon { - NMDhcpClient parent; - NMDhcpDhcpcanonPrivate _priv; -}; - -struct _NMDhcpDhcpcanonClass { - NMDhcpClientClass parent; -}; - -G_DEFINE_TYPE(NMDhcpDhcpcanon, nm_dhcp_dhcpcanon, NM_TYPE_DHCP_CLIENT) - -#define NM_DHCP_DHCPCANON_GET_PRIVATE(self) \ - _NM_GET_PRIVATE(self, NMDhcpDhcpcanon, NM_IS_DHCP_DHCPCANON) - -/*****************************************************************************/ - -static const char * -nm_dhcp_dhcpcanon_get_path(void) -{ - return nm_utils_find_helper("dhcpcanon", DHCPCANON_PATH, NULL); -} - -static gboolean -dhcpcanon_start(NMDhcpClient *client, - const char *mode_opt, - GBytes *duid, - gboolean release, - pid_t *out_pid, - guint needed_prefixes, - GError **error) -{ - NMDhcpDhcpcanon *self = NM_DHCP_DHCPCANON(client); - NMDhcpDhcpcanonPrivate *priv = NM_DHCP_DHCPCANON_GET_PRIVATE(self); - gs_unref_ptrarray GPtrArray *argv = NULL; - pid_t pid; - gs_free_error GError *local = NULL; - const char *iface; - const char *system_bus_address; - const char *dhcpcanon_path; - gs_free char *binary_name = NULL; - gs_free char *pid_file = NULL; - gs_free char *system_bus_address_env = NULL; - int addr_family; - - g_return_val_if_fail(!priv->pid_file, FALSE); - - iface = nm_dhcp_client_get_iface(client); - - addr_family = nm_dhcp_client_get_addr_family(client); - - dhcpcanon_path = nm_dhcp_dhcpcanon_get_path(); - if (!dhcpcanon_path) { - nm_utils_error_set_literal(error, NM_UTILS_ERROR_UNKNOWN, "dhcpcanon binary not found"); - return FALSE; - } - - _LOGD("dhcpcanon_path: %s", dhcpcanon_path); - - pid_file = g_strdup_printf(RUNSTATEDIR "/dhcpcanon%c-%s.pid", - nm_utils_addr_family_to_char(addr_family), - iface); - _LOGD("pid_file: %s", pid_file); - - /* Kill any existing dhcpcanon from the pidfile */ - binary_name = g_path_get_basename(dhcpcanon_path); - nm_dhcp_client_stop_existing(pid_file, binary_name); - - argv = g_ptr_array_new(); - g_ptr_array_add(argv, (gpointer) dhcpcanon_path); - - g_ptr_array_add(argv, (gpointer) "-sf"); /* Set script file */ - g_ptr_array_add(argv, (gpointer) nm_dhcp_helper_path); - - g_ptr_array_add(argv, (gpointer) "-pf"); /* Set pid file */ - g_ptr_array_add(argv, (gpointer) pid_file); - - if (priv->conf_file) { - g_ptr_array_add(argv, (gpointer) "-cf"); /* Set interface config file */ - g_ptr_array_add(argv, (gpointer) priv->conf_file); - } - - /* Usually the system bus address is well-known; but if it's supposed - * to be something else, we need to push it to dhcpcanon, since dhcpcanon - * sanitizes the environment it gives the action scripts. - */ - system_bus_address = getenv("DBUS_SYSTEM_BUS_ADDRESS"); - if (system_bus_address) { - system_bus_address_env = g_strdup_printf("DBUS_SYSTEM_BUS_ADDRESS=%s", system_bus_address); - g_ptr_array_add(argv, (gpointer) "-e"); - g_ptr_array_add(argv, (gpointer) system_bus_address_env); - } - - g_ptr_array_add(argv, (gpointer) iface); - g_ptr_array_add(argv, NULL); - - if (!g_spawn_async(NULL, - (char **) argv->pdata, - NULL, - G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL - | G_SPAWN_STDERR_TO_DEV_NULL, - nm_utils_setpgid, - NULL, - &pid, - &local)) { - nm_utils_error_set(error, - NM_UTILS_ERROR_UNKNOWN, - "dhcpcanon failed to start: %s", - local->message); - return FALSE; - } - - nm_assert(pid > 0); - _LOGI("dhcpcanon started with pid %d", pid); - nm_dhcp_client_watch_child(client, pid); - priv->pid_file = g_steal_pointer(&pid_file); - return TRUE; -} - -static gboolean -ip4_start(NMDhcpClient *client, GError **error) -{ - return dhcpcanon_start(client, NULL, NULL, FALSE, NULL, 0, error); -} - -static void -stop(NMDhcpClient *client, gboolean release) -{ - NMDhcpDhcpcanon *self = NM_DHCP_DHCPCANON(client); - NMDhcpDhcpcanonPrivate *priv = NM_DHCP_DHCPCANON_GET_PRIVATE(self); - int errsv; - - NM_DHCP_CLIENT_CLASS(nm_dhcp_dhcpcanon_parent_class)->stop(client, release); - - if (priv->pid_file) { - if (remove(priv->pid_file) == -1) { - errsv = errno; - _LOGD("could not remove dhcp pid file \"%s\": %d (%s)", - priv->pid_file, - errsv, - nm_strerror_native(errsv)); - } - g_free(priv->pid_file); - priv->pid_file = NULL; - } -} - -/*****************************************************************************/ - -static void -nm_dhcp_dhcpcanon_init(NMDhcpDhcpcanon *self) -{ - NMDhcpDhcpcanonPrivate *priv = NM_DHCP_DHCPCANON_GET_PRIVATE(self); - - priv->dhcp_listener = g_object_ref(nm_dhcp_listener_get()); - g_signal_connect(priv->dhcp_listener, - NM_DHCP_LISTENER_EVENT, - G_CALLBACK(nm_dhcp_client_handle_event), - self); -} - -static void -dispose(GObject *object) -{ - NMDhcpDhcpcanonPrivate *priv = NM_DHCP_DHCPCANON_GET_PRIVATE(object); - - if (priv->dhcp_listener) { - g_signal_handlers_disconnect_by_func(priv->dhcp_listener, - G_CALLBACK(nm_dhcp_client_handle_event), - NM_DHCP_DHCPCANON(object)); - g_clear_object(&priv->dhcp_listener); - } - - nm_clear_g_free(&priv->pid_file); - - G_OBJECT_CLASS(nm_dhcp_dhcpcanon_parent_class)->dispose(object); -} - -static void -nm_dhcp_dhcpcanon_class_init(NMDhcpDhcpcanonClass *dhcpcanon_class) -{ - NMDhcpClientClass *client_class = NM_DHCP_CLIENT_CLASS(dhcpcanon_class); - GObjectClass *object_class = G_OBJECT_CLASS(dhcpcanon_class); - - object_class->dispose = dispose; - - client_class->ip4_start = ip4_start; - client_class->stop = stop; -} - -const NMDhcpClientFactory _nm_dhcp_client_factory_dhcpcanon = { - .name = "dhcpcanon", - .get_type_4 = nm_dhcp_dhcpcanon_get_type, - .get_path = nm_dhcp_dhcpcanon_get_path, -}; - -#endif /* WITH_DHCPCANON */ diff --git a/src/core/dhcp/nm-dhcp-listener.c b/src/core/dhcp/nm-dhcp-listener.c index 05e428f80..095131cc8 100644 --- a/src/core/dhcp/nm-dhcp-listener.c +++ b/src/core/dhcp/nm-dhcp-listener.c @@ -31,9 +31,6 @@ const NMDhcpClientFactory *const _nm_dhcp_manager_factories[6] = { * the first available plugin. */ &_nm_dhcp_client_factory_internal, -#if WITH_DHCPCANON - &_nm_dhcp_client_factory_dhcpcanon, -#endif #if WITH_DHCPCD &_nm_dhcp_client_factory_dhcpcd, #endif diff --git a/src/core/meson.build b/src/core/meson.build index 6dd60be87..3167b80ce 100644 --- a/src/core/meson.build +++ b/src/core/meson.build @@ -120,7 +120,6 @@ libNetworkManager = static_library( 'devices/nm-lldp-listener.c', 'dhcp/nm-dhcp-dhclient.c', 'dhcp/nm-dhcp-dhclient-utils.c', - 'dhcp/nm-dhcp-dhcpcanon.c', 'dhcp/nm-dhcp-dhcpcd.c', 'dhcp/nm-dhcp-listener.c', 'dns/nm-dns-dnsmasq.c',