[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/08: environment: Turn "lo" up in network-less containers.
From: |
guix-commits |
Subject: |
01/08: environment: Turn "lo" up in network-less containers. |
Date: |
Mon, 5 Oct 2020 04:43:04 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit b68d4106518abed20ba308831b65dcc69bf120a5
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun Oct 4 22:40:26 2020 +0200
environment: Turn "lo" up in network-less containers.
This is a followup to 0f53c801b91919380a924b402d1ff822bb1dc6ea.
* guix/scripts/environment.scm (launch-environment/container): Add call
to 'set-network-interface-up'.
* tests/guix-environment-container.sh: Add test.
---
guix/scripts/environment.scm | 6 +++++-
tests/guix-environment-container.sh | 11 +++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 9698111..085f11a 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -34,6 +34,7 @@
#: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 @@ WHILE-LIST."
;; 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.
diff --git a/tests/guix-environment-container.sh
b/tests/guix-environment-container.sh
index 3674aa6..f2d15c8 100644
--- a/tests/guix-environment-container.sh
+++ b/tests/guix-environment-container.sh
@@ -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\"))'`"
- branch master updated (5aa7d76 -> 62cf60d), guix-commits, 2020/10/05
- 01/08: environment: Turn "lo" up in network-less containers.,
guix-commits <=
- 02/08: gnu: seahorse: Update to 3.36., guix-commits, 2020/10/05
- 04/08: gnu: Add gnote., guix-commits, 2020/10/05
- 05/08: gnu: mergerfs: Update to 2.31.0., guix-commits, 2020/10/05
- 07/08: gnu: python-mutagen: Update to 1.45.1., guix-commits, 2020/10/05
- 06/08: gnu: mergerfs-tools: Update to 480296e., guix-commits, 2020/10/05
- 08/08: gnu: picard: Update to 2.4.4., guix-commits, 2020/10/05
- 03/08: gnu: Add gnome-commander., guix-commits, 2020/10/05