OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.159 / (download) - annotate - [select for diffs], Sun Jun 2 23:26:39 2024 UTC (6 days, 3 hours ago) by jsg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.158: +1 -3 lines
Diff to previous 1.158 (colored)

remove prototypes with no matching function
leave prototypes with functions in OpenSMTPD-extras
ok op@

Revision 1.158 / (download) - annotate - [select for diffs], Mon May 13 06:48:26 2024 UTC (3 weeks, 5 days ago) by jsg
Branch: MAIN
Changes since 1.157: +11 -9 lines
Diff to previous 1.157 (colored)

fix some leaks; ok op@

Revision 1.157 / (download) - annotate - [select for diffs], Thu May 2 18:14:33 2024 UTC (5 weeks, 2 days ago) by op
Branch: MAIN
Changes since 1.156: +16 -24 lines
Diff to previous 1.156 (colored)

unbreak parsing of IPv6 addresses in file-backed table(5)s

The file parser splits the line on the ':' character too for key-value
tables, and so mis-parses IPv6 addresses.  The "::1 localhost" example
in table(5) is actually parsed as key "" and value ":1 localhost".

For list tables, the "# @list" marker can be used as a workaround, but
for key-valued the parser has to be fixed.

There are also some weird edge cases when splitting the lines.

Now the parser always splits on the first whitespace or colon, and then
strips the spaces.  For lines starting with '[' the parser will jump to
the matching ']' before attempting to split.  So, for example:

	[::1]:localhost		becomes	"[::1]" -> "localhost"
	[::1] example.org	becomes	"[::1]" -> "example.org"
	foo: bar		becomes "foo" -> "bar"
	foo::bar		becomes "foo" -> ":bar"
	foo : bar		becomes "foo" -> ": bar"

etc...

This only affects the parser for file table(5)s and makemap(8).  Inline
tables or "proc" tables are unaffected.

ok gilles@

Revision 1.156 / (download) - annotate - [select for diffs], Sun Feb 11 09:24:26 2024 UTC (3 months, 3 weeks ago) by op
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5
Changes since 1.155: +73 -1 lines
Diff to previous 1.155 (colored)

unify smtpd and makemap table parser

These are supposed to parse the same file format but have subtle
difference in the handling of comments, continuation lines and escaping.

Converge both to the simpler smtpd parser which doesn't handle
continuation lines nor escaping, and support comments only at the start
of the line.

improvements and ok millert@

Revision 1.155 / (download) - annotate - [select for diffs], Wed Jan 3 08:11:15 2024 UTC (5 months ago) by op
Branch: MAIN
Changes since 1.154: +25 -1 lines
Diff to previous 1.154 (colored)

relax ORCPT syntax validation

We expected the ORCPT parameter to be a valid rfc822 address.  This is
wrong on multiple levels:

 - any other IANA-registered "addr-type" can be used
 - the parameter may be encoded and we didn't decode it prior validation
 - RFC3461 explicitly states that "[..] the address associated with the
   ORCPT keyword is NOT constrained to conform to the syntax rules for
   that 'addr-type'".

Instead, just validate the xtext and preserve the ORCPT value as-is.

Issue originally reported by Tim Kuijsten, Tassilo Philipp and others.

ok millert@

