summaryrefslogtreecommitdiffstats
path: root/recipes-containers/lxc/files/lxc-busybox-support-enea-linux-init.patch
blob: 4eecfaae7f13df30aa8bd9421021f05a061ccd88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
lxc: Modify  lxc-busybox to support  Enea Linux

In Enea Linux, the busybox commands are split between busybox.nosuid (symlinked
as /bin/busybox) and busybox.suid. This patch enables  the commands provided by
the latter and also replaces the busybox init with the SysV counterpart.

Upstream-Status: Pending

Signed-off-by: Petre Pircalabu <petre.pircalabu@enea.com>

--- a/templates/lxc-busybox.in
+++ b/templates/lxc-busybox.in
@@ -129,6 +129,7 @@ EOF
     # and propose a shell on the tty, the last one is
     # not needed
     cat <<EOF >> $rootfs/etc/inittab
+id:5:initdefault:
 ::sysinit:/etc/init.d/rcS
 tty1::respawn:/bin/getty -L tty1 115200 vt100
 console::askfirst:/bin/sh
@@ -209,8 +210,28 @@ configure_busybox()
       xargs -n1 ln -s busybox
     popd > /dev/null
 
-    # relink /sbin/init
-    ln $rootfs/bin/busybox $rootfs/sbin/init
+    which busybox.suid >/dev/null 2>&1
+
+    if [ $? -eq 0 ]; then
+	# copy busybox.suid in the rootfs
+	cp $(which busybox.suid) $rootfs/bin
+	if [ $? -ne 0 ]; then
+            echo "failed to copy busybox.suid in the rootfs"
+            return 1
+	fi
+
+	pushd $rootfs/bin > /dev/null || return 1
+	./busybox.suid --help | grep 'Currently defined functions:' -A300 | \
+	    grep -v 'Currently defined functions:' | tr , '\n' | \
+	    xargs -n1 ln -s busybox.suid
+	popd > /dev/null
+    fi
+
+    # use SysV init
+    pushd $rootfs/sbin > /dev/null || return 1
+    cp /sbin/init.sysvinit .
+    ln -s init.sysvinit init
+    popd > /dev/null
 
     # passwd exec must be setuid
     chmod +s $rootfs/bin/passwd