Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First experimental implementation of ESMTP, HELO fallback and various improvements #11

Open
wants to merge 36 commits into
base: master
Choose a base branch
from

Conversation

micia
Copy link

@micia micia commented Oct 3, 2012

These commits implement basic ESMTP parsing and support, as well as implementing a basic HELO fallback in case everything else fails. The main changes are:

  • ESMTP aware connections to remote hosts and separation between config structure and connection (no more ssl in config).
  • HELO fallback if possible and if user allows it in the configuration files.
  • I/O error checking when reading mails (by testing ferror()).
  • Better config file parsing, by ignoring trailing and ending spaces in config files (chomp() function).
  • Reworked read_remote() function to be more efficient with less cryptic if guards, while allowing for more flexible external buffer semantics.
  • Avoid infinite loops until connection timeout in read_remote(), if the remote host closes the connection on dma (read would return 0, thus pos would be equal to len, causing infinite loops).
  • read_remote() now returns full status number rather than status / 100 to allow for more flexible behaviour in mail delivery logic.
  • Support for PLAIN authentication.
  • Rather than assuming the remote host not to close the connection if dma requires an unsupported feature, now dma parses ESMTP and never sends requests for non advertised features (most SMTP servers will close the connection on an unsupported feature), for example it won't use CRAM MD5 authentication if EHLO response doesn't list it.
  • New VERBOSE configuration option to debug network communication between remote host and dma (disabled by default and dangerous for privacy).
  • New NOHELO configuration option that disables HELO fallback.
  • Minimal configuration file checking (but still very incomplete).
  • Other minor fixes, mainly due to code changes, also config files and man page were updated.

These features are not fully tested yet, but using dma on a daily basis I don't see any issue, but a code review and a more in depth test would be necessary.

micia added 30 commits October 2, 2012 16:23
…en, improve external buffer logic to report actual length to the caller, make it return the actual status code rather than status code / 100
… ESMTP aware functions, rework authentication mechanisms accordingly
Rework routines to perform basic checking for I/O errors and improve logic to
check for meaningful configuration, user defined ports are now validated and
stored in unsigned integers for maximum portability.
USESSL implies SECURETRANS so the condition is redundant.
Makes the config file parser ignore trailing and ending whitespaces,
leading to the expected results while parsing badly formatted files.
Also makes the chomp() function deal with the comments directly, to have
consistend behaviour across every configuration file.
Make HELO fallback possible only if no authentication was supplied by the user,
also fix a bug in ESMTP flags refreshing (actually drop old features)
If server advertises the login possibility and the user provides
us with authentication credential, dma should use them or fail.
Do not let read_remote tolerate invalid status numbers anywhere in
the message, also unify error handling and ensure null byte termination
for any string.
errno could be zero leading to a confusing message like:
SMTP login failed: success
Remote connection depends on global status, which is unreliable and unpredictable,
encapsulate any connection configuration into a struct connection and use only
this one for communication, this way any delivery will be easily manageable and
the struct config will be read only across the process.
Code and both config file and man pages refer that option as SECURETRANS, not SECURETRANSFER.
SECURETRANS option is actually SECURETRANSFER
micia added 6 commits October 3, 2012 20:55
Be less redundant with hostnames and addresses, the first one should be enough.
Actually send AUTH PLAIN and encode credentials properly.
Fix a typo in man page, remove unused macro constant, make ESMTP parsing more strict
bzero() and bcopy() are deprecated and marked as legacy by POSIX,
bcopy() is not even specified anymore by POSIX.
Clear FILE stream error flag on retry to allow delivery logic to retry properly on
I/O error failure.
Warn on read errors during bounce creation but still try to
deliver the bounced mail.
Main delivery routine is responsible to clear FILE stream error
indicator to provide a valid stream to the bounce routine.
@corecode
Copy link
Owner

Thanks, still trying to find time to review the patches. Please be patient.

@corecode
Copy link
Owner

I suspect it might be better to create a formal parser with yacc/lex. What do you think? We can also chat more quickly on IRC ##dma@freenode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants