зеркало из https://github.com/mozilla/pjs.git
add hidden per smtp server pref to allow overriding of EHLO/HELO argument, patch by ch.ey@gmx.net, r/sr=bienvenu 244030
This commit is contained in:
Родитель
98befb796e
Коммит
8de7785714
|
@ -40,11 +40,11 @@
|
|||
|
||||
interface nsIAuthPrompt;
|
||||
|
||||
[scriptable, uuid(556ee1e9-8221-4c00-a502-8ce44f029b47)]
|
||||
[scriptable, uuid(eef39b32-9050-11db-92fa-000c6e0abfac)]
|
||||
interface nsISmtpServer : nsISupports {
|
||||
|
||||
|
||||
attribute string key; // unique identifier
|
||||
|
||||
|
||||
attribute AUTF8String description; // user provided description for the server
|
||||
attribute string hostname;
|
||||
attribute PRInt32 port;
|
||||
|
@ -58,6 +58,7 @@ interface nsISmtpServer : nsISupports {
|
|||
attribute long authMethod;
|
||||
readonly attribute boolean trySecAuth;
|
||||
attribute long trySSL;
|
||||
readonly attribute string helloArgument;
|
||||
|
||||
readonly attribute string serverURI;
|
||||
string getPasswordWithUI(in wstring promptString, in wstring promptTitle,
|
||||
|
@ -66,5 +67,5 @@ interface nsISmtpServer : nsISupports {
|
|||
in nsIAuthPrompt netPrompt, out string userid, out string password);
|
||||
void forgetPassword();
|
||||
|
||||
void clearAllValues();
|
||||
void clearAllValues();
|
||||
};
|
||||
|
|
|
@ -313,6 +313,7 @@ void nsSmtpProtocol::Initialize(nsIURI * aURL)
|
|||
smtpServer->GetAuthMethod(&m_prefAuthMethod);
|
||||
smtpServer->GetTrySSL(&m_prefTrySSL);
|
||||
smtpServer->GetTrySecAuth(&m_prefTrySecAuth);
|
||||
smtpServer->GetHelloArgument(getter_Copies(m_helloArgument));
|
||||
}
|
||||
|
||||
rv = RequestOverrideInfo(smtpServer);
|
||||
|
@ -353,33 +354,51 @@ void nsSmtpProtocol::Initialize(nsIURI * aURL)
|
|||
return;
|
||||
}
|
||||
|
||||
void nsSmtpProtocol::GetUserDomainName(nsACString& aResult)
|
||||
void nsSmtpProtocol::AppendHelloArgument(nsACString& aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
PRNetAddr iaddr; // IP address for this connection
|
||||
// our transport is always a nsISocketTransport
|
||||
nsCOMPtr<nsISocketTransport> socketTransport = do_QueryInterface(m_transport);
|
||||
// should return the interface ip of the SMTP connection
|
||||
// minimum case - see bug 68877 and RFC 2821, chapter 4.1.1.1
|
||||
rv = socketTransport->GetSelfAddr(&iaddr);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
// is a custom EHLO/HELO argument configured for the transport to be used?
|
||||
if (!m_helloArgument.IsEmpty())
|
||||
{
|
||||
// turn it into a string
|
||||
char ipAddressString[64];
|
||||
if (PR_NetAddrToString(&iaddr, ipAddressString, sizeof(ipAddressString)) == PR_SUCCESS)
|
||||
{
|
||||
NS_ASSERTION(PR_IsNetAddrType(&iaddr, PR_IpAddrV4Mapped) == PR_FALSE,
|
||||
"unexpected IPv4-mapped IPv6 address");
|
||||
|
||||
if (iaddr.raw.family == PR_AF_INET6) // IPv6 style address?
|
||||
aResult.AssignLiteral("[IPv6:");
|
||||
aResult += m_helloArgument;
|
||||
}
|
||||
else
|
||||
{
|
||||
// is a FQDN known for this system?
|
||||
char hostName[256];
|
||||
PR_GetSystemInfo(PR_SI_HOSTNAME_UNTRUNCATED, hostName, sizeof hostName);
|
||||
if ((hostName[0] != '\0') && (strchr(hostName, '.') != NULL))
|
||||
{
|
||||
aResult += hostName;
|
||||
}
|
||||
else
|
||||
aResult.AssignLiteral("[");
|
||||
{
|
||||
PRNetAddr iaddr; // IP address for this connection
|
||||
// our transport is always a nsISocketTransport
|
||||
nsCOMPtr<nsISocketTransport> socketTransport = do_QueryInterface(m_transport);
|
||||
// should return the interface ip of the SMTP connection
|
||||
// minimum case - see bug 68877 and RFC 2821, chapter 4.1.1.1
|
||||
rv = socketTransport->GetSelfAddr(&iaddr);
|
||||
|
||||
aResult.Append(nsDependentCString(ipAddressString) + NS_LITERAL_CSTRING("]"));
|
||||
}
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
// turn it into a string
|
||||
char ipAddressString[64];
|
||||
if (PR_NetAddrToString(&iaddr, ipAddressString, sizeof(ipAddressString)) == PR_SUCCESS)
|
||||
{
|
||||
NS_ASSERTION(PR_IsNetAddrType(&iaddr, PR_IpAddrV4Mapped) == PR_FALSE,
|
||||
"unexpected IPv4-mapped IPv6 address");
|
||||
|
||||
if (iaddr.raw.family == PR_AF_INET6) // IPv6 style address?
|
||||
aResult.AppendLiteral("[IPv6:");
|
||||
else
|
||||
aResult.AppendLiteral("[");
|
||||
|
||||
aResult.Append(nsDependentCString(ipAddressString) + NS_LITERAL_CSTRING("]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,7 +525,6 @@ PRInt32 nsSmtpProtocol::SmtpResponse(nsIInputStream * inputStream, PRUint32 leng
|
|||
PRInt32 nsSmtpProtocol::ExtensionLoginResponse(nsIInputStream * inputStream, PRUint32 length)
|
||||
{
|
||||
PRInt32 status = 0;
|
||||
nsCAutoString buffer("EHLO ");
|
||||
|
||||
if (m_responseCode != 220)
|
||||
{
|
||||
|
@ -515,31 +533,18 @@ PRInt32 nsSmtpProtocol::ExtensionLoginResponse(nsIInputStream * inputStream, PRU
|
|||
#endif
|
||||
nsExplainErrorDetails(m_runningURL, NS_ERROR_SMTP_GREETING,
|
||||
m_responseText.get());
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
|
||||
|
||||
m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
|
||||
return(NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER);
|
||||
}
|
||||
|
||||
char hostName[256];
|
||||
PR_GetSystemInfo(PR_SI_HOSTNAME_UNTRUNCATED, hostName, sizeof hostName);
|
||||
|
||||
if ((hostName[0] != '\0') && (strchr(hostName, '.') != NULL))
|
||||
{
|
||||
buffer += hostName;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCAutoString domainName(256);
|
||||
|
||||
GetUserDomainName(domainName);
|
||||
buffer += domainName;
|
||||
// buffer += " hostname not available";
|
||||
}
|
||||
nsCAutoString buffer("EHLO ");
|
||||
AppendHelloArgument(buffer);
|
||||
buffer += CRLF;
|
||||
|
||||
nsCOMPtr<nsIURI> url = do_QueryInterface(m_runningURL);
|
||||
|
||||
status = SendData(url, buffer.get());
|
||||
|
||||
m_nextState = SMTP_RESPONSE;
|
||||
|
@ -680,22 +685,11 @@ PRInt32 nsSmtpProtocol::SendEhloResponse(nsIInputStream * inputStream, PRUint32
|
|||
return(NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER);
|
||||
}
|
||||
|
||||
nsCAutoString buffer("HELO ");
|
||||
char hostName[256];
|
||||
PR_GetSystemInfo(PR_SI_HOSTNAME_UNTRUNCATED, hostName, sizeof hostName);
|
||||
if ((hostName[0] != '\0') && (strchr(hostName, '.') != NULL))
|
||||
{
|
||||
buffer += hostName;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCAutoString domainName(256);
|
||||
|
||||
GetUserDomainName(domainName);
|
||||
buffer += domainName;
|
||||
}
|
||||
buffer += CRLF;
|
||||
status = SendData(url, buffer.get());
|
||||
nsCAutoString buffer("HELO ");
|
||||
AppendHelloArgument(buffer);
|
||||
buffer += CRLF;
|
||||
|
||||
status = SendData(url, buffer.get());
|
||||
|
||||
m_nextState = SMTP_RESPONSE;
|
||||
m_nextStateAfterResponse = SMTP_SEND_HELO_RESPONSE;
|
||||
|
@ -751,7 +745,6 @@ PRInt32 nsSmtpProtocol::SendEhloResponse(nsIInputStream * inputStream, PRUint32
|
|||
|
||||
if(m_prefTrySecAuth)
|
||||
{
|
||||
|
||||
if (responseLine.Find("GSSAPI", PR_TRUE, 5) >= 0)
|
||||
SetFlag(SMTP_AUTH_GSSAPI_ENABLED);
|
||||
|
||||
|
|
|
@ -176,12 +176,13 @@ private:
|
|||
nsCString m_responseText; /* text returned from Smtp server */
|
||||
nsMsgLineStreamBuffer *m_lineStreamBuffer; // used to efficiently extract lines from the incoming data stream
|
||||
|
||||
char *m_addressCopy;
|
||||
char *m_addresses;
|
||||
PRUint32 m_addressesLeft;
|
||||
char *m_verifyAddress;
|
||||
char *m_addressCopy;
|
||||
char *m_addresses;
|
||||
PRUint32 m_addressesLeft;
|
||||
char *m_verifyAddress;
|
||||
nsXPIDLCString m_mailAddr;
|
||||
PRInt32 m_sizelimit;
|
||||
nsXPIDLCString m_helloArgument;
|
||||
PRInt32 m_sizelimit;
|
||||
|
||||
// *** the following should move to the smtp server when we support
|
||||
// multiple smtp servers
|
||||
|
@ -256,7 +257,7 @@ private:
|
|||
|
||||
PRInt32 SendMessageInFile();
|
||||
|
||||
void GetUserDomainName(nsACString& domainName);
|
||||
void AppendHelloArgument(nsACString& aResult);
|
||||
nsresult GetPassword(char **aPassword);
|
||||
nsresult GetUsernamePassword(char **aUsername, char **aPassword);
|
||||
nsresult PromptForPassword(nsISmtpServer *aSmtpServer, nsISmtpUrl *aSmtpUrl, const PRUnichar **formatStrings, char **aPassword);
|
||||
|
|
|
@ -228,6 +228,21 @@ nsSmtpServer::GetTrySecAuth(PRBool *trySecAuth)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSmtpServer::GetHelloArgument(char * *aHelloArgument)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_ARG_POINTER(aHelloArgument);
|
||||
rv = mPrefBranch->GetCharPref("hello_argument", aHelloArgument);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
rv = mDefPrefBranch->GetCharPref("hello_argument", aHelloArgument);
|
||||
if (NS_FAILED(rv))
|
||||
*aHelloArgument = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSmtpServer::GetAuthMethod(PRInt32 *authMethod)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче