提交 9576545a 编写于 作者: R Robert Scheck 提交者: Rich Salz

Add LMTP support (RFC 2033) to s_client ("-starttls lmtp")

Reviewed-by: NRichard Levitte <levitte@openssl.org>
Reviewed-by: NRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1945)
上级 5defbe6f
...@@ -619,7 +619,8 @@ const OPTIONS s_client_options[] = { ...@@ -619,7 +619,8 @@ const OPTIONS s_client_options[] = {
{"keymatexportlen", OPT_KEYMATEXPORTLEN, 'p', {"keymatexportlen", OPT_KEYMATEXPORTLEN, 'p',
"Export len bytes of keying material (default 20)"}, "Export len bytes of keying material (default 20)"},
{"fallback_scsv", OPT_FALLBACKSCSV, '-', "Send the fallback SCSV"}, {"fallback_scsv", OPT_FALLBACKSCSV, '-', "Send the fallback SCSV"},
{"name", OPT_SMTPHOST, 's', "Hostname to use for \"-starttls smtp\""}, {"name", OPT_SMTPHOST, 's',
"Hostname to use for \"-starttls lmtp\" or \"-starttls smtp\""},
{"CRL", OPT_CRL, '<', "CRL file to use"}, {"CRL", OPT_CRL, '<', "CRL file to use"},
{"crl_download", OPT_CRL_DOWNLOAD, '-', "Download CRL from distribution points"}, {"crl_download", OPT_CRL_DOWNLOAD, '-', "Download CRL from distribution points"},
{"CRLform", OPT_CRLFORM, 'F', "CRL format (PEM or DER) PEM is default"}, {"CRLform", OPT_CRLFORM, 'F', "CRL format (PEM or DER) PEM is default"},
...@@ -743,7 +744,8 @@ typedef enum PROTOCOL_choice { ...@@ -743,7 +744,8 @@ typedef enum PROTOCOL_choice {
PROTO_XMPP_SERVER, PROTO_XMPP_SERVER,
PROTO_CONNECT, PROTO_CONNECT,
PROTO_IRC, PROTO_IRC,
PROTO_POSTGRES PROTO_POSTGRES,
PROTO_LMTP
} PROTOCOL_CHOICE; } PROTOCOL_CHOICE;
static const OPT_PAIR services[] = { static const OPT_PAIR services[] = {
...@@ -756,6 +758,7 @@ static const OPT_PAIR services[] = { ...@@ -756,6 +758,7 @@ static const OPT_PAIR services[] = {
{"telnet", PROTO_TELNET}, {"telnet", PROTO_TELNET},
{"irc", PROTO_IRC}, {"irc", PROTO_IRC},
{"postgres", PROTO_POSTGRES}, {"postgres", PROTO_POSTGRES},
{"lmtp", PROTO_LMTP},
{NULL, 0} {NULL, 0}
}; };
...@@ -1854,6 +1857,7 @@ int s_client_main(int argc, char **argv) ...@@ -1854,6 +1857,7 @@ int s_client_main(int argc, char **argv)
switch ((PROTOCOL_CHOICE) starttls_proto) { switch ((PROTOCOL_CHOICE) starttls_proto) {
case PROTO_OFF: case PROTO_OFF:
break; break;
case PROTO_LMTP:
case PROTO_SMTP: case PROTO_SMTP:
{ {
/* /*
...@@ -1867,14 +1871,24 @@ int s_client_main(int argc, char **argv) ...@@ -1867,14 +1871,24 @@ int s_client_main(int argc, char **argv)
int foundit = 0; int foundit = 0;
BIO *fbio = BIO_new(BIO_f_buffer()); BIO *fbio = BIO_new(BIO_f_buffer());
BIO_push(fbio, sbio); BIO_push(fbio, sbio);
/* wait for multi-line response to end from SMTP */ /* Wait for multi-line response to end from LMTP or SMTP */
do { do {
mbuf_len = BIO_gets(fbio, mbuf, BUFSIZZ); mbuf_len = BIO_gets(fbio, mbuf, BUFSIZZ);
} }
while (mbuf_len > 3 && mbuf[3] == '-'); while (mbuf_len > 3 && mbuf[3] == '-');
BIO_printf(fbio, "EHLO %s\r\n", ehlo); switch ((PROTOCOL_CHOICE) starttls_proto) {
case PROTO_LMTP:
BIO_printf(fbio, "LHLO %s\r\n", ehlo);
break;
case PROTO_SMTP:
BIO_printf(fbio, "EHLO %s\r\n", ehlo);
break;
}
(void)BIO_flush(fbio); (void)BIO_flush(fbio);
/* wait for multi-line response to end EHLO SMTP response */ /*
* Wait for multi-line response to end LHLO LMTP or EHLO SMTP
* response.
*/
do { do {
mbuf_len = BIO_gets(fbio, mbuf, BUFSIZZ); mbuf_len = BIO_gets(fbio, mbuf, BUFSIZZ);
if (strstr(mbuf, "STARTTLS")) if (strstr(mbuf, "STARTTLS"))
......
...@@ -437,7 +437,7 @@ command for more information. ...@@ -437,7 +437,7 @@ command for more information.
send the protocol-specific message(s) to switch to TLS for communication. send the protocol-specific message(s) to switch to TLS for communication.
B<protocol> is a keyword for the intended protocol. Currently, the only B<protocol> is a keyword for the intended protocol. Currently, the only
supported keywords are "smtp", "pop3", "imap", "ftp", "xmpp", "xmpp-server", supported keywords are "smtp", "pop3", "imap", "ftp", "xmpp", "xmpp-server",
"irc" and "postgres." "irc", "postgres" and "lmtp".
=item B<-xmpphost hostname> =item B<-xmpphost hostname>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册