From d8327719e353198a1dffad88c246fee065054a6b Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 7 Dec 2017 14:00:37 +0100 Subject: [PATCH] auth_handler: respond with passed error if we get a PVE::Exception Allows to fix a problem where a logged in connected client was logged out because we could not verify him for this call as the cluster filesystem was unavailable. If we get such a exception then use it for responding. THis is save as no logged out client can get ever do anything where login privileges are required and a logged in client cannot to anything during the problematic period, but does not gets logged out. Partail fix for #1589 Signed-off-by: Thomas Lamprecht --- PVE/APIServer/AnyEvent.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/PVE/APIServer/AnyEvent.pm b/PVE/APIServer/AnyEvent.pm index d7271a2..382eab4 100755 --- a/PVE/APIServer/AnyEvent.pm +++ b/PVE/APIServer/AnyEvent.pm @@ -1217,7 +1217,14 @@ sub unshift_read_header { Net::SSLeay::ERR_clear_error(); # always delay unauthorized calls by 3 seconds my $delay = 3; - if (my $formatter = PVE::APIServer::Formatter::get_login_formatter($format)) { + + if (ref($err) eq "PVE::Exception") { + + $err->{code} ||= HTTP_INTERNAL_SERVER_ERROR, + my $resp = HTTP::Response->new($err->{code}, $err->{msg}); + $self->response($reqstate, $resp, undef, 0, $delay); + + } elsif (my $formatter = PVE::APIServer::Formatter::get_login_formatter($format)) { my ($raw, $ct, $nocomp) = $formatter->($path, $auth, $self->{formatter_config}); my $resp; -- 2.39.2