summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/lka_session.c
AgeCommit message (Collapse)Author
2013-07-19Introduce expand string modifiersEric Faurot
2013-05-24sync with OpenSMTPD 5.3.2Eric Faurot
ok gilles@
2013-02-14- smtpctl trace expand, enables tracing of aliases expansionGilles Chehade
- replace "users" keyword with "userbase" when providing alternate userbase - disambiguise expansion nodes when expanding across domains and userbases - allow use of '=' instead of '=>' when declaring a mapping ok eric@
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-01-31assorted fixes spotted by Coverity.Eric Faurot
some log message updates. ok gilles@
2013-01-28- introduce 'smtpctl trace lookup' to trace lookup processGilles Chehade
- improve logging of the transfer process trace by me, logging by eric
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-27missing initialization.Eric 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-16Prevent a possible buffer overflow in lka_expand_format() that can leadEric Faurot
to a server crash, and let the smtp session fail if that happens. spotted by todd@, discussed with eric@ and chl@ commited for gilles@
2012-10-14substitute wrong comas into semicolonsCharles Longeau
ok gilles@ eric@
2012-10-13missing headerGilles Chehade
2012-10-13in aliases expansion, we can avoid requesting parent for ~user/.forward, ifGilles Chehade
we check that user is a system user first before sending the imsg
2012-10-13Make map_lookup() and make_compare() set errno on failure to distinguishEric Faurot
between "no match" and "internal error" (e.g. missing or broken db file). Adapt alias expansion and ruleset matching code to check for such errors, in which case the current processing is aborted, and a temporary failure is reported to the smtp session. ok gilles@
2012-10-11- replace "from all" and "for all" with "from any" and "for any"Gilles Chehade
ok eric@, chl@
2012-10-10For each alias node, mark if it has been expanded from an alias map orEric Faurot
from a .forward file. Local deliveries for files and filters expanded from an alias map are run as user _smtpd. issue reported by tood@ ok gilles@ todd@
2012-10-09make "relay ... as ..." work again. It's been zapped by mistake.Eric Faurot
spotted by todd@ ok gilles@
2012-10-03we reintroduced a bug that was fixed 2 years ago with the aliases rewrite:Gilles Chehade
During the entire expansion process, a username may be larger than MAXLOGNAME because it may be an alias going through another expansion. We should use a buffer that's large enough to fit a mailaddr user-part so we avoid hitting a truncation check leading to a fatal(). ok eric@, ok chl@
2012-10-03- add a EXPAND_DEPTH define for ... expansion depthGilles Chehade
- bump the expansion depth from 5 to 10 - add the current node depth to log_debug() ok eric@, ok chl@
2012-09-30- add decision to the rule so that we can actually perform a reject matchGilles Chehade
ie: reject from 192.168.1.0/24 for domain "openbsd.org" accept from 192.168.0.0/16 for domain "openbsd.org" deliver to mbox it was documented but not working. ok eric@ & chl@
2012-09-29finally remove rule member from struct envelope.Eric Faurot
"wow!" gilles@
2012-09-27clarify the alias expansion code.Eric Faurot
The session manages a list of nodes to process. A node has a link to the parent node from which it has been expanded, and a link to the rule that led to its creation. Depending on its type and the associated rule, each node is either "expanded" to create new nodes or "submitted" to create a final envelope. Nodes which have already been seen, either processed or not, are discarded to avoid loops. The expansion process is bootstrapped by creating an EXPAND_ADDRESS node from the original dest, with no rule and no parent. It is done when all nodes have been expanded or if an error occurs before. The expand depth is limited 5 levels. The whole expansion fails if the limit is reached. While there, make sure that only one .forward file is queried at a time, and only append the subfolder tag in the maildir case. Fixe issues with some virtual map setups where the dest would get mixed up, and make the whole expansion process generally easier to follow. ok chl@ gilles@
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-24spaces -> tabsEric Faurot
2012-09-21Do not pass the username to forwards_get() which does not have to care aboutEric Faurot
this. Instead, set the username on the expand context, and copy it on the expand nodes as they are inserted. ok gilles@
2012-09-21wrap expandtree into a "struct expand".Eric Faurot
ok gilles@
2012-09-21move struct lka_session definition in lka_session.cEric Faurot
ok gilles@
2012-09-21Move ruleset_match() prototype to smtpd.h and make the envelope const.Eric Faurot
Adapt a lot of functions in chain to use const args where required. ok gilles@
2012-09-19Remove aliases_exists() and aliases_virtual_exists(). The correspondingEric Faurot
*_get() functions can be called directly. ok gilles@
2012-09-19start cleaning the expansion code:Eric Faurot
- change expandtree_* prefix to expand_ for better readability and because the structure might change at some point - rename <>_free_nodes() to <>_free() - remove unused <>_remove_node() - refcounting has no purpose at all; just remove it as well as the decrement/increment functions, and replace the latter with <>_insert - expandnode flags is only used to know if it's been processed or not, don't make it a flag but a simple field with clear name. ok gilles@ chl@
2012-09-18make use of expandtree_free_nodes() in lka_session_destroy().Eric Faurot
change to a simpler implementation for it while there. ok gilles@
2012-09-18- add xmemdup() helper.Eric Faurot
- remove useless block in switch. ok gilles@
2012-09-18simple lka cleanups:Eric Faurot
- fix lka* function prototypes in smtpd.h - make static functions static - merge lka_session_init() into lka_session() - make lka_session.c use tree.c to store sessions ok gilles@
2012-09-18remove C_NET. it's not used and there is no plan for it at the moment.Eric Faurot
ok gilles@
2012-09-17Fix format expansion in smtpd.conf, it has confused a lot of people and itGilles Chehade
turns out documentation got it wrong. This commit changes formats and doc, it makes situation saner: %A = user part of sender address %D = domain part of sender address %a = user part of recipient address %d = domain part of recipient address %u = unix account of recipient ok eric@
2012-08-21Allow smtpd to work as a backup MX, relaying only to MXs with higherEric Faurot
priority in the DNS record. For example: accept for domain "foo.org" relay backup "mx3.foo.org" will relay mails for "foo.org" using only hosts with higher priority (i.e. lower value) than "mx3.foo.org", which is supposed to be the current server. If the specified backup MX is not found in the DNS record, relaying works as normal. ok gilles@
2012-08-19coding style: replace all occurences of u_int* with uint*Charles Longeau
ok eric@
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-07-29- introduce xlowercase() and allow lowercase() to fail gracefullyGilles Chehade
- replace all calls to lowercase() with calls to xlowercase() - in the format string expansion, lowercase() all formats we will have to reassess all calls to xlowercase() even though it has never triggered as far as I know, we can probably gracefully fail some of them. right now we're just keeping former behaviour. this commit fixes issue reported by Hugo Osvaldo Barrera where a %u format could lead to a delivery failure (ie: GILLES@openbsd.org should be expanded to gilles, not GILLES ... only for local deliveries). ok chl@ on the idea, ok eric@ on the diff
2012-07-29get rid of A_INVALID.Eric Faurot
little code cleanup while here. ok gilles@
2012-07-12add support for maildir tagging/folders.Charles Longeau
ok gilles@ ok eric@ on previous versions of this patch
2011-12-13split user_backend.c into user.c and user_pwd.c to be consistent with theEric Faurot
backend scheme. Also rename USER_GETPWNAM to USER_PWD. ok chl@ gilles@
2011-12-13- introduce delivery backend API (delivery.c)Gilles Chehade
- move each delivery method to it's own delivery backend - simplify smtpd.c accordingly - rename A_EXT -> A_MDA since that's what we really do ok eric@
2011-12-12remove comments about dead "struct delivery"Charles Longeau
"obvious ok" gilles@
2011-12-08rename struct user to struct mta_user to avoid namespace conflict elsewhereTodd T. Fries
ok chl@ & gilles@
2011-10-25rewrite the sender user/domain as specified in the manpage when matchingEric Faurot
a "relay... as" rule. mikeb can now send mails. ok gilles@ mikeb@
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-22correctly set relay when expanding envelopesEric Faurot
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-07-04%u in format string is rcpt.user not rcpt.domainGilles Chehade
From Tim van der Molen <tbvdm@xs4all.nl>