History log of /openbsd-current/usr.sbin/smtpd/table.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.53 28-May-2024 op

actually honour the services supported by the proc tables

ok gilles@


# 1.52 07-May-2024 op

change the smtpd table protocol

Using imsg for the "proc" table (external programs) has proven quite
painful in practice since a lot of smtpd internals (structs, enums,
etc..) have to be kept in sync with the various tables implementations.

Instead, a filter-like protocol for tables decouples the implementations
and allows to write and test tables easily.

The new text-based transport protocol is documented in the (added)
smtpd-tables(7) manpage.

The old imsg protocol is no longer supported and existing tables have to
be converted. In particular, users of opensmtpd-extras tables will need
install the new opensmtpd-table-* packages.

With lots of suggestions and improvements from gilles and a tweak
from Philipp (philipp+openbsd [at] bureaucracy [dot] de), thanks!

ok gilles


Revision tags: OPENBSD_7_5_BASE
# 1.51 04-Jan-2024 op

fix IPv6 addresses table lookups

Rework parse_sockaddr() to not reach inet_pton() with a brace-wrapped
IPv6 address.

Issue reported by Kirill Miazine.
ok millert@


Revision tags: OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.50 14-Jun-2021 eric

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

ok jung@


Revision tags: OPENBSD_6_9_BASE
# 1.49 23-Dec-2020 martijn

Use regfree after we're done with preg.

From gilles@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.48 10-Jan-2019 eric

report errno in debug logs and other minor cleanups.

ok gilles@


# 1.47 28-Dec-2018 eric

introduce table_dump() and tweak format

ok gilles@


# 1.46 28-Dec-2018 eric

simplify code

ok gilles@


# 1.45 28-Dec-2018 eric

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

ok gilles@


# 1.44 28-Dec-2018 eric

remove unused members in struct table


# 1.43 27-Dec-2018 eric

table_fetch() always expect a valid dst pointer.

ok gilles@


# 1.42 27-Dec-2018 eric

introduce dump() and add() table methods, only implemented for static tables.

ok gilles@


# 1.41 27-Dec-2018 eric

pass the table pointer to the lookup()/fecth() methods

ok gilles@


# 1.40 27-Dec-2018 eric

change the close() method to take the table pointer

ok gilles


# 1.39 27-Dec-2018 eric

Make the backend open method return an int to report success.
The implementation is responsible for setting the handle pointer
as needed.

ok gilles@


# 1.38 26-Dec-2018 eric

reorder parameters for consistency


# 1.37 26-Dec-2018 eric

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

ok gilles@


# 1.36 26-Dec-2018 eric

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

ok gilles@


# 1.35 26-Dec-2018 eric

move the table backend name in the backend struct.
remove unused function.

ok gilles@


# 1.34 23-Dec-2018 eric

Simplify the table backend interface: lookup results are returned
as strings, and parsing is handled by the upper layer.

ok gilles@


# 1.33 21-Dec-2018 gilles

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@


# 1.32 02-Nov-2018 gilles

add REG_NOSUB to flags in regcompile

suggested by jung@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.52 07-May-2024 op

change the smtpd table protocol

Using imsg for the "proc" table (external programs) has proven quite
painful in practice since a lot of smtpd internals (structs, enums,
etc..) have to be kept in sync with the various tables implementations.

Instead, a filter-like protocol for tables decouples the implementations
and allows to write and test tables easily.

The new text-based transport protocol is documented in the (added)
smtpd-tables(7) manpage.

The old imsg protocol is no longer supported and existing tables have to
be converted. In particular, users of opensmtpd-extras tables will need
install the new opensmtpd-table-* packages.

With lots of suggestions and improvements from gilles and a tweak
from Philipp (philipp+openbsd [at] bureaucracy [dot] de), thanks!

ok gilles


Revision tags: OPENBSD_7_5_BASE
# 1.51 04-Jan-2024 op

fix IPv6 addresses table lookups

Rework parse_sockaddr() to not reach inet_pton() with a brace-wrapped
IPv6 address.

Issue reported by Kirill Miazine.
ok millert@


Revision tags: OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.50 14-Jun-2021 eric

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

ok jung@


Revision tags: OPENBSD_6_9_BASE
# 1.49 23-Dec-2020 martijn

Use regfree after we're done with preg.

From gilles@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.48 10-Jan-2019 eric

