OpenBSD CVS

CVS log for src/usr.sbin/smtpd/lka_session.c


[BACK] Up to [local] / src / usr.sbin / smtpd

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.100 / (download) - annotate - [select for diffs], Fri Feb 2 23:33:42 2024 UTC (4 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, HEAD
Changes since 1.99: +15 -1 lines
Diff to previous 1.99 (colored)

when an alternate delivery user is provided in a dispatcher, do not process
any recipient .forward file except that of the alternate delivery user.

ok millert@

Revision 1.99 / (download) - annotate - [select for diffs], Fri Feb 2 22:02:12 2024 UTC (4 months ago) by gilles
Branch: MAIN
Changes since 1.98: +14 -1 lines
Diff to previous 1.98 (colored)

there's no good reason to allow smtpd to execute custom command set by root
in a .forward file so disallow custom commands and file reading, only allow
setting forward addresses and users.

as root is no longer allowed to run any MDA but mbox, we can be stricter on
the setup of the MDA process and refuse to exec anything that's not an mbox
dispatcher.

tested by op@ who edited a root envelope to simulate an exploit injecting a
custom command in a root envelope, smtpd refused to exec.

ok millert@ and op@

Revision 1.98 / (download) - annotate - [select for diffs], Fri Nov 3 13:40:07 2023 UTC (7 months ago) by op
Branch: MAIN
Changes since 1.97: +2 -3 lines
Diff to previous 1.97 (colored)

initialize `format' earlier

It's easier to see that it's never used un-initialized.

ok tb@

Revision 1.97 / (download) - annotate - [select for diffs], Wed Sep 22 17:19:58 2021 UTC (2 years, 8 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.96: +3 -4 lines
Diff to previous 1.96 (colored)

remove test traces committed by mistake

Revision 1.96 / (download) - annotate - [select for diffs], Wed Sep 22 17:11:35 2021 UTC (2 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.95: +11 -10 lines
Diff to previous 1.95 (colored)

decode srs-encoded address in the right place.
fixes a bug where ruleset was not evaluated with the expanded address.

reported by Stefan Haller

ok millert@

Revision 1.95 / (download) - annotate - [select for diffs], Mon Jun 14 17:58:15 2021 UTC (2 years, 11 months ago) by eric
Branch: MAIN
Changes since 1.94: +1 -18 lines
Diff to previous 1.94 (colored)

add required headers for smtpd.h and remove unnecessary ones in other files.

ok jung@

Revision 1.94 / (download) - annotate - [select for diffs], Thu Dec 31 08:27:15 2020 UTC (3 years, 5 months ago) by martijn
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.93: +8 -8 lines
Diff to previous 1.93 (colored)

Rename the pony process to dispatcher and klondike to crypto.

From gilles@
OK millert@ giovanni@

Revision 1.93 / (download) - annotate - [select for diffs], Fri Sep 20 17:46:05 2019 UTC (4 years, 8 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.92: +24 -3 lines
Diff to previous 1.92 (colored)

teach smtpd how to do SRS so hosts that act as forwarders don't break SPF.
this basic implementation does SRS0/SRS1 encoding/decoding, validating time
and checksums.

with insight from semarie@, ok eric@ and millert@

Revision 1.92 / (download) - annotate - [select for diffs], Fri Dec 28 11:40:29 2018 UTC (5 years, 5 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.91: +2 -2 lines
Diff to previous 1.91 (colored)

remove the tag workaround for table_create() and table_find(),
now that static tables handle their updates internally.

ok gilles@

Revision 1.91 / (download) - annotate - [select for diffs], Thu Dec 27 15:41:50 2018 UTC (5 years, 5 months ago) by gilles
Branch: MAIN
Changes since 1.90: +7 -3 lines
Diff to previous 1.90 (colored)

extract subaddress from last resolved node, not from dest or rcpt address
which was incorrect and can lead to ambiguous cases, this will affect the
people who were using subaddresses within aliases themselves AND expected
deliveries to a maildir subdir of the recipient user.

ok eric@

Revision 1.90 / (download) - annotate - [select for diffs], Wed Dec 26 20:13:43 2018 UTC (5 years, 5 months ago) by eric
Branch: MAIN
Changes since 1.89: +2 -2 lines
Diff to previous 1.89 (colored)

reorder parameters for consistency

Revision 1.89 / (download) - annotate - [select for diffs], Wed Dec 26 14:15:12 2018 UTC (5 years, 5 months ago) by eric
Branch: MAIN
Changes since 1.88: +2 -2 lines
Diff to previous 1.88 (colored)

get rid of the unused dict argument in table lookup and fetch api.

ok gilles@

Revision 1.88 / (download) - annotate - [select for diffs], Thu Nov 1 18:01:51 2018 UTC (5 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.87: +4 -3 lines
Diff to previous 1.87 (colored)

log_warn() -> log_warnx() and only display warning that running commands
from aliases is dangerous if expand node is EXPAND_FILTER

Revision 1.87 / (download) - annotate - [select for diffs], Wed Jul 25 10:19:28 2018 UTC (5 years, 10 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.86: +2 -2 lines
Diff to previous 1.86 (colored)

delivery to a filename should be in mbox format otherwise it will lack the
^From separator and corrupt files

ok eric@

Revision 1.86 / (download) - annotate - [select for diffs], Sun Jul 8 13:10:49 2018 UTC (5 years, 11 months ago) by gilles
Branch: MAIN
Changes since 1.85: +14 -3 lines
Diff to previous 1.85 (colored)

when rejecting a recipient due to any kind of error related to .forward and
aliases/virtual expansion, provide a more explicit status in the session.

ok millert@

Revision 1.85 / (download) - annotate - [select for diffs], Sat Jul 7 13:38:55 2018 UTC (5 years, 11 months ago) by gilles
Branch: MAIN
Changes since 1.84: +3 -1 lines
Diff to previous 1.84 (colored)

make it more obvious that there was a problem with a .forward file:

424 4.2.4 Mailing list expansion problem
524 5.2.4 Mailing list expansion problem

postmaster still has to look to logs to understand the real issue but at
least it doesn't go unnoticed anymore.

ok eric@

Revision 1.84 / (download) - annotate - [select for diffs], Sat Jun 16 19:41:26 2018 UTC (5 years, 11 months ago) by gilles
Branch: MAIN
Changes since 1.83: +2 -2 lines
Diff to previous 1.83 (colored)

rework the table API so that it takes a struct smtpd * context in parameter
of functions creating, looking up or destroying tables.

this is a first step in cleaning up parse.y so it doesn't have side effects
outside of parse_config(), bringing nothing but making code cleaner.

ok millert@

Revision 1.83 / (download) - annotate - [select for diffs], Thu May 31 21:06:12 2018 UTC (6 years ago) by gilles
Branch: MAIN
Changes since 1.82: +3 -3 lines
Diff to previous 1.82 (colored)

remove 'where' parameter from all x*() functions in utils.c, it doesn't
really help us with anything, propagate the change in codebase

ok millert@

Revision 1.82 / (download) - annotate - [select for diffs], Thu May 24 11:38:24 2018 UTC (6 years ago) by gilles
Branch: MAIN
Changes since 1.81: +82 -137 lines
Diff to previous 1.81 (colored)

switch smtpd to new grammar

ok eric@

Revision 1.81 / (download) - annotate - [select for diffs], Fri May 26 21:30:00 2017 UTC (7 years ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.80: +2 -318 lines
Diff to previous 1.80 (colored)

move variables expansion out of lka_session into their own file, this is a
mechanical diff to simplify a bit the lka code and prepare for moving
variables outside of the lookup process into the chrooted mda process.
no functional change for now.

ok eric@

Revision 1.80 / (download) - annotate - [select for diffs], Wed Aug 31 10:18:08 2016 UTC (7 years, 9 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.79: +4 -4 lines
Diff to previous 1.79 (colored)

allow overriding the subaddressing delimiter with subaddressing-delimiter
keyword, the default is still +

ok eric@, sunil@

Revision 1.79 / (download) - annotate - [select for diffs], Mon Dec 28 22:08:30 2015 UTC (8 years, 5 months ago) by jung
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.78: +17 -17 lines
Diff to previous 1.78 (colored)

remove spaces after '!'

no binary change

ok millert

Revision 1.78 / (download) - annotate - [select for diffs], Mon Dec 14 10:22:12 2015 UTC (8 years, 5 months ago) by jung
Branch: MAIN
Changes since 1.77: +4 -4 lines
Diff to previous 1.77 (colored)

remove trailing whitespace

ok sunil gilles

Revision 1.77 / (download) - annotate - [select for diffs], Mon Nov 30 12:57:05 2015 UTC (8 years, 6 months ago) by gilles
Branch: MAIN
Changes since 1.76: +5 -3 lines
Diff to previous 1.76 (colored)

replace a fatalx() with a graceful failure

Revision 1.76 / (download) - annotate - [select for diffs], Mon Nov 30 12:26:55 2015 UTC (8 years, 6 months ago) by sunil
Branch: MAIN
Changes since 1.75: +3 -1 lines
Diff to previous 1.75 (colored)

While delivering to lmtp or mda, accept optional "as user" parameter
whose privileges would be used instead of the default.

Ok gilles@ jung@

Revision 1.75 / (download) - annotate - [select for diffs], Mon Nov 30 11:14:01 2015 UTC (8 years, 6 months ago) by gilles
Branch: MAIN
Changes since 1.74: +4 -12 lines
Diff to previous 1.74 (colored)

remove mailaddr_to_username(), no longer needed

suggested by jung@

Revision 1.74 / (download) - annotate - [select for diffs], Mon Nov 30 10:56:25 2015 UTC (8 years, 6 months ago) by gilles
Branch: MAIN
Changes since 1.73: +6 -7 lines
Diff to previous 1.73 (colored)

teach aliases expansion how to deal with user+tag

ok sunil@, ok jung@

Revision 1.73 / (download) - annotate - [select for diffs], Wed Oct 28 07:43:44 2015 UTC (8 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.72: +1 -9 lines
Diff to previous 1.72 (colored)

remove old check on username length that simply makes no sense nowadays

ok millert@ sunil@

Revision 1.72 / (download) - annotate - [select for diffs], Wed Oct 28 07:25:30 2015 UTC (8 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.71: +27 -1 lines
Diff to previous 1.71 (colored)

aliases support resolving to maildir:/path

ok sunil@ millert@

Revision 1.71 / (download) - annotate - [select for diffs], Tue Oct 6 06:44:47 2015 UTC (8 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.70: +4 -4 lines
Diff to previous 1.70 (colored)

fix snprintf() error checking in token expansion code, these can't possibly
fail but it's no excuse for getting the checks wrong.

spotted by qualys

Revision 1.68.4.1 / (download) - annotate - [select for diffs], Fri Oct 2 01:33:33 2015 UTC (8 years, 8 months ago) by gilles
Branch: OPENBSD_5_6
Changes since 1.68: +5 -1 lines
Diff to previous 1.68 (colored) next main 1.69 (colored)

Errata 031:
fix multiple security and reliability issues found during an audit by
Qualys Security

Revision 1.69.2.1 / (download) - annotate - [select for diffs], Fri Oct 2 01:28:43 2015 UTC (8 years, 8 months ago) by gilles
Branch: OPENBSD_5_7
Changes since 1.69: +5 -1 lines
Diff to previous 1.69 (colored) next main 1.70 (colored)

Errata 017:
fix multiple security and reliability issues found during an audit by
Qualys Security

Revision 1.69.6.1 / (download) - annotate - [select for diffs], Fri Oct 2 00:55:02 2015 UTC (8 years, 8 months ago) by gilles
Branch: OPENBSD_5_8
Changes since 1.69: +5 -1 lines
Diff to previous 1.69 (colored) next main 1.70 (colored)

Errata 004:
fix multiple security and reliability issues found during an audit by
Qualys Security

Revision 1.70 / (download) - annotate - [select for diffs], Fri Oct 2 00:29:51 2015 UTC (8 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.69: +5 -1 lines
Diff to previous 1.69 (colored)

fix a stack-based buffer overflow in the token expansion code of the lookup
process (unprivileged), allowing a local user to crash the server or
potentially execute arbitrary code.

reported by Qualys Security

Revision 1.69 / (download) - annotate - [select for diffs], Tue Jan 20 17:37:54 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_7_BASE
Branch point for: OPENBSD_5_8, OPENBSD_5_7
Changes since 1.68: +2 -1 lines
Diff to previous 1.68 (colored)

use <limits.h> comprehensively.  For now try to push <> includes to
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.

Revision 1.68 / (download) - annotate - [select for diffs], Tue Jul 8 13:49:09 2014 UTC (9 years, 11 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE
Branch point for: OPENBSD_5_6
Changes since 1.67: +2 -2 lines
Diff to previous 1.67 (colored)

Update the table API: lookup functions can take an optional parameters
dictionnary (currently not set). While there, add a helper for forking
external backends, and remove unused table functions.

ok gilles@

Revision 1.67 / (download) - annotate - [select for diffs], Wed Apr 30 09:17:29 2014 UTC (10 years, 1 month ago) by gilles
Branch: MAIN
Changes since 1.66: +2 -48 lines
Diff to previous 1.66 (colored)

when using maildir, do not create automatically create folders to match tag
in email address (ie: gilles+tag => ~/Maildir/.tag), instead use the folder
if it already exists and deliver to the mail Maildir otherwise.

ok eric@ and chl@

Revision 1.66 / (download) - annotate - [select for diffs], Sat Apr 19 12:55:23 2014 UTC (10 years, 1 month ago) by gilles
Branch: MAIN
Changes since 1.65: +18 -13 lines
Diff to previous 1.65 (colored)

when receiving mail for user+tag@ and maildir is setup, we create a .tag
subdirectory in the maildir, add missing check to strlcat() so that if path
with .tag exceeds SMTPD_MAXPATHLEN we fail instead of creating a .tag dir
that's truncated.

(void) cast strlcpy()/strlcat() that cannot truncate

Revision 1.65 / (download) - annotate - [select for diffs], Fri Apr 4 16:10:42 2014 UTC (10 years, 2 months ago) by eric
Branch: MAIN
Changes since 1.64: +11 -11 lines
Diff to previous 1.64 (colored)

Merge the mda, mta and smtp processes into a single unprivileged
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@

Revision 1.64 / (download) - annotate - [select for diffs], Fri Feb 28 16:00:11 2014 UTC (10 years, 3 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.63: +2 -2 lines
Diff to previous 1.63 (colored)

The user.directory expansion is not supposed to be escaped.

ok gilles@ deraadt@

Revision 1.63 / (download) - annotate - [select for diffs], Tue Feb 4 10:38:06 2014 UTC (10 years, 4 months ago) by eric
Branch: MAIN
Changes since 1.62: +1 -1 lines
Diff to previous 1.62 (colored)

extend allowed charset for email address, escape all potentially dangerous ones.

Revision 1.62 / (download) - annotate - [select for diffs], Thu Dec 26 17:25:32 2013 UTC (10 years, 5 months ago) by eric
Branch: MAIN
Changes since 1.61: +5 -5 lines
Diff to previous 1.61 (colored)

bcopy -> memmove
bzero -> memset

Revision 1.61 / (download) - annotate - [select for diffs], Tue Nov 19 10:22:42 2013 UTC (10 years, 6 months ago) by eric
Branch: MAIN
Changes since 1.60: +44 -18 lines
Diff to previous 1.60 (colored)

Allow '*' in the user part of mailaddresses.  By default, potentially dangerous
characters are replaced when expanding for local deliveries, unless the "raw"
modifier is specified.

Revision 1.60 / (download) - annotate - [select for diffs], Wed Nov 6 10:01:29 2013 UTC (10 years, 7 months ago) by eric
Branch: MAIN
Changes since 1.59: +47 -7 lines
Diff to previous 1.59 (colored)

Much much improved config parser and related changes.
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).

Revision 1.59 / (download) - annotate - [select for diffs], Mon Oct 28 09:14:58 2013 UTC (10 years, 7 months ago) by eric
Branch: MAIN
Changes since 1.58: +4 -1 lines
Diff to previous 1.58 (colored)

bzero() some structs before using them, to be safe.

Revision 1.58 / (download) - annotate - [select for diffs], Sat Oct 26 12:27:59 2013 UTC (10 years, 7 months ago) by eric
Branch: MAIN
Changes since 1.57: +2 -2 lines
Diff to previous 1.57 (colored)

%i -> %d in format strings

Revision 1.57 / (download) - annotate - [select for diffs], Fri Jul 19 08:12:19 2013 UTC (10 years, 10 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.56: +92 -7 lines
Diff to previous 1.56 (colored)

Introduce expand string modifiers

Revision 1.56 / (download) - annotate - [select for diffs], Fri May 24 17:03:14 2013 UTC (11 years ago) by eric
Branch: MAIN
Changes since 1.55: +71 -26 lines
Diff to previous 1.55 (colored)

sync with OpenSMTPD 5.3.2

ok gilles@

Revision 1.55 / (download) - annotate - [select for diffs], Thu Feb 14 12:30:49 2013 UTC (11 years, 3 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.54: +31 -25 lines
Diff to previous 1.54 (colored)

- smtpctl trace expand, enables tracing of aliases expansion
- 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@

Revision 1.54 / (download) - annotate - [select for diffs], Tue Feb 5 11:45:18 2013 UTC (11 years, 4 months ago) by gilles
Branch: MAIN
Changes since 1.53: +8 -3 lines
Diff to previous 1.53 (colored)

- handle getaddrinfo() error as LKA_TEMPFAIL
- 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

Revision 1.53 / (download) - annotate - [select for diffs], Thu Jan 31 18:34:43 2013 UTC (11 years, 4 months ago) by eric
Branch: MAIN
Changes since 1.52: +6 -2 lines
Diff to previous 1.52 (colored)

assorted fixes spotted by Coverity.
some log message updates.

ok gilles@

Revision 1.52 / (download) - annotate - [select for diffs], Mon Jan 28 11:09:53 2013 UTC (11 years, 4 months ago) by gilles
Branch: MAIN
Changes since 1.51: +26 -22 lines
Diff to previous 1.51 (colored)

- introduce 'smtpctl trace lookup' to trace lookup process
- improve logging of the transfer process

trace by me, logging by eric

Revision 1.51 / (download) - annotate - [select for diffs], Sat Jan 26 09:37:23 2013 UTC (11 years, 4 months ago) by gilles
Branch: MAIN
Changes since 1.50: +333 -216 lines
Diff to previous 1.50 (colored)

Sync with our smtpd repo:

* 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@

Revision 1.50 / (download) - annotate - [select for diffs], Tue Nov 27 09:39:44 2012 UTC (11 years, 6 months ago) by eric
Branch: MAIN
Changes since 1.49: +2 -1 lines
Diff to previous 1.49 (colored)

missing initialization.

ok gilles@

Revision 1.49 / (download) - annotate - [select for diffs], Mon Nov 12 14:58:53 2012 UTC (11 years, 6 months ago) by eric
Branch: MAIN
Changes since 1.48: +16 -16 lines
Diff to previous 1.48 (colored)

Cleanups and improvements:

* 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@

Revision 1.48 / (download) - annotate - [select for diffs], Tue Oct 16 11:10:38 2012 UTC (11 years, 7 months ago) by eric
Branch: MAIN
Changes since 1.47: +23 -8 lines
Diff to previous 1.47 (colored)

Prevent a possible buffer overflow in lka_expand_format() that can lead
to a server crash, and let the smtp session fail if that happens.

spotted by todd@, discussed with eric@ and chl@

commited for gilles@

Revision 1.47 / (download) - annotate - [select for diffs], Sun Oct 14 13:31:46 2012 UTC (11 years, 7 months ago) by chl
Branch: MAIN
Changes since 1.46: +3 -3 lines
Diff to previous 1.46 (colored)

substitute wrong comas into semicolons

ok gilles@ eric@

Revision 1.46 / (download) - annotate - [select for diffs], Sat Oct 13 21:38:27 2012 UTC (11 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.45: +2 -1 lines
Diff to previous 1.45 (colored)

missing header

Revision 1.45 / (download) - annotate - [select for diffs], Sat Oct 13 21:33:33 2012 UTC (11 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.44: +10 -1 lines
Diff to previous 1.44 (colored)

in aliases expansion, we can avoid requesting parent for ~user/.forward, if
we check that user is a system user first before sending the imsg

Revision 1.44 / (download) - annotate - [select for diffs], Sat Oct 13 08:01:47 2012 UTC (11 years, 7 months ago) by eric
Branch: MAIN
Changes since 1.43: +23 -9 lines
Diff to previous 1.43 (colored)

Make map_lookup() and make_compare() set errno on failure to distinguish
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@

Revision 1.43 / (download) - annotate - [select for diffs], Thu Oct 11 21:14:32 2012 UTC (11 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.42: +2 -2 lines
Diff to previous 1.42 (colored)

- replace "from all" and "for all" with "from any" and "for any"

ok eric@, chl@

Revision 1.42 / (download) - annotate - [select for diffs], Wed Oct 10 18:02:37 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.41: +32 -19 lines
Diff to previous 1.41 (colored)

For each alias node, mark if it has been expanded from an alias map or
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@

Revision 1.41 / (download) - annotate - [select for diffs], Tue Oct 9 21:33:38 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.40: +7 -1 lines
Diff to previous 1.40 (colored)

make "relay ... as ..." work again.  It's been zapped by mistake.

spotted by todd@

ok gilles@

Revision 1.40 / (download) - annotate - [select for diffs], Wed Oct 3 19:42:16 2012 UTC (11 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.39: +9 -2 lines
Diff to previous 1.39 (colored)

we reintroduced a bug that was fixed 2 years ago with the aliases rewrite:

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@

Revision 1.39 / (download) - annotate - [select for diffs], Wed Oct 3 18:09:18 2012 UTC (11 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.38: +9 -7 lines
Diff to previous 1.38 (colored)

- add a EXPAND_DEPTH define for ... expansion depth
- bump the expansion depth from 5 to 10
- add the current node depth to log_debug()

ok eric@, ok chl@

Revision 1.38 / (download) - annotate - [select for diffs], Sun Sep 30 14:28:16 2012 UTC (11 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.37: +3 -3 lines
Diff to previous 1.37 (colored)

- add decision to the rule so that we can actually perform a reject match
  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@

Revision 1.37 / (download) - annotate - [select for diffs], Sat Sep 29 10:35:01 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.36: +2 -1 lines
Diff to previous 1.36 (colored)

finally remove rule member from struct envelope.

"wow!" gilles@

Revision 1.36 / (download) - annotate - [select for diffs], Thu Sep 27 18:57:25 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.35: +254 -368 lines
Diff to previous 1.35 (colored)

clarify the alias expansion code.

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@

Revision 1.35 / (download) - annotate - [select for diffs], Wed Sep 26 19:52:20 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.34: +29 -28 lines
Diff to previous 1.34 (colored)

Stop using the delivery_data union (field "to") in delivery_mda.
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@

Revision 1.34 / (download) - annotate - [select for diffs], Mon Sep 24 08:56:12 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.33: +32 -32 lines
Diff to previous 1.33 (colored)

spaces -> tabs

Revision 1.33 / (download) - annotate - [select for diffs], Fri Sep 21 19:37:08 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.32: +4 -2 lines
Diff to previous 1.32 (colored)

Do not pass the username to forwards_get() which does not have to care about
this.  Instead, set the username on the expand context, and copy it on the
expand nodes as they are inserted.

ok gilles@

Revision 1.32 / (download) - annotate - [select for diffs], Fri Sep 21 16:40:20 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.31: +9 -9 lines
Diff to previous 1.31 (colored)

wrap expandtree into a "struct expand".

ok gilles@

Revision 1.31 / (download) - annotate - [select for diffs], Fri Sep 21 13:23:07 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.30: +18 -1 lines
Diff to previous 1.30 (colored)

move struct lka_session definition in lka_session.c

ok gilles@

Revision 1.30 / (download) - annotate - [select for diffs], Fri Sep 21 10:22:29 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.29: +1 -2 lines
Diff to previous 1.29 (colored)

Move ruleset_match() prototype to smtpd.h and make the envelope const.
Adapt a lot of functions in chain to use const args where required.

ok gilles@

Revision 1.29 / (download) - annotate - [select for diffs], Wed Sep 19 10:10:30 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.28: +5 -12 lines
Diff to previous 1.28 (colored)

Remove aliases_exists() and aliases_virtual_exists(). The corresponding
*_get() functions can be called directly.

ok gilles@

Revision 1.28 / (download) - annotate - [select for diffs], Wed Sep 19 09:06:35 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.27: +4 -6 lines
Diff to previous 1.27 (colored)

start cleaning the expansion code:

- 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@

Revision 1.27 / (download) - annotate - [select for diffs], Tue Sep 18 15:35:13 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.26: +2 -7 lines
Diff to previous 1.26 (colored)

make use of expandtree_free_nodes() in lka_session_destroy().
change to a simpler implementation for it while there.

ok gilles@

Revision 1.26 / (download) - annotate - [select for diffs], Tue Sep 18 14:23:01 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.25: +4 -9 lines
Diff to previous 1.25 (colored)

- add xmemdup() helper.
- remove useless block in switch.

ok gilles@

Revision 1.25 / (download) - annotate - [select for diffs], Tue Sep 18 13:42:39 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.24: +35 -90 lines
Diff to previous 1.24 (colored)

simple lka cleanups:

- 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@

Revision 1.24 / (download) - annotate - [select for diffs], Tue Sep 18 12:13:22 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.23: +1 -2 lines
Diff to previous 1.23 (colored)

remove C_NET. it's not used and there is no plan for it at the moment.

ok gilles@

Revision 1.23 / (download) - annotate - [select for diffs], Mon Sep 17 18:44:57 2012 UTC (11 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.22: +4 -4 lines
Diff to previous 1.22 (colored)

Fix format expansion in smtpd.conf, it has confused a lot of people and it
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@

Revision 1.22 / (download) - annotate - [select for diffs], Tue Aug 21 20:19:46 2012 UTC (11 years, 9 months ago) by eric
Branch: MAIN
Changes since 1.21: +2 -3 lines
Diff to previous 1.21 (colored)

Allow smtpd to work as a backup MX, relaying only to MXs with higher
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@

Revision 1.21 / (download) - annotate - [select for diffs], Sun Aug 19 14:16:58 2012 UTC (11 years, 9 months ago) by chl
Branch: MAIN
Changes since 1.20: +7 -7 lines
Diff to previous 1.20 (colored)

coding style: replace all occurences of u_int* with uint*

ok eric@

Revision 1.20 / (download) - annotate - [select for diffs], Thu Aug 9 09:48:02 2012 UTC (11 years, 10 months ago) by eric
Branch: MAIN
Changes since 1.19: +6 -3 lines
Diff to previous 1.19 (colored)

Improve the message flows to completely isolate operations on the
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@

Revision 1.19 / (download) - annotate - [select for diffs], Sun Jul 29 17:21:43 2012 UTC (11 years, 10 months ago) by gilles
Branch: MAIN
Changes since 1.18: +7 -2 lines
Diff to previous 1.18 (colored)

- introduce xlowercase() and allow lowercase() to fail gracefully
- 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

Revision 1.18 / (download) - annotate - [select for diffs], Sun Jul 29 16:33:01 2012 UTC (11 years, 10 months ago) by eric
Branch: MAIN
Changes since 1.17: +6 -13 lines
Diff to previous 1.17 (colored)

get rid of A_INVALID.
little code cleanup while here.

ok gilles@

Revision 1.17 / (download) - annotate - [select for diffs], Thu Jul 12 08:51:43 2012 UTC (11 years, 10 months ago) by chl
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.16: +16 -4 lines
Diff to previous 1.16 (colored)

add support for maildir tagging/folders.

ok gilles@
ok eric@ on previous versions of this patch

Revision 1.16 / (download) - annotate - [select for diffs], Tue Dec 13 22:04:35 2011 UTC (12 years, 5 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.15: +4 -4 lines
Diff to previous 1.15 (colored)

split user_backend.c into user.c and user_pwd.c to be consistent with the
backend scheme. Also rename USER_GETPWNAM to USER_PWD.

ok chl@ gilles@

Revision 1.15 / (download) - annotate - [select for diffs], Tue Dec 13 21:44:47 2011 UTC (12 years, 5 months ago) by gilles
Branch: MAIN
Changes since 1.14: +5 -5 lines
Diff to previous 1.14 (colored)

- introduce delivery backend API (delivery.c)
- 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@

Revision 1.14 / (download) - annotate - [select for diffs], Mon Dec 12 16:45:16 2011 UTC (12 years, 5 months ago) by chl
Branch: MAIN
Changes since 1.13: +1 -4 lines
Diff to previous 1.13 (colored)

remove comments about dead "struct delivery"

"obvious ok" gilles@

Revision 1.13 / (download) - annotate - [select for diffs], Thu Dec 8 17:00:28 2011 UTC (12 years, 6 months ago) by todd
Branch: MAIN
Changes since 1.12: +3 -3 lines
Diff to previous 1.12 (colored)

rename struct user to struct mta_user to avoid namespace conflict elsewhere
ok chl@ & gilles@

Revision 1.12 / (download) - annotate - [select for diffs], Tue Oct 25 10:25:51 2011 UTC (12 years, 7 months ago) by eric
Branch: MAIN
Changes since 1.11: +13 -3 lines
Diff to previous 1.11 (colored)

rewrite the sender user/domain as specified in the manpage when matching
a "relay... as" rule.

mikeb can now send mails.

ok gilles@ mikeb@

Revision 1.11 / (download) - annotate - [select for diffs], Sun Oct 23 09:30:07 2011 UTC (12 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.10: +56 -55 lines
Diff to previous 1.10 (colored)

fsqueue no longer stores envelopes by dumping the structure, instead use a
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@

Revision 1.10 / (download) - annotate - [select for diffs], Sat Oct 22 18:03:27 2011 UTC (12 years, 7 months ago) by eric
Branch: MAIN
Changes since 1.9: +4 -3 lines
Diff to previous 1.9 (colored)

correctly set relay when expanding envelopes

ok gilles@

Revision 1.9 / (download) - annotate - [select for diffs], Sat Aug 27 22:32:41 2011 UTC (12 years, 9 months ago) by gilles
Branch: MAIN
Changes since 1.8: +1 -2 lines
Diff to previous 1.8 (colored)

initial support for a session-time filtering API

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

Revision 1.8 / (download) - annotate - [select for diffs], Mon Jul 4 19:44:31 2011 UTC (12 years, 11 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.7: +2 -2 lines
Diff to previous 1.7 (colored)

%u in format string is rcpt.user not rcpt.domain

From Tim van der Molen <tbvdm@xs4all.nl>

Revision 1.7 / (download) - annotate - [select for diffs], Thu Jun 9 17:41:52 2011 UTC (13 years ago) by gilles
Branch: MAIN
Changes since 1.6: +5 -1 lines
Diff to previous 1.6 (colored)

'relay as' and 'relay via as' rules allow smtpd to rewrite the user part,
the domain part or the entire address of the sender at the SMTP sesssion
level. this is not masquerade but allows smtpd to communicate with hosts
that do a check of SMTP sender fqdn.

sent to tech@, a couple 'no regression' feedbacks

Revision 1.6 / (download) - annotate - [select for diffs], Sat May 21 18:11:40 2011 UTC (13 years ago) by gilles
Branch: MAIN
Changes since 1.5: +1 -8 lines
Diff to previous 1.5 (colored)

these log_debug()s should not have been committed :)

Revision 1.5 / (download) - annotate - [select for diffs], Sat May 21 18:04:51 2011 UTC (13 years ago) by gilles
Branch: MAIN
Changes since 1.4: +16 -3 lines
Diff to previous 1.4 (colored)

when a user add himself to his own ~/.forward, the delivery method was not
reset by ruleset matching and since it was cleared upon entering
lka_session_resolve_node(), it would trigger a fatal().

Revision 1.4 / (download) - annotate - [select for diffs], Tue May 17 18:54:32 2011 UTC (13 years ago) by gilles
Branch: MAIN
Changes since 1.3: +22 -15 lines
Diff to previous 1.3 (colored)

introduce new user_backend API for smtpd to lookup the users it wants to
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.

Revision 1.3 / (download) - annotate - [select for diffs], Mon May 16 21:52:53 2011 UTC (13 years ago) by gilles
Branch: MAIN
Changes since 1.2: +1 -2 lines
Diff to previous 1.2 (colored)

remove useless assignation

Revision 1.2 / (download) - annotate - [select for diffs], Mon May 16 21:42:03 2011 UTC (13 years ago) by gilles
Branch: MAIN
Changes since 1.1: +11 -1 lines
Diff to previous 1.1 (colored)

when a C_VDOM recipient expands to a local user, envelope expansion will
reprocess the envelope. since the original condition we matched is still
C_VDOM, it triggers an expansion loop causing recipient to be rejected.

this *should* fix the issue experienced by armani@, it does on my laptop.

Revision 1.1 / (download) - annotate - [select for diffs], Mon May 16 21:05:51 2011 UTC (13 years ago) by gilles
Branch: MAIN

murder struct path and make sure smtpd uses simpler structures that do not
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.

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.