diff options
author | Ludovic Courtès <ludo@gnu.org> | 2016-11-21 00:32:21 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2016-11-21 00:34:49 +0100 |
commit | e48fcd7b8d07f213b23e3b432b0f10db917f69fa (patch) | |
tree | 67f63fcedd28ea5f585a244715a7469a4bbc25e6 | |
parent | 9e38e3cf527d907b499f8fc909aac5d0e25a5af7 (diff) | |
download | guix-e48fcd7b8d07f213b23e3b432b0f10db917f69fa.tar guix-e48fcd7b8d07f213b23e3b432b0f10db917f69fa.tar.gz |
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.
-rw-r--r-- | gnu/services/networking.scm | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 884c542439..3a4133a153 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -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 |