OpenBSD CVS

CVS log for src/usr.sbin/smtpd/Attic/client.c


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.40, Sun Jan 29 11:37:32 2012 UTC (12 years, 4 months ago) by eric
Branch: MAIN
CVS Tags: HEAD
Changes since 1.39: +1 -1 lines
FILE REMOVED

Rewrite io code in smtp and mta using the iobuf/ioev interface to have
a better separation between io and protocol logic.  As a side-effect,
it fixes a couple of long-standing issues in the io path, and
hopefully add fresh ones instead.  Kill client.c in the process.

ok gilles@

Revision 1.39 / (download) - annotate - [select for diffs], Sun Dec 11 19:58:09 2011 UTC (12 years, 5 months ago) by eric
Branch: MAIN
Changes since 1.38: +14 -42 lines
Diff to previous 1.38 (colored)

utility function for parsing and validating SMTP response lines

ok gilles@

Revision 1.38 / (download) - annotate - [select for diffs], Thu Nov 3 14:34:13 2011 UTC (12 years, 7 months ago) by chl
Branch: MAIN
Changes since 1.37: +1 -17 lines
Diff to previous 1.37 (colored)

since smtpctl doesn't need to be build along with client.c,
client.c doesn't need to be build with -DCLIENT_NO_SSL anymore,
so get rid of #ifdef CLIENT_NO_SSL

ok eric@

