From 09806901be06fd99b0c7ed3f15bc4de2d03ec174 Mon Sep 17 00:00:00 2001 From: Paul Barker Date: Wed, 4 May 2016 08:23:32 +0100 Subject: toybox: Upgrade to 0.7.0 Add additional patches to fix issues seen during testing on qemux86. Signed-off-by: Paul Barker Signed-off-by: Martin Jansa --- .../toybox/toybox/0001-Fix-segfault-in-login.patch | 33 +++++++++ .../0002-Add-b-and-F-arguments-to-hostname.patch | 84 ++++++++++++++++++++++ meta-oe/recipes-core/toybox/toybox_0.6.0.bb | 65 ----------------- meta-oe/recipes-core/toybox/toybox_0.7.0.bb | 69 ++++++++++++++++++ 4 files changed, 186 insertions(+), 65 deletions(-) create mode 100644 meta-oe/recipes-core/toybox/toybox/0001-Fix-segfault-in-login.patch create mode 100644 meta-oe/recipes-core/toybox/toybox/0002-Add-b-and-F-arguments-to-hostname.patch delete mode 100644 meta-oe/recipes-core/toybox/toybox_0.6.0.bb create mode 100644 meta-oe/recipes-core/toybox/toybox_0.7.0.bb (limited to 'meta-oe/recipes-core') diff --git a/meta-oe/recipes-core/toybox/toybox/0001-Fix-segfault-in-login.patch b/meta-oe/recipes-core/toybox/toybox/0001-Fix-segfault-in-login.patch new file mode 100644 index 0000000000..939885b961 --- /dev/null +++ b/meta-oe/recipes-core/toybox/toybox/0001-Fix-segfault-in-login.patch @@ -0,0 +1,33 @@ +From 863b129441c12eb75d63e4f4fe9a8f7df81607fd Mon Sep 17 00:00:00 2001 +From: Paul Barker +Date: Sun, 1 May 2016 14:50:59 +0100 +Subject: [PATCH] Fix segfault in login + +Fix a bug in readfileat where *plen would be corrupted if you didn't supply +your own buffer (because ibuf is 0 in that case, not a pointer to the start +of the allocated space). This caused a segfault in the 'login' program. + +Partial backport of upstream commit 81f31e463bd982a8344ea8681938eb43c9114652 + +Signed-off-by: Paul Barker +Upstream-status: Backport +--- + lib/lib.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/lib.c b/lib/lib.c +index 6559030..e5bb605 100644 +--- a/lib/lib.c ++++ b/lib/lib.c +@@ -475,7 +475,7 @@ char *readfileat(int dirfd, char *name, char *ibuf, off_t *plen) + rbuf = buf+rlen; + len -= rlen; + } +- *plen = len = rlen+(buf-ibuf); ++ *plen = len = rlen+(rbuf-buf); + close(fd); + + if (rlen<0) { +-- +2.1.4 + diff --git a/meta-oe/recipes-core/toybox/toybox/0002-Add-b-and-F-arguments-to-hostname.patch b/meta-oe/recipes-core/toybox/toybox/0002-Add-b-and-F-arguments-to-hostname.patch new file mode 100644 index 0000000000..e300494114 --- /dev/null +++ b/meta-oe/recipes-core/toybox/toybox/0002-Add-b-and-F-arguments-to-hostname.patch @@ -0,0 +1,84 @@ +From 151f576ab1fba44137beaeb95620b7942662b4d3 Mon Sep 17 00:00:00 2001 +From: Paul Barker +Date: Sun, 1 May 2016 15:42:57 +0100 +Subject: [PATCH] Add -b and -F arguments to hostname + +These arguments are required to correctly set the hostname at boot time. + +Signed-off-by: Paul Barker +Upstream-status: Submitted +--- + toys/lsb/hostname.c | 42 ++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 40 insertions(+), 2 deletions(-) + +diff --git a/toys/lsb/hostname.c b/toys/lsb/hostname.c +index 23467fb..ebfc803 100644 +--- a/toys/lsb/hostname.c ++++ b/toys/lsb/hostname.c +@@ -4,23 +4,61 @@ + * + * http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/hostname.html + +-USE_HOSTNAME(NEWTOY(hostname, NULL, TOYFLAG_BIN)) ++USE_HOSTNAME(NEWTOY(hostname, "bF:", TOYFLAG_BIN)) + + config HOSTNAME + bool "hostname" + default y + help +- usage: hostname [newname] ++ usage: hostname [-b] [-F FILENAME] [newname] + + Get/Set the current hostname ++ ++ -b Set hostname to 'localhost' if otherwise unset ++ -F Set hostname to contents of FILENAME + */ + + #define FOR_hostname + #include "toys.h" + ++GLOBALS( ++ char *fname; ++) ++ + void hostname_main(void) + { + const char *hostname = toys.optargs[0]; ++ ++ if (toys.optflags & FLAG_F) { ++ char *buf; ++ if ((hostname = buf = readfile(TT.fname, 0, 0))) { ++ size_t len = strlen(hostname); ++ char *end = buf + len - 1; ++ ++ /* Trim trailing whitespace. */ ++ while (len && isspace(*end)) { ++ *end-- = '\0'; ++ len--; ++ } ++ if (!len) { ++ free(buf); ++ hostname = NULL; ++ if (!(toys.optflags & FLAG_b)) ++ error_exit("empty file '%s'", TT.fname); ++ } ++ } else if (!(toys.optflags & FLAG_b)) ++ error_exit("failed to read '%s'", TT.fname); ++ } ++ ++ if (!hostname && toys.optflags & FLAG_b) { ++ /* Do nothing if hostname already set. */ ++ if (gethostname(toybuf, sizeof(toybuf))) perror_exit("get failed"); ++ if (strnlen(toybuf, sizeof(toybuf))) exit(0); ++ ++ /* Else set hostname to localhost. */ ++ hostname = "localhost"; ++ } ++ + if (hostname) { + if (sethostname(hostname, strlen(hostname))) + perror_exit("set failed '%s'", hostname); +-- +2.1.4 + diff --git a/meta-oe/recipes-core/toybox/toybox_0.6.0.bb b/meta-oe/recipes-core/toybox/toybox_0.6.0.bb deleted file mode 100644 index da03200b2d..0000000000 --- a/meta-oe/recipes-core/toybox/toybox_0.6.0.bb +++ /dev/null @@ -1,65 +0,0 @@ -SUMMARY = "Toybox combines common utilities together into a single executable." -HOMEPAGE = "http://www.landley.net/toybox/" - -SRC_URI = "http://www.landley.net/toybox/downloads/${BPN}-${PV}.tar.gz" - -SRC_URI[md5sum] = "7f4a6c89e56c48e3350e611f5b36c2cf" -SRC_URI[sha256sum] = "b6e2694d19ac08f1c3416d5b2a02a31d445db2ed98dec89761430cdff2c9710d" - - -LICENSE = "BSD-0-Clause" -LIC_FILES_CHKSUM = "file://LICENSE;md5=f0b8b3dd6431bcaa245da0a08bd0d511" - -SECTION = "base" - -do_configure() { - oe_runmake defconfig - - # Disable killall5 as it isn't managed by update-alternatives - sed -e 's/CONFIG_KILLALL5=y/# CONFIG_KILLALL5 is not set/' -i .config -} - -do_compile() { - oe_runmake toybox_unstripped - - # Create a list of links needed - oe_runmake generated/instlist - ./generated/instlist long | sed -e 's#^#/#' > toybox.links -} - -do_install() { - # Install manually instead of using 'make install' - install -d ${D}${base_bindir} - if grep -q "CONFIG_TOYBOX_SUID=y" ${B}/.config; then - install -m 4755 ${B}/toybox_unstripped ${D}${base_bindir}/toybox - else - install -m 0755 ${B}/toybox_unstripped ${D}${base_bindir}/toybox - fi - - install -d ${D}${sysconfdir} - install -m 0644 ${B}/toybox.links ${D}${sysconfdir} -} - -inherit update-alternatives - -# If you've chosen to install toybox you probably want it to take precedence -# over busybox where possible but not over other packages -ALTERNATIVE_PRIORITY = "60" - -python do_package_prepend () { - # Read links from /etc/toybox.links and create appropriate - # update-alternatives variables - - dvar = d.getVar('D', True) - pn = d.getVar('PN', True) - target = "/bin/toybox" - - f = open('%s/etc/toybox.links' % (dvar), 'r') - for alt_link_name in f: - alt_link_name = alt_link_name.strip() - alt_name = os.path.basename(alt_link_name) - d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name) - d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name) - d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target) - f.close() -} diff --git a/meta-oe/recipes-core/toybox/toybox_0.7.0.bb b/meta-oe/recipes-core/toybox/toybox_0.7.0.bb new file mode 100644 index 0000000000..d7b469a899 --- /dev/null +++ b/meta-oe/recipes-core/toybox/toybox_0.7.0.bb @@ -0,0 +1,69 @@ +SUMMARY = "Toybox combines common utilities together into a single executable." +HOMEPAGE = "http://www.landley.net/toybox/" +DEPENDS = "attr" + +SRC_URI = " \ + http://www.landley.net/toybox/downloads/${BPN}-${PV}.tar.gz \ + file://0001-Fix-segfault-in-login.patch \ + file://0002-Add-b-and-F-arguments-to-hostname.patch \ +" + +SRC_URI[md5sum] = "d86c78624b47625c2f0fc64eda599443" +SRC_URI[sha256sum] = "65428816f88ad3fe92b67df86dc05427c8078fe03843b8b9715fdfa6d29c0f97" + +LICENSE = "BSD-0-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=f0b8b3dd6431bcaa245da0a08bd0d511" + +SECTION = "base" + +do_configure() { + oe_runmake defconfig + + # Disable killall5 as it isn't managed by update-alternatives + sed -e 's/CONFIG_KILLALL5=y/# CONFIG_KILLALL5 is not set/' -i .config +} + +do_compile() { + oe_runmake toybox_unstripped + + # Create a list of links needed + oe_runmake generated/instlist + ./generated/instlist long | sed -e 's#^#/#' > toybox.links +} + +do_install() { + # Install manually instead of using 'make install' + install -d ${D}${base_bindir} + if grep -q "CONFIG_TOYBOX_SUID=y" ${B}/.config; then + install -m 4755 ${B}/toybox_unstripped ${D}${base_bindir}/toybox + else + install -m 0755 ${B}/toybox_unstripped ${D}${base_bindir}/toybox + fi + + install -d ${D}${sysconfdir} + install -m 0644 ${B}/toybox.links ${D}${sysconfdir} +} + +inherit update-alternatives + +# If you've chosen to install toybox you probably want it to take precedence +# over busybox where possible but not over other packages +ALTERNATIVE_PRIORITY = "60" + +python do_package_prepend () { + # Read links from /etc/toybox.links and create appropriate + # update-alternatives variables + + dvar = d.getVar('D', True) + pn = d.getVar('PN', True) + target = "/bin/toybox" + + f = open('%s/etc/toybox.links' % (dvar), 'r') + for alt_link_name in f: + alt_link_name = alt_link_name.strip() + alt_name = os.path.basename(alt_link_name) + d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name) + d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name) + d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target) + f.close() +} -- cgit v1.2.3-54-g00ecf