2d17f8
From c9d58506297ed6c86c9d8a91d861e4de3772e699 Mon Sep 17 00:00:00 2001
2d17f8
From: Mrunal Patel <mrunalp@gmail.com>
2d17f8
Date: Tue, 7 Jul 2015 17:46:44 -0400
2d17f8
Subject: [PATCH] Don't make modifications to /dev there are no devices in the
2d17f8
 configuration
2d17f8
2d17f8
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2d17f8
---
2d17f8
 libcontainer/rootfs_linux.go | 26 ++++++++++++++++----------
2d17f8
 1 file changed, 16 insertions(+), 10 deletions(-)
2d17f8
2d17f8
diff --git a/libcontainer/rootfs_linux.go b/libcontainer/rootfs_linux.go
2d17f8
index 88aa77d..21f380d 100644
2d17f8
--- a/libcontainer/rootfs_linux.go
2d17f8
+++ b/libcontainer/rootfs_linux.go
2d17f8
@@ -27,6 +27,8 @@ func setupRootfs(config *configs.Config, console *linuxConsole) (err error) {
2d17f8
 	if err := prepareRoot(config); err != nil {
2d17f8
 		return newSystemError(err)
2d17f8
 	}
2d17f8
+
2d17f8
+	setupDev := len(config.Devices) == 0
2d17f8
 	for _, m := range config.Mounts {
2d17f8
 		for _, precmd := range m.PremountCmds {
2d17f8
 			if err := mountCmd(precmd); err != nil {
2d17f8
@@ -43,14 +45,16 @@ func setupRootfs(config *configs.Config, console *linuxConsole) (err error) {
2d17f8
 			}
2d17f8
 		}
2d17f8
 	}
2d17f8
-	if err := createDevices(config); err != nil {
2d17f8
-		return newSystemError(err)
2d17f8
-	}
2d17f8
-	if err := setupPtmx(config, console); err != nil {
2d17f8
-		return newSystemError(err)
2d17f8
-	}
2d17f8
-	if err := setupDevSymlinks(config.Rootfs); err != nil {
2d17f8
-		return newSystemError(err)
2d17f8
+	if !setupDev {
2d17f8
+		if err := createDevices(config); err != nil {
2d17f8
+			return newSystemError(err)
2d17f8
+		}
2d17f8
+		if err := setupPtmx(config, console); err != nil {
2d17f8
+			return newSystemError(err)
2d17f8
+		}
2d17f8
+		if err := setupDevSymlinks(config.Rootfs); err != nil {
2d17f8
+			return newSystemError(err)
2d17f8
+		}
2d17f8
 	}
2d17f8
 	if err := syscall.Chdir(config.Rootfs); err != nil {
2d17f8
 		return newSystemError(err)
2d17f8
@@ -63,8 +67,10 @@ func setupRootfs(config *configs.Config, console *linuxConsole) (err error) {
2d17f8
 	if err != nil {
2d17f8
 		return newSystemError(err)
2d17f8
 	}
2d17f8
-	if err := reOpenDevNull(config.Rootfs); err != nil {
2d17f8
-		return newSystemError(err)
2d17f8
+	if !setupDev {
2d17f8
+		if err := reOpenDevNull(config.Rootfs); err != nil {
2d17f8
+			return newSystemError(err)
2d17f8
+		}
2d17f8
 	}
2d17f8
 	if config.Readonlyfs {
2d17f8
 		if err := setReadonly(); err != nil {