summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--recipes-containers/lxc/files/lxc-0.9.0-enable-chroot-chpasswd-functionality-for-busybox-hosts.patch70
-rw-r--r--recipes-containers/lxc/lxc_0.9.0.bb1
2 files changed, 71 insertions, 0 deletions
diff --git a/recipes-containers/lxc/files/lxc-0.9.0-enable-chroot-chpasswd-functionality-for-busybox-hosts.patch b/recipes-containers/lxc/files/lxc-0.9.0-enable-chroot-chpasswd-functionality-for-busybox-hosts.patch
new file mode 100644
index 00000000..d07c6580
--- /dev/null
+++ b/recipes-containers/lxc/files/lxc-0.9.0-enable-chroot-chpasswd-functionality-for-busybox-hosts.patch
@@ -0,0 +1,70 @@
1From 4ddc14bd0866ff769421857044dd14867f1944d5 Mon Sep 17 00:00:00 2001
2From: Bogdan Purcareata <bogdan.purcareata@freescale.com>
3Date: Thu, 11 Apr 2013 16:15:43 +0300
4Subject: [PATCH v2] lxc-template: enable chroot + chpasswd functionality for
5 Busybox hosts
6
7This patch supports the scenario where a user wants to install a
8busybox container on a busybox host.
9
10When running the template, in order to change the root password,
11the template needs to do the chroot. On busybox-powered hosts, chroot
12is not part of the coreutils package - it's part of busybox. And the
13busybox implementation or chroot only works if it has /lib in the new
14root populated with the right binaries (or at least that's the
15solution I found to make it work).
16
17The temporarily bind-mounts /lib in the NEWROOT, chroots there,
18changes the password, goes back and unmounts. This set of operations
19is contained in a new MOUNT namespace, using the lxc-unshare call.
20
21Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
22---
23 templates/lxc-busybox.in | 30 ++++++++++++++++++++++++++++--
24 1 file changed, 28 insertions(+), 2 deletions(-)
25
26diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in
27index cb425ec..2ca2bfd 100644
28--- a/templates/lxc-busybox.in
29+++ b/templates/lxc-busybox.in
30@@ -189,9 +189,35 @@ configure_busybox()
31 # passwd exec must be setuid
32 chmod +s $rootfs/bin/passwd
33 touch $rootfs/etc/shadow
34- echo "setting root passwd to root"
35- echo "root:root" | chroot $rootfs chpasswd
36
37+ # setting passwd for root
38+ CHPASSWD_FILE=$rootfs/root/chpasswd.sh
39+
40+ cat <<EOF >$CHPASSWD_FILE
41+echo "setting root password to \"root\""
42+
43+mount --bind /lib $rootfs/lib
44+if [ \$? -ne 0 ]; then
45+ echo "Failed bind-mounting /lib at $rootfs/lib"
46+ exit 1
47+fi
48+
49+chroot $rootfs chpasswd <<EOFF 2>/dev/null
50+root:root
51+EOFF
52+
53+
54+if [ \$? -ne 0 ]; then
55+ echo "Failed to change root password"
56+ exit 1
57+fi
58+
59+umount $rootfs/lib
60+
61+EOF
62+
63+ lxc-unshare -s MOUNT -- /bin/sh < $CHPASSWD_FILE
64+ rm $CHPASSWD_FILE
65
66 # add ssh functionality if dropbear package available on host
67 which dropbear >/dev/null 2>&1
68--
691.7.11.7
70
diff --git a/recipes-containers/lxc/lxc_0.9.0.bb b/recipes-containers/lxc/lxc_0.9.0.bb
index fcda0ba4..63ce2d66 100644
--- a/recipes-containers/lxc/lxc_0.9.0.bb
+++ b/recipes-containers/lxc/lxc_0.9.0.bb
@@ -23,6 +23,7 @@ RDEPENDS_${PN} = " \
23 23
24SRC_URI = "http://lxc.sourceforge.net/download/lxc/${PN}-${PV}.tar.gz \ 24SRC_URI = "http://lxc.sourceforge.net/download/lxc/${PN}-${PV}.tar.gz \
25 file://lxc-0.9.0-disable-udhcp-from-busybox-template.patch \ 25 file://lxc-0.9.0-disable-udhcp-from-busybox-template.patch \
26 file://lxc-0.9.0-enable-chroot-chpasswd-functionality-for-busybox-hosts.patch \
26 " 27 "
27SRC_URI[md5sum] = "8552a4479090616f4bc04d8473765fc9" 28SRC_URI[md5sum] = "8552a4479090616f4bc04d8473765fc9"
28SRC_URI[sha256sum] = "1e1767eae6cc5fbf892c0e193d25da420ba19f2db203716c38f7cdea3b654120" 29SRC_URI[sha256sum] = "1e1767eae6cc5fbf892c0e193d25da420ba19f2db203716c38f7cdea3b654120"