Closes #1197.
UmaskScope(std::optional<mode_t> new_umask);
~UmaskScope();
+ void release();
+
private:
std::optional<mode_t> m_saved_umask = std::nullopt;
};
}
inline UmaskScope::~UmaskScope()
+{
+ release();
+}
+
+inline void
+UmaskScope::release()
{
#ifndef _WIN32
if (m_saved_umask) {
# if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic pop
# endif
+ m_saved_umask = std::nullopt;
}
#endif
}
#include <Hash.hpp>
#include <InodeCache.hpp>
#include <ProgressBar.hpp>
+#include <UmaskScope.hpp>
#include <ccache.hpp>
#include <core/CacheEntry.hpp>
#include <core/Manifest.hpp>
Config config;
config.read();
+ UmaskScope umask_scope(config.umask());
+
const std::string arg = optarg ? optarg : std::string();
switch (c) {
}
case EXTRACT_RESULT: {
+ umask_scope.release(); // Use original umask for files outside cache dir
const auto cache_entry_data = read_from_path_or_stdin(arg);
if (!cache_entry_data) {
PRINT(stderr, "Error: \"{}\"", cache_entry_data.error());
export CCACHE_UMASK=002
export CCACHE_TEMPDIR=$CCACHE_DIR/tmp
+ $CCACHE -C
+ expect_perm "$CCACHE_DIR" drwxrwxr-x
+ expect_perm "$CCACHE_DIR/0" drwxrwxr-x
+ expect_perm "$CCACHE_DIR/0/stats" -rw-rw-r--
+ rm -rf $CCACHE_DIR
+
+ $CCACHE -c
+ expect_perm "$CCACHE_DIR" drwxrwxr-x
+ expect_perm "$CCACHE_DIR/0" drwxrwxr-x
+ expect_perm "$CCACHE_DIR/0/stats" -rw-rw-r--
+ rm -rf $CCACHE_DIR
+
+ $CCACHE -z
+ expect_perm "$CCACHE_DIR" drwxrwxr-x
+ expect_perm "$CCACHE_DIR/0" drwxrwxr-x
+ expect_perm "$CCACHE_DIR/0/stats" -rw-rw-r--
+ rm -rf $CCACHE_DIR
+
cat <<EOF >test.c
int main() {}
EOF