sstate: fix touching files inside pseudo
PATCH 1/1 sstate: fix touching files inside pseudo
running the 'id' command inside the sstate_create_package function shows that this funcion run inside the pseudo:
uid=0(root) gid=0(root) groups=0(root)
The check for touch files [ ! -w ${SSTATE_PKG} ] will always return true and the touch can fail when the real user don't have permission or
in readonly filesystem.
As the documentation refers, the file test operator "-w" check if the file has write permission (for the user running the test).
We can avoid this test running the touch and mask any return errors that we have.
--- meta/classes/sstate.bbclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/sstate.bbclass +2 -2
@@ -830,7 +830,7 @@ sstate_task_postfunc[dirs] = "${WORKDIR}" sstate_create_package () { # Exit early if it already exists if [ -e ${SSTATE_PKG} ]; then - [ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG} + touch ${SSTATE_PKG} || true return fi
@@ -865,7 +865,7 @@ sstate_create_package () { else rm $TFILE fi - [ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG} + touch ${SSTATE_PKG} || true } python sstate_sign_package () {
Signature · 1 line
2.33.1
Quoted 34 lines
-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Jose Quaresma
Sent: den 18 oktober 2021 20:47
To: [email protected]
Cc: Jose Quaresma <[email protected]>
Subject: [OE-core] [PATCH] sstate: fix touching files inside pseudorunning the 'id' command inside the
sstate_create_packagefunction shows that this funcion run inside the pseudo:uid=0(root) gid=0(root) groups=0(root)
The check for touch files [ ! -w ${SSTATE_PKG} ] will always return true and the touch can fail when the real user don't have permission or
in readonly filesystem.As the documentation refers, the file test operator "-w" check if the file has write permission (for the user running the test).
We can avoid this test running the touch and mask any return errors that we have.
Signed-off-by Jose Quaresma <[email protected]>--- meta/classes/sstate.bbclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)meta/classes/sstate.bbclass +0
-0
meta/classes/sstate.bbclass sstate_task_postfunc[dirs] = "${WORKDIR}" · line 833
Quoted 5 lines
meta/classes/sstate.bbclass +1
-1@@ -830,7 +830,7 @@ sstate_task_postfunc[dirs] = "${WORKDIR}" sstate_create_package () { # Exit early if it already exists if [ -e ${SSTATE_PKG} ]; then - [ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG} + touch ${SSTATE_PKG} || true
You should pass stderr to /dev/null to avoid messages in the log if/when touch fails, i.e.:
touch ${SSTATE_PKG} 2>/dev/null || :Quoted 13 lines
meta/classes/sstate.bbclass +1
-2return fi@@ -865,7 +865,7 @@ sstate_create_package () { else rm $TFILE fi - [ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG} + touch ${SSTATE_PKG} || true } python sstate_sign_package () { --
Quoted 1 line
2.33.1
//Peter
Peter Kjellerstedt <[email protected]> escreveu no dia terça, 19/10/2021 à(s) 20:37:
Quoted 43 lines
Quoted 34 lines
-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Jose Quaresma
Sent: den 18 oktober 2021 20:47
To: [email protected]
Cc: Jose Quaresma <[email protected]>
Subject: [OE-core] [PATCH] sstate: fix touching files inside pseudorunning the 'id' command inside the
sstate_create_packagefunction shows that this funcion run inside the pseudo:uid=0(root) gid=0(root) groups=0(root)
The check for touch files [ ! -w ${SSTATE_PKG} ] will always return true and the touch can fail when the real user don't have permission or
in readonly filesystem.As the documentation refers, the file test operator "-w" check if the file has write permission (for the user running the test).
We can avoid this test running the touch and mask any return errors that we have.
Signed-off-by Jose Quaresma <[email protected]>--- meta/classes/sstate.bbclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)meta/classes/sstate.bbclass +0
-0meta/classes/sstate.bbclass sstate_task_postfunc[dirs] = "${WORKDIR}" · line 833
Quoted 5 lines
meta/classes/sstate.bbclass +1
-1@@ -830,7 +830,7 @@ sstate_task_postfunc[dirs] = "${WORKDIR}" sstate_create_package () { # Exit early if it already exists if [ -e ${SSTATE_PKG} ]; then - [ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG} + touch ${SSTATE_PKG} || trueYou should pass stderr to
/dev/nullto avoid messages in the log if/when touch fails, i.e.:
Quoted 3 lines
touch ${SSTATE_PKG} 2>/dev/null || :I only see the logs when the task fails but I will add the redirection and send a V2.
Thanks for the review.
Quoted 18 lines
Quoted 13 lines
meta/classes/sstate.bbclass +1
-2return fi@@ -865,7 +865,7 @@ sstate_create_package () { else rm $TFILE fi - [ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG} + touch ${SSTATE_PKG} || true } python sstate_sign_package () { --Quoted 1 line
2.33.1
//Peter
Signature · 3 lines
Best regards, José Quaresma