From 9b354394e2ba818880ba8c65000c417ef1c560a7 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Sun, 5 May 2019 18:31:41 +0200 Subject: procd: detect lxc container and behave accordingly meaning to not mount some specific parts witch cause trouble. The patch is based on previous work of @mikma to combine OpenWrt with lxd[0]. This patch however adds a detection copied from *virt-what* to check /proc/1/environment for the string "container". Thanks to @dangowrt for the cleanup. [0]: https://github.com/containercraft/openwrt-lxd/blob/master/patches/procd-openwrt-18.06/001_lxd_no_mounts.patch Signed-off-by: Paul Spooren --- plug/coldplug.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'plug') diff --git a/plug/coldplug.c b/plug/coldplug.c index c6a89c3..12df421 100644 --- a/plug/coldplug.c +++ b/plug/coldplug.c @@ -22,6 +22,7 @@ #include "../libc-compat.h" #include "hotplug.h" +#include "../container.h" static struct uloop_process udevtrigger; @@ -43,13 +44,16 @@ void procd_coldplug(void) char *argv[] = { "udevtrigger", NULL }; unsigned int oldumask = umask(0); - umount2("/dev/pts", MNT_DETACH); - umount2("/dev/", MNT_DETACH); - mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755,size=512K"); + if (!is_container()) { + umount2("/dev/pts", MNT_DETACH); + umount2("/dev/", MNT_DETACH); + mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755,size=512K"); + mkdir("/dev/pts", 0755); + mount("devpts", "/dev/pts", "devpts", MS_NOEXEC | MS_NOSUID, 0); + } + ignore(symlink("/tmp/shm", "/dev/shm")); - mkdir("/dev/pts", 0755); umask(oldumask); - mount("devpts", "/dev/pts", "devpts", MS_NOEXEC | MS_NOSUID, 0); udevtrigger.cb = udevtrigger_complete; udevtrigger.pid = fork(); if (!udevtrigger.pid) { -- cgit v1.2.1