Skip to contentSkip to conversation

sstate: another fix for touching files inside pseudo

PATCH Jose Quaresma 2 participants 3 messages Nov 6, 2021 – Nov 7, 2021 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi Steve,

Can this patch be backported to dunfell branch to land in the next release 3.1.12?

Jose

Jose Quaresma via lists.openembedded.org <quaresma.jose= [email protected]> escreveu no dia quinta, 4/11/2021 à(s) 19:14:

Quoted 73 lines

This patch is a fixup for 676757f "sstate: fix touching files inside pseudo"

running the 'id' command inside the sstate_unpack_package function shows that this funcion run inside the pseudo:

uid=0(root) gid=0(root) groups=0(root)

The check for [ -w ${SSTATE_PKG} ] and [ -O ${SSTATE_PKG}.siginfo ] 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).
- the file test operator "-O" check if you are owner of file

We can avoid this test running the touch and mask any return errors that we have.

---

V2: match the original code

 meta/classes/sstate.bbclass | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
meta/classes/sstate.bbclass +0 -8
index 8182010047..849723d4dc 100644
@@ -900,12 +900,12 @@ sstate_unpack_package () {
        fi
 
        tar -I "$ZSTD" -xvf ${SSTATE_PKG}
-       # update .siginfo atime on local/NFS mirror
-       [ -O ${SSTATE_PKG}.siginfo ] && [ -w ${SSTATE_PKG}.siginfo ] && [
-h ${SSTATE_PKG}.siginfo ] && touch -a ${SSTATE_PKG}.siginfo
-       # Use "! -w ||" to return true for read only files
-       [ ! -w ${SSTATE_PKG} ] || touch --no-dereference ${SSTATE_PKG}
-       [ ! -w ${SSTATE_PKG}.sig ] || [ ! -e ${SSTATE_PKG}.sig ] || touch
--no-dereference ${SSTATE_PKG}.sig
-       [ ! -w ${SSTATE_PKG}.siginfo ] || [ ! -e ${SSTATE_PKG}.siginfo ]
|| touch --no-dereference ${SSTATE_PKG}.siginfo
+       # update .siginfo atime on local/NFS mirror if it is a symbolic

link
+ [ ! -h ${SSTATE_PKG}.siginfo ] || touch -a ${SSTATE_PKG}.siginfo
2>/dev/null || true

meta/classes/sstate.bbclass +3 -0
+       # update each symbolic link instead of any referenced file
+       touch --no-dereference ${SSTATE_PKG} 2>/dev/null || true
+       [ ! -e ${SSTATE_PKG}.sig ] || touch --no-dereference

${SSTATE_PKG}.sig 2>/dev/null || true
+ [ ! -e ${SSTATE_PKG}.siginfo ] || touch --no-dereference
${SSTATE_PKG}.siginfo 2>/dev/null || true
}

BB_HASHCHECK_FUNCTION = "sstate_checkhashes"
--
2.33.1

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

Signature · 3 lines
Best regards,

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

Hi Steve,

Can this patch be backported to dunfell branch to land in the next release 3.1.12?

This patch won't apply due to the zstd related changes in master. Could you submit a dunfell version of the patch?

Steve

Quoted 76 lines

Jose

Jose Quaresma via lists.openembedded.org <[email protected]> escreveu no dia quinta, 4/11/2021 à(s) 19:14:

Quoted 52 lines

This patch is a fixup for 676757f "sstate: fix touching files inside pseudo"

running the 'id' command inside the sstate_unpack_package function shows that this funcion run inside the pseudo:

uid=0(root) gid=0(root) groups=0(root)

The check for [ -w ${SSTATE_PKG} ] and [ -O ${SSTATE_PKG}.siginfo ] 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).
- the file test operator "-O" check if you are owner of file

We can avoid this test running the touch and mask any return errors that we have.

---

V2: match the original code

 meta/classes/sstate.bbclass | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
meta/classes/sstate.bbclass +6 -7
index 8182010047..849723d4dc 100644
@@ -900,12 +900,12 @@ sstate_unpack_package () {
        fi
 
        tar -I "$ZSTD" -xvf ${SSTATE_PKG}
-       # update .siginfo atime on local/NFS mirror
-       [ -O ${SSTATE_PKG}.siginfo ] && [ -w ${SSTATE_PKG}.siginfo ] && [ -h ${SSTATE_PKG}.siginfo ] && touch -a ${SSTATE_PKG}.siginfo
-       # Use "! -w ||" to return true for read only files
-       [ ! -w ${SSTATE_PKG} ] || touch --no-dereference ${SSTATE_PKG}
-       [ ! -w ${SSTATE_PKG}.sig ] || [ ! -e ${SSTATE_PKG}.sig ] || touch --no-dereference ${SSTATE_PKG}.sig
-       [ ! -w ${SSTATE_PKG}.siginfo ] || [ ! -e ${SSTATE_PKG}.siginfo ] || touch --no-dereference ${SSTATE_PKG}.siginfo
+       # update .siginfo atime on local/NFS mirror if it is a symbolic link
+       [ ! -h ${SSTATE_PKG}.siginfo ] || touch -a ${SSTATE_PKG}.siginfo 2>/dev/null || true
+       # update each symbolic link instead of any referenced file
+       touch --no-dereference ${SSTATE_PKG} 2>/dev/null || true
+       [ ! -e ${SSTATE_PKG}.sig ] || touch --no-dereference ${SSTATE_PKG}.sig 2>/dev/null || true
+       [ ! -e ${SSTATE_PKG}.siginfo ] || touch --no-dereference ${SSTATE_PKG}.siginfo 2>/dev/null || true
 }
 
 BB_HASHCHECK_FUNCTION = "sstate_checkhashes"
