mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
environment: Turn "lo" up in network-less containers.
This is a followup to 0f53c801b9
.
* guix/scripts/environment.scm (launch-environment/container): Add call
to 'set-network-interface-up'.
* tests/guix-environment-container.sh: Add test.
This commit is contained in:
parent
5aa7d764be
commit
b68d410651
2 changed files with 16 additions and 1 deletions
|
@ -34,6 +34,7 @@ (define-module (guix scripts environment)
|
|||
#:use-module (guix scripts build)
|
||||
#:use-module (gnu build linux-container)
|
||||
#:use-module (gnu build accounts)
|
||||
#:use-module ((guix build syscalls) #:select (set-network-interface-up))
|
||||
#:use-module (gnu system linux-container)
|
||||
#:use-module (gnu system file-systems)
|
||||
#:use-module (gnu packages)
|
||||
|
@ -554,7 +555,10 @@ (define (optional-mapping->fs mapping)
|
|||
;; to resolve "localhost".
|
||||
(call-with-output-file "/etc/hosts"
|
||||
(lambda (port)
|
||||
(display "127.0.0.1 localhost\n" port))))
|
||||
(display "127.0.0.1 localhost\n" port)))
|
||||
|
||||
;; Allow local AF_INET communications.
|
||||
(set-network-interface-up "lo"))
|
||||
|
||||
;; For convenience, start in the user's current working
|
||||
;; directory or, if unmapped, the home directory.
|
||||
|
|
|
@ -48,6 +48,17 @@ fi
|
|||
guix environment --container --ad-hoc --bootstrap guile-bootstrap \
|
||||
-- guile -c '(exit (pair? (getaddrinfo "localhost" "80")))'
|
||||
|
||||
# We should get ECONNREFUSED, not ENETUNREACH, which would indicate that "lo"
|
||||
# is down.
|
||||
guix environment --container --ad-hoc --bootstrap guile-bootstrap \
|
||||
-- guile -c "(exit (= ECONNREFUSED
|
||||
(catch 'system-error
|
||||
(lambda ()
|
||||
(let ((sock (socket AF_INET SOCK_STREAM 0)))
|
||||
(connect sock AF_INET INADDR_LOOPBACK 12345)))
|
||||
(lambda args
|
||||
(pk 'errno (system-error-errno args))))))"
|
||||
|
||||
# Make sure '--preserve' is honored.
|
||||
result="`FOOBAR=42; export FOOBAR; guix environment -C --ad-hoc --bootstrap \
|
||||
guile-bootstrap -E ^FOO -- guile -c '(display (getenv \"FOOBAR\"))'`"
|
||||
|
|
Loading…
Reference in a new issue