Revision 1.37 / (download) - annotate - [select for diffs], Wed Jul 6 20:56:16 2011 UTC (12 years, 10 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.36: +1 -2 lines
Diff to previous 1.36 (colored)

fix that fscking "fgetln(): bad file descriptor" bug experienced by many.

long story short: datafp is reused by the possibly multiple client sessions
of a MTA session. fclosing it in client_close() will cause the file pointer
to be invalidated as soon as we fail the primary MX and attempt the second.

bug introduced while trying to fix a leak causing a crash for a user, now
smtpd will unconditionnally fclose() in MTA_DONE and if a leak still exists
then we should track why the mta session doesnt reach MTA_DONE.

Revision 1.36 / (download) - annotate - [select for diffs], Sat May 14 11:06:32 2011 UTC (13 years ago) by gilles
Branch: MAIN
Changes since 1.35: +4 -3 lines
Diff to previous 1.35 (colored)

char -> u_char

Revision 1.35 / (download) - annotate - [select for diffs], Sat Mar 26 10:59:59 2011 UTC (13 years, 2 months ago) by gilles
Branch: MAIN
Changes since 1.34: +3 -4 lines
Diff to previous 1.34 (colored)

have the client API receive a stdio stream rather than a fd to the message
fd. this shifts responsibility for the fclose to the caller, prevents a
memory leak and makes everyone happy.

diff by Jared Yanovich, thanks !

Revision 1.34 / (download) - annotate - [select for diffs], Mon Mar 21 09:21:57 2011 UTC (13 years, 2 months ago) by gilles
Branch: MAIN
Changes since 1.33: +4 -1 lines
Diff to previous 1.33 (colored)

fix a memory leak in client.c and properly close envelope in
queue_shared.c

diff from Jared Yanovich, sent to bugs@ by Jonny Mosco

Revision 1.33 / (download) - annotate - [select for diffs], Sun Nov 28 13:56:43 2010 UTC (13 years, 6 months ago) by gilles
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.32: +2 -25 lines
Diff to previous 1.32 (colored)

a bit of .h cleanups, no functionnal change

Revision 1.32 / (download) - annotate - [select for diffs], Sat Oct 9 22:05:35 2010 UTC (13 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.31: +1 -1 lines
Diff to previous 1.31 (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.31 / (download) - annotate - [select for diffs], Tue Jun 1 23:06:23 2010 UTC (14 years ago) by jacekm
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.30: +1 -1 lines
Diff to previous 1.30 (colored)

new queue, again; gcc2 compile tested by deraadt

Revision 1.30 / (download) - annotate - [select for diffs], Tue Jun 1 19:47:08 2010 UTC (14 years ago) by jacekm
Branch: MAIN
Changes since 1.29: +0 -2 lines
Diff to previous 1.29 (colored)

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

Revision 1.29 / (download) - annotate - [select for diffs], Mon May 31 23:38:56 2010 UTC (14 years ago) by jacekm
Branch: MAIN
Changes since 1.28: +3 -1 lines
Diff to previous 1.28 (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.28 / (download) - annotate - [select for diffs], Wed May 26 16:44:32 2010 UTC (14 years ago) by nicm
Branch: MAIN
Changes since 1.27: +2 -2 lines
Diff to previous 1.27 (colored)

Move imsg into libutil and add a man page.

Minor bump for libutil.

Previous versions of this diff and man page looked at by various people.

"you should just commit" deraadt

Revision 1.27 / (download) - annotate - [select for diffs], Wed May 26 13:56:08 2010 UTC (14 years ago) by nicm
Branch: MAIN
Changes since 1.26: +29 -29 lines
Diff to previous 1.26 (colored)

Rename some imsg bits to make namespace collisions less likely buf to
ibuf, buf_read to ibuf_read, READ_BUF_SIZE to IBUF_READ_SIZE.

ok henning gilles claudio jacekm deraadt

Revision 1.26 / (download) - annotate - [select for diffs], Sat Jan 2 16:41:19 2010 UTC (14 years, 5 months ago) by jacekm
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.25: +32 -36 lines
Diff to previous 1.25 (colored)

Replace 3 struct smtp_client members (ssl_handshake, rcptokay, dying) with a
bitmap called "flags".

Revision 1.25 / (download) - annotate - [select for diffs], Sat Jan 2 13:42:42 2010 UTC (14 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.24: +165 -139 lines
Diff to previous 1.24 (colored)

Factor out parts of client_read() into client_socket_read() and
client_get_reply(), downsizing it from 170+ to just over 30 lines.
The gotos are now gone, too.

Revision 1.24 / (download) - annotate - [select for diffs], Sat Jan 2 11:06:37 2010 UTC (14 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.23: +30 -42 lines
Diff to previous 1.23 (colored)

Simplify code by removing struct smtp_client member, int iomode, which was
used for keeping track of the current polling mode.  Introduce new function
client_poll() that determines what mode of polling is required at the time of
call.

Revision 1.23 / (download) - annotate - [select for diffs], Wed Dec 23 17:16:03 2009 UTC (14 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.22: +298 -219 lines
Diff to previous 1.22 (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.22 / (download) - annotate - [select for diffs], Wed Dec 16 21:40:01 2009 UTC (14 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.21: +2 -2 lines
Diff to previous 1.21 (colored)

Don't lose a line each time a chunkful of content is read off the disk.
Problem spotted by todd@

Revision 1.21 / (download) - annotate - [select for diffs], Wed Dec 16 02:20:32 2009 UTC (14 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.20: +2 -2 lines
Diff to previous 1.20 (colored)

Fix RCPT TO failure handling, bug introduced in r1.18.

Revision 1.20 / (download) - annotate - [select for diffs], Tue Dec 15 11:45:51 2009 UTC (14 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.19: +19 -24 lines
Diff to previous 1.19 (colored)

Simplify SSL code client-side, no functional change.

Revision 1.19 / (download) - annotate - [select for diffs], Sat Dec 12 14:03:59 2009 UTC (14 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.18: +64 -57 lines
Diff to previous 1.18 (colored)

When acting as a client do content reads from the disk progressively
as the remote accepts more data instead of doing one big read into
the memory in the beginning of session.

Revision 1.18 / (download) - annotate - [select for diffs], Sat Dec 12 10:33:11 2009 UTC (14 years, 5 months ago) by jacekm
Branch: MAIN
Changes since 1.17: +189 -413 lines
Diff to previous 1.17 (colored)

Simplify client_* api, mainly by making fatal conditions result in immediate
fatals instead of passing the error up (kills ~300 lines).

Implement sending of the QUIT command which replaces crude close(2).

tested by gilles@, todd@

Revision 1.17 / (download) - annotate - [select for diffs], Tue Nov 17 09:22:19 2009 UTC (14 years, 6 months ago) by jacekm
Branch: MAIN
Changes since 1.16: +2 -1 lines
Diff to previous 1.16 (colored)

Fix handling of 5yz response to EHLO, ie. fallback to HELO.

Revision 1.16 / (download) - annotate - [select for diffs], Wed Nov 11 15:36:10 2009 UTC (14 years, 6 months ago) by jacekm
Branch: MAIN
Changes since 1.15: +17 -12 lines
Diff to previous 1.15 (colored)

Check if the receive buffer has any unused space before reading from socket in
buf_read (and in ssl_buf_read).

Revision 1.15 / (download) - annotate - [select for diffs], Wed Nov 11 11:41:05 2009 UTC (14 years, 6 months ago) by jacekm
Branch: MAIN
Changes since 1.14: +8 -12 lines
Diff to previous 1.14 (colored)

Fix crlf issue in buf_getln, similar to that in smtp_session.c r1.123.

ok gilles@

Revision 1.14 / (download) - annotate - [select for diffs], Wed Nov 11 11:25:17 2009 UTC (14 years, 6 months ago) by jacekm
Branch: MAIN
Changes since 1.13: +10 -10 lines
Diff to previous 1.13 (colored)

improve buf_getln readability, no fuctional change.

Revision 1.13 / (download) - annotate - [select for diffs], Wed Nov 11 10:27:41 2009 UTC (14 years, 6 months ago) by jacekm
Branch: MAIN
Changes since 1.12: +15 -4 lines
Diff to previous 1.12 (colored)

Ensure all replies are at least 4 chars long.  If only 3 chars were
received, append a space character.  This enables other parts of
the daemon to safely index into 4th character of the reply buffer
without the risk of accessing one byte beyond NUL.

ok gilles@

Revision 1.12 / (download) - annotate - [select for diffs], Tue Nov 10 14:57:03 2009 UTC (14 years, 6 months ago) by jacekm
Branch: MAIN
Changes since 1.11: +2 -2 lines
Diff to previous 1.11 (colored)

Eliminate space after colon in "RCPT TO:" as required by RFC.

Revision 1.11 / (download) - annotate - [select for diffs], Tue Nov 10 14:54:13 2009 UTC (14 years, 6 months ago) by jacekm
Branch: MAIN
Changes since 1.10: +17 -2 lines
Diff to previous 1.10 (colored)

In absence of the ehlo parameter, generate one based on locally
bound IP address ("EHLO [1.2.3.4]") as dictated by RFC.

ok gilles@

Revision 1.10 / (download) - annotate - [select for diffs], Tue Nov 10 00:24:53 2009 UTC (14 years, 6 months ago) by jacekm
Branch: MAIN
Changes since 1.9: +13 -8 lines
Diff to previous 1.9 (colored)

Check for extension keywords on final multiline reply.  Skip the
check for states other than CLIENT_EHLO.  Verify response is not
shorter than 3 chars.

From Nils Frohberg
ok gilles@

Revision 1.9 / (download) - annotate - [select for diffs], Sun Oct 25 20:43:29 2009 UTC (14 years, 7 months ago) by chl
Branch: MAIN
Changes since 1.8: +2 -2 lines
Diff to previous 1.8 (colored)

Fix potential null dereference.

Found by LLVM/Clang Static Analyzer.

ok gilles@

Revision 1.8 / (download) - annotate - [select for diffs], Mon Oct 19 19:53:05 2009 UTC (14 years, 7 months ago) by gilles
Branch: MAIN
Changes since 1.7: +2 -2 lines
Diff to previous 1.7 (colored)

fix compile time warning due to missing cast

Revision 1.7 / (download) - annotate - [select for diffs], Sat Oct 3 10:02:43 2009 UTC (14 years, 8 months ago) by jacekm
Branch: MAIN
Changes since 1.6: +4 -1 lines
Diff to previous 1.6 (colored)

Avoid NULL dereference when the final RCPT TO is refused.
Reported by Didier Wiroth <dwiroth@gmail.com>

Revision 1.6 / (download) - annotate - [select for diffs], Tue Sep 22 15:44:31 2009 UTC (14 years, 8 months ago) by jacekm
Branch: MAIN
Changes since 1.5: +3 -2 lines
Diff to previous 1.5 (colored)

Make the error messages for failures at EHLO more precise by
distinguishing between unavailable extensions and those that are
available but have failed.

Revision 1.5 / (download) - annotate - [select for diffs], Tue Sep 22 12:24:06 2009 UTC (14 years, 8 months ago) by jacekm
Branch: MAIN
Changes since 1.4: +16 -18 lines
Diff to previous 1.4 (colored)

When at MAIL FROM stage, handle the case when STARTTLS is required but not
available.  Also, make the client_next_state() calls across the code more
idiomatic.

Revision 1.4 / (download) - annotate - [select for diffs], Thu Sep 17 23:51:23 2009 UTC (14 years, 8 months ago) by jacekm
Branch: MAIN
Changes since 1.3: +3 -3 lines
Diff to previous 1.3 (colored)

The client API is meant to require STARTTLS by default, a behaviour which
can be altered using client_ssl_optional().
Reported by Michael Lechtermann <michael@lechtermann.net>

Revision 1.3 / (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.2: +635 -109 lines
Diff to previous 1.2 (colored)

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

Revision 1.2 / (download) - annotate - [select for diffs], Thu Aug 27 11:42:50 2009 UTC (14 years, 9 months ago) by jacekm
Branch: MAIN
Changes since 1.1: +2 -0 lines
Diff to previous 1.1 (colored)

$OpenBSD$

Revision 1.1 / (download) - annotate - [select for diffs], Thu Aug 27 11:41:26 2009 UTC (14 years, 9 months ago) by jacekm
Branch: MAIN

Implement client side of the SMTP protocol in a library-like module.
Make bounce code and /usr/sbin/sendmail interface use this new API.
The mta process continues to use its own implementation, but
eventually will be switched to use this shared module.

Buffer routines are taken from buffer.c rather than from evbuffer.
This is one step forward to using a single buffer API across the
program.

"it looks sexy" gilles@

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.