summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/util.c
AgeCommit message (Collapse)Author
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-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-10teach smtpctl how to display envelopes and messages using their id.Gilles Chehade
this allows an admin to inspect the queue without having to manually extract bucket and find the path to an envelope or message. diff by Sunil Nimmagadda <sunil@poolp.org> ok eric@, chl@ and I
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-04change to from=<...>, to=<...> instead of to=<...> for loggingTodd T. Fries
from gilles@ ok 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-26log final user and method used for local deliveries.Eric Faurot
ok gilles@
2012-09-25need inttypes.hEric Faurot
from millert@
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-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-20constify parameters that are supposed to be const.Eric Faurot
ok gilles@
2012-09-18- add xmemdup() helper.Eric Faurot
- remove useless block in switch. ok gilles@
2012-09-16replace BSD-licensed mkdir_p() with ISC-licensed mkdirs(), this allows usGilles Chehade
to avoid a dual-licensed util.c for no reason ok chl@
2012-09-15When enqueueing from the local socket, the input address is faked as "::1".Eric Faurot
This is confusing and even broken, as systems running with ipv6 disabled on lo0 will not be able to enqueue mails using the local socket. So instead, use AF_LOCAL and print it as "local" in envelopes/maps. Add it to the "localhost" and "all" maps accordingly, and fix the ruleset matching. ok gilles@ chl@
2012-08-27don't call ckdir() on each mktmpfile() call.Charles Longeau
ok gilles@
2012-08-26- define ZLIB_BUFFER_SIZE instead of hardcoding 8192Gilles Chehade
- check gzdopen() failure - call gzclose() whenever a failure occurs after gzdopen() - simplify slightly some checks in compress/uncompress - create PATH_TEMPORARY in /var/spool/smtpd, chmod 700, owned by _smtpd - compress_zlib should use PATH_TEMPORARY instread of /tmp as we're chrooted and this will otherwise lead to a fatal() ok chl@
2012-08-25Add compress_backend, allowing compression of messages and envelopes in the ↵Charles Longeau
queue. To use it, just add "queue compress" in smtpd.conf. For now, only zlib is used. lots of feedback from eric@ and gilles@ ok eric@ gilles@
2012-08-25- add myself to the copyright in control.c, i've done quite a few changesGilles Chehade
there in the last few years ;-) - get rid of availdesc(): getdtablecount() is so much more reliable - get rid of env->sc_maxconn, we can be much smarter with getdtablecount() and getdtablesize() - disable accept when we hit the control process fd reserve - disable accept when we fail - enable accept when we're back below the limit this is not the full fd exhaustion diff, i'll merge changes from relayd tomorrow, this was only required to get rid of the env->sc_maxconn and availdesc() mess "reads alright" eric@
2012-08-19coding style: replace all occurences of u_int* with uint*Charles Longeau
ok eric@
2012-08-11make sure generated id is never 0.Eric Faurot
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-08-07Implement a set of tree_* functions for storing arbitrary pointers in splayEric Faurot
trees with uint64_t keys. Also add x{m,c}alloc and xstrdup helpers. 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-12add support for maildir tagging/folders.Charles Longeau
ok gilles@ ok eric@ on previous versions of this patch
2012-07-11enable back = char in address localpart, that is sometimes used by mailing ↵Charles Longeau
lists. ok gilles@ eric@
2012-07-11Don't respect RFC 5322, that allows some crazy characters in emailCharles Longeau
localpart, like !#$&'*/=?^`{|}~ ... and all the other ones that can be double quoted, just refuse them. ok gilles@ eric@
2012-07-10accept address literal for the recipient domain.Charles Longeau
while there, change valid_{local,domain}part() prototypes to use const char *. with input from gilles@ and eric@ ok gilles@ eric@
2012-07-08- plug text_to_relayhost() in parse.y to support relay URLs.Gilles Chehade
- document the new URL syntax in smtpd.conf.5 - replace starttls:// schema with tls:// Beware, "relay via" rules should now be expressed with a relay URL: accept [...] relay via "mx1.example.org" smtps port 465 becomes accept [...] relay via "smtps://mx1.example.org" This will allow using mappings of relays with different protocols and options. Make sure to update your smtpd.conf if you relay via ! ok eric, ok chl
2012-07-02Sleeping here is definitely not what we want to do. Use a cyclingEric Faurot
counter with some randomness to generate short-lived unique ids. ok gilles@
2012-05-29- introduce text_to_relayhost() which converts an url into a relayhost.Gilles Chehade
urls are of the form: [schema://]host[:ip] not used, yet other commits are following ;-)
2012-05-23- introduce temp_inet_net_pton_ipv6() temporarily until we have AF_INET6Gilles Chehade
support in inet_net_pton(). - in text_to_netaddr(), if we are handling an inet6 netmask AND we have inet_net_pton() that failed with EAFNOSUPPORT, THEN we fallback to this. quick fix to unbreak setups that use inet6, a diff is floating to have it supported at the right place.
2012-05-13- cleanup parse.y by removing lots of code that should not have been there,Gilles Chehade
but in ruleset.c and util.c instead. - introduce the new map_compare() map API call to allow iterating over keys and comparing them with provided key using provided function. this allows checking a partial key in a key set, very useful for comparing an address to a set of netmask. - introduce new map kind K_NETADDR - implement K_NETADDR for map_db and map_stdio - teach ruleset checking how to use the map_compare() with K_NETADDR we can now do the following: map "srcaddr" source plain "/etc/mail/srcaddr.txt" accept from map srcaddr for domain "openbsd.org" [...]
2012-01-28remove even more annoying debug logsGilles Chehade
ok eric@
2012-01-12remove envelope_get_errormsg() and move envelope_set_errormsg()Eric Faurot
to envelope.c ok gilles@
2012-01-11Simplify runner/queue by getting rid of Q_PURGE. Instead, let smtpdEric Faurot
periodically clear the purge/ directory. At init time, the fsqueue backend simply moves the existing incoming/ dir in purge/ to discard aborted sessions. ok gilles@ chl@
2011-12-18remove unused headerCharles Longeau
ok eric@
2011-12-18- use envelope_set_errormsg() where possible.Eric Faurot
- make it use sizeof() rather than a hardcoded limit. ok chl@ gilles@
2011-12-11utility function for parsing and validating SMTP response linesEric Faurot
ok gilles@
2011-11-16remove unused functionsEric Faurot
ok gilles@ chl@
2011-11-14The spool and offline directories are backend-independent, so theyEric Faurot
must be created early by smtpd, rather than in fsqueue. ok gilles@ chl@
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-05-17introduce new user_backend API for smtpd to lookup the users it wants toGilles Chehade
deliver mail to. the only backend supported for now is USER_GETPWNAM and it is not yet possible to switch to an alternate backend. yes this means that we're very close from smtpd being able to handle fully virtual accounts for both incoming and outgoing messages.
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-14int * -> socklen_t * in getsockopt() callGilles Chehade
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 ...