]> code.ossystems Code Review - openembedded-core.git/commitdiff
sstate: another fix for touching files inside pseudo
authorJose Quaresma <quaresma.jose@gmail.com>
Thu, 4 Nov 2021 19:12:23 +0000 (19:12 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 5 Nov 2021 11:40:56 +0000 (11:40 +0000)
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.

Signed-off-by: Jose Quaresma <quaresma.jose@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/sstate.bbclass

index 8182010047b44f931a6cba0220ec4919d67849bc..849723d4dc42d86b6f9cad2c6d074f2002ac2586 100644 (file)
@@ -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"