unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Arun Isaac <arunisaac@systemreboot.net>
To: 35895@debbugs.gnu.org
Subject: [bug#35895] [PATCH] linux-container: Remove networking service when network is shared with host.
Date: Sat, 25 May 2019 12:50:30 +0530	[thread overview]
Message-ID: <20190525072030.7739-1-arunisaac@systemreboot.net> (raw)
In-Reply-To: <20190525070113.5576-1-arunisaac@systemreboot.net>

* gnu/system/linux-container.scm (dummy-networking-shepherd-service): New
procedure.
(dummy-networking-service-type): New variable.
(containerized-operating-system): If network is shared with host, replace
static-networking-service-type with dummy-networking-service-type.
---
 gnu/system/linux-container.scm | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm
index c1e963d047..ee2a476e4c 100644
--- a/gnu/system/linux-container.scm
+++ b/gnu/system/linux-container.scm
@@ -30,6 +30,7 @@
   #:use-module (gnu build linux-container)
   #:use-module (gnu services)
   #:use-module (gnu services base)
+  #:use-module (gnu services shepherd)
   #:use-module (gnu system)
   #:use-module (gnu system file-systems)
   #:export (system-container
@@ -65,6 +66,22 @@ from OS that are needed on the bare metal and not in a container."
                          files)))
             base)))
 
+(define (dummy-networking-shepherd-service _)
+  (shepherd-service
+   (documentation "Provide loopback and networking without actually doing
+anything.")
+   (provision '(loopback networking))
+   (start #~(const #t))))
+
+(define dummy-networking-service-type
+  (service-type
+   (name 'dummy-networking)
+   (extensions
+    (list (service-extension
+           shepherd-root-service-type
+           (compose list dummy-networking-shepherd-service))))
+   (default-value #f)))
+
 (define* (containerized-operating-system os mappings
                                          #:key
                                          shared-network?
@@ -96,7 +113,8 @@ containerized OS.  EXTRA-FILE-SYSTEMS is a list of file systems to add to OS."
                   agetty-service-type)
             ;; Remove nscd service if network is shared with the host.
             (if shared-network?
-                (list nscd-service-type)
+                (list nscd-service-type
+                      static-networking-service-type)
                 (list))))
 
   (operating-system
@@ -105,10 +123,14 @@ containerized OS.  EXTRA-FILE-SYSTEMS is a list of file systems to add to OS."
     (essential-services (container-essential-services
                          this-operating-system
                          #:shared-network? shared-network?))
-    (services (remove (lambda (service)
-                        (memq (service-kind service)
-                              useless-services))
-                      (operating-system-user-services os)))
+    (services (append
+               (remove (lambda (service)
+                         (memq (service-kind service)
+                               useless-services))
+                       (operating-system-user-services os))
+               (if shared-network?
+                   (list (service dummy-networking-service-type))
+                   (list))))
     (file-systems (append (map mapping->fs
                                (if shared-network?
                                    (append %network-file-mappings mappings)
-- 
2.21.0

  reply	other threads:[~2019-05-25  7:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-25  7:01 [bug#35895] [PATCH 0/1] linux-container: Remove networking service when network is shared with host Arun Isaac
2019-05-25  7:20 ` Arun Isaac [this message]
2019-05-25 12:37   ` [bug#35895] [PATCH] " Christopher Baines
2019-06-03 17:11     ` Danny Milosavljevic
2019-06-09 20:35       ` Arun Isaac
2019-06-13 21:02         ` Ludovic Courtès
2019-06-18 11:37           ` Arun Isaac
2019-06-18 14:19             ` Ludovic Courtès
2019-06-18 18:57               ` bug#35895: " Arun Isaac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190525072030.7739-1-arunisaac@systemreboot.net \
    --to=arunisaac@systemreboot.net \
    --cc=35895@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).