OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.48 / (download) - annotate - [select for diffs], Mon Jun 14 17:58:16 2021 UTC (2 years, 11 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, 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, HEAD
Changes since 1.47: +1 -13 lines
Diff to previous 1.47 (colored)

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

ok jung@

Revision 1.47 / (download) - annotate - [select for diffs], Mon Nov 25 14:18:33 2019 UTC (4 years, 6 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.46: +10 -8 lines
Diff to previous 1.46 (colored)

store smtp session username in envelope and allow ruleset to match specific
users or mailaddr:

match auth "gilles@openbsd.org" [...]
match auth "@openbsd.org" [...]

ok eric@

Revision 1.46 / (download) - annotate - [select for diffs], Tue Nov 12 20:21:46 2019 UTC (4 years, 6 months ago) by gilles
Branch: MAIN
Changes since 1.45: +6 -3 lines
Diff to previous 1.45 (colored)

fix a logic bug in ruleset matching that makes `from socket` rules possibly
crash depending on how the ruleset is crafted.

Revision 1.45 / (download) - annotate - [select for diffs], Mon Nov 4 00:05:38 2019 UTC (4 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.44: +8 -2 lines
Diff to previous 1.44 (colored)

fix a possible crash when combining "from rdns", nested virtual aliases and
a particular sequence of rules causing "from rdns" to be hit again from the
expanded aliases. this requires crafting a specific configuration.

Revision 1.44 / (download) - annotate - [select for diffs], Sun Aug 11 17:23:12 2019 UTC (4 years, 9 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.43: +6 -2 lines
Diff to previous 1.43 (colored)

add 'from rdns' to ruleset match criterias making it possible to match
envelopes created by sessions that had or did not have an rDNS:

    match from rdns [...] action "local"
    match !from rdns [...] reject

Revision 1.43 / (download) - annotate - [select for diffs], Sun Aug 11 10:54:44 2019 UTC (4 years, 9 months ago) by gilles
Branch: MAIN
Changes since 1.42: +6 -8 lines
Diff to previous 1.42 (colored)

properly implement the "from socket" match criteria, so it is now possible
to specifically match a connection that happened through the local enqueuer

Revision 1.42 / (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.41: +8 -8 lines
Diff to previous 1.41 (colored)

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

ok gilles@

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

simplify code

ok gilles@

Revision 1.40 / (download) - annotate - [select for diffs], Wed Dec 26 15:55:09 2018 UTC (5 years, 5 months ago) by eric
Branch: MAIN
Changes since 1.39: +8 -25 lines
Diff to previous 1.39 (colored)

introduce a table_match() function to check for a key in a table

ok gilles@

Revision 1.39 / (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.38: +2 -2 lines
Diff to previous 1.38 (colored)

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

ok gilles@

Revision 1.38 / (download) - annotate - [select for diffs], Sat Dec 22 08:54:02 2018 UTC (5 years, 5 months ago) by gilles
Branch: MAIN
Changes since 1.37: +6 -2 lines
Diff to previous 1.37 (colored)

introduce new matching criteria 'from rdns' to match sessions based on rDNS
of the client, works with literal and tables, both string and regex:

	match from rdns "mx1.poolp.org" for any action blahblah

Revision 1.37 / (download) - annotate - [select for diffs], Fri Dec 21 21:35:29 2018 UTC (5 years, 5 months ago) by gilles
Branch: MAIN
Changes since 1.36: +31 -7 lines
Diff to previous 1.36 (colored)

since we already support regex lookups in tables for builtin filters, let's
also support regex lookups in match rule criterias performing table lookups

ok millert@

Revision 1.36 / (download) - annotate - [select for diffs], Sat Jun 16 19:41:26 2018 UTC (5 years, 11 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.35: +7 -7 lines
Diff to previous 1.35 (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.35 / (download) - annotate - [select for diffs], Thu May 24 11:38:24 2018 UTC (6 years ago) by gilles
Branch: MAIN
Changes since 1.34: +180 -94 lines
Diff to previous 1.34 (colored)

switch smtpd to new grammar

ok eric@

Revision 1.34 / (download) - annotate - [select for diffs], Mon Feb 13 12:23:47 2017 UTC (7 years, 3 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.33: +5 -3 lines
Diff to previous 1.33 (colored)

allow negation of authenticated keyword:
	accept ! authenticated [...]

ok sunil@, jung@

Revision 1.33 / (download) - annotate - [select for diffs], Wed Aug 31 15:24:04 2016 UTC (7 years, 9 months ago) by gilles
Branch: MAIN
Changes since 1.32: +4 -1 lines
Diff to previous 1.32 (colored)

introduce "authenticated" parameter so rules may apply to authenticated
sessions specifically

ok eric@, sunil@, jung@

Revision 1.32 / (download) - annotate - [select for diffs], Tue Oct 27 20:14:19 2015 UTC (8 years, 7 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.31: +1 -8 lines
Diff to previous 1.31 (colored)

aliases_virtual_check() has been unneeded for a while

ok jung@, ok sunil@, ok millert@

Revision 1.31 / (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_8, OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.30: +2 -1 lines
Diff to previous 1.30 (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.30 / (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, OPENBSD_5_6
Changes since 1.29: +3 -3 lines
Diff to previous 1.29 (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.29 / (download) - annotate - [select for diffs], Wed Nov 6 10:01:29 2013 UTC (10 years, 7 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.28: +33 -17 lines
Diff to previous 1.28 (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.28 / (download) - annotate - [select for diffs], Fri May 24 17:03:14 2013 UTC (11 years ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.27: +1 -2 lines
Diff to previous 1.27 (colored)

sync with OpenSMTPD 5.3.2

ok gilles@

Revision 1.27 / (download) - annotate - [select for diffs], Sat Jan 26 09:37:23 2013 UTC (11 years, 4 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.26: +67 -144 lines
Diff to previous 1.26 (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.26 / (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.25: +4 -6 lines
Diff to previous 1.25 (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.25 / (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.24: +35 -17 lines
Diff to previous 1.24 (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.24 / (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.23: +4 -4 lines
Diff to previous 1.23 (colored)

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

ok eric@, chl@

Revision 1.23 / (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.22: +7 -9 lines
Diff to previous 1.22 (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.22 / (download) - annotate - [select for diffs], Sat Sep 15 15:12:11 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.21: +6 -1 lines
Diff to previous 1.21 (colored)

When enqueueing from the local socket, the input address is faked as "::1".
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@

Revision 1.21 / (download) - annotate - [select for diffs], Sun May 13 00:10:49 2012 UTC (12 years ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.20: +42 -23 lines
Diff to previous 1.20 (colored)

- cleanup parse.y by removing lots of code that should not have been there,
  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" [...]

Revision 1.20 / (download) - annotate - [select for diffs], Sun Oct 23 09:30:07 2011 UTC (12 years, 7 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.19: +5 -5 lines
Diff to previous 1.19 (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.19 / (download) - annotate - [select for diffs], Sat May 21 18:39:03 2011 UTC (13 years ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.18: +1 -2 lines
Diff to previous 1.18 (colored)

remove annoying log_debug()

Revision 1.18 / (download) - annotate - [select for diffs], Mon May 16 21:05:52 2011 UTC (13 years ago) by gilles
Branch: MAIN
Changes since 1.17: +14 -8 lines
Diff to previous 1.17 (colored)

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.

Revision 1.17 / (download) - annotate - [select for diffs], Sun May 1 12:57:11 2011 UTC (13 years, 1 month ago) by eric
Branch: MAIN
Changes since 1.16: +6 -6 lines
Diff to previous 1.16 (colored)

the smtpd env is meant to be global, so do not pass it all around.

discussed with and ok gilles@

Revision 1.16 / (download) - annotate - [select for diffs], Sun Apr 17 13:36:07 2011 UTC (13 years, 1 month ago) by gilles
Branch: MAIN
Changes since 1.15: +13 -10 lines
Diff to previous 1.15 (colored)

cleanups, cosmethic changes, functions that should be static are now static
no functionnal change

Revision 1.15 / (download) - annotate - [select for diffs], Sun Nov 28 14:35:58 2010 UTC (13 years, 6 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.14: +1 -6 lines
Diff to previous 1.14 (colored)

remove all unused headers

Revision 1.14 / (download) - annotate - [select for diffs], Sun Nov 28 13:56:43 2010 UTC (13 years, 6 months ago) by gilles
Branch: MAIN
Changes since 1.13: +3 -1 lines
Diff to previous 1.13 (colored)

a bit of .h cleanups, no functionnal change

Revision 1.13 / (download) - annotate - [select for diffs], Thu May 27 15:36:04 2010 UTC (14 years ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.12: +23 -35 lines
Diff to previous 1.12 (colored)

when a rule has two conditions (ie: accept for { domain foo, domain bar } )
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

Revision 1.12 / (download) - annotate - [select for diffs], Wed Apr 21 19:53:16 2010 UTC (14 years, 1 month ago) by gilles
Branch: MAIN
Changes since 1.11: +2 -2 lines
Diff to previous 1.11 (colored)

map_lookup() takes an additionnal parameter of type enum map_kind which
will be used to select the appropriate map parser. make sure every call
to map_lookup() is updated. map_lookup() currently ignores the value.

Revision 1.11 / (download) - annotate - [select for diffs], Sun Feb 28 12:23:12 2010 UTC (14 years, 3 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.10: +4 -3 lines
Diff to previous 1.10 (colored)

the netmask fix I commited a couple days ago lacked the AF_INET6 bits,
this commit fixes pr user/6328

bug reported and fix verified by Martin Hedenfalk <martinh@bzero.se>

Revision 1.10 / (download) - annotate - [select for diffs], Fri Feb 26 15:06:40 2010 UTC (14 years, 3 months ago) by gilles
Branch: MAIN
Changes since 1.9: +53 -34 lines
Diff to previous 1.9 (colored)

- fix netmask matching for AF_INET, it was broken in many ways, problem
  was reported by nicm@ which spent a couple hours with me trying to
  understand what was causing the bug, and helping me write and test fix.

Revision 1.9 / (download) - annotate - [select for diffs], Wed Feb 17 13:47:31 2010 UTC (14 years, 3 months ago) by gilles
Branch: MAIN
Changes since 1.8: +2 -2 lines
Diff to previous 1.8 (colored)

the map api becomes backend-agnostic with initial support for db(3) and
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@

Revision 1.8 / (download) - annotate - [select for diffs], Tue Nov 3 22:57:41 2009 UTC (14 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.7: +16 -3 lines
Diff to previous 1.7 (colored)

teach makemap how to build a set, which is a map containing only keys.
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

Revision 1.7 / (download) - annotate - [select for diffs], Tue Nov 3 19:13:34 2009 UTC (14 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.6: +4 -10 lines
Diff to previous 1.6 (colored)

- remove a useless member of struct cond
- 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@

Revision 1.6 / (download) - annotate - [select for diffs], Tue Nov 3 17:50:13 2009 UTC (14 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.5: +1 -4 lines
Diff to previous 1.5 (colored)

remove annoying log_debug

Revision 1.5 / (download) - annotate - [select for diffs], Mon Oct 19 20:48:13 2009 UTC (14 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.4: +9 -3 lines
Diff to previous 1.4 (colored)

currently, smtpd is capable of having multiple listeners with different
options but they will all share the same ruleset. this means that there
is no way to have a rule apply to a session established on one listener
but not applied on another.

this commit brings initial support for tagging listeners and having the
rules able to match these specific listeners. The following will define
a rule which will only apply to interfaces tagged as "mynet":

listen on lo0			# implicit lo0 tag
listen on fxp0 tag mynet
listen on fxp1 tag mynet

accept on mynet for domain "example.org" deliver to mbox

Revision 1.4 / (download) - annotate - [select for diffs], Mon Oct 12 18:14:51 2009 UTC (14 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.3: +4 -2 lines
Diff to previous 1.3 (colored)

fix a bug where matching a "for all" rule with multiple condition will not
let us know which condition we matched.

Revision 1.3 / (download) - annotate - [select for diffs], Sun Oct 11 17:40:49 2009 UTC (14 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.2: +14 -1 lines
Diff to previous 1.2 (colored)

implement proper virtual domains instead of faking them on top of primary
domains. this means that:

- virtual domains no longer deliver to a local user when not told to
- they no longer attempt to resolve aliases when not told to
- they no longer need an explicit rule in smtpd.conf for EACH domain
- the "virtual" map is no longer hardcoded
- smtpd no longer needs a restart to support a new domain

instead we introduce the: accept for virtual map "mapname" [...] syntax
which refers to a map that can be manipulated at runtime.

idea discussed and okayd with jacekm@

Revision 1.2 / (download) - annotate - [select for diffs], Wed Oct 7 13:29:40 2009 UTC (14 years, 8 months ago) by jacekm
Branch: MAIN
Changes since 1.1: +1 -3 lines
Diff to previous 1.1 (colored)

remove noisy log_debug, requested by gilles@

Revision 1.1 / (download) - annotate - [select for diffs], Mon Jun 1 22:51:47 2009 UTC (15 years ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6

add new file ruleset.c with code related to the ruleset matching, and kill
the two or three "almost" identical versions of ruleset matching loops from
lka and mfa by having one unified function in ruleset.c; ok jacekm@

while at it, bring maildir support back to life; trivial one-liner by me

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.