From: Jacob Bachmeyer Date: Thu, 20 Oct 2022 03:47:46 +0000 (-0500) Subject: Revise interpretation of directives into operation lists X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=43da810eaaf4ac49f2bb796767e2a0db06f8d891;p=gatekeeper.git Revise interpretation of directives into operation lists The operation list structure replaces the "order" subkey in elements in the %info hash; as such, the "replace" option should not produce an entry in the operation list, instead being a global flag stored in the header. --- diff --git a/gatekeeper.pl b/gatekeeper.pl index c30f7a8..fe816db 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -1354,7 +1354,7 @@ sub verify_keyring { # other things, this lets us use gpgv everywhere, for paranoia's sake. # -=item $ops = interpret_directive ( $directive ) +=item $oplist = interpret_directive ( $directive ) Analyze the elements in DIRECTIVE, performing basic validation. An exception is thrown if DIRECTIVE contains invalid element values. @@ -1371,8 +1371,10 @@ sub interpret_directive { my $directive = shift; # presumed tainted my $directive_file_contents = shift; # temporary scaffold - my %header = ( package => undef, directory => undef, version => undef ); - my @ops; + my %options = ( replace => undef ); + my %header = ( version => undef, options => \%options, + package => undef, directory => undef ); + my @ops = ([header => \%header]); my $have_install = 0; # can only install one file per directive my $filename; my $cnt = 0; # TODO: remove this @@ -1438,12 +1440,13 @@ sub interpret_directive { $tainted_val =~ /^(true|false)$/ or fatal("invalid parameters for replace command: $tainted_val", 1,$directive_file_contents); - push @ops, [set => replace => ($1 eq 'true')]; + $options{replace} = ($1 eq 'true'); $info{"replace"} = $1; #ok. } elsif ($tainted_cmd eq 'comment') { # Comments are ok, we ignore them } elsif (IN_TEST_MODE && $tainted_cmd eq 'no-op') { # The testsuite uses a no-op command to validate directive processing. + push @ops, ['no-op']; $info{'no-op'} = {order => $cnt++}; } else { fatal("Invalid directive line:\n\n $tainted_cmd $tainted_val", @@ -1454,8 +1457,6 @@ sub interpret_directive { { push @ops, [install => $filename]; $have_install = 1 } } - unshift @ops, [header => \%header]; - return \@ops; }