From patchwork Sun Mar 23 13:00:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Abramov X-Patchwork-Id: 40730 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 9529F27BBE2; Sun, 23 Mar 2025 13:05:43 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, 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 B68A927BBE9 for ; Sun, 23 Mar 2025 13:05:41 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twL10-0003Da-Ec; Sun, 23 Mar 2025 09:05:22 -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 1twL0i-00037X-G7 for guix-patches@gnu.org; Sun, 23 Mar 2025 09:05:09 -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 1twL0i-0002eq-0G; Sun, 23 Mar 2025 09:05:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=nc1NSNy6MJxJoZc+NE8Q+c7UCnRlQAN4LmfuCr/fEpc=; b=k7lLPbj6TayKCuzbe5MbH7mLb8ipuuXZPHyS4N6paWusewXW3yrUTIf2bP3izxLZWF2dU6RL3eKHG5Z+GI0VaO/wiJFsCWgrNaU53RfnGO2rt4194fspimOZN7mJNmwbGEKYpoa/0dL3ES/2wDq0xr5GSyXWedYLrh4sEMu0yCCG+R9XijWuceIIUP6KYbZi8GG3mbip1T2VrwkVDIq1gi7z6qWFTarmo9I33d5dyINi07lq3AicAreXXbXVQu5eFKuQnoPwXOjXs4pu0AOMbIKEDg72G6xIBZt1UDTA7na36/fVSHVnguTBrJQL5QimyvJG7jNPSRp0fSlqjLW4KQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twL0h-0000S3-F3; Sun, 23 Mar 2025 09:05:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77204] [PATCH v2 1/3] services: dnsmasq: Provide shepherd-provision and shepherd-requirement fields. Resent-From: Alexey Abramov Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 13:05:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77204 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77204@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 77204-submit@debbugs.gnu.org id=B77204.17427350531310 (code B ref 77204); Sun, 23 Mar 2025 13:05:03 +0000 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 13:04:13 +0000 Received: from localhost ([127.0.0.1]:48158 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twKzs-0000Ky-B9 for submit@debbugs.gnu.org; Sun, 23 Mar 2025 09:04:13 -0400 Received: from mail.mmer.org ([178.22.65.174]:38658) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twKzY-0000GI-8E for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 09:03:53 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 736852d5 for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=dRi8RcgD1EP48s9FzDoF3aujQ dDnzYg7duPbtZy63DE=; b=OqF6xiqgMew6SQ7iwH4oNHOTS+RA34ietiLXNJZJT Ws488F6MSSEMN4eqhoPIhCa8Qo1tQO7YnGIzheuHjS337aLjUbemkFiwzSziWLoK B2faH2V0AxUNZI6YZ4fAbPZMWhQwviGF2fRmGCHTLWTrzSgImyjzmQM3Dnu1Hbdc xM= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id f6a4121d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:42 +0000 (UTC) Date: Sun, 23 Mar 2025 14:00:52 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 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: Alexey Abramov X-ACL-Warn: , Alexey Abramov via Guix-patches X-Patchwork-Original-From: Alexey Abramov via Guix-patches via From: Alexey Abramov 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 * doc/guix.texi: Document the change. * gnu/services/dns.scm ()[provision]: Rename the field to [shepherd-provision] for consistency with other services. * gnu/services/dns.scm ()[shepherd-requirement]: New field. * gnu/services/dns.scm (dnsmasq-shepherd-service): Use newly-created fields. * doc/guix-cookbook.texi (Custom NAT-based network for libvirt): Rename `provision' field record to shepherd-provision. --- doc/guix-cookbook.texi | 4 ++-- doc/guix.texi | 11 ++++++++--- gnu/services/dns.scm | 12 ++++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index fe4cac79c3a..d4832b9bb40 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -4031,8 +4031,8 @@ Custom NAT-based network for libvirt (service dnsmasq-service-type (dnsmasq-configuration ;; You can have multiple instances of `dnsmasq-service-type` as long - ;; as each one has a different provision. - (provision '(dnsmasq-virbr0)) + ;; as each one has a different shepherd-provision. + (shepherd-provision '(dnsmasq-virbr0)) (extra-options (list ;; Only bind to the virtual bridge. This ;; avoids conflicts with other running diff --git a/doc/guix.texi b/doc/guix.texi index bcb1f9d9cf8..90fa6779657 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35067,9 +35067,14 @@ DNS Services @item @code{package} (default: @var{dnsmasq}) Package object of the dnsmasq server. -@item @code{provision} (default: @code{'(dnsmasq)}) -A list of symbols for the Shepherd service corresponding to this dnsmasq -configuration. +@item @code{shepherd-provision} (default: @code{'(dnsmasq)}) +@itemx @code{shepherd-requirement} (default: @code{'(user-processes networking)}) +This option can be used to provide a list of Shepherd service names +(symbols) provided by this service. You might want to change the default +value if you intend to run several @command{dnsmasq} instances. + +Likewise, @code{shepherd-requirement} is a list of Shepherd service names +(symbols) that this service will depend on. @item @code{no-hosts?} (default: @code{#f}) When true, don't read the hostnames in /etc/hosts. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index 05291eb65d9..9276504ffd0 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -742,8 +742,10 @@ (define-record-type* dnsmasq-configuration? (package dnsmasq-configuration-package (default dnsmasq)) ;file-like - (provision dnsmasq-provision - (default '(dnsmasq))) + (shepherd-provision dnsmasq-configuration-shepherd-provision + (default '(dnsmasq))) + (shepherd-requirement dnsmasq-configuration-shepherd-requirement + (default '(user-processes networking))) (no-hosts? dnsmasq-configuration-no-hosts? (default #f)) ;boolean (port dnsmasq-configuration-port @@ -802,6 +804,8 @@ (define-record-type* (define (dnsmasq-shepherd-service config) (match-record config (package + shepherd-provision + shepherd-requirement no-hosts? port local-service? listen-addresses resolv-file no-resolv? @@ -815,8 +819,8 @@ (define (dnsmasq-shepherd-service config) tftp-lowercase? tftp-port-range tftp-root tftp-unique-root extra-options) (shepherd-service - (provision (dnsmasq-provision config)) - (requirement '(user-processes networking)) + (provision shepherd-provision) + (requirement shepherd-requirement) (documentation "Run the dnsmasq DNS server.") (start #~(make-forkexec-constructor (list From patchwork Sun Mar 23 13:00:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Abramov X-Patchwork-Id: 40731 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 C53B027BBE2; Sun, 23 Mar 2025 13:05:46 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, 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 EBCCD27BBE9 for ; Sun, 23 Mar 2025 13:05:45 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twL12-0003Ed-Hu; Sun, 23 Mar 2025 09:05:24 -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 1twL0k-00039K-6I for guix-patches@gnu.org; Sun, 23 Mar 2025 09:05:10 -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 1twL0j-0002f8-EM; Sun, 23 Mar 2025 09:05:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=HljRVIEI70/WZE0AbyBNknmXbvI1D81HHFdSzUgD5Fo=; b=pmCiGrO4QgWx/4OZP26ASLdQ716GPrFbZM9tkgsKPjoht2QxK6Y1K54mZ7u6byOMMZtLvv/VswPtYer9Xpa6wA8CUOnzqtF9XVD9z/sIkXdIp6z3zm5UDtrv9C1fJqh5BwW66tdy9OtWx6o7j/YDY3Dm9WCl48QTLJRg5gn6XC5ytta1J2ghDS9qPYwP5D9sOKcT1FKGHubY1+QQrZkekhE/jxW+QtwuUyadkjMaYU9fQWx2iJFxnmQYxheLRkQYArczsA8EPqGXGXlGVsnLysXGhXwdOAyEVhfhqG6st0VtvwVdLHi4wYAn8qezMZEcZcmFtGUFf1pDnsw2z8kQRA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twL0j-0000Sa-44; Sun, 23 Mar 2025 09:05:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77204] [PATCH v2 2/3] services: dnsmasq: Provide pid-file, conf-file and conf-dir configuration fields. Resent-From: Alexey Abramov Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 13:05:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77204 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77204@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 77204-submit@debbugs.gnu.org id=B77204.17427350551337 (code B ref 77204); Sun, 23 Mar 2025 13:05:04 +0000 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 13:04:15 +0000 Received: from localhost ([127.0.0.1]:48160 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twKzt-0000L5-C7 for submit@debbugs.gnu.org; Sun, 23 Mar 2025 09:04:15 -0400 Received: from mail.mmer.org ([178.22.65.174]:38658) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twKzZ-0000GI-QE for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 09:03:57 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id 57139c71 for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=wud+yZMr1JkwM2qSLU9KIyfFu r+k4DCRk+EIg2LcdXE=; b=LnoBJWnlWwUyYgfWMsNplzDVOLCDXftPATsNHp74O AAhfGjPrBiFZnYrgE9vFraqGL5c+4KN7ZUFgm/wvIRzCjK8W6uFDsPffw5LrBi7S q2FCSijav/TR3Ajs+h9YA4OwIDxigYstrB4RJ7b+gllGmojBqH2+IcUm3AWOk061 1k= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 1d99c4f6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:43 +0000 (UTC) Date: Sun, 23 Mar 2025 14:00:53 +0100 Message-ID: <1832a2647a2c1dff6d066e413f76b40cad59ce06.1742734854.git.levenson@mmer.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 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: Alexey Abramov X-ACL-Warn: , Alexey Abramov via Guix-patches X-Patchwork-Original-From: Alexey Abramov via Guix-patches via From: Alexey Abramov 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 * doc/guix.texi: Document it. * gnu/services/dns.scm: Export all record accessors. * gnu/services/dns.scm ()[pid-file]: New field. * gnu/services/dns.scm ()[conf-file]: New field. * gnu/services/dns.scm ()[conf-dir]: New field. * gnu/services/dns.scm ()[extra-options]: Move it to the end of the definition, because it is a last resort. * gnu/services/dns.scm (dnsmasq-shepherd-service): Use newly-created fields. --- doc/guix.texi | 14 ++++ gnu/services/dns.scm | 162 +++++++++++++++++++++++++++---------------- 2 files changed, 117 insertions(+), 59 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 90fa6779657..1bbd1824a87 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35076,6 +35076,9 @@ DNS Services Likewise, @code{shepherd-requirement} is a list of Shepherd service names (symbols) that this service will depend on. +@item @code{pid-file} (default: @code{"/run/dnsmasq.pid"}) +Specify an alternate path for dnsmasq to record its process-id in. + @item @code{no-hosts?} (default: @code{#f}) When true, don't read the hostnames in /etc/hosts. @@ -35196,6 +35199,17 @@ DNS Services resolving MAC addresses is only possible if the client is in the local network or obtained a DHCP lease from dnsmasq. +@item @code{conf-file} (default: @code{'()}) +Specify a configuration file or multiple. The given value should be a list of +string paths to the configuration files. File-like objects are also supported. + +@item @code{conf-dir} (default: @code{#f}) +Read all the files in the given directory as configuration +files. @command{dnsmasq} also supports extensions for the field, but +here it is not implemented. It is more convenient to make +@code{computed-file} directory in the store and use that. Files are +loaded in alphabetical order of filename. + @item @code{extra-options} (default: @code{'()}) This option provides an ``escape hatch'' for the user to provide arbitrary command-line arguments to @command{dnsmasq} as a list of strings. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index 9276504ffd0..6e2ec7c2067 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -54,6 +54,38 @@ (define-module (gnu services dns) dnsmasq-service-type dnsmasq-configuration + dnsmasq-configuration-package + dnsmasq-configuration-shepherd-provision + dnsmasq-configuration-shepherd-requirement + dnsmasq-configuration-pid-file + dnsmasq-configuration-no-hosts? + dnsmasq-configuration-port + dnsmasq-configuration-local-service? + dnsmasq-configuration-listen-address + dnsmasq-configuration-resolv-file + dnsmasq-configuration-no-resolv? + dnsmasq-configuration-forward-private-reverse-lookup? + dnsmasq-configuration-query-servers-in-order? + dnsmasq-configuration-servers + dnsmasq-configuration-servers-file + dnsmasq-configuration-addresses + dnsmasq-configuration-cache-size + dnsmasq-configuration-negative-cache? + dnsmasq-configuration-cpe-id + dnsmasq-configuration-tftp-enable? + dnsmasq-configuration-tftp-no-fail? + dnsmasq-configuration-tftp-single-port? + dnsmasq-tftp-secure? + dnsmasq-tftp-max + dnsmasq-tftp-mtu + dnsmasq-tftp-no-blocksize? + dnsmasq-tftp-lowercase? + dnsmasq-tftp-port-range + dnsmasq-tftp-root + dnsmasq-tftp-unique-root + dnsmasq-configuration-conf-file + dnsmasq-configuration-conf-dir + dnsmasq-configuration-extra-options unbound-service-type unbound-configuration @@ -740,72 +772,77 @@ (define knot-resolver-service-type (define-record-type* dnsmasq-configuration make-dnsmasq-configuration dnsmasq-configuration? - (package dnsmasq-configuration-package - (default dnsmasq)) ;file-like + (package dnsmasq-configuration-package + (default dnsmasq)) ;file-like (shepherd-provision dnsmasq-configuration-shepherd-provision (default '(dnsmasq))) (shepherd-requirement dnsmasq-configuration-shepherd-requirement (default '(user-processes networking))) - (no-hosts? dnsmasq-configuration-no-hosts? - (default #f)) ;boolean - (port dnsmasq-configuration-port - (default 53)) ;integer - (local-service? dnsmasq-configuration-local-service? - (default #t)) ;boolean - (listen-addresses dnsmasq-configuration-listen-address - (default '())) ;list of string - (extra-options dnsmasq-configuration-extra-options - (default '())) ;list of string - (resolv-file dnsmasq-configuration-resolv-file - (default "/etc/resolv.conf")) ;string - (no-resolv? dnsmasq-configuration-no-resolv? - (default #f)) ;boolean + (pid-file dnsmasq-configuration-pid-file + (default "/run/dnsmasq.pid")) ;string + (no-hosts? dnsmasq-configuration-no-hosts? + (default #f)) ;boolean + (port dnsmasq-configuration-port + (default 53)) ;integer + (local-service? dnsmasq-configuration-local-service? + (default #t)) ;boolean + (listen-addresses dnsmasq-configuration-listen-address + (default '())) ;list of string + (resolv-file dnsmasq-configuration-resolv-file + (default "/etc/resolv.conf")) ;string + (no-resolv? dnsmasq-configuration-no-resolv? + (default #f)) ;boolean (forward-private-reverse-lookup? - dnsmasq-configuration-forward-private-reverse-lookup? - (default #t)) ;boolean - (query-servers-in-order? - dnsmasq-configuration-query-servers-in-order? - (default #f)) ;boolean - (servers dnsmasq-configuration-servers - (default '())) ;list of string - (servers-file dnsmasq-configuration-servers-file - (default #f)) ;string|file-like - (addresses dnsmasq-configuration-addresses - (default '())) ;list of string - (cache-size dnsmasq-configuration-cache-size - (default 150)) ;integer - (negative-cache? dnsmasq-configuration-negative-cache? - (default #t)) ;boolean - (cpe-id dnsmasq-configuration-cpe-id - (default #f)) ;string - (tftp-enable? dnsmasq-configuration-tftp-enable? - (default #f)) ;boolean - (tftp-no-fail? dnsmasq-configuration-tftp-no-fail? - (default #f)) ;boolean - (tftp-single-port? dnsmasq-configuration-tftp-single-port? - (default #f)) ;boolean - (tftp-secure? dnsmasq-tftp-secure? - (default #f)) ;boolean - (tftp-max dnsmasq-tftp-max - (default #f)) ;integer - (tftp-mtu dnsmasq-tftp-mtu - (default #f)) ;integer - (tftp-no-blocksize? dnsmasq-tftp-no-blocksize? - (default #f)) ;boolean - (tftp-lowercase? dnsmasq-tftp-lowercase? - (default #f)) ;boolean - (tftp-port-range dnsmasq-tftp-port-range - (default #f)) ;string - (tftp-root dnsmasq-tftp-root - (default "/var/empty,lo")) ;string - (tftp-unique-root dnsmasq-tftp-unique-root - (default #f))) ;"" or "ip" or "mac" - + dnsmasq-configuration-forward-private-reverse-lookup? + (default #t)) ;boolean + (query-servers-in-order? dnsmasq-configuration-query-servers-in-order? + (default #f)) ;boolean + (servers dnsmasq-configuration-servers + (default '())) ;list of string + (servers-file dnsmasq-configuration-servers-file + (default #f)) ;string|file-like + (addresses dnsmasq-configuration-addresses + (default '())) ;list of string + (cache-size dnsmasq-configuration-cache-size + (default 150)) ;integer + (negative-cache? dnsmasq-configuration-negative-cache? + (default #t)) ;boolean + (cpe-id dnsmasq-configuration-cpe-id + (default #f)) ;string + (tftp-enable? dnsmasq-configuration-tftp-enable? + (default #f)) ;boolean + (tftp-no-fail? dnsmasq-configuration-tftp-no-fail? + (default #f)) ;boolean + (tftp-single-port? dnsmasq-configuration-tftp-single-port? + (default #f)) ;boolean + (tftp-secure? dnsmasq-tftp-secure? + (default #f)) ;boolean + (tftp-max dnsmasq-tftp-max + (default #f)) ;integer + (tftp-mtu dnsmasq-tftp-mtu + (default #f)) ;integer + (tftp-no-blocksize? dnsmasq-tftp-no-blocksize? + (default #f)) ;boolean + (tftp-lowercase? dnsmasq-tftp-lowercase? + (default #f)) ;boolean + (tftp-port-range dnsmasq-tftp-port-range + (default #f)) ;string + (tftp-root dnsmasq-tftp-root + (default "/var/empty,lo")) ;string + (tftp-unique-root dnsmasq-tftp-unique-root + (default #f)) ;"" or "ip" or "mac" + (conf-file dnsmasq-configuration-conf-file + (default '())) ;list of string|file-like + (conf-dir dnsmasq-configuration-conf-dir + (default #f)) ;string|file-like + (extra-options dnsmasq-configuration-extra-options + (default '()))) (define (dnsmasq-shepherd-service config) (match-record config (package shepherd-provision shepherd-requirement + pid-file no-hosts? port local-service? listen-addresses resolv-file no-resolv? @@ -817,7 +854,8 @@ (define (dnsmasq-shepherd-service config) tftp-single-port? tftp-secure? tftp-max tftp-mtu tftp-no-blocksize? tftp-lowercase? tftp-port-range - tftp-root tftp-unique-root extra-options) + tftp-root tftp-unique-root + conf-file conf-dir extra-options) (shepherd-service (provision shepherd-provision) (requirement shepherd-requirement) @@ -826,7 +864,7 @@ (define (dnsmasq-shepherd-service config) (list #$(file-append package "/sbin/dnsmasq") "--keep-in-foreground" - "--pid-file=/run/dnsmasq.pid" + (string-append "--pid-file=" #$pid-file) #$@(if no-hosts? '("--no-hosts") '()) @@ -897,8 +935,14 @@ (define (dnsmasq-shepherd-service config) (format #f "--tftp-unique-root=~a" tftp-unique-root) (format #f "--tftp-unique-root"))) '()) + #$@(map (lambda (conf-file) + #~(string-append "--conf-file=" #$conf-file)) + conf-file) + #$@(if conf-dir + (list #~(string-append "--conf-dir=" #$conf-dir)) + '()) #$@extra-options) - #:pid-file "/run/dnsmasq.pid")) + #:pid-file #$pid-file)) (stop #~(make-kill-destructor))))) (define (dnsmasq-activation config) From patchwork Sun Mar 23 13:00:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Abramov X-Patchwork-Id: 40732 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 A5AF527BBE2; Sun, 23 Mar 2025 13:05:44 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, 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 D3AF627BBE9 for ; Sun, 23 Mar 2025 13:05:43 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twL0w-0003Cq-E8; Sun, 23 Mar 2025 09:05:20 -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 1twL0n-0003BY-AT for guix-patches@gnu.org; Sun, 23 Mar 2025 09:05:10 -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 1twL0l-0002fS-NS; Sun, 23 Mar 2025 09:05:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=W3Y2ALuJqlsYR4efjZ+a0ESMPG4SlWfy6/v1KtTkkFc=; b=abSOO+4n7kVAckt5btjRmuQtHjIUJf8XL0vjRXBCwyILjJBUVVPsDRIYh30LC4/Q9qK/kXt5eCTplk/u3CTSR4WoePh7gBq4ckKa7GlqNahCab2vU8qwieo0JmWNwIcNYCzlNj1LXN533Qp5ZT1CyvVxaLu3EITdp78xadZUuwhiXeOJtAacaMsBSZ5TYYly5zQ/ppxkOunEp4ftx/UFuFpXyieblIJ+G6vpVD8cCbqunf4OKgoWVdLZEHEqWWeWHyBUEyJ/T5Nv+mj3kYShZhHlIbInkBWHNj/WrgtPmtEbVcXN3k1ClljDhTE5JWBT7rG/qWWXZKI4aKFxC64Ykg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twL0l-0000TN-CS; Sun, 23 Mar 2025 09:05:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77204] [PATCH v2 3/3] services: dnsmasq: Provide stats and reload actions. Resent-From: Alexey Abramov Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 13:05:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77204 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77204@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 77204-submit@debbugs.gnu.org id=B77204.17427350751501 (code B ref 77204); Sun, 23 Mar 2025 13:05:07 +0000 Received: (at 77204) by debbugs.gnu.org; 23 Mar 2025 13:04:35 +0000 Received: from localhost ([127.0.0.1]:48162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twL0D-0000Nx-ET for submit@debbugs.gnu.org; Sun, 23 Mar 2025 09:04:34 -0400 Received: from mail.mmer.org ([178.22.65.174]:45906) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twKzc-0000HS-Tm for 77204@debbugs.gnu.org; Sun, 23 Mar 2025 09:04:00 -0400 Received: from mail.mmer.org (localhost [127.0.0.1]) by mail.mmer.org (OpenSMTPD) with ESMTP id c634ca5c for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mmer.org; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=sGUPfFte1ktzdr8NyQTWJgIqd IGcmu2Ru1y2OEjD4CQ=; b=NR52XOKqV0Hju4G0ECKRAAD1gn/GygGkQq6D4wLS+ JEiRbaaGVQWuFHbdnROgJ9H58rTpvsh1pdsYy9GuHbJH1ocGqAT1UvLg14DgjAbJ rLxslCgPzJMjt9tNeXyW5hAzZwDEQ+ZfXDjW3E0IJOrPOuqcjhb5qXhUqIoknaan Lw= Received: from delta (16-254-250-62.ftth.glasoperator.nl [62.250.254.16]) by mail.mmer.org (OpenSMTPD) with ESMTPSA id 841c2d5e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <77204@debbugs.gnu.org>; Sun, 23 Mar 2025 13:03:43 +0000 (UTC) Date: Sun, 23 Mar 2025 14:00:54 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 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: Alexey Abramov X-ACL-Warn: , Alexey Abramov via Guix-patches X-Patchwork-Original-From: Alexey Abramov via Guix-patches via From: Alexey Abramov 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 * gnu/services/dns.scm (dnsmasq-service-reload-action) (dnsmasq-service-stats-action): New functions. * doc/guix.texi: Document the change. * gnu/tests/networking.scm: Add tests. --- doc/guix.texi | 10 ++++ gnu/services/dns.scm | 22 +++++++++ gnu/tests/networking.scm | 98 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 1bbd1824a87..816a9ed57d0 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35060,6 +35060,16 @@ DNS Services @end lisp @end defvar +@code{dnsmasq-service-type} also provides few helpful actions which are +@code{reload} and @code{stats}. For example: + +@example +herd stats dnsmasq +@end example + +Will ask @command{dnsmasq} service to dump its statistics to the system log, which +is usually @file{/var/log/messages}. + @deftp {Data Type} dnsmasq-configuration Data type representing the configuration of dnsmasq. diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm index 6e2ec7c2067..a091dbfb86c 100644 --- a/gnu/services/dns.scm +++ b/gnu/services/dns.scm @@ -860,6 +860,8 @@ (define (dnsmasq-shepherd-service config) (provision shepherd-provision) (requirement shepherd-requirement) (documentation "Run the dnsmasq DNS server.") + (actions (list (dnsmasq-service-reload-action config) + (dnsmasq-service-stats-action config))) (start #~(make-forkexec-constructor (list #$(file-append package "/sbin/dnsmasq") @@ -951,6 +953,26 @@ (define (dnsmasq-activation config) ;; create directory to store dnsmasq lease file (mkdir-p "/var/lib/misc"))) +(define (dnsmasq-service-reload-action config) + (match-record config () + (shepherd-action + (name 'reload) + (documentation "Send a SIGHUP signal to re-load /etc/hosts and /etc/ethers and any +file given by --dhcp-hostsfile, --dhcp-hostsdir, --dhcp-optsfile, --dhcp-optsdir, +--addn-hosts or --hostsdir. SIGHUP does NOT re-read the configuration file.") + (procedure #~(lambda (running) + (let ((pid (process-id running))) + (kill pid SIGHUP))))))) + +(define (dnsmasq-service-stats-action config) + (match-record config () + (shepherd-action + (name 'stats) + (documentation "Send a SIGUSR1 to write statistics to the system log.") + (procedure #~(lambda (running) + (let ((pid (process-id running))) + (kill pid SIGUSR1))))))) + (define dnsmasq-service-type (service-type (name 'dnsmasq) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index 7d54ebba50e..fdc515ceb04 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -27,6 +27,7 @@ (define-module (gnu tests networking) #:use-module (gnu system vm) #:use-module (gnu services) #:use-module (gnu services base) + #:use-module (gnu services dns) #:use-module (gnu services networking) #:use-module (guix gexp) #:use-module (guix store) @@ -46,6 +47,7 @@ (define-module (gnu tests networking) %test-openvswitch %test-dhcpd %test-dhcpcd + %test-dnsmasq %test-tor %test-iptables %test-ipfs)) @@ -675,6 +677,102 @@ (define %test-dhcpd (description "Test a running DHCP daemon configuration.") (value (run-dhcpd-test)))) + + +;;; +;;; dnsmasq tests +;;; + + +(define dnsmasq-os-configuration + (dnsmasq-configuration)) + +(define %dnsmasq-os + (simple-operating-system + (service dhcp-client-service-type) + (service dnsmasq-service-type + (dnsmasq-configuration + (extra-options + (list "--log-facility=/tmp/dnsmasq.log")))))) + + +(define (run-dnsmasq-test) + (define os + (marionette-operating-system %dnsmasq-os + #:imported-modules '((gnu services herd)))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (gnu build marionette) + (srfi srfi-64)) + + (define marionette + (make-marionette (list #$(virtual-machine os)))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "dnsmasq") + + (test-assert "dnsmasq is alive" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (wait-for-service 'dnsmasq)) + marionette)) + + (test-assert "pid file exists" + (wait-for-file + '#$(dnsmasq-configuration-pid-file dnsmasq-os-configuration) + marionette)) + + (test-assert "send SIGHUP" + (positive? + (marionette-eval + '(begin + (use-modules (ice-9 rdelim)) + (system* "sync") + (let* ((port (open-input-file "/tmp/dnsmasq.log"))) + (seek port 0 SEEK_END) + (system* "herd" "reload" "dnsmasq") + (system* "sync") + (let ((line (read-line port))) + (close-port port) + (string-contains line "read /etc/hosts")))) + marionette))) + + (test-assert "send SIGUSR1" + (positive? + (marionette-eval + '(begin + (use-modules (ice-9 rdelim)) + (system* "sync") + (let* ((port (open-input-file "/tmp/dnsmasq.log"))) + (seek port 0 SEEK_END) + (system* "herd" "stats" "dnsmasq") + (system* "sync") + (let ((line (read-line port))) + (close-port port) + (string-contains-ci line "time")))) + marionette))) + + (test-assert "dnsmasq is alive" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (wait-for-service 'dnsmasq)) + marionette)) + + (test-end)))) + + (gexp->derivation "dnsmasq-test" test)) + +(define %test-dnsmasq + (system-test + (name "dnsmasq") + (description "Test a running dnsmasq daemon configuration.") + (value (run-dnsmasq-test)))) + + ;;; ;;; DHCPCD Daemon