@@ -19,6 +19,33 @@ stdenv.mkDerivation {
1919 # Add the closures of the top-level store objects.
2020 storePaths=$(perl ${pathsFromGraph} closure-*)
2121
22+ # If a Hydra slave happens to have store paths with bad permissions/mtime,
23+ # abort now so that they don't end up in ISO images in the channel.
24+ # https://github.com/NixOS/nixpkgs/issues/32242
25+ hasBadPaths=""
26+ for path in $storePaths; do
27+ if [ -h "$path" ]; then
28+ continue
29+ fi
30+
31+ mtime=$(stat -c %Y "$path")
32+ mode=$(stat -c %a "$path")
33+
34+ if [ "$mtime" != 1 ]; then
35+ echo "Store path '$path' has an invalid mtime."
36+ hasBadPaths=1
37+ fi
38+ if [ "$mode" != 444 ] && [ "$mode" != 555 ]; then
39+ echo "Store path '$path' has invalid permissions."
40+ hasBadPaths=1
41+ fi
42+ done
43+
44+ if [ -n "$hasBadPaths" ]; then
45+ echo "You have bad paths in your store, please fix them."
46+ exit 1
47+ fi
48+
2249 # Also include a manifest of the closures in a format suitable
2350 # for nix-store --load-db.
2451 printRegistration=1 perl ${pathsFromGraph} closure-* > nix-path-registration