Revision 1.154 / (download) - annotate - [select for diffs], Mon Jun 14 17:58:16 2021 UTC (2 years, 11 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.153: +2 -16 lines
Diff to previous 1.153 (colored)

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

ok jung@

Revision 1.153 / (download) - annotate - [select for diffs], Wed Mar 31 19:09:19 2021 UTC (3 years, 2 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.152: +5 -7 lines
Diff to previous 1.152 (colored)

turn log_trace() into a macro to prevent evaluating the format string
parameters when tracing is not enabled.

ok millert@

Revision 1.152 / (download) - annotate - [select for diffs], Sun Nov 29 20:07:38 2020 UTC (3 years, 6 months ago) by tb
Branch: MAIN
Changes since 1.151: +2 -2 lines
Diff to previous 1.151 (colored)

Sync bsnprintf() with ldapd/util.c r1.13

Pointed out by jmatthew and requested by florian.

Revision 1.151 / (download) - annotate - [select for diffs], Mon Feb 24 23:54:28 2020 UTC (4 years, 3 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.150: +3 -3 lines
Diff to previous 1.150 (colored)

Cast argument of ctype(3) macros to unsigned char, not int.
Similar to a diff from Hiltjo Posthum.  OK jung@ deraadt@

Revision 1.150 / (download) - annotate - [select for diffs], Thu Oct 3 04:49:12 2019 UTC (4 years, 8 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.149: +2 -1 lines
Diff to previous 1.149 (colored)

fix memory leak in error code path

Revision 1.149 / (download) - annotate - [select for diffs], Mon Sep 30 08:31:41 2019 UTC (4 years, 8 months ago) by martijn
Branch: MAIN
Changes since 1.148: +1 -60 lines
Diff to previous 1.148 (colored)

Allow maildir and mbox MDAs to tempfail on situations that might be
resolved over time.

While here remove mkdirs component from utils.c, which isn't used anywhere.

OK gilles@, millert@

Revision 1.148 / (download) - annotate - [select for diffs], Sun Sep 29 10:03:49 2019 UTC (4 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.147: +21 -1 lines
Diff to previous 1.147 (colored)

SRS uses base64 encoding for the checksum, however while this is ok when we
only have MTA in the loop, some implementations like Dovecot's LMTP dislike
finding '/' in an e-mail address. Since checksum is meant to be verified at
the MX that generated the SRS encoding, use alternate rfc354 base64 encode,
swapping '/' with '_' and '+' with '-'.

ok eric@ millert@

Revision 1.147 / (download) - annotate - [select for diffs], Wed Aug 28 19:46:20 2019 UTC (4 years, 9 months ago) by eric
Branch: MAIN
Changes since 1.146: +27 -23 lines
Diff to previous 1.146 (colored)

change valid_domainname() to accept a trailing dot.

ok millert@

Revision 1.146 / (download) - annotate - [select for diffs], Fri Aug 23 12:09:41 2019 UTC (4 years, 9 months ago) by eric
Branch: MAIN
Changes since 1.145: +13 -2 lines
Diff to previous 1.145 (colored)

martijn@ found a regression so revert to the old behavior for now

Revision 1.145 / (download) - annotate - [select for diffs], Fri Aug 23 07:09:52 2019 UTC (4 years, 9 months ago) by eric
Branch: MAIN
Changes since 1.144: +35 -10 lines
Diff to previous 1.144 (colored)

res_hnok() is too lenient wrt to acceptable domain name in mail addresses.
replace it with a valid_domainname() check that implements something closer
to RFC 5321, but still usable in real-life.

ok gilles@ millert@

Revision 1.144 / (download) - annotate - [select for diffs], Sat Aug 10 15:46:22 2019 UTC (4 years, 10 months ago) by gilles
Branch: MAIN
Changes since 1.143: +7 -2 lines
Diff to previous 1.143 (colored)

enforce domain length check in valid_domainpart(), checking it in caller is
not the proper place, also since helo uses valid_domainpart(), such a check
would have indirectly prevented last weeks errata.

Revision 1.143 / (download) - annotate - [select for diffs], Sat Aug 10 09:35:43 2019 UTC (4 years, 10 months ago) by gilles
Branch: MAIN
Changes since 1.142: +4 -1 lines
Diff to previous 1.142 (colored)

valid_domainpart() uses res_hnok() internally which considers the hostnames
ending with a dot to be valid. add a check to make sure that if domain part
ends with a dot, it is rejected as it should.

issue reported by Hans Freitag <hans.freitag@conesphere.com>

Revision 1.142 / (download) - annotate - [select for diffs], Wed Jul 3 03:24:03 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.141: +2 -2 lines
Diff to previous 1.141 (colored)

snprintf/vsnprintf return < 0 on error, rather than -1.

Revision 1.141 / (download) - annotate - [select for diffs], Fri Jun 28 13:32:51 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.140: +3 -3 lines
Diff to previous 1.140 (colored)

When system calls indicate an error they return -1, not some arbitrary
value < 0.  errno is only updated in this case.  Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.

Revision 1.140 / (download) - annotate - [select for diffs], Wed Jan 30 21:33:34 2019 UTC (5 years, 4 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.139: +1 -48 lines
Diff to previous 1.139 (colored)

missed in previous revert, function not called anymore

Revision 1.139 / (download) - annotate - [select for diffs], Wed Jan 30 14:21:01 2019 UTC (5 years, 4 months ago) by gilles
Branch: MAIN
Changes since 1.138: +48 -1 lines
Diff to previous 1.138 (colored)

don't be too strict with .forward permissions, it's ok to process it if the
group has write access, it's not ok if the world has write access.

ok eric@

Revision 1.138 / (download) - annotate - [select for diffs], Wed Oct 31 16:32:12 2018 UTC (5 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.137: +16 -1 lines
Diff to previous 1.137 (colored)

add helper valid_smtp_response() to be used in upcoming commits

Revision 1.137 / (download) - annotate - [select for diffs], Sun Sep 2 21:06:44 2018 UTC (5 years, 9 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.136: +2 -2 lines
Diff to previous 1.136 (colored)

mailaddr matching was working for the exact and domain match, but not when
only a user-part was supplied.

ok millert@ and eric@

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

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

ok millert@

Revision 1.135 / (download) - annotate - [select for diffs], Tue May 29 18:16:14 2018 UTC (6 years ago) by gilles
Branch: MAIN
Changes since 1.134: +19 -1 lines
Diff to previous 1.134 (colored)

provide mail user agents with the same environments as Postfix

ok millert@, eric@

Revision 1.134 / (download) - annotate - [select for diffs], Thu Apr 26 20:57:59 2018 UTC (6 years, 1 month ago) by eric
Branch: MAIN
Changes since 1.133: +2 -1 lines
Diff to previous 1.133 (colored)

sync log.h with other daemons

ok gilles@

Revision 1.133 / (download) - annotate - [select for diffs], Tue Jan 30 12:44:55 2018 UTC (6 years, 4 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.132: +1 -8 lines
Diff to previous 1.132 (colored)

don't reject smtp responses containing non-printable chars as long
as the status is valid. use strnvis() for displaying status lines
in "smtpctl show queue".

ok gilles@ sunil@

Revision 1.132 / (download) - annotate - [select for diffs], Mon Jan 9 14:49:22 2017 UTC (7 years, 5 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.131: +2 -2 lines
Diff to previous 1.131 (colored)

Stop accessing verbose and debug variables from log.c directly.

This replaces log_verbose() and "extern int verbose" with the two functions
log_setverbose() and log_getverbose().

Pointed out by benno@
OK krw@ eric@ gilles@ (OK gilles@ for the snmpd bits as well)

Revision 1.131 / (download) - annotate - [select for diffs], Mon Jan 9 09:53:23 2017 UTC (7 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.130: +25 -1 lines
Diff to previous 1.130 (colored)

smtpd joins the 7 other daemons that share the same log.c file.

The only major difference was the "log_trace" concept that is only
used by smtpd - move it from log.c into util.c and make it a local
concept.  This also needed to rename the global "verbose" variable to
"tracing" in a few places.

OK krw@ gilles@ eric@

Revision 1.130 / (download) - annotate - [select for diffs], Wed Nov 30 18:38:32 2016 UTC (7 years, 6 months ago) by eric
Branch: MAIN
Changes since 1.129: +1 -26 lines
Diff to previous 1.129 (colored)

remove unused iobuf helpers

Revision 1.129 / (download) - annotate - [select for diffs], Thu Nov 17 17:34:55 2016 UTC (7 years, 6 months ago) by eric
Branch: MAIN
Changes since 1.128: +28 -1 lines
Diff to previous 1.128 (colored)

Add io api functions for dealing with buffered data, as wrapper around
their iobuf counterparts.

ok gilles@ sunil@

Revision 1.128 / (download) - annotate - [select for diffs], Wed Aug 31 10:18:08 2016 UTC (7 years, 9 months ago) by gilles
Branch: MAIN
Changes since 1.127: +3 -3 lines
Diff to previous 1.127 (colored)

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

ok eric@, sunil@

Revision 1.127 / (download) - annotate - [select for diffs], Mon May 16 17:43:18 2016 UTC (8 years ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.126: +3 -3 lines
Diff to previous 1.126 (colored)

replace hardcoded + with TAG_CHAR

Revision 1.126 / (download) - annotate - [select for diffs], Fri Mar 25 15:06:58 2016 UTC (8 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.125: +1 -28 lines
Diff to previous 1.125 (colored)

Nuke session_socket_blockmode() and session_socket_linger(). Use
the identical io_set_blocking() and io_set_linger().

Since both are always called to turn off blocking or lingering,
nuke the parameter and associated enum in favour of "just doing the
right thing".

While passing remove the unneeded last parameter to the remaining
fcntl(F_GETFL).

Finally, rename the functions to io_set_nonblocking() and
io_set_nolinger() for clarity.

No functional change.

Started with a sweep of fcntl() usage inspired by guenther@.

ok gilles@

Revision 1.125 / (download) - annotate - [select for diffs], Tue Jan 12 17:29:43 2016 UTC (8 years, 4 months ago) by sunil
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.124: +43 -40 lines
Diff to previous 1.124 (colored)

Let smtpd start on machines without a FQDN as hostname.

Ok millert@ gilles@ jung@

Revision 1.124 / (download) - annotate - [select for diffs], Mon Dec 28 22:08:30 2015 UTC (8 years, 5 months ago) by jung
Branch: MAIN
Changes since 1.123: +9 -9 lines
Diff to previous 1.123 (colored)

remove spaces after '!'

no binary change

ok millert

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

remove trailing whitespace

ok sunil gilles

Revision 1.122 / (download) - annotate - [select for diffs], Sat Oct 17 22:24:36 2015 UTC (8 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.121: +29 -2 lines
Diff to previous 1.121 (colored)

mailaddr_match() allows comparing two struct mailaddr taking into account
catchall and +-tags

ok millert@ and jung@ for util.c

Revision 1.121 / (download) - annotate - [select for diffs], Sat Oct 17 12:59:52 2015 UTC (8 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.120: +4 -4 lines
Diff to previous 1.120 (colored)

our strip() function should use isspace()

ok jung@, ok millert@

Revision 1.120 / (download) - annotate - [select for diffs], Mon Oct 12 07:58:19 2015 UTC (8 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.119: +1 -4 lines
Diff to previous 1.119 (colored)

do not umask() [with the wrong umask] around mkstemp() calls, no matter
how broken other systems are.
ok guenther gilles

Revision 1.119 / (download) - annotate - [select for diffs], Sat Oct 10 11:42:49 2015 UTC (8 years, 8 months ago) by jung
Branch: MAIN
Changes since 1.118: +7 -14 lines
Diff to previous 1.118 (colored)

three conversions of fgetln() to getline()

ok eric sunil

Revision 1.118 / (download) - annotate - [select for diffs], Tue Oct 6 06:04:46 2015 UTC (8 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.117: +2 -2 lines
Diff to previous 1.117 (colored)

fix values passed to umask(), they should be octal.
the permissions are even more restrictive than they should.

misc bug reported by qualys

Revision 1.117 / (download) - annotate - [select for diffs], Tue Oct 6 05:48:34 2015 UTC (8 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.116: +5 -3 lines
Diff to previous 1.116 (colored)

fix reallocarray() constructs to always use temporary variable

Revision 1.116 / (download) - annotate - [select for diffs], Mon Oct 5 22:08:14 2015 UTC (8 years, 8 months ago) by stsp
Branch: MAIN
Changes since 1.115: +2 -1 lines
Diff to previous 1.115 (colored)

actually use lbuf in getmailname()
ok millert@ gilles@

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

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

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

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

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

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

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

in secure_file(), make uid checking on .forward files more strict to avoid
users creating hardlink to root-owned files and leaking first line.

reported by Qualys Security

Revision 1.114 / (download) - annotate - [select for diffs], Sun Aug 16 20:53:19 2015 UTC (8 years, 9 months ago) by gilles
Branch: MAIN
Changes since 1.113: +4 -1 lines
Diff to previous 1.113 (colored)

when we switch valid_domainpart() from our own logic to using res_hnok() we
missed the fact that res_hnok() will consider an empty string as valid.

Revision 1.113 / (download) - annotate - [select for diffs], Wed May 6 08:37:47 2015 UTC (9 years, 1 month ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE
Branch point for: OPENBSD_5_8
Changes since 1.112: +3 -19 lines
Diff to previous 1.112 (colored)

use res_hnok() to valid domain part in valid_domain()

ok eric@

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

use <limits.h> comprehensively.  For now try to push <> includes to
each .c file, and out of the .h files.  To avoid overinclude.
ok gilles, in principle.  If this has been done right, -portable should
become easier to maintain.

Revision 1.111 / (download) - annotate - [select for diffs], Fri Jan 16 06:40:21 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.110: +2 -1 lines
Diff to previous 1.110 (colored)

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)

Revision 1.110 / (download) - annotate - [select for diffs], Sun May 25 10:55:36 2014 UTC (10 years ago) by espie
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE
Branch point for: OPENBSD_5_6
Changes since 1.109: +3 -5 lines
Diff to previous 1.109 (colored)

use reallocarray.
okay gilles@

Revision 1.109 / (download) - annotate - [select for diffs], Sat Apr 19 14:32:03 2014 UTC (10 years, 1 month ago) by gilles
Branch: MAIN
Changes since 1.108: +3 -3 lines
Diff to previous 1.108 (colored)

(void) cast a strlcpy that cannot truncate

Revision 1.108 / (download) - annotate - [select for diffs], Tue Feb 4 10:38:06 2014 UTC (10 years, 4 months ago) by eric
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.107: +2 -6 lines
Diff to previous 1.107 (colored)

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

Revision 1.107 / (download) - annotate - [select for diffs], Tue Feb 4 09:50:31 2014 UTC (10 years, 4 months ago) by eric
Branch: MAIN
Changes since 1.106: +15 -1 lines
Diff to previous 1.106 (colored)

add base64_encode/base64_decode helpers

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

get rid of fdlimit()

Revision 1.105 / (download) - annotate - [select for diffs], Wed Jan 8 15:30:49 2014 UTC (10 years, 5 months ago) by deraadt
Branch: MAIN
Changes since 1.104: +3 -3 lines
Diff to previous 1.104 (colored)

ctype cleanup; ok gilles

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

bcopy -> memmove
bzero -> memset

Revision 1.103 / (download) - annotate - [select for diffs], Thu Nov 28 10:43:37 2013 UTC (10 years, 6 months ago) by eric
Branch: MAIN
Changes since 1.102: +11 -9 lines
Diff to previous 1.102 (colored)

unsigned char casts for ctype
ok gilles@

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

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

Revision 1.101 / (download) - annotate - [select for diffs], Tue Oct 29 14:30:05 2013 UTC (10 years, 7 months ago) by eric
Branch: MAIN
Changes since 1.100: +4 -4 lines
Diff to previous 1.100 (colored)

use "/etc/mail/mailname" instead of "/etc/mailname" and make it a define.

Revision 1.100 / (download) - annotate - [select for diffs], Tue Oct 29 13:22:54 2013 UTC (10 years, 7 months ago) by eric
Branch: MAIN
Changes since 1.99: +6 -1 lines
Diff to previous 1.99 (colored)

randomize counter part of generated uids

Revision 1.99 / (download) - annotate - [select for diffs], Sun Oct 27 18:50:59 2013 UTC (10 years, 7 months ago) by eric
Branch: MAIN
Changes since 1.98: +45 -30 lines
Diff to previous 1.98 (colored)

use log_* functions instead of err*/warn*

Revision 1.98 / (download) - annotate - [select for diffs], Fri Oct 25 21:31:23 2013 UTC (10 years, 7 months ago) by eric
Branch: MAIN
Changes since 1.97: +70 -1 lines
Diff to previous 1.97 (colored)

local enqueuer improvements:

- parse the whole input before trying to establish the connection
  to the local socket: fixes timeout problems when reading the output
  of a long running program.

- use sendmail(8)-like exit status.

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

add '!' in email addresses supported charset

Revision 1.96 / (download) - annotate - [select for diffs], Fri Jul 19 08:12:19 2013 UTC (10 years, 10 months ago) by eric
Branch: MAIN
Changes since 1.95: +18 -1 lines
Diff to previous 1.95 (colored)

Introduce expand string modifiers

Revision 1.95 / (download) - annotate - [select for diffs], Fri Jul 19 07:37:29 2013 UTC (10 years, 10 months ago) by eric
Branch: MAIN
Changes since 1.94: +1 -28 lines
Diff to previous 1.94 (colored)

get rid of sa_set_port() and its awfully contorted implementation

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

sync with OpenSMTPD 5.3.2

ok gilles@

Revision 1.93 / (download) - annotate - [select for diffs], Fri Apr 12 18:22:49 2013 UTC (11 years, 1 month ago) by eric
Branch: MAIN
Changes since 1.92: +2 -2 lines
Diff to previous 1.92 (colored)

replace MAX_LINE_SIZE and SMTP_LINE_MAX with SMTPD_MAXLINESIZE for
consistency and clarity.  Remove useless and confusing extra byte in
a few arrays based on this define.

ok gilles@

Revision 1.92 / (download) - annotate - [select for diffs], Tue Feb 5 11:45:18 2013 UTC (11 years, 4 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.91: +2 -2 lines
Diff to previous 1.91 (colored)

- handle getaddrinfo() error as LKA_TEMPFAIL
- handle getsockname() error in smtp_connected()
- accept '/' as part of user-part, expand to ':' as done by qmail
- fix wrong check in mda leading to bogus Return-Path header
- fix aliases parsing when there's a white space between key and separator
- some cosmethic cleanup

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

assorted fixes spotted by Coverity.
some log message updates.

ok gilles@

Revision 1.90 / (download) - annotate - [select for diffs], Sat Jan 26 09:37:24 2013 UTC (11 years, 4 months ago) by gilles
Branch: MAIN
Changes since 1.89: +34 -426 lines
Diff to previous 1.89 (colored)

Sync with our smtpd repo:

* first bricks of ldap and sqlite support (not finished but both working)
* new table API to replace map API, all lookups are done through tables
* improved handling of temporary errors throughout the daemon
* improved scheduler and mta logic: connection reuse, optimizes batches
* improved queue: more tolerant to admin errors, new layout, less disk-IO
* improved memory usage under high load
* SSL certs/keys isolated to lookup process to avoid facing network
* VIRTUAL support improved, fully virtual setups possible now
* runtime tracing of processes through smtpctl trace
* ssl_privsep.c sync-ed with relayd
* ssl.c no longer contains smtpd specific interfaces
* smtpd-specific ssl bits moved to ssl_smtpd.c
* update mail address in copyright

FLUSH YOUR QUEUE. FLUSH YOUR QUEUE. FLUSH YOUR QUEUE. FLUSH YOUR QUEUE.

smtpd.conf(5) simplified, it will require adaptations

ok eric@

Revision 1.89 / (download) - annotate - [select for diffs], Fri Nov 23 10:55:25 2012 UTC (11 years, 6 months ago) by eric
Branch: MAIN
Changes since 1.88: +60 -58 lines
Diff to previous 1.88 (colored)

knf

ok gilles@

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

Cleanups and improvements:

* Log more events (especially client session) and use a better scheme
  for that: each messages is prefixed with a token to easily identify
  its class:
    - info/warn/debug: general server messages
    - smtp-in: smtp client connections
    - relay: status update for relayed messages
    - delivery: status update for local deliveries

* Implement "smtpctl monitor" to display updates of selected internal
  counters.

* When reloading the on-disk queue at startup do not commit a message
  if no envelope was submitted for that message.

* Remove unused stuff in the config parser.

ok gilles@

Revision 1.87 / (download) - annotate - [select for diffs], Wed Oct 10 19:39:11 2012 UTC (11 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.86: +18 -1 lines
Diff to previous 1.86 (colored)

teach smtpctl how to display envelopes and messages using their id.
this allows an admin to inspect the queue without having to manually
extract bucket and find the path to an envelope or message.

diff by Sunil Nimmagadda <sunil@poolp.org>

ok eric@, chl@ and I

Revision 1.86 / (download) - annotate - [select for diffs], Sun Oct 7 15:46:38 2012 UTC (11 years, 8 months ago) by chl
Branch: MAIN
Changes since 1.85: +24 -1 lines
Diff to previous 1.85 (colored)

convert iobuf_queue()'s to iobuf_fqueue(). (idea from gilles@)
introduce iobuf_xinit() and iobuf_xfqueue(). (idea from eric@)

ok gilles@

Revision 1.85 / (download) - annotate - [select for diffs], Thu Oct 4 12:17:09 2012 UTC (11 years, 8 months ago) by todd
Branch: MAIN
Changes since 1.84: +4 -3 lines
Diff to previous 1.84 (colored)

change to from=<...>, to=<...> instead of to=<...> for logging
from gilles@ ok eric@

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

Stop using the delivery_data union (field "to") in delivery_mda.
It's confusing and not necessary as it's only used for "buffer".
Instead, just add a "buffer" member in the structure and rename
"as_user" to "user".

The delivery_data union becomes an anonymous union in expandnode,
which is the only other place where it's used.

ok gilles@

Revision 1.83 / (download) - annotate - [select for diffs], Wed Sep 26 09:43:42 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.82: +21 -2 lines
Diff to previous 1.82 (colored)

log final user and method used for local deliveries.

ok gilles@

Revision 1.82 / (download) - annotate - [select for diffs], Tue Sep 25 15:36:29 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.81: +2 -1 lines
Diff to previous 1.81 (colored)

need inttypes.h

from millert@

Revision 1.81 / (download) - annotate - [select for diffs], Fri Sep 21 12:33:32 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.80: +23 -1 lines
Diff to previous 1.80 (colored)

Add a log_envelope() function that log envelope status in a uniform way.
It automagically adds an rcpt=<user@domain> field if "dest" differs from
the original "rcpt". The function takes an "extra" parameter that allows
to add some specific info depending on the context.

ok gilles@

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

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

ok gilles@

Revision 1.79 / (download) - annotate - [select for diffs], Thu Sep 20 14:28:57 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.78: +3 -3 lines
Diff to previous 1.78 (colored)

constify parameters that are supposed to be const.

ok gilles@

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

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

ok gilles@

Revision 1.77 / (download) - annotate - [select for diffs], Sun Sep 16 11:53:57 2012 UTC (11 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.76: +50 -73 lines
Diff to previous 1.76 (colored)

replace BSD-licensed mkdir_p() with ISC-licensed mkdirs(), this allows us
to avoid a dual-licensed util.c for no reason

ok chl@

Revision 1.76 / (download) - annotate - [select for diffs], Sat Sep 15 15:12:11 2012 UTC (11 years, 8 months ago) by eric
Branch: MAIN
Changes since 1.75: +6 -4 lines
Diff to previous 1.75 (colored)

When enqueueing from the local socket, the input address is faked as "::1".
This is confusing and even broken, as systems running with ipv6 disabled on
lo0 will not be able to enqueue mails using the local socket.

So instead, use AF_LOCAL and print it as "local" in envelopes/maps.  Add it
to the "localhost" and "all" maps accordingly, and fix the ruleset matching.

ok gilles@ chl@

Revision 1.75 / (download) - annotate - [select for diffs], Mon Aug 27 11:59:38 2012 UTC (11 years, 9 months ago) by chl
Branch: MAIN
Changes since 1.74: +1 -4 lines
Diff to previous 1.74 (colored)

don't call ckdir() on each mktmpfile() call.

ok gilles@

Revision 1.74 / (download) - annotate - [select for diffs], Sun Aug 26 11:52:48 2012 UTC (11 years, 9 months ago) by gilles
Branch: MAIN
Changes since 1.73: +4 -6 lines
Diff to previous 1.73 (colored)

- define ZLIB_BUFFER_SIZE instead of hardcoding 8192
- check gzdopen() failure
- call gzclose() whenever a failure occurs after gzdopen()
- simplify slightly some checks in compress/uncompress
- create PATH_TEMPORARY in /var/spool/smtpd, chmod 700, owned by _smtpd
- compress_zlib should use PATH_TEMPORARY instread of /tmp as we're
	chrooted and this will otherwise lead to a fatal()

ok chl@

Revision 1.73 / (download) - annotate - [select for diffs], Sat Aug 25 23:35:09 2012 UTC (11 years, 9 months ago) by chl
Branch: MAIN
Changes since 1.72: +23 -1 lines
Diff to previous 1.72 (colored)

Add compress_backend, allowing compression of messages and envelopes in the queue.
To use it, just add "queue compress" in smtpd.conf. For now, only zlib is used.

lots of feedback from eric@ and gilles@

ok eric@ gilles@

Revision 1.72 / (download) - annotate - [select for diffs], Sat Aug 25 22:03:26 2012 UTC (11 years, 9 months ago) by gilles
Branch: MAIN
Changes since 1.71: +1 -14 lines
Diff to previous 1.71 (colored)

- add myself to the copyright in control.c, i've done quite a few changes
there in the last few years ;-)
- get rid of availdesc(): getdtablecount() is so much more reliable
- get rid of env->sc_maxconn, we can be much smarter with getdtablecount()
	and getdtablesize()
- disable accept when we hit the control process fd reserve
- disable accept when we fail
- enable accept when we're back below the limit

this is not the full fd exhaustion diff, i'll merge changes from relayd
tomorrow, this was only required to get rid of the env->sc_maxconn and
availdesc() mess

"reads alright" eric@

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

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

ok eric@

Revision 1.70 / (download) - annotate - [select for diffs], Sat Aug 11 12:43:11 2012 UTC (11 years, 10 months ago) by eric
Branch: MAIN
Changes since 1.69: +7 -3 lines
Diff to previous 1.69 (colored)

make sure generated id is never 0.

ok gilles@

Revision 1.69 / (download) - annotate - [select for diffs], Wed Aug 8 08:50:42 2012 UTC (11 years, 10 months ago) by eric
Branch: MAIN
Changes since 1.68: +46 -1 lines
Diff to previous 1.68 (colored)

Improve the scheduler backend API.

New envelopes are pushed into the scheduler through the insert()
commit() rollback() transactional interface functions.

Worklists are pulled from the scheduler through a single batch()
interface function, which returns a list of envelope ids and the
type of processing. Envelopes returned in this batch are said to
be "in-flight", as opposed to "pending". They are supposed to be
processed in some way, and either updated() or deleted() at some
point.

The schedule()/remove() functions are used to alter the internal
state of "pending" envelopes to make them schedulable.  The enve-
lopes will be part of a worklist on the next call to batch().

Rewrite the scheduler_ramqueue backend.

The initial queue loading in now done by the queue.

ok gilles@

Revision 1.68 / (download) - annotate - [select for diffs], Tue Aug 7 21:47:58 2012 UTC (11 years, 10 months ago) by eric
Branch: MAIN
Changes since 1.67: +35 -1 lines
Diff to previous 1.67 (colored)

Implement a set of tree_* functions for storing arbitrary pointers in splay
trees with uint64_t keys. Also add x{m,c}alloc and xstrdup helpers.

ok gilles@

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

- introduce xlowercase() and allow lowercase() to fail gracefully
- replace all calls to lowercase() with calls to xlowercase()
- in the format string expansion, lowercase() all formats

we will have to reassess all calls to xlowercase() even though it has never
triggered as far as I know, we can probably gracefully fail some of them.
right now we're just keeping former behaviour.

this commit fixes issue reported by Hugo Osvaldo Barrera where a %u format
could lead to a delivery failure (ie: GILLES@openbsd.org should be expanded
to gilles, not GILLES ... only for local deliveries).

ok chl@ on the idea, ok eric@ on the diff

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

add support for maildir tagging/folders.

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

Revision 1.65 / (download) - annotate - [select for diffs], Wed Jul 11 22:16:45 2012 UTC (11 years, 11 months ago) by chl
Branch: MAIN
Changes since 1.64: +2 -2 lines
Diff to previous 1.64 (colored)

enable back = char in address localpart, that is sometimes used by mailing lists.

ok gilles@ eric@

Revision 1.64 / (download) - annotate - [select for diffs], Wed Jul 11 17:20:00 2012 UTC (11 years, 11 months ago) by chl
Branch: MAIN
Changes since 1.63: +6 -2 lines
Diff to previous 1.63 (colored)

Don't respect RFC 5322, that allows some crazy characters in email
localpart, like !#$&'*/=?^`{|}~ ... and all the other ones that
can be double quoted, just refuse them.

ok gilles@ eric@

Revision 1.63 / (download) - annotate - [select for diffs], Tue Jul 10 16:11:43 2012 UTC (11 years, 11 months ago) by chl
Branch: MAIN
Changes since 1.62: +24 -3 lines
Diff to previous 1.62 (colored)

accept address literal for the recipient domain.
while there, change valid_{local,domain}part() prototypes to use const char *.

with input from gilles@ and eric@

ok gilles@ eric@

Revision 1.62 / (download) - annotate - [select for diffs], Sun Jul 8 15:48:00 2012 UTC (11 years, 11 months ago) by gilles
Branch: MAIN
Changes since 1.61: +3 -3 lines
Diff to previous 1.61 (colored)

- plug text_to_relayhost() in parse.y to support relay URLs.
- document the new URL syntax in smtpd.conf.5
- replace starttls:// schema with tls://

Beware, "relay via" rules should now be expressed with a relay URL:

	accept [...] relay via "mx1.example.org" smtps port 465
becomes accept [...] relay via "smtps://mx1.example.org"

This will allow using mappings of relays with different protocols and
options.

Make sure to update your smtpd.conf if you relay via !

ok eric, ok chl

Revision 1.61 / (download) - annotate - [select for diffs], Mon Jul 2 10:32:28 2012 UTC (11 years, 11 months ago) by eric
Branch: MAIN
Changes since 1.60: +3 -12 lines
Diff to previous 1.60 (colored)

Sleeping here is definitely not what we want to do. Use a cycling
counter with some randomness to generate short-lived unique ids.

ok gilles@

Revision 1.60 / (download) - annotate - [select for diffs], Tue May 29 19:29:44 2012 UTC (12 years ago) by gilles
Branch: MAIN
Changes since 1.59: +58 -1 lines
Diff to previous 1.59 (colored)

- introduce text_to_relayhost() which converts an url into a relayhost.
  urls are of the form: [schema://]host[:ip]

not used, yet other commits are following ;-)

Revision 1.59 / (download) - annotate - [select for diffs], Wed May 23 22:46:58 2012 UTC (12 years ago) by gilles
Branch: MAIN
Changes since 1.58: +46 -1 lines
Diff to previous 1.58 (colored)

- introduce temp_inet_net_pton_ipv6() temporarily until we have AF_INET6
  support in inet_net_pton().

- in text_to_netaddr(), if we are handling an inet6 netmask AND we have
  inet_net_pton() that failed with EAFNOSUPPORT, THEN we fallback to
  this.

quick fix to unbreak setups that use inet6, a diff is floating to have
it supported at the right place.

Revision 1.58 / (download) - annotate - [select for diffs], Sun May 13 00:10:49 2012 UTC (12 years ago) by gilles
Branch: MAIN
Changes since 1.57: +60 -1 lines
Diff to previous 1.57 (colored)

- cleanup parse.y by removing lots of code that should not have been there,
  but in ruleset.c and util.c instead.

- introduce the new map_compare() map API call to allow iterating over keys
  and comparing them with provided key using provided function. this allows
  checking a partial key in a key set, very useful for comparing an address
  to a set of netmask.

- introduce new map kind K_NETADDR
- implement K_NETADDR for map_db and map_stdio
- teach ruleset checking how to use the map_compare() with K_NETADDR

we can now do the following:

   map "srcaddr" source plain "/etc/mail/srcaddr.txt"

   accept from map srcaddr for domain "openbsd.org" [...]

Revision 1.57 / (download) - annotate - [select for diffs], Sat Jan 28 16:54:10 2012 UTC (12 years, 4 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.56: +1 -4 lines
Diff to previous 1.56 (colored)

remove even more annoying debug logs

ok eric@

Revision 1.56 / (download) - annotate - [select for diffs], Thu Jan 12 15:01:33 2012 UTC (12 years, 4 months ago) by eric
Branch: MAIN
Changes since 1.55: +1 -25 lines
Diff to previous 1.55 (colored)

remove envelope_get_errormsg() and move envelope_set_errormsg()
to envelope.c

ok gilles@

Revision 1.55 / (download) - annotate - [select for diffs], Wed Jan 11 17:46:37 2012 UTC (12 years, 5 months ago) by eric
Branch: MAIN
Changes since 1.54: +83 -1 lines
Diff to previous 1.54 (colored)

Simplify runner/queue by getting rid of Q_PURGE.  Instead, let smtpd
periodically clear the purge/ directory.  At init time, the fsqueue
backend simply moves the existing incoming/ dir in purge/ to discard
aborted sessions.

ok gilles@ chl@

Revision 1.54 / (download) - annotate - [select for diffs], Sun Dec 18 22:51:29 2011 UTC (12 years, 5 months ago) by chl
Branch: MAIN
Changes since 1.53: +1 -2 lines
Diff to previous 1.53 (colored)

remove unused header

ok eric@

Revision 1.53 / (download) - annotate - [select for diffs], Sun Dec 18 18:43:30 2011 UTC (12 years, 5 months ago) by eric
Branch: MAIN
Changes since 1.52: +5 -6 lines
Diff to previous 1.52 (colored)

- use envelope_set_errormsg() where possible.
- make it use sizeof() rather than a hardcoded limit.

ok chl@ gilles@

Revision 1.52 / (download) - annotate - [select for diffs], Sun Dec 11 19:58:09 2011 UTC (12 years, 6 months ago) by eric
Branch: MAIN
Changes since 1.51: +35 -1 lines
Diff to previous 1.51 (colored)

utility function for parsing and validating SMTP response lines

ok gilles@

Revision 1.51 / (download) - annotate - [select for diffs], Wed Nov 16 19:38:56 2011 UTC (12 years, 6 months ago) by eric
Branch: MAIN
Changes since 1.50: +1 -65 lines
Diff to previous 1.50 (colored)

remove unused functions

ok gilles@ chl@

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

The spool and offline directories are backend-independent, so they
must be created early by smtpd, rather than in fsqueue.

ok gilles@ chl@

Revision 1.49 / (download) - annotate - [select for diffs], Thu Oct 27 14:32:57 2011 UTC (12 years, 7 months ago) by chl
Branch: MAIN
Changes since 1.48: +5 -4 lines
Diff to previous 1.48 (colored)

Use PRI{x,d}64 in format strings instead of %llx, %lld or %qd to print {u_,}int64_t or time_t

While there, cast some time_t to int64_t

These will fix build warnings for portable smptd

ok gilles@ eric@

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

fsqueue no longer stores envelopes by dumping the structure, instead use a
couple of load/dump functions to convert to and from a human readable fmt.
while at it kill struct delivery and merge back its fields to the envelope.

this basically means we shouldn't require users to flush their queues every
time we make a change to struct envelope.

work is not done, but we're at a better state than the binary fsqueue so
we'll improve it in-tree.

has been running on my own box for the last 12 hours or so
ok eric@, chl@

Revision 1.47 / (download) - annotate - [select for diffs], Tue May 17 18:54:32 2011 UTC (13 years ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.46: +5 -5 lines
Diff to previous 1.46 (colored)

introduce new user_backend API for smtpd to lookup the users it wants to
deliver mail to. the only backend supported for now is USER_GETPWNAM and
it is not yet possible to switch to an alternate backend.

yes this means that we're very close from smtpd being able to handle fully
virtual accounts for both incoming and outgoing messages.

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

murder struct path and make sure smtpd uses simpler structures that do not
bring a shitload of unnecessary information everywhere. this required many
parts of smtpd to be refactored and more specifically envelope expansion.

in the process lots of code got simplified, and the envelope expansion code
has been isolated to lka_session.c with some longstanding bugs fixed.

Diff has been tested by many with no major regression reported.
armani@ spotted a bug in a setup where a domain is listed a both primary
and virtual, I will fix that in-tree as it's becoming painful to maintain
this diff out.

Revision 1.45 / (download) - annotate - [select for diffs], Sat May 14 11:04:42 2011 UTC (13 years ago) by gilles
Branch: MAIN
Changes since 1.44: +3 -2 lines
Diff to previous 1.44 (colored)

int * -> socklen_t * in getsockopt() call

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

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

Revision 1.43 / (download) - annotate - [select for diffs], Sun Apr 17 11:39:23 2011 UTC (13 years, 1 month ago) by gilles
Branch: MAIN
Changes since 1.42: +6 -6 lines
Diff to previous 1.42 (colored)

a structure describing an envelope should be called struct envelope, not
struct message ...

Revision 1.42 / (download) - annotate - [select for diffs], Fri Apr 15 17:21:24 2011 UTC (13 years, 1 month ago) by gilles
Branch: MAIN
Changes since 1.41: +1 -48 lines
Diff to previous 1.41 (colored)

valid_message_id() and valid_message_uid() are no longer needed

Revision 1.41 / (download) - annotate - [select for diffs], Fri Apr 15 17:01:05 2011 UTC (13 years, 1 month ago) by gilles
Branch: MAIN
Changes since 1.40: +51 -1 lines
Diff to previous 1.40 (colored)

kill message_id and message_uid

smtpd now has an evpid associated to each delivery message, the evpid is an
u_int64_t where the upper 32 bits are the msgid, and the 32 bits are the
envelope unique identifier for that message. this results in lots of space
saved in both disk-based and ram-based queues, but also simplifies a lot of
code.

change has been stressed on my desktop, and has ran on my MX for the entire
afternoon without a regression.

Revision 1.40 / (download) - annotate - [select for diffs], Tue Mar 29 20:43:51 2011 UTC (13 years, 2 months ago) by eric
Branch: MAIN
Changes since 1.39: +1 -71 lines
Diff to previous 1.39 (colored)

remove unused code now that reverse lookups are done through asr.

ok gilles@

Revision 1.39 / (download) - annotate - [select for diffs], Thu Mar 3 08:09:14 2011 UTC (13 years, 3 months ago) by gilles
Branch: MAIN
Changes since 1.38: +15 -14 lines
Diff to previous 1.38 (colored)

fix ss_to_text() and ss_to_ptr() so IP addresses are logged correctly
on big-endian machines ...

spotted and tested by landry@ (and I)

Revision 1.38 / (download) - annotate - [select for diffs], Mon Nov 29 15:25:56 2010 UTC (13 years, 6 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.37: +128 -5 lines
Diff to previous 1.37 (colored)

replace the fork-based-non-blocking-resolver-hack by shiny async resolver
written by eric@. it is still experimental but still better than what we
had earlier so ... we'll improve in tree :)

diff by me with *lots* of help from eric@, tested by todd and I (and a
few people out there)

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

a bit of .h cleanups, no functionnal change

Revision 1.36 / (download) - annotate - [select for diffs], Sat Oct 9 22:05:35 2010 UTC (13 years, 8 months ago) by gilles
Branch: MAIN
Changes since 1.35: +105 -111 lines
Diff to previous 1.35 (colored)

backout the "new" queue code commited 4 months ago. it has many good ideas,
is way more optimized than what we had earlier and there's definitely stuff
we want to keep, however it is early optimization that doesn't account for
many features and makes them hard (if not impossible) to write without
ugly workarounds that ruin the purpose of the optimizations.

the backout goes to 30 May's right before the commit and catches up on all
the non-queue related commits that happened since then.

i'll work on reintroducing the ideas from this queue when the basic
features we expect from a MTA are implemented.

suggested on tech@ about a week ago, no objections, several "please make
smtpd move forward" mails from hackers and tech readers.

Revision 1.35 / (download) - annotate - [select for diffs], Tue Jun 1 23:06:25 2010 UTC (14 years ago) by jacekm
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.34: +111 -105 lines
Diff to previous 1.34 (colored)

new queue, again; gcc2 compile tested by deraadt

Revision 1.34 / (download) - annotate - [select for diffs], Tue Jun 1 19:47:09 2010 UTC (14 years ago) by jacekm
Branch: MAIN
Changes since 1.33: +104 -110 lines
Diff to previous 1.33 (colored)

New queue doesn't compile on gcc2, back out.  Spotted by deraadt@

Revision 1.33 / (download) - annotate - [select for diffs], Mon May 31 23:38:56 2010 UTC (14 years ago) by jacekm
Branch: MAIN
Changes since 1.32: +111 -105 lines
Diff to previous 1.32 (colored)

Rewrite entire queue code.

Major goals:

1) Fix bad performance caused by the runner process doing full queue
read in 1s intervals.  My Soekris can now happily accept >50 msg/s
while having multi-thousand queue; before, one hundred queue would
bring the system to its knees.

2) Introduce Qmail-like scheduler that doesn't write as much to the
disk so that it needs less code for servicing error conditions,
which in some places can be tricky to get right.

3) Introduce separation between the scheduler and the backend; these
two queue aspects shouldn't be too tied too each other.  This means
that eg. storing queue in SQL requires rewrite of just queue_backend.c.

4) Make on-disk queue format architecture independent, and more
easily extensible, to reduce number of flag days in the future.

Minor goals:

ENOSPC no longer prevents delivery attempts, fixed session limiting
for relayed mail, improved batching of "relay via" mails, human-readable
mailq output, "show queue raw" command, clearer logging, sending
of single bounce about multiple recipients, exact delay= computation,
zero delay between deliveries while within session limit (currently
1s delay between re-scheduling is enforced), mta no longer requests
content fd, corrected session limit for bounce submissions, tiny
<100B queue files instead of multi-KB, detect loops before accepting
mail, reduce traffic on imsg channels by killing enormous struct
submit_status.

Revision 1.32 / (download) - annotate - [select for diffs], Wed Dec 23 17:16:03 2009 UTC (14 years, 5 months ago) by jacekm
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.31: +42 -2 lines
Diff to previous 1.31 (colored)

Implementation of RFC 2920 PIPELINING extension, client side only for now.

This restructures the client_* API internals significantly.  The code becomes
pipelining in nature.  All SMTP commands are put on the output queue and
dequeued as quickly as possible.  Once dequeued, they're moved to the receive
queue so that replies can be matched with previous commands.

Dequeuing commands from the output queue halts when the count of commands
currently in-pipeline (``cmdi'') is equal to the command send window (``cmdw'').
There are three cmdw values useful in practice:

0               clear pipeline, ie. inhibit all future sends
1               disable pipelining, ie. use old ``one-request-one-reply`` mode
SIZE_T_MAX      enable pipelining, ie. dequeue as many commands as possible

At the beginning of session cmdw is 1.  When it is found that peer supports
PIPELINING, it grows to SIZE_T_MAX.  After dequeing DATA it is again 1.  After
sending QUIT it is 0.

Each command dequeued from the output queue becomes a buf in a msgbuf.  The act
of combining multiple commands into a single send operation did not need to be
implemented: buf_write() already combines bufs using iovec and sends them at
once using sendmsg(2).

Tested by todd@ and oga@

"looks good" to gilles@

Revision 1.31 / (download) - annotate - [select for diffs], Mon Dec 14 19:56:55 2009 UTC (14 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.30: +6 -8 lines
Diff to previous 1.30 (colored)

Tweak the logic behind setting the fd limits so that smtpd is less likely
to get upset by custom soft/hard ulimit settings.

Suggested by todd@

Revision 1.30 / (download) - annotate - [select for diffs], Sun Dec 13 22:02:55 2009 UTC (14 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.29: +31 -1 lines
Diff to previous 1.29 (colored)

Use safe fd limits in smtp, lka, queue, and control.  Removes a
possibility for fd-starvation fatal when under heavy load.

Revision 1.29 / (download) - annotate - [select for diffs], Sun Nov 8 21:40:05 2009 UTC (14 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.28: +18 -1 lines
Diff to previous 1.28 (colored)

- make aliases expansion use a rb tree instead of a tail queue, the code
  doesn't take advantage of the new structure yet, but this was a needed
  change for upcoming improvements.
- introduce aliasestree_{lookup,insert,remove} to the aliases api
- rename queue_generate_id() to generate_uid() and move it to utils.c as
  it is used all over the place and not only in queue

tree idea discussed with jacekm@, if you update rebuild aliases db, make
clean and flush queue

Revision 1.28 / (download) - annotate - [select for diffs], Sun Nov 8 19:38:26 2009 UTC (14 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.27: +15 -1 lines
Diff to previous 1.27 (colored)

first commit of a serie to cleanup, simplify and improve aliases resolution
which is probably the most complex code in smtpd right now. no longer use a
single list to hold aliases to be resolved and resolved aliases, and do not
use struct alias to hold resolved aliases. instead use a delivery list that
is a list of struct path, and populate it with resolved aliases.

idea discussed with jacekm@, this needs some testing to make sure it does
not introduce a regression with aliases. flush your queue and make clean.

Revision 1.27 / (download) - annotate - [select for diffs], Tue Sep 15 16:50:06 2009 UTC (14 years, 8 months ago) by jacekm
Branch: MAIN
Changes since 1.26: +27 -1 lines
Diff to previous 1.26 (colored)

Extend SMTP client_* API to support SSL+AUTH, and use it in the mta
process to relay mails.  ok gilles@

Revision 1.26 / (download) - annotate - [select for diffs], Thu Aug 27 09:21:28 2009 UTC (14 years, 9 months ago) by jacekm
Branch: MAIN
Changes since 1.25: +3 -3 lines
Diff to previous 1.25 (colored)

getpwnam failure that results in setting errno could confuse the
check for non-existent ~/.forward, so make the check more robust;
fix a fd leak under rare circumstances; use secure_file for
testing .forward file security.

Revision 1.25 / (download) - annotate - [select for diffs], Sat Aug 8 00:18:38 2009 UTC (14 years, 10 months ago) by gilles
Branch: MAIN
Changes since 1.24: +2 -2 lines
Diff to previous 1.24 (colored)

missing cast

Revision 1.24 / (download) - annotate - [select for diffs], Sat Aug 8 00:02:22 2009 UTC (14 years, 10 months ago) by gilles
Branch: MAIN
Changes since 1.23: +7 -7 lines
Diff to previous 1.23 (colored)

import some changes from portable smtpd to reduce the delta between both.
this commit contains mostly missing casts and cosmethic changes, do not
expect to build this anywhere but on OpenBSD, it does not contain any of
the portable glue.

Revision 1.23 / (download) - annotate - [select for diffs], Thu Aug 6 14:12:48 2009 UTC (14 years, 10 months ago) by gilles
Branch: MAIN
Changes since 1.22: +28 -1 lines
Diff to previous 1.22 (colored)

- introduce message_set_errormsg() to set the error description that will
  appear in a bounce message, and message_get_errormsg() to retrieve that
  message.
- when loop is detected, call message_set_errormsg()
- in mta, call message_set_errormsg() for each recipient failure
- in mta, call message_set_errormsg() to copy batch errors to recipients if
  we failed to deliver for a session related error
- when bouncing, add the recipient and error reason to the bounce message

Revision 1.22 / (download) - annotate - [select for diffs], Mon Jun 1 18:24:01 2009 UTC (15 years ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.21: +1 -23 lines
Diff to previous 1.21 (colored)

No need for save_getpwuid and such functions which call endpwent.
endpwent is not needed unless setpwent (with stayopen = 1) or getpwent
was used.  getpwuid/getpwnam do not use getpwent; i think people must
be assuming this.  we are going to improve the man pages for this.
ok gilles

Revision 1.21 / (download) - annotate - [select for diffs], Sun May 10 11:29:40 2009 UTC (15 years, 1 month ago) by jacekm
Branch: MAIN
Changes since 1.20: +3 -2 lines
Diff to previous 1.20 (colored)

assert copyright; ok gilles@

Revision 1.20 / (download) - annotate - [select for diffs], Fri Apr 24 10:02:35 2009 UTC (15 years, 1 month ago) by jacekm
Branch: MAIN
Changes since 1.19: +16 -1 lines
Diff to previous 1.19 (colored)

Make aliases case-insensitive, issue reported by Daniel Ouelett; ok gilles@

Revision 1.19 / (download) - annotate - [select for diffs], Thu Mar 12 11:08:26 2009 UTC (15 years, 3 months ago) by pea
Branch: MAIN
Changes since 1.18: +29 -1 lines
Diff to previous 1.18 (colored)

Add new function time_to_text to correctly display the date.
Use it to display the date in received from header and when we
store headers.

ok jacekm@

Revision 1.18 / (download) - annotate - [select for diffs], Tue Mar 10 01:25:42 2009 UTC (15 years, 3 months ago) by jacekm
Branch: MAIN
Changes since 1.17: +2 -1 lines
Diff to previous 1.17 (colored)

ascribe copyright to code taken from OpenSSH, pointed out by deraadt

Revision 1.17 / (download) - annotate - [select for diffs], Mon Mar 9 23:35:04 2009 UTC (15 years, 3 months ago) by jacekm
Branch: MAIN
Changes since 1.16: +32 -1 lines
Diff to previous 1.16 (colored)

run external mda directly, not via sh -c; this steals addargs() API
from OpenSSH; ok gilles@

Revision 1.16 / (download) - annotate - [select for diffs], Sun Mar 1 21:58:53 2009 UTC (15 years, 3 months ago) by jacekm
Branch: MAIN
Changes since 1.15: +54 -1 lines
Diff to previous 1.15 (colored)

- Refuse delivery to mbox that is a symlink, pipe, chardev, etc. etc.
- Introduce secure_file, based on secure_filename from OpenSSH, it
checks that mbox has right perms, and that path components are
trustworthy, too.

ok gilles@

Revision 1.15 / (download) - annotate - [select for diffs], Tue Feb 24 12:07:47 2009 UTC (15 years, 3 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.14: +0 -0 lines
Diff to previous 1.14 (colored)

teach smtpctl's parser how to deal with parameters that are not necessarily
a token so that it is possible to do: smtpctl schedule <message id/uid>

introduce F_MESSAGE_FORCESCHEDULE which lets the runner schedule a message
even if the retry delay has not been expired.

F_MESSAGE_ENQUEUED is a valid flag for a message and should not cause an\
errx() in smtpctl show queue

Revision 1.14 / (download) - annotate - [select for diffs], Mon Feb 23 22:59:40 2009 UTC (15 years, 3 months ago) by gilles
Branch: MAIN
Changes since 1.13: +48 -1 lines
Diff to previous 1.13 (colored)

add valid_message_id() and valid_message_uid() which test that a message id
and uid do not look wrong. this was not needed earlier because we only deal
with message id's coming from trusted sources, but smtpctl will soon have a
new feature which requires us to deal with user provided message id's.

Revision 1.13 / (download) - annotate - [select for diffs], Sun Feb 22 11:59:12 2009 UTC (15 years, 3 months ago) by jacekm
Branch: MAIN
Changes since 1.12: +23 -1 lines
Diff to previous 1.12 (colored)

put repeated inet_ntop calls into new func ss_to_text, which uses
getnameinfo internally; ok gilles@

Revision 1.12 / (download) - annotate - [select for diffs], Sun Feb 22 11:44:29 2009 UTC (15 years, 3 months ago) by form
Branch: MAIN
Changes since 1.11: +3 -3 lines
Diff to previous 1.11 (colored)

replace MAX* constants by sizeof where possible

ok jacekm@

Revision 1.11 / (download) - annotate - [select for diffs], Wed Feb 18 22:39:12 2009 UTC (15 years, 3 months ago) by jacekm
Branch: MAIN
Changes since 1.10: +45 -2 lines
Diff to previous 1.10 (colored)

- add basic syntax checking to mfa
- decline source routing at MAIL FROM, strip at RCPT TO

ok gilles@

Revision 1.10 / (download) - annotate - [select for diffs], Wed Jan 28 12:56:46 2009 UTC (15 years, 4 months ago) by jacekm
Branch: MAIN
Changes since 1.9: +6 -4 lines
Diff to previous 1.9 (colored)

in safe_fclose, ensure file is closed upon return, and additionally
signify temp failure to the caller if ferror is true; ok gilles@

Revision 1.9 / (download) - annotate - [select for diffs], Tue Jan 27 22:48:29 2009 UTC (15 years, 4 months ago) by gilles
Branch: MAIN
Changes since 1.8: +1 -2 lines
Diff to previous 1.8 (colored)

first bricks of enqueue code which allows smtpctl to submit mail to queue
without "talking" smtp to listeners. currently, a big part of the server
side code is done (and requires a cleanup), next step is to get it usable
properly from a mail user agent.

Revision 1.8 / (download) - annotate - [select for diffs], Tue Jan 27 15:57:01 2009 UTC (15 years, 4 months ago) by gilles
Branch: MAIN
Changes since 1.7: +1 -16 lines
Diff to previous 1.7 (colored)

err, actually session_set_path was moved to utils.c because it was used by
the enqueue code i'm working on, but this is no longer necessary since the
enqueue code uses recipient_to_path. revert part of previous commit

Revision 1.7 / (download) - annotate - [select for diffs], Tue Jan 27 15:50:15 2009 UTC (15 years, 4 months ago) by gilles
Branch: MAIN
Changes since 1.6: +62 -1 lines
Diff to previous 1.6 (colored)

*** empty log message ***

Revision 1.6 / (download) - annotate - [select for diffs], Thu Jan 8 19:17:31 2009 UTC (15 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.5: +13 -1 lines
Diff to previous 1.5 (colored)

ensure getpwnam is always followed by endpwent; ok gilles@ henning@

Revision 1.5 / (download) - annotate - [select for diffs], Sun Jan 4 17:45:58 2009 UTC (15 years, 5 months ago) by gilles
Branch: MAIN
Changes since 1.4: +24 -1 lines
Diff to previous 1.4 (colored)

When matching a recipient domain to a rule, do not use strcasecmp, but use
new hostname_match() function which recognizes * as a wildcard. We can now
do: accept for domain "*.example.org" to match all subdomains.

idea from Nicholas Marriott <nicholas.marriott@gmail.com>, hostname_match()
from me in place of his fnmatch() calls.

ok jacekm@

Revision 1.4 / (download) - annotate - [select for diffs], Thu Jan 1 16:15:47 2009 UTC (15 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.3: +1 -15 lines
Diff to previous 1.3 (colored)

remove unnecessary includes; ok gilles@

Revision 1.3 / (download) - annotate - [select for diffs], Fri Dec 19 12:09:00 2008 UTC (15 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.2: +2 -2 lines
Diff to previous 1.2 (colored)

fix indentation, no binary change.

Revision 1.2 / (download) - annotate - [select for diffs], Thu Dec 18 23:57:17 2008 UTC (15 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.1: +21 -1 lines
Diff to previous 1.1 (colored)

Introduce safe_fclose, which tries to push file to the disk as
quickly as possible; it fails under temporary error conditions,
letting caller react appropriately.

ok gilles@

Revision 1.1 / (download) - annotate - [select for diffs], Thu Dec 11 22:17:12 2008 UTC (15 years, 6 months ago) by gilles
Branch: MAIN

- bsnprintf() is a wrapper to snprintf() that can be used when we handle an
	encoding error or a truncation the same way. This will turn many of
	our snprintf() checks into boolean checks.

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