The .real command was not given the same permissions and ownership as
the original pre-wrap file and this is now fixed.

A situation where the original pre-wrap file did not have write
permissions would cause a failure in the wrapping is also fixed.

Test update also included.

Signed-off-by: Paulo Neves <ptsne...@gmail.com>
---
 .../wrapper/cmdline-shebang-wrapper-test.bb           | 11 ++++++++++-
 meta/classes/utils.bbclass                            |  3 +++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/meta-selftest/recipes-test/wrapper/cmdline-shebang-wrapper-test.bb 
b/meta-selftest/recipes-test/wrapper/cmdline-shebang-wrapper-test.bb
index c4126a41fc..c3d3548d4a 100644
--- a/meta-selftest/recipes-test/wrapper/cmdline-shebang-wrapper-test.bb
+++ b/meta-selftest/recipes-test/wrapper/cmdline-shebang-wrapper-test.bb
@@ -8,7 +8,10 @@ SRC_URI += "file://test.awk"
 EXCLUDE_FROM_WORLD = "1"
 do_install() {
     install -d ${D}${bindir}
-    install -m 0755 ${WORKDIR}/test.awk ${D}${bindir}/test
+    # was not able to make ownership preservation check
+    install -m 0400 ${WORKDIR}/test.awk ${D}${bindir}/test
+
+    perm_old="$(stat --format='%a' ${D}${bindir}/test)"
     sed -i -e 's|@AWK_BIN@|${bindir}/awk|g' ${D}${bindir}/test
     create_cmdline_shebang_wrapper ${D}${bindir}/test
     if [ $(${D}${bindir}/test) != "Don't Panic!" ]; then
@@ -16,6 +19,12 @@ do_install() {
     else
         bbnote "Wrapper is good"
     fi
+
+    perm_new="$(stat --format='%a' ${D}${bindir}/test.real)"
+
+    if [ "$perm_new" != "$perm_old" ]; then
+        bbfatal "Wrapper permissions for ${D}${bindir}/test.real not 
preserved. Found $perm_new but expected $perm_old"
+    fi
 }
 
 BBCLASSEXTEND = "native"
diff --git a/meta/classes/utils.bbclass b/meta/classes/utils.bbclass
index b58c22771f..e6f7f95d80 100644
--- a/meta/classes/utils.bbclass
+++ b/meta/classes/utils.bbclass
@@ -202,6 +202,9 @@ create_cmdline_shebang_wrapper () {
        argument="$(sed -ne 's/^#! *//p;q' $cmd)"
        # strip the shebang from the real script as we do not want it to be 
usable anyway
        tail -n +2 $cmd > $cmd.real
+       chown --reference=$cmd $cmd.real
+       chmod --reference=$cmd $cmd.real
+       rm -f $cmd
        cmdname=$(basename $cmd)
        dirname=$(dirname $cmd)
        cmdoptions=$@
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#167555): 
https://lists.openembedded.org/g/openembedded-core/message/167555
Mute This Topic: https://lists.openembedded.org/mt/92145213/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to