Yocto 2.5

Move OpenBMC to Yocto 2.5(sumo)

Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I5c5ad6904a16e14c1c397f0baf10c9d465594a78
diff --git a/import-layers/yocto-poky/meta/recipes-core/busybox/busybox.inc b/import-layers/yocto-poky/meta/recipes-core/busybox/busybox.inc
index a6bfd46..d1675c3 100644
--- a/import-layers/yocto-poky/meta/recipes-core/busybox/busybox.inc
+++ b/import-layers/yocto-poky/meta/recipes-core/busybox/busybox.inc
@@ -106,7 +106,7 @@
 }
 
 do_prepare_config () {
-	if [ "$BUILD_REPRODUCIBLE_BINARIES" = "1" ]; then
+	if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
 		export KCONFIG_NOTIMESTAMP=1
 	fi
 	sed -e '/CONFIG_STATIC/d' \
@@ -146,7 +146,7 @@
 
 do_compile() {
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
-	if [ "$BUILD_REPRODUCIBLE_BINARIES" = "1" ]; then
+	if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
 		export KCONFIG_NOTIMESTAMP=1
 	fi
 	if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then
@@ -158,6 +158,12 @@
 		cp .config .config.orig
 		oe_runmake busybox.cfg.suid
 		oe_runmake busybox.cfg.nosuid
+
+		# workaround for suid bug 10346
+		if ! grep -q "CONFIG_SH_IS_NONE" busybox.cfg.nosuid; then
+			echo "CONFIG_SH_IS_NONE" >> busybox.cfg.suid
+		fi
+
 		for i in `cat busybox.cfg.suid busybox.cfg.nosuid`; do
 			echo "# $i is not set" >> .config.disable.apps
 		done
@@ -167,12 +173,24 @@
 			cat busybox.cfg.$s | while read item; do
 				grep -w "$item" .config.orig
 			done > .config.app.$s
+
+			# workaround for suid bug 10346
+			if [ "$s" = "suid" ] ; then
+				sed "s/.*CONFIG_SH_IS_NONE.*$/CONFIG_SH_IS_NONE=y/" -i .config.app.suid
+			fi
+
 			merge_config.sh -m .config.nonapps .config.app.$s
 			oe_runmake busybox_unstripped
 			mv busybox_unstripped busybox.$s
 			oe_runmake busybox.links
 			mv busybox.links busybox.links.$s
 		done
+
+		# hard fail if sh is being linked to the suid busybox (detects bug 10346)
+		if grep -q -x "/bin/sh" busybox.links.suid; then
+			bbfatal "busybox suid binary incorrectly provides /bin/sh"
+		fi
+
 		# copy .config.orig back to .config, because the install process may check this file
 		cp .config.orig .config
 		# cleanup
@@ -206,7 +224,7 @@
 			install -m 0755 ${B}/busybox.nosuid ${D}${base_bindir}
 			install -m 0644 ${S}/busybox.links.suid ${D}${sysconfdir}
 			install -m 0644 ${S}/busybox.links.nosuid ${D}${sysconfdir}
-			if grep -q "CONFIG_FEATURE_SH_IS_ASH=y" ${B}/.config; then
+			if grep -q "CONFIG_SH_IS_ASH=y" ${B}/.config; then
 				ln -sf busybox.nosuid ${D}${base_bindir}/sh
 			fi
 			# Keep a default busybox for people who want to invoke busybox directly.
@@ -220,7 +238,7 @@
 				install -m 0755 ${B}/busybox ${D}${base_bindir}
 			fi
 			install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
-			if grep -q "CONFIG_FEATURE_SH_IS_ASH=y" ${B}/.config; then
+			if grep -q "CONFIG_SH_IS_ASH=y" ${B}/.config; then
 				ln -sf busybox ${D}${base_bindir}/sh
 			fi
 			# We make this symlink here to eliminate the error when upgrading together