services: dhcp-client: Ignore interfaces that cannot be activated.

Fixes <https://bugs.gnu.org/38524>.

* gnu/services/networking.scm (dhcp-client-service-type): Filter interfaces
that cannot be activated.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Brice Waegeneire 2019-12-14 08:23:26 +01:00 committed by Ludovic Courtès
parent 7a241c6350
commit 747b7246a6
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -234,14 +234,15 @@ (define pid-file
(define valid?
(lambda (interface)
(and (arp-network-interface? interface)
(not (loopback-network-interface? interface)))))
(not (loopback-network-interface? interface))
;; XXX: Make sure the interfaces are up so that
;; 'dhclient' can actually send/receive over them.
;; Ignore those that cannot be activated.
(false-if-exception
(set-network-interface-up interface)))))
(define ifaces
(filter valid? (all-network-interface-names)))
;; XXX: Make sure the interfaces are up so that 'dhclient' can
;; actually send/receive over them.
(for-each set-network-interface-up ifaces)
(false-if-exception (delete-file #$pid-file))
(let ((pid (fork+exec-command
(cons* #$dhclient "-nw"