From: Jacob Bachmeyer Date: Sat, 8 Oct 2022 03:57:13 +0000 (-0500) Subject: Reduce the visibility of the log style global X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a088feb21fdba74aabca5542703c5a60c2a01766;p=gatekeeper.git Reduce the visibility of the log style global While $Log_Style is now a global variable, the use of "strict" means that it is only accessible in lexical scopes where it has been aliased using the "our" feature. These are limited, therefore reducing its scope from a file-scope quasi-global lexical to only the initialization code and the ftp_syslog function, where it is actually used. --- diff --git a/gatekeeper.pl b/gatekeeper.pl index 6de257f..5d18b48 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -309,9 +309,11 @@ my $email_blacklist = "/home/gatekpr/etc/email_blacklist"; # List of all package maintainers my $maintainers_bypkg = "/home/gatekpr/etc/maintainers.bypkg"; -my $Log_Style = 'GNU'; -$Log_Style = 'Alpha' if ($style eq 'alpha'); -$Log_Style = 'Distros' if ($style eq 'distros'); +{ + our $Log_Style = 'GNU'; + $Log_Style = 'Alpha' if ($style eq 'alpha'); + $Log_Style = 'Distros' if ($style eq 'distros'); +} # maintainer e-mail address my $maintainer_email = "ftp-upload-report\@gnu.org"; @@ -363,7 +365,7 @@ if (IN_TEST_MODE) { # override the above for testing die "gatekeeper: test mode: TEST_SYSLOG_SOCKET not valid" unless $ENV{TEST_SYSLOG_SOCKET} && -S $ENV{TEST_SYSLOG_SOCKET} && -w _; # override log message tag - $Log_Style = 'Test'; + our $Log_Style = 'Test'; } else { # in production mode # ensure we are using the real gpgv open my $gpgv,'-|',GPGV_BIN, '--version' @@ -396,6 +398,8 @@ sub ftp_syslog { my $priority = shift; my $message = shift; + our $Log_Style; + # Remove a trailing newline $message =~ s/[\r\n]+$//; # Collapse the message to a single line for syslog