[lxc-devel] [lxc/master] lxc_init: don't mount filesystems

hallyn on Github lxc-bot at linuxcontainers.org
Tue Feb 27 20:51:36 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 669 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180227/d07b5f6c/attachment.bin>
-------------- next part --------------
From 0011e0975c229e8a37aeaf3e21ebe4afa6201628 Mon Sep 17 00:00:00 2001
From: Serge Hallyn <shallyn at cisco.com>
Date: Tue, 27 Feb 2018 12:05:30 -0600
Subject: [PATCH] lxc_init: don't mount filesystems

We have an extensive set of container config options to do this
for us, and doing this unconditionally breaks several use cases.
For instance, if we want to bind mount a /dev/shm using the
container configuration, then lxc-execute, then lxc-init will
rudely unmount the /dev/shm and remount it as a private tmpfs.

Signed-off-by: Serge Hallyn <shallyn at cisco.com>
---
 src/lxc/cmd/lxc_init.c |  2 --
 src/lxc/initutils.c    | 41 -----------------------------------------
 2 files changed, 43 deletions(-)

diff --git a/src/lxc/cmd/lxc_init.c b/src/lxc/cmd/lxc_init.c
index 315c643fa..a0dabb66a 100644
--- a/src/lxc/cmd/lxc_init.c
+++ b/src/lxc/cmd/lxc_init.c
@@ -318,8 +318,6 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	lxc_setup_fs();
-
 	remove_self();
 
 	pid = fork();
diff --git a/src/lxc/initutils.c b/src/lxc/initutils.c
index 12c33630b..56926fb5f 100644
--- a/src/lxc/initutils.c
+++ b/src/lxc/initutils.c
@@ -28,47 +28,6 @@
 
 lxc_log_define(lxc_initutils, lxc);
 
-static int mount_fs(const char *source, const char *target, const char *type)
-{
-	/* the umount may fail */
-	if (umount(target))
-		WARN("Failed to unmount %s : %s", target, strerror(errno));
-
-	if (mount(source, target, type, 0, NULL)) {
-		ERROR("Failed to mount %s : %s", target, strerror(errno));
-		return -1;
-	}
-
-	DEBUG("'%s' mounted on '%s'", source, target);
-
-	return 0;
-}
-
-extern void lxc_setup_fs(void)
-{
-	if (mount_fs("proc", "/proc", "proc"))
-		INFO("Failed to remount proc");
-
-	/* if /dev has been populated by us, /dev/shm does not exist */
-	if (access("/dev/shm", F_OK) && mkdir("/dev/shm", 0777))
-		INFO("Failed to create /dev/shm");
-
-	/* if we can't mount /dev/shm, continue anyway */
-	if (mount_fs("shmfs", "/dev/shm", "tmpfs"))
-		INFO("Failed to mount /dev/shm");
-
-	/* If we were able to mount /dev/shm, then /dev exists */
-	/* Sure, but it's read-only per config :) */
-	if (access("/dev/mqueue", F_OK) && mkdir("/dev/mqueue", 0666)) {
-		DEBUG("Failed to create '/dev/mqueue'");
-		return;
-	}
-
-	/* continue even without posix message queue support */
-	if (mount_fs("mqueue", "/dev/mqueue", "mqueue"))
-		INFO("Failed to mount /dev/mqueue");
-}
-
 static char *copy_global_config_value(char *p)
 {
 	int len = strlen(p);


More information about the lxc-devel mailing list