Skip to content

Commit

Permalink
[qmf] Use socket's local address for HELO and EHLO messages. Fixes JB…
Browse files Browse the repository at this point in the history
…#46655
  • Loading branch information
rainemak committed Jul 23, 2019
1 parent e6a0093 commit dd47d76
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
@@ -0,0 +1,69 @@
From f1d94263e07c729a55abf227ca7a3fc4137a4445 Mon Sep 17 00:00:00 2001
From: Raine Makelainen <raine.makelainen@jolla.com>
Date: Tue, 23 Jul 2019 11:44:27 +0300
Subject: [PATCH 18/18] Use socket's local address for HELO and EHLO messages

Signed-off-by: Raine Makelainen <raine.makelainen@jolla.com>
---
src/plugins/messageservices/smtp/smtpclient.cpp | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/plugins/messageservices/smtp/smtpclient.cpp b/src/plugins/messageservices/smtp/smtpclient.cpp
index 19f69880..0300dcf1 100644
--- a/src/plugins/messageservices/smtp/smtpclient.cpp
+++ b/src/plugins/messageservices/smtp/smtpclient.cpp
@@ -81,11 +81,14 @@ static QByteArray messageId(const QByteArray& domainName, quint32 addressCompone
'>').toLatin1();
}

-static QByteArray localName()
+static QByteArray localName(const QHostAddress &hostAddress)
{
+
QByteArray result(QHostInfo::localDomainName().toLatin1());
if (!result.isEmpty())
return result;
+ if (!hostAddress.isNull())
+ return "[" + hostAddress.toString().toLatin1() + "]";
QList<QHostAddress> addresses(QNetworkInterface::allAddresses());
if (addresses.isEmpty())
return "localhost.localdomain";
@@ -317,7 +320,7 @@ void SmtpClient::connected(QMailTransport::EncryptType encryptType)
#ifndef QT_NO_SSL
if ((smtpCfg.smtpEncryption() == QMailTransport::Encrypt_TLS) && (status == TLS)) {
// We have entered TLS mode - restart the SMTP dialog
- QByteArray ehlo("EHLO " + localName());
+ QByteArray ehlo("EHLO " + localName(transport->socket().localAddress()));
sendCommand(ehlo);
status = Helo;
}
@@ -460,7 +463,7 @@ void SmtpClient::nextAction(const QString &response)
capabilities.clear();

// We need to know if extensions are supported
- QByteArray ehlo("EHLO " + localName());
+ QByteArray ehlo("EHLO " + localName(transport->socket().localAddress()));
sendCommand(ehlo);
status = Helo;
} else {
@@ -472,7 +475,7 @@ void SmtpClient::nextAction(const QString &response)
{
if (responseCode == 500) {
// EHLO is not implemented by this server - fallback to HELO
- QByteArray ehlo("HELO " + localName());
+ QByteArray ehlo("HELO " + localName(transport->socket().localAddress()));
sendCommand(ehlo);
} else if (responseCode == 250) {
if (domainName.isEmpty()) {
@@ -703,7 +706,7 @@ void SmtpClient::nextAction(const QString &response)
operationFailed(QMailServiceAction::Status::ErrConfiguration, response);
}
// Restart the authentication process
- QByteArray ehlo("EHLO " + localName());
+ QByteArray ehlo("EHLO " + localName(transport->socket().localAddress()));
sendCommand(ehlo);
status = Helo;
} else {
--
2.21.0

2 changes: 2 additions & 0 deletions rpm/qmf-qt5.spec
Expand Up @@ -45,6 +45,7 @@ Patch14: 0014-Prevent-push-enabled-status-to-go-out-of-sync.patch
Patch15: 0015-Check-if-IDLE-connection-needs-to-be-established-aft.patch
Patch16: 0016-Revert-Fix-bundled-zlib-detection.patch
Patch17: 0017-Add-signature-settings-in-account.patch
Patch18: 0018-Use-socket-s-local-address-for-HELO-and-EHLO-message.patch

%description
The Qt Messaging Framework, QMF, consists of a C++ library and daemon server
Expand Down Expand Up @@ -167,6 +168,7 @@ This package contains the tests for Qt Messaging Framework (QMF).
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1

%build

Expand Down

0 comments on commit dd47d76

Please sign in to comment.