unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Sent <richard@freakingpenguin.com>
To: 71561@debbugs.gnu.org
Cc: "Richard Sent" <richard@freakingpenguin.com>,
	"Florian Pelz" <pelzflorian@pelzflorian.de>,
	"Ludovic Courtès" <ludo@gnu.org>,
	"Matthew Trzcinski" <matt@excalamus.com>,
	"Maxim Cournoyer" <maxim.cournoyer@gmail.com>
Subject: [bug#71561] [PATCH 1/2] services: networking: Allow dhcp-client to use a config file
Date: Mon, 17 Jun 2024 20:49:12 -0400	[thread overview]
Message-ID: <b15c77d654ccdf788dd68a8d92cc3bc4e67cb1e7.1718671753.git.richard@freakingpenguin.com> (raw)
In-Reply-To: <0888b6afe4003512c452fad2bc88370b007fc0ca.1718387578.git.richard@freakingpenguin.com>

* gnu/services/networking.scm (dhcp-client-configuration) [config-file]: New
field.
(dhcp-client-configuration-config-file): New accessor.
(dhcp-client-shepherd-service): Use the config file when invoking
dhclient if supplied.
* doc/guix.texi: Document it.

Change-Id: I286de4ddf59c5e606bf1fe0a7510570869e62b1a
---
 doc/guix.texi               |  3 +++
 gnu/services/networking.scm | 15 +++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 0102fd0fad..ad67a436ea 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -21035,6 +21035,9 @@ Networking Setup
 non-loopback interfaces that can be activated.  Otherwise the DHCP
 client listens only on the specified interfaces.
 
+@item @code{config-file} (default: @code{#f})
+The configuration file for the DHCP client.
+
 @item @code{shepherd-requirement} (default: @code{'()})
 @itemx @code{shepherd-provision} (default: @code{'(networking)})
 This option can be used to provide a list of symbols naming Shepherd services
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 378e117a86..12d8934e43 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -91,6 +91,7 @@ (define-module (gnu services networking)
             dhcp-client-configuration?
             dhcp-client-configuration-package
             dhcp-client-configuration-interfaces
+            dhcp-client-configuration-config-file
             dhcp-client-configuration-shepherd-provision
             dhcp-client-configuration-shepherd-requirement
 
@@ -319,6 +320,8 @@ (define-record-type* <dhcp-client-configuration>
                         (default '()))
   (shepherd-provision   dhcp-client-configuration-shepherd-provision
                         (default '(networking)))
+  (config-file dhcp-client-configuration-config-file
+               (default #f))
   (interfaces   dhcp-client-configuration-interfaces
                 (default 'all)))                  ;'all | list of strings
 
@@ -329,6 +332,7 @@ (define dhcp-client-shepherd-service
            (requirement (dhcp-client-configuration-shepherd-requirement config))
            (provision (dhcp-client-configuration-shepherd-provision config))
            (interfaces (dhcp-client-configuration-interfaces config))
+           (config-file (dhcp-client-configuration-config-file config))
            (pid-file "/var/run/dhclient.pid"))
        (list (shepherd-service
               (documentation "Set up networking via DHCP.")
@@ -364,6 +368,11 @@ (define dhcp-client-shepherd-service
                                        (_
                                         #~'#$interfaces))))
 
+                         (define config-file-args
+                           (if #$config-file
+                               (list "-cf" #$config-file)
+                               '()))
+
                          (false-if-exception (delete-file #$pid-file))
                          (let ((pid (fork+exec-command
                                      ;; By default dhclient uses a
@@ -371,8 +380,10 @@ (define dhcp-client-shepherd-service
                                      ;; DDNS, which is incompatable with
                                      ;; non-ISC DHCP servers; thus, pass '-I'.
                                      ;; <https://kb.isc.org/docs/aa-01091>.
-                                     (cons* dhclient "-nw" "-I"
-                                            "-pf" #$pid-file ifaces))))
+                                     `(,dhclient "-nw" "-I"
+                                                 "-pf" ,#$pid-file
+                                                 ,@config-file-args
+                                                 ,@ifaces))))
                            (and (zero? (cdr (waitpid pid)))
                                 (read-pid-file #$pid-file)))))
               (stop #~(make-kill-destructor))))))

base-commit: b993f4735d41e690dbafb8ee2e17fce996a8cf20
-- 
2.45.1





  parent reply	other threads:[~2024-06-18  0:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-14 17:52 [bug#71561] [PATCH] services: networking: Allow dhcp-client to use a config file Richard Sent
2024-06-17 21:01 ` Maxim Cournoyer
2024-06-18  0:53   ` Richard Sent
2024-06-18  0:49 ` Richard Sent [this message]
2024-06-18  0:49   ` [bug#71561] [PATCH 2/2] doc: Prepend ISC to DHCP client references Richard Sent
2024-06-18 12:12     ` Maxim Cournoyer
2024-06-18 12:12   ` [bug#71561] [PATCH 1/2] services: networking: Allow dhcp-client to use a config file Maxim Cournoyer
2024-06-24  2:15 ` bug#71561: [PATCH] " Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b15c77d654ccdf788dd68a8d92cc3bc4e67cb1e7.1718671753.git.richard@freakingpenguin.com \
    --to=richard@freakingpenguin.com \
    --cc=71561@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    --cc=matt@excalamus.com \
    --cc=maxim.cournoyer@gmail.com \
    --cc=pelzflorian@pelzflorian.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).