report errno in debug logs and other minor cleanups.

ok gilles@


# 1.47 28-Dec-2018 eric

introduce table_dump() and tweak format

ok gilles@


# 1.46 28-Dec-2018 eric

simplify code

ok gilles@


# 1.45 28-Dec-2018 eric

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

ok gilles@


# 1.44 28-Dec-2018 eric

remove unused members in struct table


# 1.43 27-Dec-2018 eric

table_fetch() always expect a valid dst pointer.

ok gilles@


# 1.42 27-Dec-2018 eric

introduce dump() and add() table methods, only implemented for static tables.

ok gilles@


# 1.41 27-Dec-2018 eric

pass the table pointer to the lookup()/fecth() methods

ok gilles@


# 1.40 27-Dec-2018 eric

change the close() method to take the table pointer

ok gilles


# 1.39 27-Dec-2018 eric

Make the backend open method return an int to report success.
The implementation is responsible for setting the handle pointer
as needed.

ok gilles@


# 1.38 26-Dec-2018 eric

reorder parameters for consistency


# 1.37 26-Dec-2018 eric

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

ok gilles@


# 1.36 26-Dec-2018 eric

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

ok gilles@


# 1.35 26-Dec-2018 eric

move the table backend name in the backend struct.
remove unused function.

ok gilles@


# 1.34 23-Dec-2018 eric

Simplify the table backend interface: lookup results are returned
as strings, and parsing is handled by the upper layer.

ok gilles@


# 1.33 21-Dec-2018 gilles

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@


# 1.32 02-Nov-2018 gilles

add REG_NOSUB to flags in regcompile

suggested by jung@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.51 04-Jan-2024 op

fix IPv6 addresses table lookups

Rework parse_sockaddr() to not reach inet_pton() with a brace-wrapped
IPv6 address.

Issue reported by Kirill Miazine.
ok millert@


Revision tags: OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.50 14-Jun-2021 eric

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

ok jung@


Revision tags: OPENBSD_6_9_BASE
# 1.49 23-Dec-2020 martijn

Use regfree after we're done with preg.

From gilles@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.48 10-Jan-2019 eric

report errno in debug logs and other minor cleanups.

ok gilles@


# 1.47 28-Dec-2018 eric

introduce table_dump() and tweak format

ok gilles@


# 1.46 28-Dec-2018 eric

simplify code

ok gilles@


# 1.45 28-Dec-2018 eric

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

ok gilles@


# 1.44 28-Dec-2018 eric

remove unused members in struct table


# 1.43 27-Dec-2018 eric

table_fetch() always expect a valid dst pointer.

ok gilles@


# 1.42 27-Dec-2018 eric

introduce dump() and add() table methods, only implemented for static tables.

ok gilles@


# 1.41 27-Dec-2018 eric

pass the table pointer to the lookup()/fecth() methods

ok gilles@


# 1.40 27-Dec-2018 eric

change the close() method to take the table pointer

ok gilles


# 1.39 27-Dec-2018 eric

Make the backend open method return an int to report success.
The implementation is responsible for setting the handle pointer
as needed.

ok gilles@


# 1.38 26-Dec-2018 eric

reorder parameters for consistency


# 1.37 26-Dec-2018 eric

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

ok gilles@


# 1.36 26-Dec-2018 eric

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

ok gilles@


# 1.35 26-Dec-2018 eric

move the table backend name in the backend struct.
remove unused function.

ok gilles@


# 1.34 23-Dec-2018 eric

Simplify the table backend interface: lookup results are returned
as strings, and parsing is handled by the upper layer.

ok gilles@


# 1.33 21-Dec-2018 gilles

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@


# 1.32 02-Nov-2018 gilles

add REG_NOSUB to flags in regcompile

suggested by jung@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.50 14-Jun-2021 eric

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

ok jung@


Revision tags: OPENBSD_6_9_BASE
# 1.49 23-Dec-2020 martijn

Use regfree after we're done with preg.

From gilles@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.48 10-Jan-2019 eric

report errno in debug logs and other minor cleanups.

ok gilles@


# 1.47 28-Dec-2018 eric

introduce table_dump() and tweak format

ok gilles@


# 1.46 28-Dec-2018 eric

simplify code

ok gilles@


# 1.45 28-Dec-2018 eric

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

ok gilles@


# 1.44 28-Dec-2018 eric

