Commit 0a075818 authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 346275: checksetup.pl should read the "answers" file into a Safe

Patch By Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=myk
parent 0d94f047
...@@ -206,11 +206,18 @@ L<Bugzilla::Install::Requirements> ...@@ -206,11 +206,18 @@ L<Bugzilla::Install::Requirements>
=cut =cut
######################################################################
# Initialization
######################################################################
use strict; use strict;
use 5.008; use 5.008;
use File::Basename; use File::Basename;
use File::Find; use File::Find;
use Getopt::Long qw(:config bundling); use Getopt::Long qw(:config bundling);
use Pod::Usage;
use Safe;
BEGIN { chdir dirname($0); } BEGIN { chdir dirname($0); }
use lib "."; use lib ".";
use Bugzilla::Constants; use Bugzilla::Constants;
...@@ -220,31 +227,40 @@ if ($^O =~ /MSWin32/i) { ...@@ -220,31 +227,40 @@ if ($^O =~ /MSWin32/i) {
require 5.008001; # for CGI 2.93 or higher require 5.008001; # for CGI 2.93 or higher
} }
my ($silent, %switch); ######################################################################
our %answer; # Subroutines
######################################################################
sub read_answers_file {
my %hash;
if ($ARGV[0]) {
my $s = new Safe;
$s->rdo($ARGV[0]);
die "Error reading $ARGV[0]: $!" if $!;
die "Error evaluating $ARGV[0]: $@" if $@;
# Now read the param back out from the sandbox
%hash = %{$s->varglob('answer')};
}
return \%hash;
}
######################################################################
# Live Code
######################################################################
my %switch;
GetOptions(\%switch, 'help|h|?', 'check-modules', 'no-templates|t', GetOptions(\%switch, 'help|h|?', 'check-modules', 'no-templates|t',
'verbose|v|no-silent'); 'verbose|v|no-silent');
########################################################################### # Print the help message if that switch was selected.
# Check for help request. Display help page if --help/-h/-? was passed.
###########################################################################
use Pod::Usage;
pod2usage({-verbose => 1, -exitval => 1}) if $switch{'help'}; pod2usage({-verbose => 1, -exitval => 1}) if $switch{'help'};
########################################################################### # Read in the "answers" file if it exists, for running in
# Non-interactive override. Pass a filename on the command line which is # non-interactive mode.
# a Perl script. This script defines a %answer hash whose names are tags our %answer = %{read_answers_file()};
# and whose values are answers to all the questions checksetup.pl asks. my $silent = scalar(keys %answer) && !$switch{'verbose'};
# Grep this file for references to that hash to see the tags to use for the
# possible answers. One example is ADMIN_EMAIL.
###########################################################################
if ($ARGV[0] && ($ARGV[0] !~ /^-/)) {
do $ARGV[0]
or ($@ && die("Error $@ processing $ARGV[0]"))
or die("Error $! processing $ARGV[0]");
$silent = !$switch{'verbose'};
}
########################################################################### ###########################################################################
# Display version information # Display version information
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment