Disallow build products that are symlinks

Otherwise you can do

  ln -s /etc/passwd $out/foo
  echo "file misc $out/foo" >> $out/nix-support/hydra-build-products

and get Hydra to serve its /etc/passwd file.
This commit is contained in:
Eelco Dolstra 2013-02-23 16:28:44 +01:00
parent aa7ddeb8e9
commit 6658419f69
2 changed files with 3 additions and 3 deletions

View file

@ -173,6 +173,7 @@ sub checkPath {
my $storeDir = $Nix::Config::storeDir . "/";
error($c, "Invalid path in build product.")
if substr($path, 0, length($storeDir)) ne $storeDir || $path =~ /\/\.\./;
error($c, "Path $path is a symbolic link.") if -l $path;
}

View file

@ -788,16 +788,15 @@ sub addBuildProducts {
# Ensure that the path exists and points into the Nix store.
next unless File::Spec->file_name_is_absolute($path);
next if $path =~ /\/\.\./; # don't go up
next unless -e $path;
next unless substr($path, 0, length($storeDir)) eq $storeDir;
next unless -e $path;
next if -l $path;
# FIXME: check that the path is in the input closure
# of the build?
my $fileSize, my $sha1, my $sha256;
# !!! validate $path, $defaultPath
if (-f $path) {
my $st = stat($path) or die "cannot stat $path: $!";
$fileSize = $st->size;