GNU bug report logs - #32785
[PATCH] services: wpa-supplicant: Extend to support configuration parameters.

Previous Next

Package: guix-patches;

Reported by: Marius Bakke <mbakke <at> fastmail.com>

Date: Thu, 20 Sep 2018 15:43:02 UTC

Severity: normal

Tags: patch

Done: Marius Bakke <mbakke <at> fastmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32785 in the body.
You can then email your comments to 32785 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#32785; Package guix-patches. (Thu, 20 Sep 2018 15:43:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Marius Bakke <mbakke <at> fastmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 20 Sep 2018 15:43:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <mbakke <at> fastmail.com>
To: guix-patches <at> gnu.org
Subject: [PATCH] services: wpa-supplicant: Extend to support configuration
 parameters.
Date: Thu, 20 Sep 2018 17:42:14 +0200
This allows using WPA Supplicant "standalone" without an additional
network manager.  The default configuration is unchanged.

* gnu/services/networking.scm (<wpa-supplicant-configuration>): New record type.
(wpa-supplicant-shepherd-service): Pass configuration records to the daemon.
(wpa-supplicant-service-type): Adjust accordingly.
* doc/guix.texi (Networking Services): Document the new service type.
---
 doc/guix.texi               | 35 ++++++++++++----
 gnu/services/networking.scm | 84 +++++++++++++++++++++++++++----------
 2 files changed, 89 insertions(+), 30 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index b10e96aa9..6968a1212 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -11643,18 +11643,35 @@ When true, enable connman's vpn plugin.
 @defvr {Scheme Variable} wpa-supplicant-service-type
 This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
 supplicant}, an authentication daemon required to authenticate against
-encrypted WiFi or ethernet networks.  It is configured to listen for
-requests on D-Bus.
+encrypted WiFi or ethernet networks.
+@end defvr
 
-The value of this service is the @code{wpa-supplicant} package to use.
-Thus, it can be instantiated like this:
+@deftp {Data Type} wpa-supplicant-manager-configuration
+Data type representing the configuration of WPA Supplicant.
 
-@lisp
-(use-modules (gnu services networking))
+It takes the following parameters:
 
