3
5
Fork 0
mirror of git://git.savannah.gnu.org/guix.git synced 2023-12-14 03:33:07 +01:00

services: static-networking: Avoid use of net-tools.

* gnu/services/networking.scm (<static-networking>)[net-tools]: Remove.
(static-networking-service-type): Use 'add-network-route/gateway' and
'delete-network-route' instead of NET-TOOLS.
(static-networking-service): Adjust accordingly.
This commit is contained in:
Ludovic Courtès 2016-11-21 00:32:21 +01:00
parent 9e38e3cf52
commit e48fcd7b8d
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -62,6 +62,7 @@
bitlbee-service
bitlbee-service-type
wicd-service-type
wicd-service
network-manager-service
connman-service
@ -116,15 +117,14 @@ fe80::1%lo0 apps.facebook.com\n")
(default #f))
(gateway static-networking-gateway)
(provision static-networking-provision)
(name-servers static-networking-name-servers)
(net-tools static-networking-net-tools))
(name-servers static-networking-name-servers))
(define static-networking-service-type
(shepherd-service-type
'static-networking
(match-lambda
(($ <static-networking> interface ip netmask gateway provision
name-servers net-tools)
name-servers)
(let ((loopback? (memq 'loopback provision)))
;; TODO: Eventually replace 'route' with bindings for the appropriate
@ -146,19 +146,23 @@ fe80::1%lo0 apps.facebook.com\n")
(inet-pton AF_INET #$netmask)))
(maskaddr (and mask
(make-socket-address AF_INET
mask 0))))
mask 0)))
(gateway (and #$gateway
(inet-pton AF_INET #$gateway)))
(gatewayaddr (and gateway
(make-socket-address AF_INET
gateway 0))))
(configure-network-interface #$interface sockaddr
(logior IFF_UP
#$(if loopback?
#~IFF_LOOPBACK
0))
#:netmask maskaddr))
#$(if gateway
#~(zero? (system* (string-append #$net-tools
"/sbin/route")
"add" "-net" "default"
"gw" #$gateway))
#t)
#:netmask maskaddr)
(when gateway
(let ((sock (socket AF_INET SOCK_DGRAM 0)))
(add-network-route/gateway sock gatewayaddr)
(close-port sock))))
#$(if (pair? name-servers)
#~(call-with-output-file "/etc/resolv.conf"
(lambda (port)
@ -168,18 +172,19 @@ fe80::1%lo0 apps.facebook.com\n")
(for-each (lambda (server)
(format port "nameserver ~a~%"
server))
'#$name-servers)))
'#$name-servers)
#t))
#t)))
(stop #~(lambda _
;; Return #f is successfully stopped.
(let ((sock (socket AF_INET SOCK_STREAM 0)))
(when #$gateway
(delete-network-route sock
(make-socket-address
AF_INET INADDR_ANY 0)))
(set-network-interface-flags sock #$interface 0)
(close-port sock))
(not #$(if gateway
#~(system* (string-append #$net-tools
"/sbin/route")
"del" "-net" "default")
#t))))
(close-port sock)
#f)))
(respawn? #f)))))))
(define* (static-networking-service interface ip
@ -195,8 +200,7 @@ it must be a string specifying the default network gateway."
(static-networking (interface interface) (ip ip)
(netmask netmask) (gateway gateway)
(provision provision)
(name-servers name-servers)
(net-tools net-tools))))
(name-servers name-servers))))
(define dhcp-client-service-type
(shepherd-service-type