From d423979426e9dcf7c7f136bb521ea5818426ea7a Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Thu, 22 Apr 2021 14:51:18 +0200 Subject: [PATCH] Make sure encode_base64 does not break auth strings. The way Mail::Sendmail called encode_base64 could break auth strings into multiple lines, resulting in authentication errors. Ref pandora_enterprise#7347 --- pandora_server/lib/PandoraFMS/Sendmail.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Sendmail.pm b/pandora_server/lib/PandoraFMS/Sendmail.pm index 79be51e44c..03851e3d69 100644 --- a/pandora_server/lib/PandoraFMS/Sendmail.pm +++ b/pandora_server/lib/PandoraFMS/Sendmail.pm @@ -491,11 +491,11 @@ sub sendmail { || return fail("send AUTH LOGIN failed (lost connection?)"); socket_read() || return fail("AUTH LOGIN failed: $server_reply"); - socket_write(encode_base64($auth->{user},$CRLF)) + socket_write(encode_base64($auth->{user}, ""), $CRLF) || return fail("send LOGIN username failed (lost connection?)"); socket_read() || return fail("LOGIN username failed: $server_reply"); - socket_write(encode_base64($auth->{password},$CRLF)) + socket_write(encode_base64($auth->{password}, ""), $CRLF) || return fail("send LOGIN password failed (lost connection?)"); socket_read() || return fail("LOGIN password failed: $server_reply"); @@ -504,7 +504,7 @@ sub sendmail { warn "Trying AUTH PLAIN\n" if ($mailcfg{debug} > 9); socket_write( "AUTH PLAIN " - . encode_base64(join("\0", $auth->{user}, $auth->{user}, $auth->{password}), $CRLF) + . encode_base64(join("\0", $auth->{user}, $auth->{user}, $auth->{password}), ""), $CRLF ) || return fail("send AUTH PLAIN failed (lost connection?)"); socket_read() || return fail("AUTH PLAIN failed: $server_reply"); @@ -518,7 +518,7 @@ sub sendmail { || return fail("AUTH CRAM-MD5 failed: $server_reply"); $challenge =~ s/^\d+\s+//; my $response = _hmac_md5($auth->{password}, decode_base64($challenge)); - socket_write(encode_base64("$auth->{user} $response", $CRLF)) + socket_write(encode_base64("$auth->{user} $response", ""), $CRLF) || return fail("AUTH CRAM-MD5 failed: $server_reply"); socket_read() || return fail("AUTH CRAM-MD5 failed: $server_reply");