Merge branch 'thh-bug13' into next

* thh-bug13:
  Add some basic validation to config parser.
This commit is contained in:
Thomas Hochstein 2013-09-02 13:00:23 +02:00
commit a036e9da62

View file

@ -99,7 +99,19 @@ sub ReadConfig {
### IN : $ConfFile: config filename ### IN : $ConfFile: config filename
### OUT: reference to a hash containing the configuration ### OUT: reference to a hash containing the configuration
my ($ConfFile) = @_; 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;
}; };
################################################################################ ################################################################################