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 <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2017-12-07 14:00:37 +01:00 committed by Fabian Grünbichler
parent b1e84aa34d
commit d8327719e3

View File

@ -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;