Skip to contentSkip to conversation

sstate: fix touching files inside pseudo

PATCH In review Jose Quaresma 3 participants 4 messages Oct 20, 2021 – Oct 26, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---

v2: redirect stderr to /dev/null to avoid messages in the log

 meta/classes/sstate.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/sstate.bbclass +2 -2
index 3c179259e7..146f56ea2d 100644
@@ -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} 2>/dev/null || true
 		return
 	fi
 
@@ -865,7 +865,7 @@ sstate_create_package () {
 	else
 		rm $TFILE
 	fi
-	[ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG}
+	touch ${SSTATE_PKG} 2>/dev/null || true
 }
 
 python sstate_sign_package () {
Signature · 1 line
2.33.1
#1 lore raw
Quoted 55 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Jose Quaresma
Sent: den 20 oktober 2021 19:26
To: [email protected]
Cc: Jose Quaresma <[email protected]>
Subject: [OE-core] [PATCH v2] 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.

---

v2: redirect stderr to /dev/null to avoid messages in the log

 meta/classes/sstate.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/sstate.bbclass +2 -3
index 3c179259e7..146f56ea2d 100644
@@ -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} 2>/dev/null || true
 		return
 	fi
 
@@ -865,7 +865,7 @@ sstate_create_package () {
 	else
 		rm $TFILE
 	fi
-	[ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG}
+	touch ${SSTATE_PKG} 2>/dev/null || true
 }
 
 python sstate_sign_package () {
--
Quoted 1 line

2.33.1

Can this please be backported to Hardknott and Honister now that it has been accepted for master?

//Peter

#2 lore raw

I have found this bug on the dunfell branch, can it be backported to dunfell too?

Jose

Peter Kjellerstedt <[email protected]> escreveu no dia segunda, 25/10/2021 à(s) 15:28:

Quoted 63 lines
Quoted 55 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Jose Quaresma
Sent: den 20 oktober 2021 19:26
To: [email protected]
Cc: Jose Quaresma <[email protected]>
Subject: [OE-core] [PATCH v2] 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.

---

v2: redirect stderr to /dev/null to avoid messages in the log

 meta/classes/sstate.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/sstate.bbclass +2 -3
index 3c179259e7..146f56ea2d 100644
@@ -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} 2>/dev/null || true
              return
      fi
 
@@ -865,7 +865,7 @@ sstate_create_package () {
      else
              rm $TFILE
      fi
-     [ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG}
+     touch ${SSTATE_PKG} 2>/dev/null || true
 }
 
 python sstate_sign_package () {
--
Quoted 1 line

2.33.1

Can this please be backported to Hardknott and Honister now that it has been accepted for master?

//Peter

Signature · 3 lines
Best regards,

José Quaresma
#3 lore raw
Quoted 2 lines · Jose Quaresma

I have found this bug on the dunfell branch, can it be backported to dunfell too?

I'll add it to my testing queue.

Steve

Quoted 82 lines

Jose

Peter Kjellerstedt <[email protected]> escreveu no dia segunda, 25/10/2021 à(s) 15:28:

Quoted 54 lines
Quoted 54 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Jose Quaresma
Sent: den 20 oktober 2021 19:26
To: [email protected]
Cc: Jose Quaresma <[email protected]>
Subject: [OE-core] [PATCH v2] 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.

---

v2: redirect stderr to /dev/null to avoid messages in the log

 meta/classes/sstate.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/sstate.bbclass +2 -2
index 3c179259e7..146f56ea2d 100644
@@ -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} 2>/dev/null || true
              return
      fi
 
@@ -865,7 +865,7 @@ sstate_create_package () {
      else
              rm $TFILE
      fi
-     [ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG}
+     touch ${SSTATE_PKG} 2>/dev/null || true
 }
 
Quoted 9 lines
Quoted 3 lines
meta/classes/sstate.bbclass +0 -1
 python sstate_sign_package () {
--

2.33.1

Can this please be backported to Hardknott and Honister now that it has been accepted for master?

//Peter

--
Best regards,

José Quaresma

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#157377): https://lists.openembedded.org/g/openembedded-core/message/157377
Mute This Topic: https://lists.openembedded.org/mt/86470820/3617601
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-