emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#71561: closed ([PATCH] services: networking: Allow dhcp-client to us


From: GNU bug Tracking System
Subject: bug#71561: closed ([PATCH] services: networking: Allow dhcp-client to use a config file)
Date: Mon, 24 Jun 2024 02:17:01 +0000

Your message dated Sun, 23 Jun 2024 22:15:43 -0400
with message-id <87jzif84s0.fsf@gmail.com>
and subject line Re: [bug#71561] [PATCH] services: networking: Allow 
dhcp-client to use a config file
has caused the debbugs.gnu.org bug report #71561,
regarding [PATCH] services: networking: Allow dhcp-client to use a config file
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
71561: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71561
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [PATCH] services: networking: Allow dhcp-client to use a config file Date: Fri, 14 Jun 2024 13:52:58 -0400
* gnu/services/networking (dhcp-client-configuration): Create
dhcp-client-configuration-config-file.
(dhcp-client-shepherd-service): Use the config file when invoking
dhclient if supplied.
* doc/guix.texi: Document it.

Change-Id: I286de4ddf59c5e606bf1fe0a7510570869e62b1a
---
Hi all.

This patch adds support for providing dhcp-client a configuration
file, which is a file of the form
https://man.archlinux.org/man/dhclient.conf.5. I believe this can be
used to resolve
https://lists.gnu.org/archive/html/help-guix/2024-06/msg00071.html
using the instructions at https://unix.stackexchange.com/a/399694,
although I haven't confirmed that. Either way, adding more flexibility
to the service is a good thing in my eyes.

 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: 7770e4140cddd5dc9c9879cb2bfcbd6cd4de59a0
-- 
2.45.1




--- End Message ---
--- Begin Message --- Subject: Re: [bug#71561] [PATCH] services: networking: Allow dhcp-client to use a config file Date: Sun, 23 Jun 2024 22:15:43 -0400 User-agent: Gnus/5.13 (Gnus v5.13)
Hi,

Richard Sent <richard@freakingpenguin.com> writes:

> * gnu/services/networking (dhcp-client-configuration): Create
> dhcp-client-configuration-config-file.
> (dhcp-client-shepherd-service): Use the config file when invoking
> dhclient if supplied.
> * doc/guix.texi: Document it.
>
> Change-Id: I286de4ddf59c5e606bf1fe0a7510570869e62b1a

Applied, thanks.

-- 
Maxim


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]