-(service wpa-supplicant-service-type)
-@end lisp
-@end defvr
+@table @asis
+@item @code{wpa-supplicant} (default: @code{wpa-supplicant})
+The WPA Supplicant package to use.
+
+@item @code{dbus?} (default: @code{#t})
+Whether to listen for requests on D-Bus.
+
+@item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
+Where to store the PID file.
+
+@item @code{interface} (default: @code{#f})
+If this is set, it must specify the name of a network interface that
+WPA supplicant will control.
+
+@item @code{config-file} (default: @code{#f})
+Optional configuration file to use.
+
+@item @code{extra-options} (default: @code{'()})
+List of additional command-line arguments to pass to the daemon.
+@end table
+@end deftp
 
 @cindex iptables
 @defvr {Scheme Variable} iptables-service-type
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index d8cf8cb68..32884c7e1 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -5,7 +5,7 @@
 ;;; Copyright © 2016 John Darrington <jmd <at> gnu.org>
 ;;; Copyright © 2017 Clément Lassieur <clement <at> lassieur.org>
 ;;; Copyright © 2017 Thomas Danckaert <post <at> thomasdanckaert.be>
-;;; Copyright © 2017 Marius Bakke <mbakke <at> fastmail.com>
+;;; Copyright © 2017, 2018 Marius Bakke <mbakke <at> fastmail.com>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me <at> tobias.gr>
 ;;; Copyright © 2018 Chris Marusich <cmmarusich <at> gmail.com>
 ;;; Copyright © 2018 Arun Isaac <arunisaac <at> systemreboot.net>
@@ -107,6 +107,16 @@
             modem-manager-configuration
             modem-manager-configuration?
             modem-manager-service-type
+
+            <wpa-supplicant-configuration>
+            wpa-supplicant-configuration
+            wpa-supplicant-configuration?
+            wpa-supplicant-configuration-wpa-supplicant
+            wpa-supplicant-configuration-pid-file
+            wpa-supplicant-configuration-dbus?
+            wpa-supplicant-configuration-interface
+            wpa-supplicant-configuration-config-file
+            wpa-supplicant-configuration-custom-arguments
             wpa-supplicant-service-type
 
             openvswitch-service-type
@@ -1159,28 +1169,60 @@ networking."))))
 ;;; WPA supplicant
 ;;;
 
-
-(define (wpa-supplicant-shepherd-service wpa-supplicant)
-  "Return a shepherd service for wpa_supplicant"
-  (list (shepherd-service
-         (documentation "Run WPA supplicant with dbus interface")
-         (provision '(wpa-supplicant))
-         (requirement '(user-processes dbus-system loopback))
-         (start #~(make-forkexec-constructor
-                   (list (string-append #$wpa-supplicant
-                                        "/sbin/wpa_supplicant")
-                         "-u" "-B" "-P/var/run/wpa_supplicant.pid")
-                   #:pid-file "/var/run/wpa_supplicant.pid"))
-         (stop #~(make-kill-destructor)))))
+(define-record-type* <wpa-supplicant-configuration>
+  wpa-supplicant-configuration make-wpa-supplicant-configuration
+  wpa-supplicant-configuration?
+  (wpa-supplicant     wpa-supplicant-configuration-wpa-supplicant ;<package>
+                      (default wpa-supplicant))
+  (pid-file           wpa-supplicant-configuration-pid-file       ;string
+                      (default "/var/run/wpa_supplicant.pid"))
+  (dbus?              wpa-supplicant-configuration-dbus?          ;Boolean
+                      (default #t))
+  (interface          wpa-supplicant-configuration-interface      ;#f | string
+                      (default #f))
+  (config-file        wpa-supplicant-configuration-config-file    ;#f | <file-like>
+                      (default #f))
+  (extra-options      wpa-supplicant-configuration-extra-options  ;list of strings
+                      (default '())))
+
+(define wpa-supplicant-shepherd-service
+  (match-lambda
+    (($ <wpa-supplicant-configuration> wpa-supplicant pid-file dbus? interface
+                                       config-file extra-options)
+     (list (shepherd-service
+            (documentation "Run the WPA supplicant daemon")
+            (provision '(wpa-supplicant))
+            (requirement '(user-processes dbus-system loopback))
+            (start #~(make-forkexec-constructor
+                      (list (string-append #$wpa-supplicant
+                                           "/sbin/wpa_supplicant")
+                            (string-append "-P" #$pid-file)
+                            "-B"        ;run in background
+                            #$@(if dbus?
+                                   #~("-u")
+                                   #~())
+                            #$@(if interface
+                                   #~(string-append "-i" #$interface)
+                                   #~())
+                            #$@(if config-file
+                                   #~(string-append "-c" #$config-file)
+                                   #~())
+                            #$@extra-options)
+                      #:pid-file #$pid-file))
+            (stop #~(make-kill-destructor)))))))
 
 (define wpa-supplicant-service-type
-  (service-type (name 'wpa-supplicant)
-                (extensions
-                 (list (service-extension shepherd-root-service-type
-                                          wpa-supplicant-shepherd-service)
-                       (service-extension dbus-root-service-type list)
-                       (service-extension profile-service-type list)))
-                (default-value wpa-supplicant)))
+  (let ((config->package
+         (match-lambda
+           (($ <wpa-supplicant-configuration> wpa-supplicant)
+            (list wpa-supplicant)))))
+    (service-type (name 'wpa-supplicant)
+                  (extensions
+                   (list (service-extension shepherd-root-service-type
+                                            wpa-supplicant-shepherd-service)
+                         (service-extension dbus-root-service-type config->package)
+                         (service-extension profile-service-type config->package)))
+                  (default-value (wpa-supplicant-configuration)))))
 
 
 ;;;
-- 
2.19.0





Information forwarded to guix-patches <at> gnu.org:
bug#32785; Package guix-patches. (Thu, 20 Sep 2018 16:13:01 GMT) Full text and rfc822 format available.

Message #8 received at 32785 <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <mbakke <at> fastmail.com>
To: 32785 <at> debbugs.gnu.org
Subject: Re: [bug#32785] [PATCH] services: wpa-supplicant: Extend to support
 configuration parameters.
Date: Thu, 20 Sep 2018 18:12:42 +0200
[Message part 1 (text/plain, inline)]
Marius Bakke <mbakke <at> fastmail.com> writes:

> This allows using WPA Supplicant "standalone" without an additional
> network manager.  The default configuration is unchanged.
>
> * gnu/services/networking.scm (<wpa-supplicant-configuration>): New record type.
> (wpa-supplicant-shepherd-service): Pass configuration records to the daemon.
> (wpa-supplicant-service-type): Adjust accordingly.
> * doc/guix.texi (Networking Services): Document the new service type.

A bit of background, since I forgot to add --notes: I have used this
patch for a long time, and decided to submit it since there was a
question about it on help-guix.

I have not tested the standalone configuration with the Guix DHCP client
service since I use a custom one.  Though I expect that to work fine.
Feedback appreciated!

[...]

> +
> +            <wpa-supplicant-configuration>
> +            wpa-supplicant-configuration
> +            wpa-supplicant-configuration?
> +            wpa-supplicant-configuration-wpa-supplicant
> +            wpa-supplicant-configuration-pid-file
> +            wpa-supplicant-configuration-dbus?
> +            wpa-supplicant-configuration-interface
> +            wpa-supplicant-configuration-config-file
> +            wpa-supplicant-configuration-custom-arguments
                                            ^^^^^^^^^
This is called 'extra-options' elsewhere and fixed locally.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#32785; Package guix-patches. (Mon, 24 Sep 2018 15:48:02 GMT) Full text and rfc822 format available.

Message #11 received at 32785 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Marius Bakke <mbakke <at> fastmail.com>
Cc: 32785 <at> debbugs.gnu.org
Subject: Re: [bug#32785] [PATCH] services: wpa-supplicant: Extend to support
 configuration parameters.
Date: Mon, 24 Sep 2018 17:47:05 +0200
Hello,

Marius Bakke <mbakke <at> fastmail.com> skribis:

> This allows using WPA Supplicant "standalone" without an additional
> network manager.  The default configuration is unchanged.
>
> * gnu/services/networking.scm (<wpa-supplicant-configuration>): New record type.
> (wpa-supplicant-shepherd-service): Pass configuration records to the daemon.
> (wpa-supplicant-service-type): Adjust accordingly.
> * doc/guix.texi (Networking Services): Document the new service type.

[...]

> +@deftp {Data Type} wpa-supplicant-manager-configuration
                                     ^
Should be ‘wpa-supplicant-configuration’.

> +    (service-type (name 'wpa-supplicant)
> +                  (extensions
> +                   (list (service-extension shepherd-root-service-type
> +                                            wpa-supplicant-shepherd-service)
> +                         (service-extension dbus-root-service-type config->package)
> +                         (service-extension profile-service-type config->package)))
> +                  (default-value (wpa-supplicant-configuration)))))

While you’re at it you can add a ‘description’ field.  :-)

I haven’t tested it but it LGTM.

Thank you!

Ludo’.




Reply sent to Marius Bakke <mbakke <at> fastmail.com>:
You have taken responsibility. (Wed, 17 Oct 2018 18:38:02 GMT) Full text and rfc822 format available.

Notification sent to Marius Bakke <mbakke <at> fastmail.com>:
bug acknowledged by developer. (Wed, 17 Oct 2018 18:38:02 GMT) Full text and rfc822 format available.

Message #16 received at 32785-done <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <mbakke <at> fastmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 32785-done <at> debbugs.gnu.org
Subject: Re: [bug#32785] [PATCH] services: wpa-supplicant: Extend to support
 configuration parameters.
Date: Wed, 17 Oct 2018 20:37:35 +0200
[Message part 1 (text/plain, inline)]
ludo <at> gnu.org (Ludovic Courtès) writes:

> Hello,
>
> Marius Bakke <mbakke <at> fastmail.com> skribis:
>
>> This allows using WPA Supplicant "standalone" without an additional
>> network manager.  The default configuration is unchanged.
>>
>> * gnu/services/networking.scm (<wpa-supplicant-configuration>): New record type.
>> (wpa-supplicant-shepherd-service): Pass configuration records to the daemon.
>> (wpa-supplicant-service-type): Adjust accordingly.
>> * doc/guix.texi (Networking Services): Document the new service type.
>
> [...]
>
>> +@deftp {Data Type} wpa-supplicant-manager-configuration
>                                      ^
> Should be ‘wpa-supplicant-configuration’.

Good catch; fixed!

>
>> +    (service-type (name 'wpa-supplicant)
>> +                  (extensions
>> +                   (list (service-extension shepherd-root-service-type
>> +                                            wpa-supplicant-shepherd-service)
>> +                         (service-extension dbus-root-service-type config->package)
>> +                         (service-extension profile-service-type config->package)))
>> +                  (default-value (wpa-supplicant-configuration)))))
>
> While you’re at it you can add a ‘description’ field.  :-)

See previous comment.

> I haven’t tested it but it LGTM.

I have done some testing and the default configuration seems to work
as before.  Pushed as acce0a474c1493ab18912bc46285248e4ccb0314.

Thank you!
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 15 Nov 2018 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 274 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.