--
Quoted 5 lines

2.33.1

--
Best regards,

José Quaresma

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

#3 lore raw

Steve Sakoman <[email protected]> escreveu no dia sábado, 6/11/2021 à(s) 21:18:

Quoted 11 lines
Quoted 4 lines · Jose Quaresma

Hi Steve,

Can this patch be backported to dunfell branch to land in the next

release 3.1.12?

This patch won't apply due to the zstd related changes in master. Could you submit a dunfell version of the patch?

Sure, I have send it for dunfell

Jose

Quoted 92 lines

Steve

Quoted 4 lines

Jose

Jose Quaresma via lists.openembedded.org <quaresma.jose=

[email protected]> escreveu no dia quinta, 4/11/2021 à(s) 19:14:

Quoted 2 lines
Quoted 2 lines

This patch is a fixup for 676757f "sstate: fix touching files inside

pseudo"

Quoted 33 lines
Quoted 33 lines

running the 'id' command inside the sstate_unpack_package function shows that this funcion run inside the pseudo:

uid=0(root) gid=0(root) groups=0(root)

The check for [ -w ${SSTATE_PKG} ] and [ -O ${SSTATE_PKG}.siginfo ] 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).
- the file test operator "-O" check if you are owner of file

We can avoid this test running the touch and mask any return errors that we have.

---

V2: match the original code

 meta/classes/sstate.bbclass | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
meta/classes/sstate.bbclass +0 -0
index 8182010047..849723d4dc 100644
@@ -900,12 +900,12 @@ sstate_unpack_package () {
        fi
 
Quoted 3 lines

meta/classes/sstate.bbclass sstate_unpack_package () { · line 904

Quoted 3 lines
meta/classes/sstate.bbclass +0 -2
        tar -I "$ZSTD" -xvf ${SSTATE_PKG}
-       # update .siginfo atime on local/NFS mirror
-       [ -O ${SSTATE_PKG}.siginfo ] && [ -w ${SSTATE_PKG}.siginfo ] &&

[ -h ${SSTATE_PKG}.siginfo ] && touch -a ${SSTATE_PKG}.siginfo

Quoted 3 lines

meta/classes/sstate.bbclass sstate_unpack_package () { · line 907

Quoted 3 lines
meta/classes/sstate.bbclass +0 -3
-       # Use "! -w ||" to return true for read only files
-       [ ! -w ${SSTATE_PKG} ] || touch --no-dereference ${SSTATE_PKG}
-       [ ! -w ${SSTATE_PKG}.sig ] || [ ! -e ${SSTATE_PKG}.sig ] ||

touch --no-dereference ${SSTATE_PKG}.sig

Quoted 1 line

meta/classes/sstate.bbclass sstate_unpack_package () { · line 908

Quoted 1 line
meta/classes/sstate.bbclass +0 -1
-       [ ! -w ${SSTATE_PKG}.siginfo ] || [ ! -e ${SSTATE_PKG}.siginfo

] || touch --no-dereference ${SSTATE_PKG}.siginfo

Quoted 1 line

meta/classes/sstate.bbclass sstate_unpack_package () { · line 903

Quoted 1 line
meta/classes/sstate.bbclass +1 -0
+       # update .siginfo atime on local/NFS mirror if it is a symbolic

link

Quoted 1 line

meta/classes/sstate.bbclass sstate_unpack_package () { · line 904

Quoted 1 line
meta/classes/sstate.bbclass +1 -0
+       [ ! -h ${SSTATE_PKG}.siginfo ] || touch -a

${SSTATE_PKG}.siginfo 2>/dev/null || true

Quoted 3 lines

meta/classes/sstate.bbclass sstate_unpack_package () { · line 907

Quoted 3 lines
meta/classes/sstate.bbclass +3 -0
+       # update each symbolic link instead of any referenced file
+       touch --no-dereference ${SSTATE_PKG} 2>/dev/null || true
+       [ ! -e ${SSTATE_PKG}.sig ] || touch --no-dereference

${SSTATE_PKG}.sig 2>/dev/null || true

Quoted 1 line

meta/classes/sstate.bbclass sstate_unpack_package () { · line 908

Quoted 1 line
meta/classes/sstate.bbclass +1 -0
+       [ ! -e ${SSTATE_PKG}.siginfo ] || touch --no-dereference

${SSTATE_PKG}.siginfo 2>/dev/null || true

Quoted 11 lines
Quoted 9 lines
meta/classes/sstate.bbclass +0 -1
 }
 
 BB_HASHCHECK_FUNCTION = "sstate_checkhashes"
--

2.33.1

Quoted 8 lines

--
Best regards,

José Quaresma

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#157943):

https://lists.openembedded.org/g/openembedded-core/message/157943

Quoted 3 lines

Mute This Topic: https://lists.openembedded.org/mt/86824160/3617601
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [

[email protected]]

Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
Best regards,

José Quaresma