Make generated files read-only

This is an attempt to discouraged manual changes of generated files,
as people have done so, just to get their changes over-written next
time those files are re-generated.

Reference: https://github.com/openssl/openssl/discussions/28269

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28612)
This commit is contained in:
Richard Levitte 2025-09-18 17:12:33 +02:00
parent 60c4feacce
commit da9fd71ab6
3 changed files with 18 additions and 4 deletions

View File

@ -950,7 +950,9 @@ EOF
} elsif (-f $inprologue) {
my $local_scripture .= <<"EOF";
$outprologue : $inprologue
IF F$SEARCH("$outprologue") .EQS. "" SET FILE/PROT=(O:RWD) $outprologue
COPY $inprologue $outprologue
SET FILE/PROT=(O:RD) $outprologue
EOF
$includefile_cache{$outprologue} = $local_scripture;
@ -962,7 +964,9 @@ EOF
} elsif (-f $inepilogue) {
my $local_scripture .= <<"EOF";
$outepilogue : $inepilogue
IF F$SEARCH("$outepilogue") .EQS. "" SET FILE/PROT=(O:RWD) $outepilogue
COPY $inepilogue $outepilogue
SET FILE/PROT=(O:RD) $outepilogue
EOF
$includefile_cache{$outepilogue} = $local_scripture;
@ -1116,7 +1120,9 @@ EOF
return <<"EOF";
$args{src} : $gen0 $deps
IF F$SEARCH("\$\@") .EQS. "" SET FILE/PROT=(O:RWD) \$\@
\$(PERL)$perlmodules $dofile "-o$target{build_file}" $gen0$gen_args > \$\@
SET FILE/PROT=(O:RD) \$\@
$decc_include_scripture
EOF
} elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
@ -1479,10 +1485,11 @@ EOF
rel2abs($config{builddir}));
return <<"EOF";
$script : $sources configdata.pm
\$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
IF F$SEARCH("$script") .EQS. "" SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
\$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
"-o$target{build_file}" $sources > $script
SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
PURGE $script
SET FILE/PROT=(S:RWED,O:RE,G:RE,W:RE) $script
PURGE $script
EOF
}
"" # Important! This becomes part of the template result.

View File

@ -1683,7 +1683,9 @@ EOF
return <<"EOF";
$args{src}: $gen0 $deps
if [ -r "\$@" ]; then chmod u+w \$@; fi
\$(PERL)$perlmodules "$dofile" "-o$target{build_file}" $gen0$gen_args > \$@
chmod a-w \$@
EOF
} elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
#
@ -2040,10 +2042,11 @@ EOF
rel2abs($config{builddir}));
return <<"EOF";
$script: $sources configdata.pm
if [ -r "$script" ]; then chmod u+w $script; fi
\$(RM) "$script"
\$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
"-o$target{build_file}" $sources > "$script"
chmod a+x $script
chmod a+x,a-w $script
EOF
}
sub generatedir {

View File

@ -845,7 +845,9 @@ EOF
return <<"EOF";
$args{src}: "$gen0" $deps
if exist \$@ attrib -r \$@
"\$(PERL)"$perlmodules "$dofile" "-o$target{build_file}" "$gen0"$gen_args > \$@
attrib +r \$@
EOF
} elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
#
@ -1054,8 +1056,10 @@ EOF
rel2abs($config{builddir}));
return <<"EOF";
$script: $sources configdata.pm
if exist $script attrib -r $script
"\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
"-o$target{build_file}" $sources > \$@
attrib +r $script
EOF
}
sub generatedir {