Greetings,

I'd like to get comments on the following code - I'm considering adding it 
to SMTPSvr.cpp in the SMTPCheckReturnPath function.

I don't want to debate whether or not this type of check is RFC compliant, 
or whether it will exclude valid hosts - I already know the answer to both 
of those questions.

What I want to know is - does the code look "sane" in terms of smoothly 
interfacing with current XMail code, and does it appear that it will do 
what the comments indicate? (I'm looking for sort of a code review before I 
put it live...:)

Comments from anyone are welcome.

Tracy

----- Proposed Code Addition -----
///////////////////////////////////////////////////////////////////////////////
//  Check HELO / EHLO parameters for validity, including DNS check and
//  connecting address check. All HELO / EHLO parameter validation has
//  been moved here, since we can't easily handle it in the HELO / EHLO
//  state, due to the possibility of authentication overriding the check
///////////////////////////////////////////////////////////////////////////////
     if (SMTPS.iSMTPState != stateAuthenticated)
     {
///////////////////////////////////////////////////////////////////////////////
//  Check to see if HELO is listed in spam-address.tab
///////////////////////////////////////////////////////////////////////////////
         if (USmtpSpamAddressCheck(SMTPS.szClientDomain) < 0)
         {
             ErrorPush();

             if (SMTPLogEnabled(SMTPS.hShbSMTP, SMTPS.pSMTPCfg))
                 SMTPLogSession(SMTPS, ppszRetDomains[0], "", "HELO=ESPAM", 0);

             if ((pszSMTPError = SvrGetConfigVar(SMTPS.hSvrConfig, 
"SmtpMsgHeloBanSpamAddress")) == NULL)
                 pszSMTPError = SysStrDup("504 You are registered as a 
spammer");

             return (ErrorPop());
         }
     }

///////////////////////////////////////////////////////////////////////////////
//  If HELO / EHLO name is an IP address, make sure it's the same one
//  as is currently connected
///////////////////////////////////////////////////////////////////////////////
         NET_ADDRESS     PeerAddr;

         if (SysInetAddr(SMTPS.szClientDomain, PeerAddr) == 0)
         {
             NET_ADDRESS     ConnAddr;
             SysGetAddrAddress(SMTPS.PeerInfo, ConnAddr);

             if (!SysSameAddress(PeerAddr, ConnAddr))
             {
                 if (SMTPLogEnabled(SMTPS.hShbSMTP, SMTPS.pSMTPCfg))
                     SMTPLogSession(SMTPS, ppszRetDomains[0], "", 
"HELO=IPNOTPEER", 0);

                 pszSMTPError = SysStrDup("550 Your HELO/EHLO parameter 
does not match connection information");

                 ErrSetErrorCode(ERR_SPAMMER_IP);
                 return (ERR_SPAMMER_IP);
             }
         }

///////////////////////////////////////////////////////////////////////////////
//  Validate that HELO is a valid DNS name
///////////////////////////////////////////////////////////////////////////////
         if (USmtpCheckMailDomain(SMTPS.hSvrConfig, SMTPS.szClientDomain) < 0)
         {
             ErrorPush();

             if (SMTPLogEnabled(SMTPS.hShbSMTP, SMTPS.pSMTPCfg))
                 SMTPLogSession(SMTPS, ppszRetDomains[0], "", 
"HELO=ENODNS", 0);

                 pszSMTPError = SysStrDup("550 Your HELO/EHLO parameter is 
not a valid domain name");

             return (ErrorPop());
         }
///////////////////////////////////////////////////////////////////////////////
//  Finished HELO / EHLO check
///////////////////////////////////////////////////////////////////////////////


-
To unsubscribe from this list: send the line "unsubscribe xmail" in
the body of a message to [EMAIL PROTECTED]
For general help: send the line "help" in the body of a message to
[EMAIL PROTECTED]

Reply via email to