summaryrefslogtreecommitdiff
path: root/plug
diff options
context:
space:
mode:
authorPaul Spooren <mail@aparcar.org>2019-05-05 18:31:41 +0200
committerHans Dedecker <hans.dedecker@technicolor.com>2019-05-08 13:34:43 +0200
commit9b354394e2ba818880ba8c65000c417ef1c560a7 (patch)
treef6901d6406ea069ed08a85b4c5e183df62c422bd /plug
parent01f3dc8b50cf9728c8a70ff9d19143f90c49b786 (diff)
downloadprocd-9b354394e2ba818880ba8c65000c417ef1c560a7.tar.gz
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 <mail@aparcar.org>
Diffstat (limited to 'plug')
-rw-r--r--plug/coldplug.c14
1 files changed, 9 insertions, 5 deletions
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) {