Bug 14385

Summary: mode of sstate files created under pseudo
Product: [Yocto Project Subprojects] Pseudo Reporter: Frans Meulenbroeks <fransmeulenbroeks>
Component: poky integrationAssignee: Eilís Ní Fhlannagáin <pidge>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: ernstp, mhalstead, pidge, randy.macleod, richard.purdie, ross.burton, yp.pseudo.watcher, yp.watcher
Version: unspecified   
Target Milestone: 5.0 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Frans Meulenbroeks 2021-05-07 11:46:10 UTC
I am using bitbake to build a yocto image with sstate.
Files created in sstate-cache are created when running under pseudo. sstate.bbclass creates these files with mode 775 (dirs) or 664 (files) so they are group readable/writable.
After creation of the files I see that the files have the right mode and are owned by root.
However when I look at the files as they are on disk after running bitbake they are owned by the user starting bitbake, and have modes 755 and 644.

My expectation was that the UID of the files would indeed be the user that starts bitbake but that the mode would be the same as the mode when the file was written.

I could not find any info on this in the docs (but maybe I overlooked) but the behavior is not as I expected.

Maybe this is intended, if so it should probably be documented (and maybe there should be an option --retain-file-modes or something like that to make that the mode is not changed). If not intended a fix would be nice.
Comment 1 Randy MacLeod 2021-05-13 14:40:26 UTC
The use case as discussed on IRC is two people to be able to share the same sstate cache. The assumption is that different parts of the code are not using the same properties.
Comment 2 Mark Hatle 2021-08-03 18:42:03 UTC
I just saw this one.  What are the umask of the user creating the files?

It's not unusual for a umask of 755 to exist.

What will end up happening is pseudo will know it's not allowed to create the files as 775/664.  But because you are running within pseudo context (in order to copy in the files from the work dir) the system will create the files and try for 775/664, but fall back to the umask if necessary.
Comment 3 Frans Meulenbroeks 2021-08-05 06:43:42 UTC
Initially I also suspected umask so I changed the umask to 0000.
However that did not resolve the issue. 

After doing that some of the dirs end up with mode 755 others with 775.
E.g. from a recent build I get:

4 drwxr-xr-x 2 frans   docker  4096 Aug  5 05:53 ./90/3d
4 drwxrwxr-x 2 frans   docker  4096 Aug  5 05:49 ./91/65

No idea why one dir is 755 and the other is 755.

(Actually all our builds run in a docker container that has umask 0000, I have outruled that this is actually a docker issue; if I create a dir under docker then outside the docker the dir has mode 777)

As mentioned in the original comment this seems related to pseudo
Comment 4 Ross Burton 2023-06-13 16:01:53 UTC
I just trawled through my huge sstate and I think I can see files with mysteriously missing group writable bits that were created in the last year.
Comment 5 Richard Purdie 2023-06-15 14:16:48 UTC
(In reply to Ross Burton from comment #4)
> I just trawled through my huge sstate and I think I can see files with
> mysteriously missing group writable bits that were created in the last year.

Any pattern to them?
Comment 6 Ross Burton 2023-06-19 18:43:51 UTC
I _think_ this is resolved in mickledore onwards.  At least I just did a fresh huge build and none of the permissions were unexpected.
Comment 7 Eilís Ní Fhlannagáin 2023-09-05 13:26:20 UTC
I've been looking for this on current master and haven't seen this yet, so I think this is in fact fixed.
Comment 8 Eilís Ní Fhlannagáin 2023-10-10 10:39:00 UTC
I'm marking this worksforme as I've yet to see this issue and concur with Ross that this has been fixed.
Comment 9 Randy MacLeod 2023-11-02 15:18:46 UTC
We think there's still a bug as reported on IRC.
It may be an issue related to different umask, sstate-tasks and pseudo.
Comment 10 Eilís Ní Fhlannagáin 2023-11-14 10:28:31 UTC
I've tried again to replicate this, using different users with different umasks, still with no luck. I'm going to try again with a clean sstate (starting with umask of 0022 and then moving to 0002) later this week, to see if I can replicate this.
Comment 11 Richard Purdie 2023-12-07 14:44:37 UTC
egueli in http://irc.yoctoproject.org/irc/%23yocto.2023-10-30.log.html reported this as happening with mickledore. I'm not aware of fixes since then.
Comment 12 Richard Purdie 2023-12-15 13:59:02 UTC
https://git.yoctoproject.org/poky/commit/?id=47cc6288280bd38f42851d6423a5ffc95a46eea4 should help

Still pending testcase?
Comment 13 Frans Meulenbroeks 2023-12-16 11:38:07 UTC
@RP this looks like a good solution.
At the moment I (as bug reporter) have no possibility to verify this, but it should be pretty straightforward to create a test case for this.
Comment 14 Randy MacLeod 2024-01-18 16:24:57 UTC
Still missing a test case.