]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Make generated files read-only
authorRichard Levitte <levitte@openssl.org>
Thu, 18 Sep 2025 15:12:33 +0000 (17:12 +0200)
committerRichard Levitte <levitte@openssl.org>
Sat, 20 Sep 2025 17:06:32 +0000 (19:06 +0200)
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)

Configurations/descrip.mms.tmpl
Configurations/unix-Makefile.tmpl
Configurations/windows-makefile.tmpl

index bc7fc36b463570f40bdee04a3a43015ef0c576a2..7c9918bb20b57a7c8b17454eff697514f4e6ac7b 100644 (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.
index 6f3e540b95c77ccf0d73ea4fd653d3a80ee67884..7fdb0b86eb87a78746b311cd44885362b5da2a8f 100644 (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 {
index b5872124debb13eaef38c42063cde7760807d947..ef39bb4c270f42b4845c0cb753f04144b93fa77c 100644 (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 {