From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:56240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUQzH-00016R-Ie for guix-patches@gnu.org; Sat, 25 May 2019 03:21:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hUQzG-0005DW-Ha for guix-patches@gnu.org; Sat, 25 May 2019 03:21:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34498) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hUQzG-0005DG-DV for guix-patches@gnu.org; Sat, 25 May 2019 03:21:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hUQzG-00050r-8p for guix-patches@gnu.org; Sat, 25 May 2019 03:21:02 -0400 Subject: [bug#35895] [PATCH] linux-container: Remove networking service when network is shared with host. References: <20190525070113.5576-1-arunisaac@systemreboot.net> In-Reply-To: <20190525070113.5576-1-arunisaac@systemreboot.net> Resent-Message-ID: From: Arun Isaac Date: Sat, 25 May 2019 12:50:30 +0530 Message-Id: <20190525072030.7739-1-arunisaac@systemreboot.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 35895@debbugs.gnu.org * 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