-SUMMARY = "Check that shebang does not exceed 128 characters"
+SUMMARY = "Check that shebang does not exceed 256 characters"
LICENSE = "CLOSED"
INHIBIT_DEFAULT_DEPS = "1"
EXCLUDE_FROM_WORLD = "1"
do_install() {
install -d ${D}${bindir}
- echo '#!BiM3cnVd1Amtv6PG+FynrQiVMbZnX5ELgF21q3EkuB+44JEGWtq8TvBJ7EGidfVs3eR3wVOUbLnjYDlKUWcm7YC/ute7f+KDHbwxziRUSUBZAUqgjiQdfQ0HnxajI0ozbM863E9JV9k13yZKYfh9/zR77Y6Dl4Dd3zOWS75LSpkAXV' > ${D}${bindir}/max-shebang
+ echo '#!4Shfcy9Ej8gPKDGNkyhmtxrwPinmpZQ1pCS3snbdqlNx7YfmTpHkeJakCMaDnQXx4c4TmtyJpGBn5F7IO1FShYG9EwtALDOsRKEDOJKRj2L7hW92wZTzlqx4mMqREqNa7Hrwql4DYVv8vmEMhIwvtHO3UaVpgvLY9Y3HhfopUVUMZJi5Xs9KKkRisrM0HBePG67tbeWL9ZstNuPKH1ikyeNB7PprwLrsjZ6EngCrhFTfYzRSuXhdrQQBBsLZBRDsy5QE' > ${D}${bindir}/max-shebang
chmod 755 ${D}${bindir}/max-shebang
}
def package_qa_check_shebang_size(path, name, d, elf):
global cpath
+ # From kernel 5.1 onwards (specifically linux 6eb3c3d0a52dc ("exec: increase
+ # BINPRM_BUF_SIZE to 256")) the shebang buffer was increased from 128 bytes
+ # to 256 bytes.
+ BINPRM_BUF_SIZE = 256
+
if elf or cpath.islink(path) or not cpath.isfile(path):
return
try:
with open(path, 'rb') as f:
- stanza = f.readline(130)
+ stanza = f.readline(BINPRM_BUF_SIZE * 2)
+ if stanza.startswith(b'#!') and len(stanza) > BINPRM_BUF_SIZE:
+ oe.qa.handle_error("shebang-size", "%s: %s maximum shebang size exceeded, the maximum size is %d" % (name, package_qa_clean_path(path, d, name), BINPRM_BUF_SIZE), d)
+ return
except IOError:
- return
-
- if stanza.startswith(b'#!'):
- try:
- stanza.decode("utf-8")
- except UnicodeDecodeError:
- #If it is not a text file, it is not a script
- return
-
- if len(stanza) > 129:
- oe.qa.handle_error("shebang-size", "%s: %s maximum shebang size exceeded, the maximum size is 128." % (name, package_qa_clean_path(path, d, name)), d)
- return
+ pass
QAPATHTEST[libexec] = "package_qa_check_libexec"
def package_qa_check_libexec(path,name, d, elf):
Expected: Fail when a shebang bigger than the max shebang-size is reached.
Author: Paulo Neves <ptsneves@gmail.com>
"""
- expected = "maximum shebang size exceeded, the maximum size is 128. [shebang-size]"
res = bitbake("sysroot-shebang-test-native -c populate_sysroot", ignore_status=True)
- self.assertTrue(expected in res.output, msg=res.output)
+ self.assertTrue("[shebang-size]" in res.output, msg=res.output)
self.assertTrue(res.status != 0)
def test_sysroot_la(self):