From 7e5f54b77978f02dc881f0b8d5700d64f18d1063 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Wed, 19 Oct 2022 22:49:36 -0500 Subject: [PATCH] Revise checks for "filename" directive element in read_directive_file The revised code uses the "filename" directive element as a command to install an uploaded file. This change ensures that a legitimate loose directive will be processed even if accompanied with a bogus file. This is a definitive break from protocol version 1.0, which was disabled in 2012 and recently removed. --- gatekeeper.pl | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index fe816db..6e6348a 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -1528,6 +1528,18 @@ sub read_directive_file { my @keyrings = keyring_file ($op_header->{package},$op_header->{directory}); fatal("no keyring for package $op_header->{package}",0) if ($#keyrings < 0); + # Check that we actually have at least one command in the directive + unless ($#$ops > 0) { + if ($directive_only) { + fatal("nothing to do - no commands in directive file",1); + } else { + # Provide a different message if this looks like an upload packet. + fatal("no filename directive specified in $directive_file. " + ."Upgrade to the latest version! " + ."See http://www.gnu.org/prep/maintain/maintain.html",1) + } + } + # If there is a command in the directive that doesn't require an actual # file to work on, we won't require the filename line in the directive # file. This will allow people to upload a directive file only to @@ -1542,28 +1554,6 @@ sub read_directive_file { # don't require a filename - currently symlink, rmsymlink, and # archive - and only the directive file was uploaded if (!exists($info{filename})) { - my $directory_command_only = 1; - foreach (keys %info) { - $directory_command_only = 0 - if (($_ ne 'directory') && ($_ ne 'package') && ($_ ne 'email') - && ($_ ne 'version')); - } - # This is where we would check for commands that require a file. - # In this version (1.1), there are none, so all we do is check - # that only the directive file was uploaded - - if (!$directive_only) { - # We have three files - # This is not allowed - we require a filename directive. - fatal("no filename directive specified in $directive_file. " - ."Upgrade to the latest version! " - ."See http://www.gnu.org/prep/maintain/maintain.html",1) - } else { - # We only have a directive file - # Do we have something to do? - fatal("nothing to do - no commands in directive file",1) - if ($directory_command_only == 1); - } $filename_required = 0; } -- 2.25.1