[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] GNU Mailutils branch, master, updated. release-2.2-154-gd992b1b
From: |
Sergey Poznyakoff |
Subject: |
[SCM] GNU Mailutils branch, master, updated. release-2.2-154-gd992b1b |
Date: |
Thu, 21 Oct 2010 22:44:58 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".
http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=d992b1b4f5d731a3e11a5caaffd22cfd068e5477
The branch, master has been updated
via d992b1b4f5d731a3e11a5caaffd22cfd068e5477 (commit)
from d9cd8883ffbad01eb69cda7ae8332038b467aaf5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d992b1b4f5d731a3e11a5caaffd22cfd068e5477
Author: Sergey Poznyakoff <address@hidden>
Date: Fri Oct 22 01:36:19 2010 +0300
Improve SMTP client.
* include/mailutils/smtp.h (mu_smtp_dot): New proto.
* libproto/mailer/smtp_dot.c: New file.
* libproto/mailer/Makefile.am (libmu_mailer_la_SOURCES): Add
smtp_dot.c.
* libproto/mailer/smtp.c (smtp_send_message): Send RSET after an
unexpected SMTP reply.
Call mu_smtp_dot after successful sending.
* libproto/mailer/smtp_data.c (_mu_smtp_data_end): Set
state to MU_SMTP_DOT.
* libproto/mailer/smtp_rset.c (mu_smtp_rset): Improve state
selection algorithm.
* libproto/mailer/smtp_send.c (mu_smtp_send_stream): Don't
reset state: it is done by _mu_smtp_data_end.
* testsuite/smtpsend.c (main): Call mu_smtp_dot after sending
message.
-----------------------------------------------------------------------
Summary of changes:
include/mailutils/smtp.h | 1 +
libproto/mailer/Makefile.am | 1 +
libproto/mailer/smtp.c | 47 +++++++++++++++++++-------
libproto/mailer/smtp_data.c | 1 +
libproto/mailer/{smtp_rset.c => smtp_dot.c} | 12 +++---
libproto/mailer/smtp_rset.c | 17 +++++++++-
libproto/mailer/smtp_send.c | 2 -
testsuite/smtpsend.c | 2 +-
8 files changed, 60 insertions(+), 23 deletions(-)
copy libproto/mailer/{smtp_rset.c => smtp_dot.c} (85%)
diff --git a/include/mailutils/smtp.h b/include/mailutils/smtp.h
index 0d692ff..1eda800 100644
--- a/include/mailutils/smtp.h
+++ b/include/mailutils/smtp.h
@@ -65,6 +65,7 @@ int mu_smtp_rcpt_basic (mu_smtp_t smtp, const char *email,
int mu_smtp_data (mu_smtp_t smtp, mu_stream_t *pstream);
int mu_smtp_send_stream (mu_smtp_t smtp, mu_stream_t str);
+int mu_smtp_dot (mu_smtp_t smtp);
int mu_smtp_rset (mu_smtp_t smtp);
int mu_smtp_quit (mu_smtp_t smtp);
diff --git a/libproto/mailer/Makefile.am b/libproto/mailer/Makefile.am
index 156dc1f..cb7ab32 100644
--- a/libproto/mailer/Makefile.am
+++ b/libproto/mailer/Makefile.am
@@ -36,6 +36,7 @@ libmu_mailer_la_SOURCES = \
smtp_create.c\
smtp_data.c\
smtp_disconnect.c\
+ smtp_dot.c\
smtp_ehlo.c\
$(SMTP_GSASL)\
smtp_io.c\
diff --git a/libproto/mailer/smtp.c b/libproto/mailer/smtp.c
index cfcad0e..5b48fce 100644
--- a/libproto/mailer/smtp.c
+++ b/libproto/mailer/smtp.c
@@ -375,8 +375,8 @@ static int
smtp_send_message (mu_mailer_t mailer, mu_message_t msg,
mu_address_t argfrom, mu_address_t argto)
{
- struct _smtp_mailer *smp = mailer->data;
- mu_smtp_t smtp = smp->smtp;
+ struct _smtp_mailer *smp;
+ mu_smtp_t smtp;
int status;
size_t size, lines, count;
const char *mail_from, *size_str;
@@ -388,7 +388,8 @@ smtp_send_message (mu_mailer_t mailer, mu_message_t msg,
smp = mailer->data;
if (!smp)
return EINVAL;
-
+ smtp = smp->smtp;
+
if ((status = mu_message_get_header (msg, &header)))
return status;
@@ -400,7 +401,7 @@ smtp_send_message (mu_mailer_t mailer, mu_message_t msg,
if (status)
return status;
- if (mu_smtp_capa_test (smp->smtp, "SIZE", &size_str) == 0 &&
+ if (mu_smtp_capa_test (smtp, "SIZE", &size_str) == 0 &&
mu_message_size (msg, &size) == 0 &&
mu_message_lines (msg, &lines) == 0)
{
@@ -409,21 +410,33 @@ smtp_send_message (mu_mailer_t mailer, mu_message_t msg,
if (msgsize && msgsize > maxsize)
return EFBIG;
- status = mu_smtp_mail_basic (smp->smtp, mail_from,
+ status = mu_smtp_mail_basic (smtp, mail_from,
"SIZE=%lu",
(unsigned long) msgsize);
}
else
- status = mu_smtp_mail_basic (smp->smtp, mail_from, NULL);
+ status = mu_smtp_mail_basic (smtp, mail_from, NULL);
if (status)
- return status;
+ {
+ if (status == MU_ERR_REPLY)
+ mu_smtp_rset (smtp);
+ return status;
+ }
status = _rcpt_to_addr (smtp, smp->rcpt_to, &count);
if (status && count == 0)
- return status;
+ {
+ if (status == MU_ERR_REPLY)
+ mu_smtp_rset (smtp);
+ return status;
+ }
status = _rcpt_to_addr (smtp, smp->rcpt_bcc, &count);
if (status && count == 0)
- return status;
+ {
+ if (status == MU_ERR_REPLY)
+ mu_smtp_rset (smtp);
+ return status;
+ }
if (mu_header_sget_value (header, MU_HEADER_BCC, NULL))
{
@@ -433,7 +446,11 @@ smtp_send_message (mu_mailer_t mailer, mu_message_t msg,
status = mu_smtp_data (smtp, &ostr);
if (status)
- return status;
+ {
+ if (status == MU_ERR_REPLY)
+ mu_smtp_rset (smtp);
+ return status;
+ }
mu_header_get_iterator (header, &itr);
for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
mu_iterator_next (itr))
@@ -451,7 +468,7 @@ smtp_send_message (mu_mailer_t mailer, mu_message_t msg,
mu_message_get_body (msg, &body);
mu_body_get_streamref (body, &bstr);
- mu_stream_copy (ostr, bstr, 0, NULL);
+ status = mu_stream_copy (ostr, bstr, 0, NULL);
mu_stream_destroy (&bstr);
mu_stream_close (ostr);
mu_stream_destroy (&ostr);
@@ -463,13 +480,17 @@ smtp_send_message (mu_mailer_t mailer, mu_message_t msg,
status = mu_smtp_send_stream (smtp, str);
mu_stream_destroy (&str);
}
- mu_smtp_quit (smtp);
mu_address_destroy (&smp->rcpt_to);
mu_address_destroy (&smp->rcpt_bcc);
+ if (status == 0)
+ {
+ status = mu_smtp_dot (smtp);
+ if (status == MU_ERR_REPLY)
+ mu_smtp_rset (smtp);
+ }
return status;
}
-
static int
_mailer_smtp_init (mu_mailer_t mailer)
{
diff --git a/libproto/mailer/smtp_data.c b/libproto/mailer/smtp_data.c
index e96fa80..efe5242 100644
--- a/libproto/mailer/smtp_data.c
+++ b/libproto/mailer/smtp_data.c
@@ -76,6 +76,7 @@ _mu_smtp_data_end (mu_smtp_t smtp)
mu_strerror (status));
}
_mu_smtp_xscript_level (smtp, MU_XSCRIPT_NORMAL);
+ smtp->state = MU_SMTP_DOT;
return status;
}
diff --git a/libproto/mailer/smtp_rset.c b/libproto/mailer/smtp_dot.c
similarity index 85%
copy from libproto/mailer/smtp_rset.c
copy to libproto/mailer/smtp_dot.c
index 7a0a2e0..8c15697 100644
--- a/libproto/mailer/smtp_rset.c
+++ b/libproto/mailer/smtp_dot.c
@@ -22,14 +22,14 @@
#include <stdlib.h>
#include <string.h>
#include <mailutils/errno.h>
-#include <mailutils/filter.h>
+#include <mailutils/cctype.h>
#include <mailutils/list.h>
+#include <mailutils/util.h>
#include <mailutils/smtp.h>
-#include <mailutils/stream.h>
#include <mailutils/sys/smtp.h>
int
-mu_smtp_rset (mu_smtp_t smtp)
+mu_smtp_dot (mu_smtp_t smtp)
{
int status;
@@ -37,12 +37,12 @@ mu_smtp_rset (mu_smtp_t smtp)
return EINVAL;
if (MU_SMTP_FISSET (smtp, _MU_SMTP_ERR))
return MU_ERR_FAILURE;
- status = mu_smtp_write (smtp, "RSET\r\n");
- MU_SMTP_CHECK_ERROR (smtp, status);
+ if (smtp->state != MU_SMTP_DOT)
+ return MU_ERR_SEQ;
status = mu_smtp_response (smtp);
MU_SMTP_CHECK_ERROR (smtp, status);
if (smtp->replcode[0] != '2')
return MU_ERR_REPLY;
- smtp->state = MU_SMTP_EHLO;
+ smtp->state = MU_SMTP_MAIL; /* FIXME: Force _EHLO perhaps? */
return 0;
}
diff --git a/libproto/mailer/smtp_rset.c b/libproto/mailer/smtp_rset.c
index 7a0a2e0..e051c7a 100644
--- a/libproto/mailer/smtp_rset.c
+++ b/libproto/mailer/smtp_rset.c
@@ -43,6 +43,21 @@ mu_smtp_rset (mu_smtp_t smtp)
MU_SMTP_CHECK_ERROR (smtp, status);
if (smtp->replcode[0] != '2')
return MU_ERR_REPLY;
- smtp->state = MU_SMTP_EHLO;
+
+ switch (smtp->state)
+ {
+ case MU_SMTP_INIT:
+ case MU_SMTP_EHLO:
+ case MU_SMTP_DOT:
+ /* RFC 2821, 4.1.1.5 RESET (RSET):
+ [RSET] is effectively equivalent to a NOOP (i.e., if has no effect)
+ if issued immediately after EHLO, before EHLO is issued in the
+ session, after an end-of-data indicator has been sent and
+ acknowledged, or immediately before a QUIT */
+ break;
+
+ default:
+ smtp->state = MU_SMTP_MAIL;
+ }
return 0;
}
diff --git a/libproto/mailer/smtp_send.c b/libproto/mailer/smtp_send.c
index 104fa12..b492573 100644
--- a/libproto/mailer/smtp_send.c
+++ b/libproto/mailer/smtp_send.c
@@ -62,7 +62,5 @@ mu_smtp_send_stream (mu_smtp_t smtp, mu_stream_t stream)
status = _smtp_data_send (smtp, input);
mu_stream_destroy (&input);
- if (status == 0)
- smtp->state = MU_SMTP_DOT;
return status;
}
diff --git a/testsuite/smtpsend.c b/testsuite/smtpsend.c
index c93dcc0..a716c3d 100644
--- a/testsuite/smtpsend.c
+++ b/testsuite/smtpsend.c
@@ -289,7 +289,7 @@ main (int argc, char **argv)
mu_stream_close (ostr);
mu_stream_destroy (&ostr);
}
-
+ MU_ASSERT (mu_smtp_dot (smtp));
MU_ASSERT (mu_smtp_quit (smtp));
mu_smtp_destroy (&smtp);
hooks/post-receive
--
GNU Mailutils
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] GNU Mailutils branch, master, updated. release-2.2-154-gd992b1b,
Sergey Poznyakoff <=