diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2022-04-03 10:50:43 +0200 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2022-04-03 10:56:56 +0200 |
commit | ef2e922f9642f943199138447b29ec53fa63ea68 (patch) | |
tree | e69651e609217f37e1c29efc85a84a258aa62af2 | |
parent | 47eceb4d4f0646d6785c6ddfdb28343976549ed3 (diff) | |
download | ccache-ef2e922f9642f943199138447b29ec53fa63ea68.tar.gz |
fix: Only use /run/user/<UID>/ccache-tmp if writable
The fix for #984 addressed a problem when /run/user/0 already exists and
ccache is run with fakeroot. However, it didn’t handle the case when
/run/user/0/ccache-tmp already exists, which will happen for instance if
the real root user has run ccache at least once.
Fix this by using access(2) to verify that the ccache-tmp directory is
writable. Note: Can’t just check the mode bits of the directory since
they appear OK since fakeroot fakes the UID.
Fixes #1044.
-rw-r--r-- | src/Config.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/Config.cpp b/src/Config.cpp index b6c51db5..a64e2529 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -1039,7 +1039,7 @@ Config::default_temporary_dir(const std::string& cache_dir) static const std::string run_user_tmp_dir = [] { #ifdef HAVE_GETEUID auto dir = FMT("/run/user/{}/ccache-tmp", geteuid()); - if (Util::create_dir(dir)) { + if (Util::create_dir(dir) && access(dir.c_str(), W_OK) == 0) { return dir; } #endif |