[lxc-devel] [distrobuilder/master] shared/chroot: Create /dev/shm

monstermunchkin on Github lxc-bot at linuxcontainers.org
Tue Mar 31 14:54:47 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 439 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200331/bbd1bfc4/attachment.bin>
-------------- next part --------------
From 2334d21b758dd7ff82439c7a0a718d38c441e9ec Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Tue, 31 Mar 2020 16:54:09 +0200
Subject: [PATCH] shared/chroot: Create /dev/shm

This creates /dev/shm in the chroot, and changes its file mode to 1777.

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

diff --git a/shared/chroot.go b/shared/chroot.go
index 711b177..5a375cc 100644
--- a/shared/chroot.go
+++ b/shared/chroot.go
@@ -169,6 +169,7 @@ func SetupChroot(rootfs string, envs DefinitionEnv, m []ChrootMount) (func() err
 		{"none", "/run", "tmpfs", 0, "", true},
 		{"none", "/tmp", "tmpfs", 0, "", true},
 		{"none", "/dev", "tmpfs", 0, "", true},
+		{"none", "/dev/shm", "tmpfs", 0, "", true},
 		{"/etc/resolv.conf", "/etc/resolv.conf", "", unix.MS_BIND, "", false},
 	}
 
@@ -217,6 +218,12 @@ func SetupChroot(rootfs string, envs DefinitionEnv, m []ChrootMount) (func() err
 		return nil, errors.Wrap(err, "Failed to populate /dev")
 	}
 
+	// Change permission for /dev/shm
+	err = unix.Chmod("/dev/shm", 1777)
+	if err != nil {
+		return nil, errors.Wrap(err, "Failed to chmod /dev/shm")
+	}
+
 	var env Environment
 
 	if envs.ClearDefaults {


More information about the lxc-devel mailing list