From: Thomas Hochstein Date: Mon, 2 Sep 2013 11:00:23 +0000 (+0200) Subject: Merge branch 'thh-bug13' into next X-Git-Tag: 0.01~1^2~1 X-Git-Url: https://code.th-h.de/?p=usenet%2Fnewsstats.git;a=commitdiff_plain;h=a036e9da62836d09282df94e52f8224279663554;hp=38fa44f89b2f0a5dac65ef1b152aefebd5513c78 Merge branch 'thh-bug13' into next * thh-bug13: Add some basic validation to config parser. --- diff --git a/NewsStats.pm b/NewsStats.pm index 1d07be6..b462cd4 100644 --- a/NewsStats.pm +++ b/NewsStats.pm @@ -99,7 +99,19 @@ sub ReadConfig { ### IN : $ConfFile: config filename ### OUT: reference to a hash containing the configuration my ($ConfFile) = @_; - return Config::Auto::parse($ConfFile, format => 'equal'); + # mandatory configuration options + my @Mandatory = ('DBDriver','DBHost','DBUser','DBPw','DBDatabase', + 'DBTableRaw','DBTableGrps'); + # read config via Config::Auto + my $ConfR = Config::Auto::parse($ConfFile, format => 'equal'); + my %Conf = %{$ConfR}; + # check for mandatory options + foreach (@Mandatory) { + &Bleat(2,sprintf("Mandatory configuration option %s is not set!",$_)) + if (!defined($Conf{$_})); + } + # $Conf{'TLH'} is checked in gatherstats.pl + return $ConfR; }; ################################################################################