[lxc-devel] [distrobuilder/master] shared: Wipe rootfs/dev

monstermunchkin on Github lxc-bot at linuxcontainers.org
Mon Aug 5 09:53:53 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190805/8e5c8fd4/attachment.bin>
-------------- next part --------------
From b48560aa0d1bf346b4e43bf381c54d155c94d8dd Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Mon, 5 Aug 2019 11:08:47 +0200
Subject: [PATCH] shared: Wipe rootfs/dev

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 shared/chroot.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/shared/chroot.go b/shared/chroot.go
index 2b6aa9d..22f1d7f 100644
--- a/shared/chroot.go
+++ b/shared/chroot.go
@@ -292,6 +292,14 @@ exit 101
 		// And now unmount the entire tree
 		syscall.Unmount(rootfs, syscall.MNT_DETACH)
 
-		return nil
+		devPath := filepath.Join(rootfs, "dev")
+
+		// Wipe $rootfs/dev
+		err := os.RemoveAll(devPath)
+		if err != nil {
+			return err
+		}
+
+		return os.MkdirAll(devPath, 0755)
 	}, nil
 }


More information about the lxc-devel mailing list