ccache / ccache

ccache – a fast compiler cache
https://ccache.dev
Other
2.27k stars 481 forks source link

CCACHE_UMASK not always taken into account with ccache 4.0 --> can't create temporary file: permission denied #710

Closed Romain-Geissler-1A closed 3 years ago

Romain-Geissler-1A commented 3 years ago

(this is a copy paste of what I wrote already in issue #703).

Hi,

FYI I recently tried to migrate my company builds to ccache 4.0 (we used 3.7.12 before) and indeed several different unrelated teams started to report me such errors.

I am right now not 100% sure this actually comes from ccache 4.0, but time wise, the problem started to happen when I switched it on by default. Our setup is:

Linux OSes shared NFS ccache directories. So in our cases, chmod/umask is important. It apparently happens on one of my ccache folder too, where only 2 users that I trust are using. I can see the following folder/rights:

drwxrwxrwx 18 combld root  357 Oct 26 00:42 .
drwxrwxrwt 18 combld root  333 Oct 25 00:01 ..
drwxrwxrwx  2 combld root 3723 Oct 26 00:38 0
drwxrwxrwx  2 combld root 3723 Oct 26 00:39 1
drwxrwxrwx  2 combld root 3473 Oct 26 00:42 2
drwxrwxrwx  2 combld root 3573 Oct 26 00:42 3
drwxrwxrwx  2 combld root 2823 Oct 26 00:41 4
drwxrwxrwx  2 combld root 2723 Oct 26 00:42 5
drwxr-xr-x  2 combld root 2273 Oct 26 00:39 6
drwxr-xr-x  2 combld root 3273 Oct 26 00:39 7
drwxr-xr-x  2 combld root 3723 Oct 26 00:42 8
drwxr-xr-x  2 combld root 3223 Oct 26 00:42 9
drwxr-xr-x  2 combld root 3373 Oct 26 00:38 a
drwxrwxrwx  2 combld root 3473 Oct 26 00:42 b
drwxr-xr-x  2 combld root 4073 Oct 26 00:39 c
-rw-rw-rw-  1 combld root  190 Oct 25 00:01 CACHEDIR.TAG
drwxr-xr-x  2 combld root 4323 Oct 26 00:39 d
drwxrwxrwx  2 combld root 2923 Oct 26 00:39 e
drwxrwxrwx  2 combld root 3273 Oct 26 00:42 f
-rw-rw-rw-  1 combld root   76 Oct 26 00:42 stats

as you can see, some folders are created with chmod 777 (so that anyone can update it, as expected for NFS ccache folder) while others are not writable by group/other. It seems strange, because normally that "combld" user shall always use the same config with the same umask when launching ccache. I don't have more details yet.

More details on my above issue. I see to be able to always reproduce it on a simple (proprietary) code repository of about 20/30 .cpp files in total. We do run ccache with this in the environment: ``` CCACHE_DIR=XXX CCACHE_BASEDIR=XXX CCACHE_NOLINK='1' CCACHE_UMASK='000' CCACHE_SLOPPINESS='time_macros' ``` the ccache directory is created by our own proprietary build system, with (in my reproducer case) permission '02777'. I tried the following: remove entirely the ccache folder run a build with ccache enabled (with the config on top) see the result in the ccache directory with the following command: find /path/to/ccache ! -perm '-a=w' With 3.7.12: "find" doesn't show any file or folder. With 4.0.0: "find" seems in my case to always return one folder containing a unique file name "stats". This is only for one folder, while all the others have correct unix rights. For example: ``` rgeissler@ncerndobedev6097:~/wk/ContextMapper (release/15.0.0 *% u=)> find ccache ! -perm '-a=w' ccache/6/7 ccache/6/7/stats rgeissler@ncerndobedev6097:~/wk/ContextMapper (release/15.0.0 *% u=)> ls -la ccache/6/7 total 12 drwxr-sr-x 2 rgeissler dev_air 4096 Oct 26 14:05 . drwxrwsrwx 8 rgeissler dev_air 4096 Oct 26 14:05 .. -rw-r--r-- 1 rgeissler dev_air 66 Oct 26 14:05 stats rgeissler@ncerndobedev6097:~/wk/ContextMapper (release/15.0.0 *% u=)> ls -la ccache/6/a total 964 drwxrwsrwx 2 rgeissler dev_air 4096 Oct 26 14:05 . drwxrwsrwx 8 rgeissler dev_air 4096 Oct 26 14:05 .. -rw-rw-rw- 1 rgeissler dev_air 452064 Oct 26 14:05 383j0vh1cgnn2v3gigpnib1bu11tj9eR -rw-rw-rw- 1 rgeissler dev_air 520621 Oct 26 14:05 76lf1v3ekeevchqg669opbfem2l5k5iR ``` I have the following suspicion: we do use "ccache" also when we do link our libraries/binaries, and obviously in these case ccache can't cache anything. So in that case, i would expect we have only a folder filled with just a "stats" file. It is possible that when that is the case, and when the folder doesn't exist yet, ccache 4.0 creates it with the original umask and ignore CCACHE_UMASK ? Note: maybe we do have other cases where directories/files aren't correctly created using CCACHE_UMASK, this is just one case that I seem to be able to reproduce all the time on a small (proprietary) example. Note: actually for me the initial I got also was a "permission denied" issue when creating a temporary file. Then when testing more i found this umask issue with the "stats" file. Maybe I also suffer from another issue, as in #703. To be checked later on my side when this specific issue is fixed. Cheers, Romain
jrosdahl commented 3 years ago

Unrelated, but I thought I should mention it anyway:

We do run ccache with this in the environment:

CCACHE_NOLINK='1'

CCACHE_NOLINK was removed in ccache 2.2 (18 years ago) and thus has no effect.

Romain-Geissler-1A commented 3 years ago

Hi,

Thanks for the information for CCACHE_NOLINK, I will remove that from our build system.

Do you know roughly already when you will release officially 4.0.1 (just for me to know if I shall cherry-pick this commit locally and apply it to 4.0 or wait for a more official release).

Cheers, Romain

jrosdahl commented 3 years ago

Do you know roughly already when you will release officially 4.0.1

No, but it shouldn't be many weeks away. As always, it depends on when I have enough spare time and interest.