return result.empty() ? "." : result;
}
-#ifndef _WIN32
mode_t
get_umask()
{
- static bool mask_retrieved = false;
- static mode_t mask;
- if (!mask_retrieved) {
- mask = umask(0);
- umask(mask);
- mask_retrieved = true;
- }
+ const mode_t mask = umask(0);
+ umask(mask);
return mask;
}
-#endif
void
hard_link(const std::string& oldpath, const std::string& newpath)
// resolve to the same file as `path`.
std::string get_relative_path(std::string_view dir, std::string_view path);
-#ifndef _WIN32
// Get process umask.
mode_t get_umask();
-#endif
// Hard-link `oldpath` to `newpath`. Throws `core::Error` on error.
void hard_link(const std::string& oldpath, const std::string& newpath);
# -------------------------------------------------------------------------
TEST "umask"
- CCACHE_SECONDARY_STORAGE="file://$PWD/secondary|umask=022"
+ export CCACHE_UMASK=042
+ CCACHE_SECONDARY_STORAGE="file://$PWD/secondary|umask=024"
rm -rf secondary
$CCACHE_COMPILE -c test.c
- expect_perm secondary drwxr-xr-x
- expect_perm secondary/CACHEDIR.TAG -rw-r--r--
+ expect_perm secondary drwxr-x-wx # 777 & 024
+ expect_perm secondary/CACHEDIR.TAG -rw-r---w- # 666 & 024
+ result_file=$(find $CCACHE_DIR -name '*R')
+ expect_perm "$(dirname "${result_file}")" drwx-wxr-x # 777 & 042
+ expect_perm "${result_file}" -rw--w-r-- # 666 & 042
- CCACHE_SECONDARY_STORAGE="file://$PWD/secondary|umask=000"
+ CCACHE_SECONDARY_STORAGE="file://$PWD/secondary|umask=026"
$CCACHE -C >/dev/null
rm -rf secondary
$CCACHE_COMPILE -c test.c
- expect_perm secondary drwxrwxrwx
- expect_perm secondary/CACHEDIR.TAG -rw-rw-rw-
+ expect_perm secondary drwxr-x--x # 777 & 026
+ expect_perm secondary/CACHEDIR.TAG -rw-r----- # 666 & 026
# -------------------------------------------------------------------------
TEST "Sharding"