summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/lka.c
AgeCommit message (Collapse)Author
2010-11-29replace the fork-based-non-blocking-resolver-hack by shiny async resolverGilles Chehade
written by eric@. it is still experimental but still better than what we had earlier so ... we'll improve in tree :) diff by me with *lots* of help from eric@, tested by todd and I (and a few people out there)
2010-11-28remove all unused headersGilles Chehade
2010-11-28a bit of .h cleanups, no functionnal changeGilles Chehade
2010-10-29smtpd no longer knows a map called "secrets" which holds credentials forGilles Chehade
authenticated relaying. one can create many maps holding credentials and name them however he/she wants, just like any other map. teach smtpd how to select a credentials map at the rule-level allowing a setup to relay through the same MX with different credentials depending on the source. smtpd.conf.5 updated to reflect changes with help from jmc@
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-09-20- fix a regression caused by latest commit (long story made short: do notGilles Chehade
attempt to expand the local delivery buffer when relaying mail, it was kind of ok before but no longer is) - use the same buffer for local deliveries to files and commands tested by jmc@ and I
2010-09-12oga@ spotted a bug in lka_expand() which caused it to miscalculate theGilles Chehade
length of its expand buffer. this commit introduces a new lka_expand() that has been simplified, that fixes the bug and that is more robust. callers of lka_expand() can now determine that it has failed and throw the recipient at session time. lka_expand() rewrite by oga@, changes around it by me, tested on a few different setups but no feedback from tech@ so ... let me know if it's breaking something for you
2010-09-08add support for sender expansion in smtpd.conf:Gilles Chehade
%U for sender localpart %D for sender domainpart diff sent to tech@ by Gregory Edigarov <greg@bestnet.kharkov.ua>, timeout by jacekm@, ok by me
2010-06-04Use correct imsg type in error reply.Jacek Masiulaniec
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-06-01Don't interpret garbage on stack; problem seemingly exposed by myJacek Masiulaniec
queue rewrite. Proper fix after gilles wakes up.
2010-06-01Fix one case of not sending smtp session id on error.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-27when a rule has two conditions (ie: accept for { domain foo, domain bar } )Gilles Chehade
expand to two rules each having its own condition rather than one rule with a tail queue of conditions. this simplifies code a bit and removes a couple hacks. basic testing by oga and me
2010-04-27initial work at fixing aliases support:Gilles Chehade
- kill struct alias, struct expandnode is used instead - introduce map_parse_alias() and map_parse_virtual() - aliases and virtual code no longer assume db(3) but use the map API which lets them become backend agnostic AND value-checked. this actually makes the code simpler by removing all values parsing from aliases.c - rename K_SECRETS -> K_SECRET, K_ALIASES -> K_ALIAS for consistency the enum has singular names. - aliases, virtual and forward now work with an expandtree and deal with multiple levels of resolving by merging expandtree's more coming soon ;)
2010-04-21introduce first map parser for maps of kind K_SECRETS !Gilles Chehade
map_parse_secret() converts a map value into a struct map_secret. lka no longer needs to do any parsing, it simply calls map_lookup() with kind K_SECRETS, checks if it returned a !NULL value, and call lka_encode_secret to safely do the base64 encoding.
2010-04-21map_lookup() takes an additionnal parameter of type enum map_kind whichGilles Chehade
will be used to select the appropriate map parser. make sure every call to map_lookup() is updated. map_lookup() currently ignores the value.
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-02-17erf, previous fix to lka crash was still using the wrong define ...Gilles Chehade
2010-02-17the map api becomes backend-agnostic with initial support for db(3) andGilles Chehade
stdio(3) backends, though for now we only enable db(3). this is the first commit of a serie to improve maps and everything related. idea discussed with and diff okay jacekm@
2010-02-17localpart of a struct path may legally exceed MAXLOGNAME, causing lka toGilles Chehade
fatalx() on a lowercase() call in some cases. make sure lka uses a buffer capable of holding a localpart, and do not attempt getpwnam() if we know it's going to fail anyway... issue reported by Ben Lindstrom <mouring@eviladmin.org>
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-15Must aim better.Jacek Masiulaniec
2009-12-14Tweak the logic behind setting the fd limits so that smtpd is less likelyJacek Masiulaniec
to get upset by custom soft/hard ulimit settings. Suggested 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-13Log FQDN and IP of the server we handed mail to. As a bonus, don't delayJacek Masiulaniec
logging of successful deliveries until all MXs were tried, plus add logging of 5yz replies. tested by todd@, "reads ok" gilles@
2009-11-10In relay case, avoid freeing garbage pointer by copying the required structJacek Masiulaniec
from the temporary imsg buffer. ok gilles@
2009-11-10move format expansion to the right place, from gilles@Jacek Masiulaniec
2009-11-10sync code with comment, from gilles@Jacek Masiulaniec
2009-11-10- add comments to explain the logic in the aliases expansion loopGilles Chehade
- more cosmethic changes to help readability - fix memory leaks - if deliverylist is empty, it means something went bad during expansion, reject recipient
2009-11-10pfff remove a comment i pasted to help me refactor code ;-)Gilles Chehade
2009-11-10more cleanup, let lka_resolve_path() request forward files and populateGilles Chehade
expandtree, this makes a lot of code clearer and removes quite a bit of complexity from various places.
2009-11-10cosmethic changes, code reordering, no functionnal changeGilles Chehade
2009-11-10introduce lka_session_fail() which factors a small piece of code used inGilles Chehade
three places: set code to 530, send imsg to notify rejection, kill lkasession
2009-11-09- add a reference count and flags to struct expand_nodeGilles Chehade
- during expansion, no longer create a new node for each result but try to lookup for an existing equivalent node and increment its reference count so that: a) we save on memory, b) we don't need to expand the same users again and again just because they keep appearing in expansion results. - while expanding, flag nodes as F_EXPAND_DONE so that we know which nodes we already processed - be smarter when expanding, if we have a clue that an iteration has not brought any new result (because no new nodes were added and all existing nodes have F_EXPAND_DONE), end expansion and proceed to delivery. - various small cleanups discussed with jacekm@ yesterday, rebuild aliases db, make clean
2009-11-09support the userpart+foobar@domainpart syntax which got wiped when i wroteGilles Chehade
the virtual domains support as it was in my way. this time, make it work as it should: userpart+foobar@domainpart becomes: path->user = userpart+foobar path->domain = domainpart path->pw_name = userpart discussed quickly with jacekm@
2009-11-08rework a bit expansion and data structures involved in the expansion so weGilles Chehade
no longer have a direct mapping between structures saved in aliases/virtual db and structures used at runtime during expansion. side effects ? struct alias is smaller, databases are smaller and it is no longer necessary to rebuild aliases/virtual databases each time jacekm@ or I make changes to some obscure structure used indirectely during expansion rebuild databases, flush queues, make clean
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-11-08first commit of a serie to cleanup, simplify and improve aliases resolutionGilles Chehade
which is probably the most complex code in smtpd right now. no longer use a single list to hold aliases to be resolved and resolved aliases, and do not use struct alias to hold resolved aliases. instead use a delivery list that is a list of struct path, and populate it with resolved aliases. idea discussed with jacekm@, this needs some testing to make sure it does not introduce a regression with aliases. flush your queue and make clean.
2009-11-05another log_debug() cleanupGilles Chehade
2009-11-05cleanup a bit the log_debug outputGilles Chehade
2009-11-05- introduce lka_session_destroy() which replaces the splay tree removal andGilles Chehade
free(lkasession) in lka_expand_rcpt() - while at it, plug a very very unlikely memory leak which i spotted while reviewing the logic
2009-11-05- move a couple prototypes in smtpd.hGilles Chehade
- remove prototypes from deprecated functions
2009-11-03teach makemap how to build a set, which is a map containing only keys.Gilles Chehade
smtpd is now capable of looking primary domains at runtime in a set, which means that the following becomes possible: map "primary" { source db "/etc/mail/primary.db" } accept for domain map "primary" deliver to mbox while at it fix a couple bugs in the aliases resolution path which caused recipients to bounce if a ruleset did not have an "accept for local" rule "diff reads good" jacekm@, flush queue & make clean
2009-11-03this commit removes the hardcoded special "aliases" map and brings supportGilles Chehade
for multiple aliases maps that can be attached at the rule level. with it, you can for example define different aliases maps for different domains or different aliases maps for the same domain depending on the client source: map "localiases" { source db "/etc/mail/localiases.db" } map "netaliases" { source db "/etc/mail/netaliases.db" } accept from 192.168.0.0/16 for local alias "localiases" deliver to mbox accept from all for local alias "netaliases" deliver to mbox idea discussed with jacekm@ and various other hackers, diff contains some bug fixes too which were not part of the original diff. man page follows very shortly ... make clean & flush queue !
2009-11-03- remove a useless member of struct condGilles Chehade
- have virtual related functions take a map id instead of a map - shrink a tiny bit ruleset matching - add missing lka_resolve_path() call in aliases resolution leading to issues spotted by nicm@