[pve-devel] [PATCH] auth_handler: respond with passed error if we get a PVE::Exception

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Dec 7 14:00:37 CET 2017


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 at proxmox.com>
---
 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.11.0





More information about the pve-devel mailing list