diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2000-10-01 01:49:02 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2000-10-01 01:49:02 +0000 |
commit | f84ac9120cb7d9f087e5dcb863c4bf25ba2985e6 (patch) | |
tree | 1965ed8ab83d1520308eb01c0471d69de74d7653 /contrib/sendmail/src/srvrsmtp.c | |
parent | 4332139a9a11f773ffe5109bed871561e3c290a1 (diff) | |
download | FreeBSD-src-f84ac9120cb7d9f087e5dcb863c4bf25ba2985e6.zip FreeBSD-src-f84ac9120cb7d9f087e5dcb863c4bf25ba2985e6.tar.gz |
Import of sendmail version 8.11.1 into vendor branch SENDMAIL with
release tag v8_11_1.
Obtained from: ftp://ftp.sendmail.org/pub/sendmail/
Diffstat (limited to 'contrib/sendmail/src/srvrsmtp.c')
-rw-r--r-- | contrib/sendmail/src/srvrsmtp.c | 95 |
1 files changed, 68 insertions, 27 deletions
diff --git a/contrib/sendmail/src/srvrsmtp.c b/contrib/sendmail/src/srvrsmtp.c index 52ea42f..9989c75 100644 --- a/contrib/sendmail/src/srvrsmtp.c +++ b/contrib/sendmail/src/srvrsmtp.c @@ -16,14 +16,16 @@ #ifndef lint # if SMTP -static char id[] = "@(#)$Id: srvrsmtp.c,v 8.471.2.2.2.40 2000/07/18 02:24:45 gshapiro Exp $ (with SMTP)"; +static char id[] = "@(#)$Id: srvrsmtp.c,v 8.471.2.2.2.58 2000/09/21 21:52:18 ca Exp $ (with SMTP)"; # else /* SMTP */ -static char id[] = "@(#)$Id: srvrsmtp.c,v 8.471.2.2.2.40 2000/07/18 02:24:45 gshapiro Exp $ (without SMTP)"; +static char id[] = "@(#)$Id: srvrsmtp.c,v 8.471.2.2.2.58 2000/09/21 21:52:18 ca Exp $ (without SMTP)"; # endif /* SMTP */ #endif /* ! lint */ #if SMTP -# include "sfsasl.h" +# if SASL || STARTTLS +# include "sfsasl.h" +# endif /* SASL || STARTTLS */ # if SASL # define ENC64LEN(l) (((l) + 2) * 4 / 3 + 1) static int saslmechs __P((sasl_conn_t *, char **)); @@ -112,6 +114,11 @@ struct cmd # define CMDDBGQSHOW 24 /* showq -- show send queue */ # define CMDDBGDEBUG 25 /* debug -- set debug mode */ +/* +** Note: If you change this list, +** remember to update 'helpfile' +*/ + static struct cmd CmdTab[] = { { "mail", CMDMAIL }, @@ -232,6 +239,7 @@ smtp(nullserver, d_flags, e) # endif /* SASL */ # if STARTTLS int r; + int rfd, wfd; volatile bool usetls = TRUE; volatile bool tls_active = FALSE; bool saveQuickAbort; @@ -435,7 +443,7 @@ smtp(nullserver, d_flags, e) else snprintf(cmdbuf, sizeof cmdbuf, "%s-%%.*s ESMTP%%s", greetcode); - message(cmdbuf, id - inp, inp, id); + message(cmdbuf, (int) (id - inp), inp, id); /* output remaining lines */ while ((id = p) != NULL && (p = strchr(id, '\n')) != NULL) @@ -1001,8 +1009,11 @@ smtp(nullserver, d_flags, e) message("454 4.3.3 TLS not available: error generating SSL handle"); break; } - if (SSL_set_rfd(srv_ssl, fileno(InChannel)) <= 0 || - SSL_set_wfd(srv_ssl, fileno(OutChannel)) <= 0) + rfd = fileno(InChannel); + wfd = fileno(OutChannel); + if (rfd < 0 || wfd < 0 || + SSL_set_rfd(srv_ssl, rfd) <= 0 || + SSL_set_wfd(srv_ssl, wfd) <= 0) { message("454 4.3.3 TLS not available: error set fd"); SSL_free(srv_ssl); @@ -1252,7 +1263,14 @@ smtp(nullserver, d_flags, e) break; } - /* print EHLO features list */ + /* + ** print EHLO features list + ** + ** Note: If you change this list, + ** remember to update 'helpfile' + */ + + message("250-ENHANCEDSTATUSCODES"); if (!bitset(PRIV_NOEXPN, PrivacyFlags)) { @@ -1506,7 +1524,8 @@ smtp(nullserver, d_flags, e) Errors > 0) goto undo_subproc_no_pm; - if (MaxMessageSize > 0 && e->e_msgsize > MaxMessageSize) + if (MaxMessageSize > 0 && + (e->e_msgsize > MaxMessageSize || e->e_msgsize < 0)) { usrerr("552 5.2.3 Message size exceeds fixed maximum message size (%ld)", MaxMessageSize); @@ -1544,7 +1563,7 @@ smtp(nullserver, d_flags, e) break; case SMFIR_TEMPFAIL: - usrerr("451 4.7.1 Try again later"); + usrerr("451 4.7.1 Please try again later"); break; } if (response != NULL) @@ -1722,7 +1741,7 @@ smtp(nullserver, d_flags, e) break; case SMFIR_TEMPFAIL: - usrerr("451 4.7.1 Try again later"); + usrerr("451 4.7.1 Please try again later"); break; } if (response != NULL) @@ -1824,7 +1843,7 @@ smtp(nullserver, d_flags, e) break; case SMFIR_TEMPFAIL: - usrerr("451 4.7.1 Try again later"); + usrerr("451 4.7.1 Please try again later"); break; } if (response != NULL) @@ -2079,7 +2098,7 @@ smtp(nullserver, d_flags, e) /* see if there is more in the vrfy list */ a = vrfyqueue; while ((a = a->q_next) != NULL && - (!QS_IS_UNDELIVERED(vrfyqueue->q_state))) + (!QS_IS_UNDELIVERED(a->q_state))) continue; printvrfyaddr(vrfyqueue, a == NULL, vrfy); vrfyqueue = a; @@ -2429,11 +2448,12 @@ mail_esmtp_args(kp, vp, e) /* NOTREACHED */ } define(macid("{msg_size}", NULL), newstr(vp), e); -# if defined(__STDC__) && !defined(BROKEN_ANSI_LIBRARY) - e->e_msgsize = strtoul(vp, (char **) NULL, 10); -# else /* defined(__STDC__) && !defined(BROKEN_ANSI_LIBRARY) */ - e->e_msgsize = strtol(vp, (char **) NULL, 10); -# endif /* defined(__STDC__) && !defined(BROKEN_ANSI_LIBRARY) */ + e->e_msgsize = strtol(vp, (char **) NULL, 10); + if (e->e_msgsize == LONG_MAX && errno == ERANGE) + { + usrerr("552 5.2.3 Message size exceeds maximum value"); + /* NOTREACHED */ + } } else if (strcasecmp(kp, "body") == 0) { @@ -2587,7 +2607,7 @@ mail_esmtp_args(kp, vp, e) # endif /* SASL */ else { - usrerr("501 5.5.4 %s parameter unrecognized", kp); + usrerr("555 5.5.4 %s parameter unrecognized", kp); /* NOTREACHED */ } } @@ -2676,7 +2696,7 @@ rcpt_esmtp_args(a, kp, vp, e) } else { - usrerr("501 5.5.4 %s parameter unrecognized", kp); + usrerr("555 5.5.4 %s parameter unrecognized", kp); /* NOTREACHED */ } } @@ -2949,7 +2969,7 @@ get_dh512() ** logl -- loglevel ** ** Returns: -** None. (not yet, maybe it should return success/failure?) +** success/failure ** ** Side Effects: ** initializes PRNG for tls library. @@ -2957,26 +2977,37 @@ get_dh512() #define MIN_RAND_BYTES 16 /* 128 bits */ -void +bool tls_rand_init(randfile, logl) char *randfile; int logl; { -# ifndef HASURANDOMDEV +# ifndef HASURANDOMDEV /* not required if /dev/urandom exists, OpenSSL does it internally */ #define RF_OK 0 /* randfile OK */ #define RF_MISS 1 /* randfile == NULL || *randfile == '\0' */ #define RF_UNKNOWN 2 /* unknown prefix for randfile */ +#define RI_NONE 0 /* no init yet */ +#define RI_SUCCESS 1 /* init was successful */ +#define RI_FAIL 2 /* init failed */ + bool ok; int randdef; + static int done = RI_NONE; /* ** initialize PRNG */ + /* did we try this before? if yes: return old value */ + if (done != RI_NONE) + return done == RI_SUCCESS; + + /* set default values */ ok = FALSE; + done = RI_FAIL; randdef = (randfile == NULL || *randfile == '\0') ? RF_MISS : RF_OK; # if EGD if (randdef == RF_OK && strncasecmp(randfile, "egd:", 4) == 0) @@ -3104,8 +3135,13 @@ tls_rand_init(randfile, logl) if (LogLevel > logl) sm_syslog(LOG_WARNING, NOQID, "TLS: Warning: random number generator not properly seeded"); + ok = TRUE; } -# endif /* !HASURANDOMDEV */ + done = ok ? RI_SUCCESS : RI_FAIL; + return ok; +# else /* !HASURANDOMDEV */ + return TRUE; +# endif /* !HASURANDOMDEV */ } /* @@ -3288,6 +3324,12 @@ inittls(ctx, req, srv, certfile, keyfile, cacertpath, cacertfile, dhparam) /* already initialized? (we could re-init...) */ if (*ctx != NULL) return TRUE; + + /* PRNG seeded? */ + if (!tls_rand_init(RandFile, 10)) + return FALSE; + + /* let's start with the assumption it will work */ ok = TRUE; # if _FFR_TLS_1 @@ -3362,12 +3404,11 @@ inittls(ctx, req, srv, certfile, keyfile, cacertpath, cacertfile, dhparam) sm_syslog(LOG_WARNING, NOQID, "TLS: error: illegal value '%s' for DHParam", dhparam); - free(dhparam); dhparam = NULL; } } if (dhparam == NULL) - dhparam = srv ? newstr("1") : newstr("5"); + dhparam = srv ? "1" : "5"; else if (*dhparam == '/') { TLS_OK_F(dhparam, "DHParameters", @@ -3810,9 +3851,9 @@ tls_get_info(ssl, e, srv, host) cert = SSL_get_peer_certificate(ssl); if (LogLevel >= 14) sm_syslog(LOG_INFO, e->e_id, - "TLS: get_verify in %s: %d get_peer: 0x%x", + "TLS: get_verify in %s: %ld get_peer: 0x%lx", srv ? "srv" : "clt", - SSL_get_verify_result(ssl), cert); + SSL_get_verify_result(ssl), (u_long) cert); if (cert != NULL) { char buf[MAXNAME]; |