]> git.proxmox.com Git - pve-http-server.git/commitdiff
auth_handler: respond with passed error if we get a PVE::Exception
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 7 Dec 2017 13:00:37 +0000 (14:00 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 11 Dec 2017 13:53:24 +0000 (14:53 +0100)
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>
PVE/APIServer/AnyEvent.pm

index d7271a23e6c991623dbf236d1c8c456a2be9c0d5..382eab4b7c64d0119c1ed5ea43368782a8dbded1 100755 (executable)
@@ -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;