X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FDispatcher.pm;h=1292f280c204978ea02cca20b0cf60ff77c13f27;hb=dbda14c263efd93aca3b7114015a47d86b8581e3;hp=93d3a18e6c491d6455758b5d8a025aaa22c0e401;hpb=e855756795da07e79807b8cf1a31cfea8d253d61;p=kivitendo-erp.git diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index 93d3a18e6..1292f280c 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -16,6 +16,7 @@ BEGIN { unshift @INC, $exe_dir; } +use Carp; use CGI qw( -no_xhtml); use Config::Std; use DateTime; @@ -58,16 +59,18 @@ sub interface_type { return $self->{interface} eq 'cgi' ? 'CGI' : 'FastCGI'; } +sub is_admin_request { + my %params = @_; + return ($params{script} eq 'admin.pl') || (($params{routing_type} eq 'controller') && ($params{script_name} eq 'Admin')); +} + sub pre_request_checks { + my (%params) = @_; + _check_for_old_config_files(); - if (!$::auth->session_tables_present) { - if ($::form->{script} eq 'admin.pl') { - ::run(); - ::end_of_request(); - } else { - show_error('login_screen/auth_db_unreachable'); - } + if (!$::auth->session_tables_present && !is_admin_request(%params)) { + show_error('login_screen/auth_db_unreachable'); } if ($::request->type !~ m/^ (?: html | js | json ) $/x) { @@ -128,6 +131,8 @@ sub pre_startup_setup { $::lxdebug->warn(@_); }; + $SIG{__DIE__} = sub { Carp::confess( @_ ) } if $::lx_office_conf{debug}->{backtrace_on_die}; + $self->_cache_file_modification_times; } @@ -218,7 +223,7 @@ sub handle_request { $::form->{action} =~ s/( |-|,|\#)/_/g; ($script, $path, $suffix) = fileparse($script_name, ".pl"); - require_main_code($script, $suffix); + require_main_code($script, $suffix) unless $script eq 'admin'; $::form->{script} = $script . $suffix; @@ -228,9 +233,12 @@ sub handle_request { } eval { - pre_request_checks(); + pre_request_checks(script => $script, action => $action, routing_type => $routing_type, script_name => $script_name); - $::form->error($::locale->text('System currently down for maintenance!')) if -e ($::lx_office_conf{paths}->{userspath} . "/nologin") && $script ne 'admin'; + if ( SL::System::InstallationLock->is_locked + && !is_admin_request(script => $script, script_name => $script_name, routing_type => $routing_type)) { + $::form->error($::locale->text('System currently down for maintenance!')); + } # For compatibility with a lot of database upgrade scripts etc: # Re-write request to old 'login.pl?action=login' to new @@ -240,50 +248,40 @@ sub handle_request { _require_controller('LoginScreen'); } - if (($script eq 'login') && !$action) { - print $::request->{cgi}->redirect('controller.pl?action=LoginScreen/user_login'); - - } elsif ($script eq 'admin') { - $::form->{titlebar} = "kivitendo " . $::locale->text('Version') . " $::form->{version}"; - ::run($session_result); + if ( (($script eq 'login') && !$action) + || ($script eq 'admin') + || (SL::Auth::SESSION_EXPIRED() == $session_result)) { + $self->redirect_to_login($script); - } else { - if (SL::Auth::SESSION_EXPIRED == $session_result) { - print $::request->{cgi}->redirect('controller.pl?action=LoginScreen/user_login&error=session'); - ::end_of_request(); - } - - my %auth_result = $self->{auth_handler}->handle( - routing_type => $routing_type, - script => $script, - controller => $script_name, - action => $action, - ); + } - ::end_of_request() unless $auth_result{auth_ok}; + my %auth_result = $self->{auth_handler}->handle( + routing_type => $routing_type, + script => $script, + controller => $script_name, + action => $action, + ); - delete @{ $::form }{ grep { m/^\{AUTH\}/ } keys %{ $::form } } unless $auth_result{keep_auth_vars}; + ::end_of_request() unless $auth_result{auth_ok}; - if ($action) { - $::instance_conf->init if $auth_result{auth_level} eq 'user'; + delete @{ $::form }{ grep { m/^\{AUTH\}/ } keys %{ $::form } } unless $auth_result{keep_auth_vars}; - map { $::form->{$_} = $::myconfig{$_} } qw(charset) - unless $action eq 'save' && $::form->{type} eq 'preferences'; + if ($action) { + $::instance_conf->init if $auth_result{auth_level} eq 'user'; - $::form->set_standard_title; - if ($routing_type eq 'old') { - ::call_sub('::' . $::locale->findsub($action)); - } else { - _run_controller($script_name, $action); - } + $::form->set_standard_title; + if ($routing_type eq 'old') { + ::call_sub('::' . $::locale->findsub($action)); } else { - $::form->error($::locale->text('action= not defined!')); + _run_controller($script_name, $action); } + } else { + $::form->error($::locale->text('action= not defined!')); } 1; } or do { - if ($EVAL_ERROR ne END_OF_REQUEST) { + if (substr($EVAL_ERROR, 0, length(END_OF_REQUEST())) ne END_OF_REQUEST()) { my $error = $EVAL_ERROR; print STDERR $error; @@ -317,6 +315,13 @@ sub handle_request { $::lxdebug->leave_sub; } +sub redirect_to_login { + my ($self, $script) = @_; + my $action = $script =~ m/^admin/i ? 'Admin/login' : 'LoginScreen/user_login&error=session'; + print $::request->cgi->redirect("controller.pl?action=${action}"); + ::end_of_request(); +} + sub unrequire_bin_mozilla { my $self = shift; return unless $self->_interface_is_fcgi;