diff --git a/bin/access-check-manager.cgi.in b/bin/access-check-manager.cgi.in index 577d25cfac780af387adcc4a330f26bf9fc62c73..75c0d217d02ba7daec63fb79e607dc37b7066816 100755 --- a/bin/access-check-manager.cgi.in +++ b/bin/access-check-manager.cgi.in @@ -13,16 +13,6 @@ my $configuration_file = $ENV{ACCOUNTMANAGER_CONFIG} || '@sysconfdir@/manager.conf'; my $configuration = Config::Tiny->read($configuration_file); -# configuration sanity check -die "no database defined in configuration, aborting\n" - unless $configuration->{database}; -die "no mailer defined in configuration, aborting\n" - unless $configuration->{mailer}; -die "no idp defined in configuration, aborting\n" - unless $configuration->{idp}; -warn "no logger in configuration, logging disabled\n" - unless $configuration->{logger}; - my $app = AccountManager::App->new( configuration => $configuration ); diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm index 1a8bbc4eb0c1d775a7e2daae4062fa2119051cc6..fa66bf8e584d64726ecfab061065dcd404d1c416 100644 --- a/lib/AccountManager/App.pm +++ b/lib/AccountManager/App.pm @@ -54,20 +54,62 @@ sub new { $self->{configuration}->{logger}->{file}, log_level => $self->{configuration}->{logger}->{level} ); + } else { + warn "no logger in configuration, logging disabled\n"; } $self->{logger} = Log::Any->get_logger(); - AccountManager::DB->register_db( - driver => $self->{configuration}->{database}->{type}, - database => $self->{configuration}->{database}->{name}, - host => $self->{configuration}->{database}->{host}, - username => $self->{configuration}->{database}->{username}, - password => $self->{configuration}->{database}->{password}, - ); + $self->{cgi} = CGI->new(); + + if (!$self->{configuration}->{mailer}) { + $self->{logger}->fatal( + "No mailer defined in configuration, aborting" + ); + $self->respond( + template => 'index.tt2.html', + data => { + content => 'errors.tt2.html', + errors => [ 'internal' ] + } + ); + } + + if (!$self->{configuration}->{idp}) { + $self->{logger}->fatal( + "No IDP defined in configuration, aborting" + ); + $self->respond( + template => 'index.tt2.html', + data => { + content => 'errors.tt2.html', + errors => [ 'internal' ] + } + ); + } + + if ($self->{configuration}->{logger}) { + AccountManager::DB->register_db( + driver => $self->{configuration}->{database}->{type}, + database => $self->{configuration}->{database}->{name}, + host => $self->{configuration}->{database}->{host}, + username => $self->{configuration}->{database}->{username}, + password => $self->{configuration}->{database}->{password}, + ); + } else { + $self->{logger}->fatal( + "No database defined in configuration, aborting" + ); + $self->respond( + template => 'index.tt2.html', + data => { + content => 'errors.tt2.html', + errors => [ 'internal' ] + } + ); + } $self->{db} = AccountManager::DB->new(); - $self->{cgi} = CGI->new(); bless $self, $pkg;