summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/bounce.c
AgeCommit message (Collapse)Author
2015-10-07Use getline(3) rather than fgetln(3). OK gilles@Todd C. Miller
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.
2014-05-28remove an errant semicolon.Daniel Dickman
ok gilles@
2014-04-19(void) cast snprintf() calls that cannot truncateGilles Chehade
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-03warn when failing to enqueue an internal bounce.Eric Faurot
2013-11-06Much much improved config parser and related changes.Eric Faurot
Simplify code and do not impose an order on conditions and rule options. Format changes that may require smtpd.conf update for some setups: - SSL certificates are no longer automatically loaded, but must be explicitely declared using the "pki" keyword. - "certificate" option becomes "pki" in listener and accept rules. - "ssl://" becomes "secure://" in relay via rules. - "helo" becomes "hostnames" in relay rules New features: - accept rules do not need an explicit action, in which case alias table or .forward must provide one. - new "forward-only" action to force relaying and reject rcpts that expand as local delivery. - "!" (negation) modifier on rule matching conditions. - new "recipient" rule matching condition. - new "verify" option on listeners and relay rules to reject invalid certificates. Other changes: - remember the helo name advertised on incoming mail and use it for sending bounces. - bump envelope version (existing envelopes are updated on-the-fly).
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-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-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-23knfEric Faurot
ok gilles@
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-10-07convert iobuf_queue()'s to iobuf_fqueue(). (idea from gilles@)Charles Longeau
introduce iobuf_xinit() and iobuf_xfqueue(). (idea from eric@) ok gilles@
2012-10-03don't try to cope with iobuf_init() failure, make it fatal() instead.Charles Longeau
from eric@ input ok gilles@
2012-10-02check iobuf_init() return value.Charles Longeau
ok gilles@ eric@
2012-09-26fix memory leak in case of fdopen() failureCharles Longeau
ok eric@ gilles@
2012-08-18Limit the number of bounce sessions running at the same time. WhenEric Faurot
committed, a bounce is put on a runnable list of bounces. This list is drained to enqueue as much bounces as possible within the limit. This avoids DoS'ing the server when lots of bounces are enqueued at startup. While there, allow new envelopes to be added to a bounce until the the very last moment (i.e. when the list of recipients is written). ok gilles@ chl@
2012-08-09Allow failure reports for different recipients of the same messageEric Faurot
to be grouped into a single bounce message. The bounce structure keeps a list of envelopes. For now, the list is constructed by delaying the re-enqueuing of a bounce envelope a bit, to wait for other bounces from the same message to be part of the same report.
2012-08-09remove unused function and prototypesEric Faurot
2012-08-09Improve the message flows to completely isolate operations on theEric Faurot
queue backend within the queue process. The scheduler sends envelope ids to the queue process which loads the envelope and forward the request to the agent responsible for the delivery. The result is sent by the agent to the queue which updates the storage before notifying the scheduler. Bounces are created and enqueued (from the client side) by the queue process, rather than the scheduler. ok gilles@
2012-08-08Improve the scheduler backend API.Eric Faurot
New envelopes are pushed into the scheduler through the insert() commit() rollback() transactional interface functions. Worklists are pulled from the scheduler through a single batch() interface function, which returns a list of envelope ids and the type of processing. Envelopes returned in this batch are said to be "in-flight", as opposed to "pending". They are supposed to be processed in some way, and either updated() or deleted() at some point. The schedule()/remove() functions are used to alter the internal state of "pending" envelopes to make them schedulable. The enve- lopes will be part of a worklist on the next call to batch(). Rewrite the scheduler_ramqueue backend. The initial queue loading in now done by the queue. ok gilles@
2012-07-09- runner is the terminology we used back when we had runqueues, we noGilles Chehade
longer have them and runner is actually a scheduler so rename. - introduce scheduler_backend which does the same to scheduler than queue_backend does to queue and map_backend does to maps - remove all occurences of RUNNER and runner, replace them with SCHEDULER and scheduler ok eric@, ok chl@
2012-06-20Finally get rid of the queue_kind enum in the queue API. Keep thatEric Faurot
internally in fsqueue backend for now, and let the fsqueue_message() and fsqueue_envelope() dispatchers do the right thing. Based on a diff by chl@ ok chl@ gilles@
2012-01-29Rewrite io code in smtp and mta using the iobuf/ioev interface to haveEric Faurot
a better separation between io and protocol logic. As a side-effect, it fixes a couple of long-standing issues in the io path, and hopefully add fresh ones instead. Kill client.c in the process. ok gilles@
2012-01-12The status field in the envelope is confusing. Its only purpose is toEric Faurot
notify the runner of what happened with an envelope that has been scheduled. It is not part of the state of the envelope, and it is not even dumped. So it should only be set by mta/mda, checked by runner to decide what to do with the envelope, and ignored everywhere else. ok gilles@
2012-01-11Finally remove the queue_message_update() function which ended upEric Faurot
being only called by bounce sessions, so most of the code there was actually useless. The envelope is directly deleted or updated at the relevant place. ok gilles@
2011-12-27Instead of using a separate "bounce" queue, create the bounce envelopeEric Faurot
directly as an envelope of the bounced message, just like "regular" envelopes. ok gilles@
2011-12-14finally kill queue_shared.c and move what is left to bounce.cEric Faurot
where it belongs. ok gilles@
2011-10-27Use PRI{x,d}64 in format strings instead of %llx, %lld or %qd to print ↵Charles Longeau
{u_,}int64_t or time_t While there, cast some time_t to int64_t These will fix build warnings for portable smptd ok gilles@ eric@
2011-10-23fsqueue no longer stores envelopes by dumping the structure, instead use aGilles Chehade
couple of load/dump functions to convert to and from a human readable fmt. while at it kill struct delivery and merge back its fields to the envelope. this basically means we shouldn't require users to flush their queues every time we make a change to struct envelope. work is not done, but we're at a better state than the binary fsqueue so we'll improve it in-tree. has been running on my own box for the last 12 hours or so ok eric@, chl@
2011-09-01Introduce a small set of functions to manage stat counters in aEric Faurot
simpler and hopefully saner way. ok gilles@ chl@
2011-05-16murder struct path and make sure smtpd uses simpler structures that do notGilles Chehade
bring a shitload of unnecessary information everywhere. this required many parts of smtpd to be refactored and more specifically envelope expansion. in the process lots of code got simplified, and the envelope expansion code has been isolated to lka_session.c with some longstanding bugs fixed. Diff has been tested by many with no major regression reported. armani@ spotted a bug in a setup where a domain is listed a both primary and virtual, I will fix that in-tree as it's becoming painful to maintain this diff out.
2011-05-01the smtpd env is meant to be global, so do not pass it all around.Eric Faurot
discussed with and ok gilles@
2011-04-17a structure describing an envelope should be called struct envelope, notGilles Chehade
struct message ...
2011-04-15kill message_id and message_uidGilles Chehade
smtpd now has an evpid associated to each delivery message, the evpid is an u_int64_t where the upper 32 bits are the msgid, and the 32 bits are the envelope unique identifier for that message. this results in lots of space saved in both disk-based and ram-based queues, but also simplifies a lot of code. change has been stressed on my desktop, and has ran on my MX for the entire afternoon without a regression.
2011-04-14fsqueue now provides fsqueue_message_fd_r() and fsqueue_message_fd_rw() toGilles Chehade
obtain a read{-only,/write} descriptor to the message file. make sure smtpd uses the new API everywhere it needs a fd, and kill the many functions that were used until now.
2011-04-14fsqueue queue backend will implement a filesystem queue:Gilles Chehade
- fsqueue->setup() performs the queue initialization; - fsqueue->message() controls messages; - fsqueue->envelope() controls envelopes; This commit brings the following to fsbackend: fsqueue_setup(), fsqueue_message_delete(), fsqueue_envelope_load(), fsqueue_envelope_update(), fsqueue_envelope_delete(). It also makes smtpd use the queue_backend API for these operations.
2011-03-26have the client API receive a stdio stream rather than a fd to the messageGilles Chehade
fd. this shifts responsibility for the fclose to the caller, prevents a memory leak and makes everyone happy. diff by Jared Yanovich, thanks !
2011-03-21do not close msgfd in bounce_session(), it is closed by client_close()Gilles Chehade
2010-11-28a bit of .h cleanups, no functionnal changeGilles Chehade
2010-10-09missing from previous commitGilles Chehade
2010-06-01new queue, again; gcc2 compile tested by deraadtJacek Masiulaniec
2010-06-01New queue doesn't compile on gcc2, back out. Spotted by deraadt@Jacek Masiulaniec
2010-05-31Rewrite entire queue code.Jacek Masiulaniec
Major goals: 1) Fix bad performance caused by the runner process doing full queue read in 1s intervals. My Soekris can now happily accept >50 msg/s while having multi-thousand queue; before, one hundred queue would bring the system to its knees. 2) Introduce Qmail-like scheduler that doesn't write as much to the disk so that it needs less code for servicing error conditions, which in some places can be tricky to get right. 3) Introduce separation between the scheduler and the backend; these two queue aspects shouldn't be too tied too each other. This means that eg. storing queue in SQL requires rewrite of just queue_backend.c. 4) Make on-disk queue format architecture independent, and more easily extensible, to reduce number of flag days in the future. Minor goals: ENOSPC no longer prevents delivery attempts, fixed session limiting for relayed mail, improved batching of "relay via" mails, human-readable mailq output, "show queue raw" command, clearer logging, sending of single bounce about multiple recipients, exact delay= computation, zero delay between deliveries while within session limit (currently 1s delay between re-scheduling is enforced), mta no longer requests content fd, corrected session limit for bounce submissions, tiny <100B queue files instead of multi-KB, detect loops before accepting mail, reduce traffic on imsg channels by killing enormous struct submit_status.
2010-05-19cleanup-only commit, removes unrequired includes, no functionnal changeGilles Chehade
2010-04-22Fix a case of runner trying to send imsg directly to smtp process insteadJacek Masiulaniec
of forwarding it via queue.