From: Richard Levitte Date: Thu, 18 Sep 2025 15:12:33 +0000 (+0200) Subject: Make generated files read-only X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=da9fd71ab65074fe908c51bf1b971ce9e88545e9;p=thirdparty%2Fopenssl.git 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 Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/28612) --- diff --git a/Configurations/descrip.mms.tmpl b/Configurations/descrip.mms.tmpl index bc7fc36b463..7c9918bb20b 100644 --- a/Configurations/descrip.mms.tmpl +++ b/Configurations/descrip.mms.tmpl @@ -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. diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 6f3e540b95c..7fdb0b86eb8 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -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 { diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl index b5872124deb..ef39bb4c270 100644 --- a/Configurations/windows-makefile.tmpl +++ b/Configurations/windows-makefile.tmpl @@ -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 {