summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/smtp.c
AgeCommit message (Collapse)Author
2012-01-31fix an issue observed this week-end while flooding ajacoutot@ :Gilles Chehade
we keep track of available fd's to prevent scheduling of messages if we know that we are going to fail. however, since the envelope is not removed from the scheduler, it will be rescheduled right away leading to a busy loop in the scheduler. we know flag the mda/mta processes as BUSY and do not schedule envelopes that target a BUSY process. also, fix a potential bug that could lead to a use after free when doing a batch/message/host traversal of schedulable envelopes. while at it fix misuse of env->sc_opts as env->sc_flags, was not really causing any issue as the misuse was constant ...
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-18Add new filters callbacks for:Charles Longeau
- network events (CONNECT/CLOSE) - commands (QUIT/RSET) ok gilles@ eric@
2012-01-13remove the status field from struct envelope, move it to the smtpEric Faurot
session, and cleanup the DS_* flags. ok gilles@ chl@
2012-01-12Remove dead code for config reloading for now. It is not functionnalEric Faurot
and confusing. ok gilles@
2011-12-13*finally* make use of certificate authority file if available !Gilles Chehade
bits from relayd, ok chl@, ok eric@
2011-12-12display proc name rather than function name in debug messageEric Faurot
ok gilles@ chl@
2011-11-14when receiving an unexpected imsg, print its name.Charles Longeau
with help and ideas from eric@ ok eric@ gilles@
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-10-09show messages sent between processes in debug modeEric Faurot
ok gilles@ chl@
2011-09-01move a log_debug() call to a less annoying spot so that it does not getGilles Chehade
called for each single line of DATA exchanged between smtp and mfa
2011-09-01Introduce a small set of functions to manage stat counters in aEric Faurot
simpler and hopefully saner way. ok gilles@ chl@
2011-08-31add support for per-line DATA callbacks, this allows filters to take theirGilles Chehade
decisions *while* the message is being received by the client.
2011-08-29add missing header needed by signal()Charles Longeau
ok gilles@
2011-08-27initial support for a session-time filtering APIGilles Chehade
currently only HELO/EHLO, MAIL, RCPT are supported, however ... I have voluntarily disabled filters at smtpd.conf level so people don't play with it until the API has stabilized a bit discussed with several people in private, no one opposed the feature
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-17cleanups, cosmethic changes, functions that should be static are now staticGilles Chehade
no functionnal change
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-03-15let smtpd use user-provided Diffie-Hellman parameters for ephemeral keyGilles Chehade
exchange. if no DH parameters are found, fallback to builtin parameters as was done until now. since we now accept user-provided DH parameters, make smtpd more strict and fatal() if the parameters are bogus. bump the key size of the DH parameters from 512bits to 1024bits, it might be bumped further after some more research. thanks to mikeb@ for his suggestions diff ok mikeb@ , man ok jmc@
2011-03-09smtpctl show stats displays inet4/inet6 repartition for incoming sessionsGilles Chehade
2010-11-28remove all unused headersGilles Chehade
2010-11-28a bit of .h cleanups, no functionnal changeGilles Chehade
2010-11-24add *maxactive statsTodd T. Fries
"ok and no need to keep them for yourself" gilles@
2010-10-09backout the "new" queue code commited 4 months ago. it has many good ideas,Gilles Chehade
is way more optimized than what we had earlier and there's definitely stuff we want to keep, however it is early optimization that doesn't account for many features and makes them hard (if not impossible) to write without ugly workarounds that ruin the purpose of the optimizations. the backout goes to 30 May's right before the commit and catches up on all the non-queue related commits that happened since then. i'll work on reintroducing the ideas from this queue when the basic features we expect from a MTA are implemented. suggested on tech@ about a week ago, no objections, several "please make smtpd move forward" mails from hackers and tech readers.
2010-06-02check event_dispatch() return valueCharles Longeau
ok jacekm@
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-21Runner process is just a helper for queue, so tear down its imsgJacek Masiulaniec
channels to parent, mda, mta, lka, smtp, and control. This leaves just the channel to queue, which forwards imsgs on runner's behalf and redirects any replies back to it. OK gilles@
2010-04-21Remove unusable ifdef DEBUG code.Jacek Masiulaniec
2010-04-20Kill *2400* lines of code by abstracting common bits of the imsg handlers.Jacek Masiulaniec
2010-01-03Implement "log verbose" and "log brief" to enable or disable verbose debugCharles Longeau
logging on runtime. Based on claudio@'s work on ripd, ospfd, ospf6d, dvmrpd, ldpd, bgpd. With help/ideas/testing from gilles@ jacekm@ todd@ ok jacekm@
2009-12-14Set initial session limit so that IMSG_SMTP_ENQUEUE can be satisfied evenJacek Masiulaniec
in absence of all other real listening sockets. Spotted by todd@
2009-12-13Use safe fd limits in smtp, lka, queue, and control. Removes aJacek Masiulaniec
possibility for fd-starvation fatal when under heavy load.
2009-11-08- make aliases expansion use a rb tree instead of a tail queue, the codeGilles Chehade
doesn't take advantage of the new structure yet, but this was a needed change for upcoming improvements. - introduce aliasestree_{lookup,insert,remove} to the aliases api - rename queue_generate_id() to generate_uid() and move it to utils.c as it is used all over the place and not only in queue tree idea discussed with jacekm@, if you update rebuild aliases db, make clean and flush queue
2009-10-25tag should also be copied from listener to message when the message isGilles Chehade
enqueued through smtpctl
2009-09-18Remove useless Received line added at the /usr/sbin/sendmail stage, itJacek Masiulaniec
was not correctly formatted anyway. Recording of sender uid has been moved to the server process (getpeereid), which means it is not subject to forgery. Based on problem report by Michael Lechtermann <michael@lechtermann.net>
2009-09-03imsg_get sets errno so use fatal instead of fatalx.Jacek Masiulaniec
2009-08-06- change all occurences of T_DAEMON_BATCH,MESSAGE to T_BOUNCE_BATCH/MESSAGEGilles Chehade
- make sure T_BOUNCE_MESSAGE is no longer OR-ed to T_MDA/MTA_MESSAGE - define F_MESSAGE_BOUNCE flag and make sure bounce sessions set it - teach smtpctl show queue how to recognize a bounce message
2009-08-06This commit reworks the entire mailer daemon support to actually make itGilles Chehade
work for real. As an added bonus, it simplifies it, makes it follow the same code path as regular messages and kills quite some code from mta, mda and store. There's still some work needed but the most painful part is behind us now ;) ok jacekm@
2009-06-07Change the way fds passed over a socket are retreived on the receiving side.Eric Faurot
Currently the receiver fetches an imsg via imsg_get() and if he expects an fd, he then calls imsg_get_fd() to fetch the next fd queued on the imsgbuf from which the imsg came. This changes hides the fd queueing mechanism to the API user. When closing an imsg with an fd, the message is flagged so that the receiving end knows it must dequeue the fd in imsg_get() and return it with the imsg structure. This way there is no (less) possible screw up from imsg_get_fd() not being called directly after imsg_get() by the user. The retreived imsg is self-contained. ok pyr@, "I like that" henning@
2009-06-06Sync with relayd:Pierre-Yves Ritschard
Stop pushing event handling in the imsg framework. Instead, provide a small glue layer on top of both imsg and libevent. This finally clearly separates event handling and imsg construction. Sidetrack bonus: remove the mega-ugly hack of having a dummy imsg_event_add stub in smtpctl. ok jaceckm@
2009-06-05make smtpd's imsg lib ready, just like relayd and ospfd.Pierre-Yves Ritschard
ok gilles@, jacekm@
2009-06-02make env->sc_listeners and env->sc_ssl pointers, one step further towardGilles Chehade
configuration reloading without killing active sessions; ok jacekm@
2009-06-01Don't destroy listening socket when pause/resume request is received,Jacek Masiulaniec
use event_del/event_add instead; ok gilles@
2009-06-01Fix EV_READ/EV_WRITE testing inside IMSG handlers. Based on similar changeJacek Masiulaniec
to the routing daemons by claudio@; ok gilles@
2009-05-25merge smtp_listener_setup into its only caller; ok gilles@Jacek Masiulaniec