diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index c3248c2c3..0bea40bd9 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -691,13 +691,20 @@ static void canonicalisePathMetaData_( if ((eaSize = llistxattr(path.c_str(), eaBuf.data(), eaBuf.size())) < 0) throw SysError("querying extended attributes of '%s'", path); - if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)) + bool resetMode = false; + if ((S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)) && !(st.st_mode & S_IWUSR)) { + resetMode = true; chmod(path.c_str(), st.st_mode | S_IWUSR); + } for (auto & eaName: tokenizeString(std::string(eaBuf.data(), eaSize), std::string("\000", 1))) { if (settings.ignoredAcls.get().count(eaName)) continue; if (lremovexattr(path.c_str(), eaName.c_str()) == -1) throw SysError("removing extended attribute '%s' from '%s'", eaName, path); } + if (resetMode) { + chmod(path.c_str(), st.st_mode); + resetMode = false; + } } #endif diff --git a/tests/functional/flakes/flakes.sh b/tests/functional/flakes/flakes.sh index 75cc329e5..85ffacf70 100644 --- a/tests/functional/flakes/flakes.sh +++ b/tests/functional/flakes/flakes.sh @@ -285,11 +285,11 @@ nix build -o $TEST_ROOT/result $flake3Dir#sth --commit-lock-file Flake lock file updates: -"?" Added input 'nonFlake': +• Added input 'nonFlake': 'git+file://"*"/flakes/flakes/nonFlake?ref=refs/heads/master&rev="*"' "*" -"?" Added input 'nonFlakeFile': +• Added input 'nonFlakeFile': 'path:"*"/flakes/flakes/nonFlake/README.md?lastModified="*"&narHash=sha256-cPh6hp48IOdRxVV3xGd0PDgSxgzj5N/2cK0rMPNaR4o%3D' "*" -"?" Added input 'nonFlakeFile2': +• Added input 'nonFlakeFile2': 'path:"*"/flakes/flakes/nonFlake/README.md?lastModified="*"&narHash=sha256-cPh6hp48IOdRxVV3xGd0PDgSxgzj5N/2cK0rMPNaR4o%3D' "* ]] nix build -o $TEST_ROOT/result flake3#fnord diff --git a/tests/unit/libstore-support/tests/libstore.hh b/tests/unit/libstore-support/tests/libstore.hh index ef93457b5..75093d3cd 100644 --- a/tests/unit/libstore-support/tests/libstore.hh +++ b/tests/unit/libstore-support/tests/libstore.hh @@ -4,6 +4,7 @@ #include #include +#include "globals.hh" #include "store-api.hh" namespace nix { @@ -11,6 +12,7 @@ namespace nix { class LibStoreTest : public ::testing::Test { public: static void SetUpTestSuite() { + settings.nixConfDir = "/dev/null"; // intentionally invalid path initLibStore(); }