Configure: Refuse to make directories in the source tree
Fixes #22907 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Todd Short <todd.short@me.com> (Merged from https://github.com/openssl/openssl/pull/22908)
This commit is contained in:
parent
266a3553d7
commit
504ff2a4ef
34
Configure
34
Configure
@ -1891,11 +1891,12 @@ if ($builder eq "unified") {
|
||||
my $base = shift;
|
||||
my $dir = shift;
|
||||
my $relativeto = shift || ".";
|
||||
my $no_mkpath = shift // 0;
|
||||
|
||||
$dir = catdir($base,$dir) unless isabsolute($dir);
|
||||
|
||||
# Make sure the directories we're building in exists
|
||||
mkpath($dir);
|
||||
mkpath($dir) unless $no_mkpath;
|
||||
|
||||
my $res = abs2rel(absolutedir($dir), rel2abs($relativeto));
|
||||
#print STDERR "DEBUG[cleandir]: $dir , $base => $res\n";
|
||||
@ -1906,6 +1907,7 @@ if ($builder eq "unified") {
|
||||
my $base = shift;
|
||||
my $file = shift;
|
||||
my $relativeto = shift || ".";
|
||||
my $no_mkpath = shift // 0;
|
||||
|
||||
$file = catfile($base,$file) unless isabsolute($file);
|
||||
|
||||
@ -1913,7 +1915,7 @@ if ($builder eq "unified") {
|
||||
my $f = basename($file);
|
||||
|
||||
# Make sure the directories we're building in exists
|
||||
mkpath($d);
|
||||
mkpath($d) unless $no_mkpath;
|
||||
|
||||
my $res = abs2rel(catfile(absolutedir($d), $f), rel2abs($relativeto));
|
||||
#print STDERR "DEBUG[cleanfile]: $d , $f => $res\n";
|
||||
@ -1943,7 +1945,7 @@ if ($builder eq "unified") {
|
||||
}
|
||||
# Then, look in our standard directory
|
||||
push @build_file_templates,
|
||||
( map { cleanfile($srcdir, catfile("Configurations", $_), $blddir) }
|
||||
( map { cleanfile($srcdir, catfile("Configurations", $_), $blddir, 1) }
|
||||
@build_file_template_names );
|
||||
|
||||
my $build_file_template;
|
||||
@ -1958,7 +1960,7 @@ if ($builder eq "unified") {
|
||||
}
|
||||
$config{build_file_templates}
|
||||
= [ cleanfile($srcdir, catfile("Configurations", "common0.tmpl"),
|
||||
$blddir),
|
||||
$blddir, 1),
|
||||
$build_file_template ];
|
||||
|
||||
my @build_dirs = ( [ ] ); # current directory
|
||||
@ -1967,7 +1969,7 @@ if ($builder eq "unified") {
|
||||
|
||||
# We want to detect configdata.pm in the source tree, so we
|
||||
# don't use it if the build tree is different.
|
||||
my $src_configdata = cleanfile($srcdir, "configdata.pm", $blddir);
|
||||
my $src_configdata = cleanfile($srcdir, "configdata.pm", $blddir, 1);
|
||||
|
||||
# Any source file that we recognise is placed in this hash table, with
|
||||
# the list of its intended destinations as value. When everything has
|
||||
@ -2320,7 +2322,7 @@ EOF
|
||||
my $dest = $_;
|
||||
my $ddest = cleanfile($buildd, $_, $blddir);
|
||||
foreach (@{$sources{$dest}}) {
|
||||
my $s = cleanfile($sourced, $_, $blddir);
|
||||
my $s = cleanfile($sourced, $_, $blddir, 1);
|
||||
|
||||
# If it's generated or we simply don't find it in the source
|
||||
# tree, we assume it's in the build tree.
|
||||
@ -2365,7 +2367,7 @@ EOF
|
||||
my $dest = $_;
|
||||
my $ddest = cleanfile($buildd, $_, $blddir);
|
||||
foreach (@{$shared_sources{$dest}}) {
|
||||
my $s = cleanfile($sourced, $_, $blddir);
|
||||
my $s = cleanfile($sourced, $_, $blddir, 1);
|
||||
|
||||
# If it's generated or we simply don't find it in the source
|
||||
# tree, we assume it's in the build tree.
|
||||
@ -2420,7 +2422,7 @@ EOF
|
||||
if scalar @{$generate{$_}} > 1;
|
||||
my @generator = split /\s+/, $generate{$dest}->[0];
|
||||
my $gen = $generator[0];
|
||||
$generator[0] = cleanfile($sourced, $gen, $blddir);
|
||||
$generator[0] = cleanfile($sourced, $gen, $blddir, 1);
|
||||
|
||||
# If the generator is itself generated, it's in the build tree
|
||||
if ($generate{$gen} || ! -f $generator[0]) {
|
||||
@ -2446,7 +2448,7 @@ EOF
|
||||
} elsif ($dest eq '') {
|
||||
$ddest = '';
|
||||
} else {
|
||||
$ddest = cleanfile($sourced, $dest, $blddir);
|
||||
$ddest = cleanfile($sourced, $dest, $blddir, 1);
|
||||
|
||||
# If the destination doesn't exist in source, it can only be
|
||||
# a generated file in the build tree.
|
||||
@ -2471,12 +2473,12 @@ EOF
|
||||
&& $f =~ m/^(.*?)\|(.*)$/) {
|
||||
$i = $1;
|
||||
$m = $2;
|
||||
$i = cleanfile($sourced, $i, $blddir);
|
||||
$i = cleanfile($sourced, $i, $blddir, 1);
|
||||
$i2 = cleanfile($buildd, $i, $blddir);
|
||||
$d = cleanfile($sourced, "$i/$m", $blddir);
|
||||
$d = cleanfile($sourced, "$i/$m", $blddir, 1);
|
||||
$d2 = cleanfile($buildd, "$i/$m", $blddir);
|
||||
} else {
|
||||
$d = cleanfile($sourced, $f, $blddir);
|
||||
$d = cleanfile($sourced, $f, $blddir, 1);
|
||||
$d2 = cleanfile($buildd, $f, $blddir);
|
||||
}
|
||||
|
||||
@ -2507,7 +2509,7 @@ EOF
|
||||
|
||||
foreach (keys %includes) {
|
||||
my $dest = $_;
|
||||
my $ddest = cleanfile($sourced, $_, $blddir);
|
||||
my $ddest = cleanfile($sourced, $_, $blddir, 1);
|
||||
|
||||
# If the destination doesn't exist in source, it can only be
|
||||
# a generated file in the build tree.
|
||||
@ -2515,7 +2517,7 @@ EOF
|
||||
$ddest = cleanfile($buildd, $_, $blddir);
|
||||
}
|
||||
foreach (@{$includes{$dest}}) {
|
||||
my $is = cleandir($sourced, $_, $blddir);
|
||||
my $is = cleandir($sourced, $_, $blddir, 1);
|
||||
my $ib = cleandir($buildd, $_, $blddir);
|
||||
push @{$unified_info{includes}->{$ddest}->{source}}, $is
|
||||
unless grep { $_ eq $is } @{$unified_info{includes}->{$ddest}->{source}};
|
||||
@ -2528,7 +2530,7 @@ EOF
|
||||
my $ddest;
|
||||
|
||||
if ($dest ne "") {
|
||||
$ddest = cleanfile($sourced, $dest, $blddir);
|
||||
$ddest = cleanfile($sourced, $dest, $blddir, 1);
|
||||
|
||||
# If the destination doesn't exist in source, it can only
|
||||
# be a generated file in the build tree.
|
||||
@ -2912,7 +2914,7 @@ my %template_vars = (
|
||||
my $configdata_outname = 'configdata.pm';
|
||||
open CONFIGDATA, ">$configdata_outname.new"
|
||||
or die "Trying to create $configdata_outname.new: $!";
|
||||
my $configdata_tmplname = cleanfile($srcdir, "configdata.pm.in", $blddir);
|
||||
my $configdata_tmplname = cleanfile($srcdir, "configdata.pm.in", $blddir, 1);
|
||||
my $configdata_tmpl =
|
||||
OpenSSL::Template->new(TYPE => 'FILE', SOURCE => $configdata_tmplname);
|
||||
$configdata_tmpl->fill_in(
|
||||
|
Loading…
x
Reference in New Issue
Block a user