remove unused members in struct table


# 1.43 27-Dec-2018 eric

table_fetch() always expect a valid dst pointer.

ok gilles@


# 1.42 27-Dec-2018 eric

introduce dump() and add() table methods, only implemented for static tables.

ok gilles@


# 1.41 27-Dec-2018 eric

pass the table pointer to the lookup()/fecth() methods

ok gilles@


# 1.40 27-Dec-2018 eric

change the close() method to take the table pointer

ok gilles


# 1.39 27-Dec-2018 eric

Make the backend open method return an int to report success.
The implementation is responsible for setting the handle pointer
as needed.

ok gilles@


# 1.38 26-Dec-2018 eric

reorder parameters for consistency


# 1.37 26-Dec-2018 eric

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

ok gilles@


# 1.36 26-Dec-2018 eric

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

ok gilles@


# 1.35 26-Dec-2018 eric

move the table backend name in the backend struct.
remove unused function.

ok gilles@


# 1.34 23-Dec-2018 eric

Simplify the table backend interface: lookup results are returned
as strings, and parsing is handled by the upper layer.

ok gilles@


# 1.33 21-Dec-2018 gilles

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@


# 1.32 02-Nov-2018 gilles

add REG_NOSUB to flags in regcompile

suggested by jung@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.49 23-Dec-2020 martijn

Use regfree after we're done with preg.

From gilles@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.48 10-Jan-2019 eric

report errno in debug logs and other minor cleanups.

ok gilles@


# 1.47 28-Dec-2018 eric

introduce table_dump() and tweak format

ok gilles@


# 1.46 28-Dec-2018 eric

simplify code

ok gilles@


# 1.45 28-Dec-2018 eric

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

ok gilles@


# 1.44 28-Dec-2018 eric

remove unused members in struct table


# 1.43 27-Dec-2018 eric

table_fetch() always expect a valid dst pointer.

ok gilles@


# 1.42 27-Dec-2018 eric

introduce dump() and add() table methods, only implemented for static tables.

ok gilles@


# 1.41 27-Dec-2018 eric

pass the table pointer to the lookup()/fecth() methods

ok gilles@


# 1.40 27-Dec-2018 eric

change the close() method to take the table pointer

ok gilles


# 1.39 27-Dec-2018 eric

Make the backend open method return an int to report success.
The implementation is responsible for setting the handle pointer
as needed.

ok gilles@


# 1.38 26-Dec-2018 eric

reorder parameters for consistency


# 1.37 26-Dec-2018 eric

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

ok gilles@


# 1.36 26-Dec-2018 eric

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

ok gilles@


# 1.35 26-Dec-2018 eric

move the table backend name in the backend struct.
remove unused function.

ok gilles@


# 1.34 23-Dec-2018 eric

Simplify the table backend interface: lookup results are returned
as strings, and parsing is handled by the upper layer.

ok gilles@


# 1.33 21-Dec-2018 gilles

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@


# 1.32 02-Nov-2018 gilles

add REG_NOSUB to flags in regcompile

suggested by jung@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.48 10-Jan-2019 eric

report errno in debug logs and other minor cleanups.

ok gilles@


# 1.47 28-Dec-2018 eric

introduce table_dump() and tweak format

ok gilles@


# 1.46 28-Dec-2018 eric

simplify code

ok gilles@


# 1.45 28-Dec-2018 eric

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

ok gilles@


# 1.44 28-Dec-2018 eric

remove unused members in struct table


# 1.43 27-Dec-2018 eric

table_fetch() always expect a valid dst pointer.

ok gilles@


# 1.42 27-Dec-2018 eric

introduce dump() and add() table methods, only implemented for static tables.

ok gilles@


# 1.41 27-Dec-2018 eric

pass the table pointer to the lookup()/fecth() methods

ok gilles@


# 1.40 27-Dec-2018 eric

change the close() method to take the table pointer

ok gilles


# 1.39 27-Dec-2018 eric

Make the backend open method return an int to report success.
The implementation is responsible for setting the handle pointer
as needed.

ok gilles@


# 1.38 26-Dec-2018 eric

reorder parameters for consistency


# 1.37 26-Dec-2018 eric

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

ok gilles@


# 1.36 26-Dec-2018 eric

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

ok gilles@


# 1.35 26-Dec-2018 eric

move the table backend name in the backend struct.
remove unused function.

