[yocto] [meta-security][python3-scapy] scapy script is broken

Scott Ellis scott at jumpnowtek.com
Sun Jan 13 07:57:45 PST 2019


The shebang line in /usr/bin/scapy and /usr/bin/UTscapy is always set
for python not python3 and so doesn't work with the python3 scapy install.

This problem existed in the 2.4.0 version as well.

I am currently using this patch in my local repo to fix python3-scapy
builds.

diff --git a/recipes-security/scapy/python-scapy.inc
b/recipes-security/scapy/python-scapy.inc
index d5a70fe..97036e0 100644
--- a/recipes-security/scapy/python-scapy.inc
+++ b/recipes-security/scapy/python-scapy.inc
@@ -15,6 +15,20 @@ do_install_ptest() {
     sed -i 's, at PTEST_PATH@,${PTEST_PATH},' ${D}${PTEST_PATH}/run-ptest
 }

+do_install_append() {
+    if [ "${PYTHON_BASEVERSION}" != "2.7" ]; then
+        bbwarn "Fixing shebang line for scapy and UTscapy"
+
+        if [ -e ${D}${bindir}/scapy ]; then
+           sed -i -e 's/python/python3/' ${D}${bindir}/scapy
+        fi
+
+        if [ -e ${D}${bindir}/UTscapy ]; then
+           sed -i -e 's/python/python3/' ${D}${bindir}/UTscapy
+        fi
+    fi
+}
+
...

scapy is just a small wrapper script to launch an interactive scrapy
session.

Adding the do_install_append() to the python3-scapy.bb doesn't work
(never gets called) so I had to add the PYTHON_BASEVERSION check and put
it in the *.inc

Open to suggestions on a better fix.






More information about the yocto mailing list