From patchwork Fri Jul 12 09:50:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "B. Wilson" X-Patchwork-Id: 29218 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 338AD27BBE9; Fri, 12 Jul 2024 10:51:44 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4562327BBE2 for ; Fri, 12 Jul 2024 10:51:42 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSCvi-00088q-J0; Fri, 12 Jul 2024 05:51:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sSCve-00088M-Oe for guix-patches@gnu.org; Fri, 12 Jul 2024 05:51:02 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSCvd-0003ZL-Ot for guix-patches@gnu.org; Fri, 12 Jul 2024 05:51:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sSCvd-0006Sg-Qx for guix-patches@gnu.org; Fri, 12 Jul 2024 05:51:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#72072] gnu: isc-dhcp: Patch dhclient to support resolvconf. Resent-From: "B. Wilson" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 12 Jul 2024 09:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 72072 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 72072@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.172077785324818 (code B ref -1); Fri, 12 Jul 2024 09:51:01 +0000 Received: (at submit) by debbugs.gnu.org; 12 Jul 2024 09:50:53 +0000 Received: from localhost ([127.0.0.1]:53225 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sSCvU-0006SD-91 for submit@debbugs.gnu.org; Fri, 12 Jul 2024 05:50:52 -0400 Received: from lists.gnu.org ([209.51.188.17]:37400) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sSCvS-0006S6-9V for submit@debbugs.gnu.org; Fri, 12 Jul 2024 05:50:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sSCvR-00086m-Pa for guix-patches@gnu.org; Fri, 12 Jul 2024 05:50:49 -0400 Received: from m42-5.mailgun.net ([69.72.42.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSCvN-0003Wh-8e for guix-patches@gnu.org; Fri, 12 Jul 2024 05:50:49 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.wilsonb.com; q=dns/txt; s=krs; t=1720777843; x=1720785043; h=Content-Type: MIME-Version: Message-Id: Subject: Subject: From: From: To: To: Date: Sender: Sender; bh=s81blLe+TkiiPP+RcFNIC8Cj9ooBI9BFu/vR2jo9XDA=; b=v3SpAoZmBScLG+AZskeW1mQpu+0Buwj+ReZ7QMs34uRl33/goBSR61FVcNIRinXdQPxjUd1YE2GzOSIowBqFhyec5ExrUKG5NIx3NWwsWPxX6vz13g51IdTitUE2ebdy+8BlZzcarTNLDXYjeZffO8cIh5xT4v4VYn5lCNPPyILIsi1RKVCdiPP+jHglHjhmXH+xC1R/mwT+V23jzlotWTZlBkGM6i4nX1n4zFCUxNLhEdGBYGQhdIbSKWJJyArCmTWrg6DyTwQjW6espN2fpDLI7sIZJECq7ZmOqGXd/iHFg4ow6Lbyuab1eub8ieAvMt9bOhWYVSvetHOe/N8SHw== X-Mailgun-Sending-Ip: 69.72.42.5 X-Mailgun-Sid: WyI5MmEzMyIsImd1aXgtcGF0Y2hlc0BnbnUub3JnIiwiMDg1NDdhIl0= Received: from wilsonb.com (wilsonb.com [104.199.203.42]) by 28a30437924b with SMTP id 6690fc73c143980835bdd703 (version=TLS1.3, cipher=TLS_AES_128_GCM_SHA256); Fri, 12 Jul 2024 09:50:43 GMT Received: from localhost (p1267142-ipngn3402fukuhanazo.fukushima.ocn.ne.jp [125.174.241.142]) by wilsonb.com (Postfix) with ESMTPSA id 394DCA1BBA for ; Fri, 12 Jul 2024 09:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wilsonb.com; s=201703; t=1720777841; bh=s81blLe+TkiiPP+RcFNIC8Cj9ooBI9BFu/vR2jo9XDA=; h=Date:To:From:Subject:From; b=rxCHjvMBN9jpMtsXusZbWYa6dUGoicg2Xl9iQgVMlqm0FSffUhCErtx4xku1k6+G7 xH6crR86M6v1/qaygpNPOZA26Sr2z+RXXe5HoIN7YCgxeRvG6uwZ+NkqQH6dRnS4Rk d7yuXP6pWG0LzHBMsFOd3Pv6pdz85rpOKFHDS2EvD0nl5xyOthUtaUSCm9coJWzT2J 8AP+5RDBXVnDOrlcVhB/E0oyhkhah6CgSL39evUnXGPgOm3yQH8BezzWprcQRuUvZd kWrmaqsaBfD0XRO6SFjXsbJwDrHZfaDwc2gHsGYtnQwTdkUrakNIb7f/vg5XQkIJIK +0TZ7QU+HOjBSRntbq/WrRSZNAjp4K1BloEcMk92dJVdmIiwv2xOh0MJ+6dWrKXb9I ij+LX+LBhU9ExZ00oo6McL14tYClarEimulawSJfx50PrFHan4StzGO1PhgACq9Q6D Ixuk8nMfNI83rLkC14aZ862i2ZAtbKR8FIZfS2sws+SH0R5e1dqk9xr/T75XF5Q7uE e+kBtVf7V6vRfbYDEJQAHWDNmd22XXoRZFEsT+XNaO1KfdNK+2sWOv5FSlVEmQQCd5 tjZXQ0t6axrSUWT4Ys3XRJ9rRWwQFsq+9OoPqoCF+YyztYwK6Myj5ZMvUvWr5JO/M1 Na99S+DzopkkdoNeukp9FY00= Date: Fri, 12 Jul 2024 18:50:39 +0900 Message-Id: <2PLKK1GND1Y65.3DPU3DJOTRHJH@wilsonb.com> User-Agent: mblaze/1.2 MIME-Version: 1.0 Received-SPF: pass client-ip=69.72.42.5; envelope-from=bounce+686de0.08547a-guix-patches=gnu.org@mg.wilsonb.com; helo=m42-5.mailgun.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: "B. Wilson" X-ACL-Warn: , "B. Wilson via Guix-patches" X-Patchwork-Original-From: "B. Wilson via Guix-patches" via From: "B. Wilson" Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Hey Guix, This patch updates libexec/dhclient-script to use resolvconf instead of directly editing /etc/resolv.conf, similar to dhcpcd and friends. This allows dhclient to play nicely with other clients which may want to contend for /etc/resolv.conf control. My particular use case is running a local dnsmasq instance, configured to allow using the various DNS servers of multiple simultaneous VPN connections. Ideally, this would be an upstream patch, but ISC announced end of maintenance in 2022, so until we migrate dhcp-client-service-type to something else, I believe it makes sense to have the patch here. Using a bare-bones.scm VM, I have confirmed that this transparently works in the default case where no /etc/resolvconf.conf is setup. In a separate patch, I will be sharing my resolvconf-service-type definition that enables the dnsmasq integration I mention. Note, however, that switching to this via a system reconfigure has the possibility of nuking DNS until the next time dhclient tries to update them. Simply restarting the networking service is enough to force this, though. Thoughts? From c96e6489117b2087db86161cc2b3fe0e813ac09f Mon Sep 17 00:00:00 2001 From: "B. Wilson" Date: Fri, 12 Jul 2024 18:03:48 +0900 Subject: [PATCH] gnu: isc-dhcp: Patch dhclient to support resolvconf. * gnu/packages/patches/dhclient-script-resolvconf-support.patch: New patch. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/admin.scm (isc-dhcp): Patch dhclient-script and update wrapper. --- gnu/local.mk | 1 + gnu/packages/admin.scm | 21 ++++--- .../dhclient-script-resolvconf-support.patch | 58 +++++++++++++++++++ 3 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 gnu/packages/patches/dhclient-script-resolvconf-support.patch diff --git a/gnu/local.mk b/gnu/local.mk index ea4cc251ae..e574154ef3 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1116,6 +1116,7 @@ dist_patch_DATA = \ %D%/packages/patches/debops-debops-defaults-fall-back-to-less.patch \ %D%/packages/patches/dee-vapi.patch \ %D%/packages/patches/dfu-programmer-fix-libusb.patch \ + %D%/packages/patches/dhclient-script-resolvconf-support.patch \ %D%/packages/patches/diffutils-fix-signal-processing.patch \ %D%/packages/patches/directfb-davinci-glibc-228-compat.patch \ %D%/packages/patches/dkimproxy-add-ipv6-support.patch \ diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm index f0aa6adc85..509dfaba20 100644 --- a/gnu/packages/admin.scm +++ b/gnu/packages/admin.scm @@ -1477,7 +1477,9 @@ (define-public isc-dhcp version "/dhcp-" version ".tar.gz")) (sha256 (base32 - "1ivkvhhvqxap6c51cli7pa6xn76ngxri1zbl45ishz4ranxidi0a")))) + "1ivkvhhvqxap6c51cli7pa6xn76ngxri1zbl45ishz4ranxidi0a")) + (patches (search-patches + "dhclient-script-resolvconf-support.patch")))) (build-system gnu-build-system) (arguments `(#:parallel-build? #f @@ -1571,12 +1573,13 @@ (define-public isc-dhcp (lambda* (#:key inputs outputs #:allow-other-keys) ;; Install the dhclient script for GNU/Linux and make sure ;; if finds all the programs it needs. - (let* ((out (assoc-ref outputs "out")) - (libexec (string-append out "/libexec")) - (coreutils (assoc-ref inputs "coreutils*")) - (inetutils (assoc-ref inputs "inetutils")) - (grep (assoc-ref inputs "grep*")) - (sed (assoc-ref inputs "sed*")) + (let* ((out (assoc-ref outputs "out")) + (libexec (string-append out "/libexec")) + (coreutils (assoc-ref inputs "coreutils*")) + (inetutils (assoc-ref inputs "inetutils")) + (grep (assoc-ref inputs "grep*")) + (resolvconf (assoc-ref inputs "resolvconf*")) + (sed (assoc-ref inputs "sed*")) (debianutils (assoc-ref inputs "debianutils"))) (substitute* "client/scripts/linux" (("/sbin/ip") @@ -1592,7 +1595,8 @@ (define-public isc-dhcp ,(map (lambda (dir) (string-append dir "/bin:" dir "/sbin")) - (list inetutils coreutils grep sed debianutils)))))))))) + (list inetutils coreutils grep sed resolvconf + debianutils)))))))))) (native-inputs (list config perl file)) @@ -1621,6 +1625,7 @@ (define-public isc-dhcp ("coreutils*" ,coreutils) ("grep*" ,grep) + ("resolvconf*" ,openresolv) ("sed*" ,sed))) (home-page "https://www.isc.org/dhcp/") diff --git a/gnu/packages/patches/dhclient-script-resolvconf-support.patch b/gnu/packages/patches/dhclient-script-resolvconf-support.patch new file mode 100644 index 0000000000..e4fd8f649e --- /dev/null +++ b/gnu/packages/patches/dhclient-script-resolvconf-support.patch @@ -0,0 +1,58 @@ +Implement resolvconf support + +Due to the potential for multiple sources contenting for /etc/resol.conf +control, this patch replaces direct file munging with resolvconf indirection. + +--- a/client/scripts/linux 1970-01-01 09:00:01.000000000 +0900 ++++ b/client/scripts/linux 1970-01-01 09:00:01.000000000 +0900 +@@ -36,11 +36,11 @@ + # This updated version mostly follows Debian script by Andrew Pollock et al. + make_resolv_conf() { + local new_resolv_conf ++ new_resolv_conf=$(mktemp) + + # DHCPv4 + if [ -n "$new_domain_search" ] || [ -n "$new_domain_name" ] || +- [ -n "$new_domain_name_servers" ]; then +- new_resolv_conf=/etc/resolv.conf.dhclient-new ++ [ -n "$new_domain_name_servers" ]; then + rm -f $new_resolv_conf + + if [ -n "$new_domain_name" ]; then +@@ -70,17 +70,12 @@ + echo nameserver $nameserver >>$new_resolv_conf + done + else # keep 'old' nameservers +- sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf >>$new_resolv_conf ++ resolvconf -l "$interface.dhcp" | sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p >>$new_resolv_conf + fi + +- if [ -f /etc/resolv.conf ]; then +- chown --reference=/etc/resolv.conf $new_resolv_conf +- chmod --reference=/etc/resolv.conf $new_resolv_conf +- fi +- mv -f $new_resolv_conf /etc/resolv.conf ++ resolvconf -a "$interface.dhpc" <"$new_resolv_conf" + # DHCPv6 + elif [ -n "$new_dhcp6_domain_search" ] || [ -n "$new_dhcp6_name_servers" ]; then +- new_resolv_conf=/etc/resolv.conf.dhclient-new + rm -f $new_resolv_conf + + if [ -n "$new_dhcp6_domain_search" ]; then +@@ -97,14 +92,10 @@ + echo nameserver $nameserver >>$new_resolv_conf + done + else # keep 'old' nameservers +- sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf >>$new_resolv_conf ++ resolvconf -l "$interface.dhcp6" | sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p >>$new_resolv_conf + fi + +- if [ -f /etc/resolv.conf ]; then +- chown --reference=/etc/resolv.conf $new_resolv_conf +- chmod --reference=/etc/resolv.conf $new_resolv_conf +- fi +- mv -f $new_resolv_conf /etc/resolv.conf ++ resolvconf -a "$interface.dhpc6" <"$new_resolv_conf" + fi + } + -- 2.45.2