ok gilles@


# 1.34 23-Dec-2018 eric

Simplify the table backend interface: lookup results are returned
as strings, and parsing is handled by the upper layer.

ok gilles@


# 1.33 21-Dec-2018 gilles

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@


# 1.32 02-Nov-2018 gilles

add REG_NOSUB to flags in regcompile

suggested by jung@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.47 28-Dec-2018 eric

introduce table_dump() and tweak format

ok gilles@


# 1.46 28-Dec-2018 eric

simplify code

ok gilles@


# 1.45 28-Dec-2018 eric

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

ok gilles@


# 1.44 28-Dec-2018 eric

remove unused members in struct table


# 1.43 27-Dec-2018 eric

table_fetch() always expect a valid dst pointer.

ok gilles@


# 1.42 27-Dec-2018 eric

introduce dump() and add() table methods, only implemented for static tables.

ok gilles@


# 1.41 27-Dec-2018 eric

pass the table pointer to the lookup()/fecth() methods

ok gilles@


# 1.40 27-Dec-2018 eric

change the close() method to take the table pointer

ok gilles


# 1.39 27-Dec-2018 eric

Make the backend open method return an int to report success.
The implementation is responsible for setting the handle pointer
as needed.

ok gilles@


# 1.38 26-Dec-2018 eric

reorder parameters for consistency


# 1.37 26-Dec-2018 eric

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

ok gilles@


# 1.36 26-Dec-2018 eric

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

ok gilles@


# 1.35 26-Dec-2018 eric

move the table backend name in the backend struct.
remove unused function.

ok gilles@


# 1.34 23-Dec-2018 eric

Simplify the table backend interface: lookup results are returned
as strings, and parsing is handled by the upper layer.

ok gilles@


# 1.33 21-Dec-2018 gilles

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@


# 1.32 02-Nov-2018 gilles

add REG_NOSUB to flags in regcompile

suggested by jung@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.46 28-Dec-2018 eric

simplify code

ok gilles@


# 1.45 28-Dec-2018 eric

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

ok gilles@


# 1.44 28-Dec-2018 eric

remove unused members in struct table


# 1.43 27-Dec-2018 eric

table_fetch() always expect a valid dst pointer.

ok gilles@


# 1.42 27-Dec-2018 eric

introduce dump() and add() table methods, only implemented for static tables.

ok gilles@


# 1.41 27-Dec-2018 eric

pass the table pointer to the lookup()/fecth() methods

ok gilles@


# 1.40 27-Dec-2018 eric

change the close() method to take the table pointer

ok gilles


# 1.39 27-Dec-2018 eric

Make the backend open method return an int to report success.
The implementation is responsible for setting the handle pointer
as needed.

ok gilles@


# 1.38 26-Dec-2018 eric

reorder parameters for consistency


# 1.37 26-Dec-2018 eric

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

ok gilles@


# 1.36 26-Dec-2018 eric

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

ok gilles@


# 1.35 26-Dec-2018 eric

move the table backend name in the backend struct.
remove unused function.

ok gilles@


# 1.34 23-Dec-2018 eric

Simplify the table backend interface: lookup results are returned
as strings, and parsing is handled by the upper layer.

ok gilles@


# 1.33 21-Dec-2018 gilles

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@


# 1.32 02-Nov-2018 gilles

add REG_NOSUB to flags in regcompile

suggested by jung@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.37 26-Dec-2018 eric

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

ok gilles@


# 1.36 26-Dec-2018 eric

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

ok gilles@


# 1.35 26-Dec-2018 eric

move the table backend name in the backend struct.
remove unused function.

ok gilles@


# 1.34 23-Dec-2018 eric

Simplify the table backend interface: lookup results are returned
as strings, and parsing is handled by the upper layer.

ok gilles@


# 1.33 21-Dec-2018 gilles

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@


# 1.32 02-Nov-2018 gilles

add REG_NOSUB to flags in regcompile

suggested by jung@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.34 23-Dec-2018 eric

Simplify the table backend interface: lookup results are returned
as strings, and parsing is handled by the upper layer.

ok gilles@


# 1.33 21-Dec-2018 gilles

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@


# 1.32 02-Nov-2018 gilles

add REG_NOSUB to flags in regcompile

suggested by jung@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.33 21-Dec-2018 gilles

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@


# 1.32 02-Nov-2018 gilles

