* Check against creation of GC roots in the store. Those roots don't
work, because findRoots() stops when it encounters a symlink to the store. And of course the store is supposed to be read-only.
This commit is contained in:
parent
f3ebd03bb1
commit
9bff7ad728
2 changed files with 7 additions and 3 deletions
|
@ -122,7 +122,7 @@ foreach my $expr (@exprs) {
|
||||||
close DRVPATHS or exit 1;
|
close DRVPATHS or exit 1;
|
||||||
|
|
||||||
foreach my $drvPath (@drvPaths) {
|
foreach my $drvPath (@drvPaths) {
|
||||||
my $target = readlink $drvPath;
|
my $target = readlink $drvPath or die "cannot read symlink `$drvPath'";
|
||||||
print STDERR "store derivation is $target\n";
|
print STDERR "store derivation is $target\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ foreach my $expr (@exprs) {
|
||||||
close OUTPATHS or exit 1;
|
close OUTPATHS or exit 1;
|
||||||
|
|
||||||
foreach my $outPath (@outPaths) {
|
foreach my $outPath (@outPaths) {
|
||||||
my $target = readlink $outPath;
|
my $target = readlink $outPath or die "cannot read symlink `$outPath'";
|
||||||
print "$target\n";
|
print "$target\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,11 @@ Path addPermRoot(const Path & _storePath, const Path & _gcRoot,
|
||||||
Path gcRoot(canonPath(_gcRoot));
|
Path gcRoot(canonPath(_gcRoot));
|
||||||
assertStorePath(storePath);
|
assertStorePath(storePath);
|
||||||
|
|
||||||
|
if (isInStore(gcRoot))
|
||||||
|
throw Error(format(
|
||||||
|
"creating a garbage collector root (%1%) in the Nix store is forbidden "
|
||||||
|
"(are you running nix-build inside the store?)") % gcRoot);
|
||||||
|
|
||||||
if (indirect) {
|
if (indirect) {
|
||||||
createSymlink(gcRoot, storePath, true);
|
createSymlink(gcRoot, storePath, true);
|
||||||
store->addIndirectRoot(gcRoot);
|
store->addIndirectRoot(gcRoot);
|
||||||
|
@ -114,7 +119,6 @@ Path addPermRoot(const Path & _storePath, const Path & _gcRoot,
|
||||||
}
|
}
|
||||||
|
|
||||||
createSymlink(gcRoot, storePath, false);
|
createSymlink(gcRoot, storePath, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that the root can be found by the garbage collector. */
|
/* Check that the root can be found by the garbage collector. */
|
||||||
|
|
Loading…
Reference in a new issue