summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/mda.c
AgeCommit message (Collapse)Author
2016-09-01zap dead codeEric Faurot
ok gilles@ sunil@
2016-05-22start work on improving the log format, this is work in progress but it'llGilles Chehade
be better worked in tree ok eric@, beck@
2016-03-25Nuke session_socket_blockmode() and session_socket_linger(). UseKenneth R Westerback
the identical io_set_blocking() and io_set_linger(). Since both are always called to turn off blocking or lingering, nuke the parameter and associated enum in favour of "just doing the right thing". While passing remove the unneeded last parameter to the remaining fcntl(F_GETFL). Finally, rename the functions to io_set_nonblocking() and io_set_nolinger() for clarity. No functional change. Started with a sweep of fcntl() usage inspired by guenther@. ok gilles@
2016-02-02Check imsg data size before use.Sunil Nimmagadda
Ok eric@ millert@
2016-01-08Add missing space in "Delivered-to:%s\n" header.Christopher Zimmermann
OK sunil@
2015-12-14Wrap long lines.Sunil Nimmagadda
Ok gilles@
2015-11-30handle "mda command too long" as a tempfailGilles Chehade
2015-11-30While delivering to lmtp or mda, accept optional "as user" parameterSunil Nimmagadda
whose privileges would be used instead of the default. Ok gilles@ jung@
2015-10-27add a rcpt-to parameter to be able to use the original (probably expanded)Joerg Jung
RCPT TO within LMTP sessions ok gilles eric
2015-10-26avoid a potential double freeJonathan Gray
ok gilles@
2015-10-11Convert some fgetln to getline.Sunil Nimmagadda
Suggestion and ok millert@, ok gilles@, eric@
2015-01-20use <limits.h> comprehensively. For now try to push <> includes toTheo de Raadt
each .c file, and out of the .h files. To avoid overinclude. ok gilles, in principle. If this has been done right, -portable should become easier to maintain.
2015-01-05some third-party mda require a prepended From separator line, so remove theGilles Chehade
prepending from delivery_filename backend and prepend conditionally earlier in the code path if delivery method is through mda or filename. ok eric@
2014-07-08fix typos.Igor Sobrado
ok jmc@
2014-04-30when using maildir, do not create automatically create folders to match tagGilles Chehade
in email address (ie: gilles+tag => ~/Maildir/.tag), instead use the folder if it already exists and deliver to the mail Maildir otherwise. ok eric@ and chl@
2014-04-19(void) cast snprintf calls that cannot truncate or for which earlier checksGilles Chehade
ensure the copy won't fail
2014-04-19add missing checks to strlcpy() when copying envelope "destination" bufferGilles Chehade
to the mda delivery buffer. we should never hit these unless we mistakenly change the value of a define, better be safe than sorry. (void) cast strlcpy/strlcat that cannot truncate or that we know and want to truncate rather than lose (informative data not used by smtpd but intended to help the human reading the log)
2014-04-04Merge the mda, mta and smtp processes into a single unprivilegedEric Faurot
process managing message reception, delivery and transfer. Mostly mechanical, but very intrusive as it required to rewamp all IMSG to fix ambiguities. with and ok gilles@
2014-02-04Add support for DSN and Enhanced Status CodeEric Faurot
2014-02-04internal improvements and cleanupsEric Faurot
- get rid of the whole penalty thing for failed envelopes in the mta and scheduler. - do not disable routes on smtp errors - try to schedule all types of envelopes on each scheduler frame.
2013-12-26bcopy -> memmoveEric Faurot
bzero -> memset
2013-11-28unsigned char casts for ctypeEric Faurot
ok gilles@
2013-11-20Rework the mda and scheduler to use the holdq mechanism instead ofEric Faurot
tempfail for limiting the number of pending deliveries to the same user. This allows to reach optimal delivery time even in case of burst, while keeping the number of inflight envelopes low.
2013-10-28bzero() some structs before using them, to be safe.Eric Faurot
2013-10-27Create the control socket in the parent process to abort early ifEric Faurot
another smtpd instance is running. Close the inherited socket in every forked process but control.
2013-10-26%i -> %d in format stringsEric Faurot
2013-07-19scheduler improvements:Eric Faurot
- implement suspend/resume scheduling for individual envelopes or message, with the associated smtpctl commands. - allow the mta to request immediate scheduling of an envelope. - on temporary failures a penalty can be given to further delay the next try.
2013-07-19Get rid of env->sc_pw and env->sc_pwqueue. Early queue initializationEric Faurot
now happens in queue_init(), and backends take the queue passwd as parameter in their init function. Remove useless SMTPD_FILTER_USER while there.
2013-07-19Remove useless sc_pid from struct smtpd.Eric Faurot
2013-05-24sync with OpenSMTPD 5.3.2Eric Faurot
ok gilles@
2013-04-12replace MAX_LINE_SIZE and SMTP_LINE_MAX with SMTPD_MAXLINESIZE forEric Faurot
consistency and clarity. Remove useless and confusing extra byte in a few arrays based on this define. ok gilles@
2013-02-05- handle getaddrinfo() error as LKA_TEMPFAILGilles Chehade
- handle getsockname() error in smtp_connected() - accept '/' as part of user-part, expand to ':' as done by qmail - fix wrong check in mda leading to bogus Return-Path header - fix aliases parsing when there's a white space between key and separator - some cosmethic cleanup
2013-02-05Spelling fixes: retreive -> retrieve. ok gillesNicholas Marriott
2013-01-31update mda to use a smaller struct mda_envelope internally.Eric Faurot
raise internal envelope limits. simplify code. ok gilles@
2013-01-28log sender address as "<>" when delivering bouncesEric Faurot
ok gilles@
2013-01-26Sync with our smtpd repo:Gilles Chehade
* first bricks of ldap and sqlite support (not finished but both working) * new table API to replace map API, all lookups are done through tables * improved handling of temporary errors throughout the daemon * improved scheduler and mta logic: connection reuse, optimizes batches * improved queue: more tolerant to admin errors, new layout, less disk-IO * improved memory usage under high load * SSL certs/keys isolated to lookup process to avoid facing network * VIRTUAL support improved, fully virtual setups possible now * runtime tracing of processes through smtpctl trace * ssl_privsep.c sync-ed with relayd * ssl.c no longer contains smtpd specific interfaces * smtpd-specific ssl bits moved to ssl_smtpd.c * update mail address in copyright FLUSH YOUR QUEUE. FLUSH YOUR QUEUE. FLUSH YOUR QUEUE. FLUSH YOUR QUEUE. smtpd.conf(5) simplified, it will require adaptations ok eric@
2012-11-12Cleanups and improvements:Eric Faurot
* Log more events (especially client session) and use a better scheme for that: each messages is prefixed with a token to easily identify its class: - info/warn/debug: general server messages - smtp-in: smtp client connections - relay: status update for relayed messages - delivery: status update for local deliveries * Implement "smtpctl monitor" to display updates of selected internal counters. * When reloading the on-disk queue at startup do not commit a message if no envelope was submitted for that message. * Remove unused stuff in the config parser. ok gilles@
2012-11-02Consistency and robustness improvements in mda:Eric Faurot
- Introduce a mda_getlastline function(); improve the code to avoid useless allocations and string formatting; make it return the last line with content (skip trailing empty lines if found). - Add a mechanism by which the mda can request the parent to abort a local delivery by killing the process. - Use ioev/iobuf for draining data to the delivery process. - Make sure to catch all transient errors and make them result in a tempfail rather than calling fatal(). - Make sure that the envelope status is properly set for all failures. - Stop using SMTP response codes; it makes no sense in this context. ok gilles@
2012-10-25Make the mda request the message fd from the queue when needed, instead ofEric Faurot
pushing the fd with the envelope. This allows the mda to deal itself with session limits. Envelopes are sent at full rate to the mda, which buffers them on per-user queues, or sends them back for rescheduling if it already has too many pending envelopes. Delivery sessions are created (within per- user and global limits) to drain the queues. This makes the server handle envelope bursts more efficiently. ok gilles@
2012-10-17rename field msg -> evp.Eric Faurot
ok gilles@
2012-10-14As discussed with gilles@, actually impose the per-user limit regardlessEric Faurot
of the delivery method. Bump the limit a bit. requested by and ok gilles@
2012-10-14Limit the number of per-user mda (external program) deliveries that can beEric Faurot
running at the same time. It prevents a user from consuming all mda "slots" with a long-running filter in his .forward file. Other delivery types are not affected. ok gilles@ chl@
2012-09-28Move mda_session to mda.c, and make it use a tree instead of a list,Eric Faurot
but still use uint32_t keys since ithe key is used as peerid in msg. ok gilles@
2012-09-27use xmalloc()/xcalloc() helpersCharles Longeau
while there unify usage of log_trace() in ramstat_set() ok gilles@ eric@
2012-09-26Stop using the delivery_data union (field "to") in delivery_mda.Eric Faurot
It's confusing and not necessary as it's only used for "buffer". Instead, just add a "buffer" member in the structure and rename "as_user" to "user". The delivery_data union becomes an anonymous union in expandnode, which is the only other place where it's used. ok gilles@
2012-09-21Add a log_envelope() function that log envelope status in a uniform way.Eric Faurot
It automagically adds an rcpt=<user@domain> field if "dest" differs from the original "rcpt". The function takes an "extra" parameter that allows to add some specific info depending on the context. ok gilles@
2012-09-20envelope type is necessarily D_MDA here.Eric Faurot
ok chl@
2012-09-16Factorize log_imsg() in imsg_dispatch() instead of in each imsg_callback()'sCharles Longeau
and put it out of profiling, so it's not accounted. While there, for PROC_PARENT: - set smtpd_process for PROC_PARENT - use setproctitle() like other processes ok gilles@
2012-08-25- introduce struct stat_valueGilles Chehade
- statistics can now have a type (counter, timestamp, timeval, timespec and possibly others in the future) - stat_increment() / stat_decrement() now take an increment/decrement value and are at the moment only of type counter - stat_set() now takes a stat_value - provide helpers to convert raw values to stat_value ok eric@, ok chl@ while at it fix a rq_queue_dump() call using a bogus timestamp in scheduler ramqueue.
2012-08-25use duration_to_text() when logging delay, for consistency.Eric Faurot
ok gilles@ chl@