add REG_NOSUB to flags in regcompile

suggested by jung@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.32 02-Nov-2018 gilles

add REG_NOSUB to flags in regcompile

suggested by jung@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.31 01-Nov-2018 gilles

introduce K_REGEX table type and table_regex_match(), unused for now

ok eric@


Revision tags: OPENBSD_6_4_BASE
# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@


# 1.30 16-Jun-2018 gilles

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@


# 1.29 31-May-2018 gilles

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@


# 1.28 29-May-2018 eric

missing case

ok gilles@


# 1.27 29-May-2018 eric

no need to parse and dump the relayhost in the lookup process.

ok gilles@


# 1.26 28-May-2018 eric

zero memory before calling text_to_relayhost()

fix issue reported by semarie@

ok gilles@


# 1.25 24-May-2018 gilles

switch smtpd to new grammar

ok eric@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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 tags: OPENBSD_6_2_BASE
# 1.24 01-May-2017 gilles

in function used for tracing, display unknown lookup types as "???"

diff from Wolf480pl


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.23 04-Jan-2016 jung

switch to /usr/local/libexec when looking for -extras and drop loop iterating
paths

this effectively reverts table.c r1.21 which was mainly introduced for a smooth
transition in -current

ok gilles


# 1.22 28-Dec-2015 jung

remove spaces after '!'

no binary change

ok millert


# 1.21 30-Nov-2015 gilles

when looking up tables, start in /usr/local/libexec before /usr/libexec, so
ports/packages can be installed in the proper place

ok jung@


# 1.20 23-Nov-2015 gilles

allow table API to lookup for mailaddr mappings

ok sunil@, ok jung@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 20-Jan-2015 deraadt

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.


# 1.18 14-Jan-2015 gilles

recipient and sender lists now support the user+TAG notation, allowing
among other things a secondary MX to filter recipients to be relayed to a
primary MX even if they are using tags. there are other nice things to do
with that feature, use your imagination.

tested and ok florian@, tested by several users for a few days too


Revision tags: OPENBSD_5_6_BASE
# 1.17 08-Jul-2014 eric

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@


# 1.16 09-May-2014 tedu

stop casting sizeof to int


# 1.15 19-Apr-2014 gilles

these snprintf() calls can't possibly truncate because they copy data from
buffers that are already protected against truncation and that do not
exceed the destination buffer size when copied together ...

however, i think we should add checks here too because it'll help us catch
errors in table backends when adding new ones if we miss a truncation check
there.


# 1.14 19-Apr-2014 gilles

(void) cast strlcat() and snprintf() that cannot truncate

be a bit more strict with an strlcat() truncation by causing it to fail in
table_create() instead of later in parse.y - in both cases, this would
cause smtpd to fatal() at startup if a table has a config file too large


Revision tags: OPENBSD_5_5_BASE
# 1.13 26-Dec-2013 eric

bcopy -> memmove
bzero -> memset


# 1.12 28-Nov-2013 eric

allow subdomain matching in mailaddr tables


# 1.11 18-Nov-2013 eric

change dict_poproot() prototype: do not take key placeholder parameter as
it can't work that way.


# 1.10 28-Oct-2013 eric

accept credentials formated as "<user> <passwd>"


# 1.9 27-Oct-2013 eric

fix parsing of inet6 addresses when prefixed with "IPv6:"


# 1.8 26-Oct-2013 eric

%i -> %d in format strings


Revision tags: OPENBSD_5_4_BASE
# 1.7 20-Jul-2013 eric

Update ldap and sqlite table backends and provide them as external backends.


# 1.6 19-Jul-2013 eric

Add a table_proc backend for delegating table lookups to another
process. Stop building experimental table_sqlite and table_ldap as
they will be provided as external backends.


# 1.5 03-Jun-2013 eric

lowercase the key when adding an entry to a static table, since the
lookups are done on lowercase strings. warn about duplicates entries
and avoid to leak memory.

ok gilles@


# 1.4 24-May-2013 eric

sync with OpenSMTPD 5.3.2

ok gilles@


Revision tags: OPENBSD_5_3_BASE
# 1.3 05-Feb-2013 gilles

unbreak broken smtpctl table update

fix by eric and I, ok eric@


# 1.2 05-Feb-2013 gilles

- 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


# 1.1 26-Jan-2013 gilles

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@