summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Neves <ptsneves@gmail.com>2022-07-03 13:41:14 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-07-04 15:15:14 +0100
commitf0ee9008597b08704726c5c140836c2497002711 (patch)
tree9afaf4ecd1f563f831f15aaced0502f52fd1b001
parent0e84a9d697842fce615f2d6a9fbbae121955051c (diff)
downloadpoky-f0ee9008597b08704726c5c140836c2497002711.tar.gz
utils: create_cmdline_shebang_wrapper preserve permission and ownership
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. (From OE-Core rev: 47973fd4f3fbb0af1a0d1bc2c39f2900a963177d) Signed-off-by: Paulo Neves <ptsneves@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta-selftest/recipes-test/wrapper/cmdline-shebang-wrapper-test.bb11
-rw-r--r--meta/classes/utils.bbclass3
2 files changed, 13 insertions, 1 deletions
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"
8EXCLUDE_FROM_WORLD = "1" 8EXCLUDE_FROM_WORLD = "1"
9do_install() { 9do_install() {
10 install -d ${D}${bindir} 10 install -d ${D}${bindir}
11 install -m 0755 ${WORKDIR}/test.awk ${D}${bindir}/test 11 # was not able to make ownership preservation check
12 install -m 0400 ${WORKDIR}/test.awk ${D}${bindir}/test
13
14 perm_old="$(stat --format='%a' ${D}${bindir}/test)"
12 sed -i -e 's|@AWK_BIN@|${bindir}/awk|g' ${D}${bindir}/test 15 sed -i -e 's|@AWK_BIN@|${bindir}/awk|g' ${D}${bindir}/test
13 create_cmdline_shebang_wrapper ${D}${bindir}/test 16 create_cmdline_shebang_wrapper ${D}${bindir}/test
14 if [ $(${D}${bindir}/test) != "Don't Panic!" ]; then 17 if [ $(${D}${bindir}/test) != "Don't Panic!" ]; then
@@ -16,6 +19,12 @@ do_install() {
16 else 19 else
17 bbnote "Wrapper is good" 20 bbnote "Wrapper is good"
18 fi 21 fi
22
23 perm_new="$(stat --format='%a' ${D}${bindir}/test.real)"
24
25 if [ "$perm_new" != "$perm_old" ]; then
26 bbfatal "Wrapper permissions for ${D}${bindir}/test.real not preserved. Found $perm_new but expected $perm_old"
27 fi
19} 28}
20 29
21BBCLASSEXTEND = "native" 30BBCLASSEXTEND = "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 () {
202 argument="$(sed -ne 's/^#! *//p;q' $cmd)" 202 argument="$(sed -ne 's/^#! *//p;q' $cmd)"
203 # strip the shebang from the real script as we do not want it to be usable anyway 203 # strip the shebang from the real script as we do not want it to be usable anyway
204 tail -n +2 $cmd > $cmd.real 204 tail -n +2 $cmd > $cmd.real
205 chown --reference=$cmd $cmd.real
206 chmod --reference=$cmd $cmd.real
207 rm -f $cmd
205 cmdname=$(basename $cmd) 208 cmdname=$(basename $cmd)
206 dirname=$(dirname $cmd) 209 dirname=$(dirname $cmd)
207 cmdoptions=$@ 210 cmdoptions=$@