Import sendmail 8.13.6

Security:       FreeBSD-SA-06:13.sendmail
This commit is contained in:
Gregory Neil Shapiro 2006-03-22 16:40:03 +00:00
parent 0c97652c0b
commit 4e4196cb74
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/sendmail/dist/; revision=157001
svn path=/vendor/sendmail/8.13.6/; revision=157003; tag=vendor/sendmail/8.13.6
82 changed files with 2376 additions and 1116 deletions

View File

@ -88,6 +88,83 @@ y+PVZ1MwnEXfTQReVSla0AAOIRirHEh4YnUVZzFSNEJqoDRZQwVd7Q==
=shxn =shxn
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----
Type Bits KeyID Created Expires Algorithm Use
pub 1024 0xAF959625 2005-12-31 ---------- RSA Sign & Encrypt
f16 Fingerprint16 = E3 F4 97 BC 9F DF 3F 1D 9B 0D DF D5 77 9A C9 79
uid Sendmail Signing Key/2006 <sendmail@Sendmail.ORG>
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.1 (OpenBSD)
mQCNA0O3FKgAAAEEALUfKjFiXc8T2XS4C8N/jJQkProkzyl7mdN0xVKqokMy9/rx
nbji5dG7WlxyJX3jI9eypZV/d5+KpXljvyC+cBIxhhmsEhVT6AsOkxlg/Y8Gmb5Q
bn2mAiyeaylvcFeHLjBA+CaMByDms97M6FbiSzdXx6JtLP1Tdx57s8ivlZYlAAUR
tDFTZW5kbWFpbCBTaWduaW5nIEtleS8yMDA2IDxzZW5kbWFpbEBTZW5kbWFpbC5P
Ukc+iQCVAwUQQ7cUqB57s8ivlZYlAQEn6gQApe1I5DhI/Y+fwI8hjx7Ydd8LQ553
CoBYnvoqrxybSZtOc3D7LHoKIb01R2hx71O282soxjL6N9SGnGQMcVPINXAcJ0Z0
mTCpUZc+QtItS44R3aqp27q0C8FTt885/pkKT0cQM/9EjWRv3kI+f39gl+MwcA3I
AV4NJmTpi6ASzmmJAJUDBRBDtxYm71iWZNQy4Z0BAbnQA/wIfK6PT+zTefydUovI
G3dDLGGxMowpdG5yQwPwkAEIPFlbLhYsk8E9t8sLsLI1briqKaqxZkHo9ggPNkZU
6Kojwrs7imUZj4AMVL7HDqOlb+jHeYsg3yq/KzKIy3i1fmyUYA/cddSJOp3a0zjy
IISZ9VPR6/KaOj8cLKTQqZG6tYkAlQMFEEO3FjvBnB0lEtNGHQEBJWgD/RkJuAVQ
LL0cEe/VBUi4CmW3iGF+mAokJZn750ibVQg25SjDUc0UScxyvSnl8ehu3fjWmsEu
ckHbzBWkMx/cnCb7xG5Ve1HGgzsBjFpvcQUM07y4JCFOfTOl3WiYP311EKBp2tnL
2i/kdD1IVITswAEQ7XId1NBIuf4P71v16rj/iQCVAwUQQ7cWRL3aj9Y/6n39AQGO
uAQApQ5v6HZkgFNKT+SaXJOsqtk+xQQd19QfQQ2U13uaJ0nQ0i4O11WUTM9qfdWF
utTlDTZKeEdz+Zb67KnuIi8PHyMpBPV1BGvWNqeiEN0Q5TmkxmaXBXTWtGeHoWw4
Jxaic4LdunSNDIpE0A9zfeaj9YJGX87I3KMf1DQ3h+FCRRWJAJUDBRBDtxZZfEtn
baAOFWMBAVi/A/0bQQvU747R5bMC0vQLRMVOtq6rDwNPlXoFhzW26AU2Pb+mKCkU
ugVqjFaAWm2ILxKvkjgDyfw6b62IvEK4rHJbfwH/FeIfi6e0+ye+TpXcCzXkARTm
FHld0IERIXpaUA6XarNlWfiqaZN0YLpCQH0M29kTFvIfyoUHn9LgvBLe1YkAlQMF
EEO3Fl9vUpPYo5umVQEBVtwEAIaSvlhM+gIKnlxN/1hpcG9639bLlUTkAt2gtn2w
4hPDZxMpblkQhcn3JcO9GD0BHNrV5qYBn3bLFwTG2FIoaROS4XyH8GPbEBWGNg9d
IGm3kLdLTWsRVCtlkLKE74ipiiaN8JhPRGAtFUjcDVSSkGNzw2jBHP0hrQEKga9R
wElSiQCVAwUQQ7cWepwcveLjXFY1AQFA/AP7BRC5j+Hed/B/RjbsbX3mxk4DprEh
6IijxC/2XAZbk1e25GspBO9Pbqs/2GufGCFX60Jj1FQJ2+vq8vg7chNNZ5XNEJse
6GrQtUx2/mEKMtvWGbWGSn53ET+AzmLne/u+f3bIh1OtXXro7w8OUkK9J+ZdG/9V
J/a0nYTlPUw6o3KJAJUDBRBDtxaE1uCh/k++Kt0BAf14BAC4mGT1gE0aoW8rn7kk
XJ3an4hThBZVuR2GS+rvwioEsIk2xe4NEFwJPGKmKq+C4vb0OWSiRev5l1fPx13x
tWDGcm2k3SukDOHB0le6gS0RQx/WHCTe/lRKiQ3w/IuhLmrDfmoOOkDj6KVb5fA0
x0Uvd4ycXUPSoJcBq7dwNg0f8YkAlQMFEEO3Foo4IttHzDdPLQEB6N0D/3LRqVT4
Dhw6UmDIre9Tag8EmqTu3R8wFTmmEYDQ+7CxW+ZbJyYEDZp/WU/6xmOE2TSHaFPQ
lgFEAaN1Cp4N9IXAM2EqeNK3fJOAsv4F5NOXbVtGJhyqG4aDUBZPvr/p123cpiiH
2yVIvHDkaacX1Tq/kECpKLj4k5D+dQYrUVdCiQCVAwUQQ7cWl4lpYrhnjAoDAQG9
pQQAg78+p2O+g7qPh1dAMcnQrI1eW3fTntWbadoKPXO5oFr/n+a74Go0D9+8J9Tt
iW3C11KR3w1q+af5wp+viJfe8YDEwvm5gcmoCxPnwOeSAzdquujnQZRE5lynr6r7
QzJOFZv457qzndC2P5qSODCkmVC6uAsRxo4Xq/zflzRXmzCJAJUDBRBDtxaeIYPh
sTlvB4kBAcvhA/9LBX9mskFW9IpA3Y5slRV1G2GFv0DXV79295p8OCKlZhEfk1y+
JyvT2hdnseD3Id2cyoMlEk57gJBuDrKdjeOLBMIJ2lOKGE6dLAsywSYkyFnngXu7
6QvoTS0mE+ahJlT9VDz79Jl6W+118cIeYzzt1TP8c1WkWBCJJcvge390BYkAlQMF
EEO3FqXI1e0plfYXcQEB7W0D/AjxxjEMuS3UedxXI8VQzTB2o3c0o5DdlK2SXgHP
SFxr9feksucCanCoYfuTWgxm/Ioy7cxtVNZT1dAHfn2MSrGN+2Adoep8E/o6PyiD
t3pCzowtXFS1wjq1j/MX5SJoDrGl0VT1sQXsWh2uOFaeMfH1w9/r9Zkl1RYXYOEn
/jkmiQCVAwUQQ7cWunCgJE0e+ZJRAQGTqgQAtdhMXLTw+tBCshX/CdLhrD0byRN5
omeib2QWmxdi7Djyz1wbDMBhnssM3SHUj/kRiorTnjv7qU8TS4z9r9zXw9U7XjCO
T/CRepb3siiHzMU4KI5bxdg0ZAsauCVDel5MItT7OlK2Fjv4vCYam/jHGYXe6AEY
dbARTWInDsFK7VCJAJUDBRBDtxgXwCnKQBb0zOkBAQHXA/47Mvt5oI8f2JbOMLkV
E14upGU+zXYeWH7j9L4AYRzjl/Lg7tT+LBTjh+HEdl2UIMdYASrC6WbKEbatb4dr
nu/pxd7/QaeSMV00P9j+Cfa3uIWn6HFUi+TH5fkLwERfkcLHKZ5SshZal9KTbjzv
uwZsArnsNN0A/d1gUqljdDI/K4kAlQMFEEO7cAXPHrUDIjJ6AQEBYWMEAIJ5g1oG
cL28orl4J7SxhOMyQODgaPRHusnWTBsa/ufUugVSR0g+3a2Pzyuq9xWqYStHf50N
hdFx45JtPmkAiWuiBsyycVbBq/ursCeL2SCQPBCcbIfB+4BUbWoU62QA0a+sY5bW
mitsU1FB2Mxd7QWqIBW4jqwB0nsAVxShRdWliJwEEAECAAYFAkO7mAoACgkQ+IYW
ZdmHE1gcHAQAkMZ2julBDdx5TeQ3rrFus44snaHiq5exlN1wIJrVIhJzmOcHq5i5
ysfoKSha0cYf6F+6kTFxNL/Y9mneisg+rWfgRYmHDzNvXcuyAY/g6rwkRoyVN70q
XhWXdY6nA29E5VH52pKCdjQgpbdyO6JDglLzfq7jVljCuPq8+PXqN+OIRgQQEQIA
BgUCQ7uYzAAKCRDEsQeYhXlqI6AlAJ48z/+X/bUYIu1yekM+Wa3uN1SgSQCePzZl
iV3/rvMdwqhHZPfM00GQQxOIRgQQEQIABgUCQ7vkHwAKCRAJp6JK0eWCB903AJ9x
Jkm4hmDjMy8+ynBwFrnKzmGUgQCdGoOE+xbNHN2kArmTHDvzd80yQAeJAJUDBRJD
u9CCXx7Ib4gMnlUBAfFkA/wP/qNyveNU4ZyJt+Ft/1xIYV4Gk/FJ4MOfpRlDYaN7
z2FXCjXtWeoxEJ8hqtWUMBuQHSm5T49Zv7Tb+6jtflscL3E/Kz3nIIr3Tzu1iNIM
m3dzI37Qdk/7tnP2fp1fO2VbrQC7CtQTYODko6vTUSLap4+NWbidGNQMSEXAFfBK
2okAlQMFEEO776zh1PwU5tB0cQEBZrEEAMjAS0ahmy5KzFgRMrrI3RkrcKwi+Hnj
Vuw6UowvW7tUhIkdFuXpd/a2YczU2Enivu7uSJgUD/2KzurD60ahJjSkC/l8xDNs
v5wvbB+nYCOVDEvL32tvGiyLyT72MpkwT3ECYXFdlwpk2P7bk87tA9isuue0Nqvr
TlO5vpTGYrPoiEYEEBECAAYFAkO9OlsACgkQorv7JAz5Vve2KACdGpTb2FWBtvXB
cyIoyLoYGLWwtSYAoLDtcY9f816jYC3awv42YCMLuKuE
=bh1L
-----END PGP PUBLIC KEY BLOCK-----
Type Bits KeyID Created Expires Algorithm Use Type Bits KeyID Created Expires Algorithm Use
pub 1024 0x1EF99251 2004-12-30 ---------- RSA Sign & Encrypt pub 1024 0x1EF99251 2004-12-30 ---------- RSA Sign & Encrypt
f16 Fingerprint16 = 4B 38 0E 0B 41 E8 FC 79 E9 7E 82 9B 04 23 EC 8A f16 Fingerprint16 = 4B 38 0E 0B 41 E8 FC 79 E9 7E 82 9B 04 23 EC 8A
@ -1094,4 +1171,4 @@ SIXqPke2iCW6+zdG1T/gS5T9T9/Lf2c9FQf0FjURAi3ynDA2RBLA5FDsI8v3
=dbDm =dbDm
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----
$Revision: 8.21 $, Last updated $Date: 2005/01/07 04:39:10 $ $Revision: 8.23 $, Last updated $Date: 2006/01/07 01:07:21 $

View File

@ -3,17 +3,18 @@
This directory has the latest sendmail(TM) software from Sendmail, Inc. This directory has the latest sendmail(TM) software from Sendmail, Inc.
Report any bugs to sendmail-bugs@sendmail.ORG Report any bugs to sendmail-bugs-YYYY@support.sendmail.org
where YYYY is the current year, e.g., 2005.
There is a web site at http://WWW.Sendmail.ORG/ -- see that site for There is a web site at http://www.sendmail.org/ -- see that site for
the latest updates. the latest updates.
+--------------+ +--------------+
| INTRODUCTION | | INTRODUCTION |
+--------------+ +--------------+
0. The vast majority of queries to <sendmail-questions@sendmail.org> 0. The vast majority of queries about sendmail are answered in the
are answered in the README files noted below. README files noted below.
1. Read this README file, especially this introduction, and the DIRECTORY 1. Read this README file, especially this introduction, and the DIRECTORY
PERMISSIONS sections. PERMISSIONS sections.
@ -463,4 +464,4 @@ sendmail Source for the sendmail program itself.
test Some test scripts (currently only for compilation aids). test Some test scripts (currently only for compilation aids).
vacation Source for the vacation program. NOT PART OF SENDMAIL! vacation Source for the vacation program. NOT PART OF SENDMAIL!
$Revision: 8.91 $, Last updated $Date: 2002/11/09 23:33:07 $ $Revision: 8.93 $, Last updated $Date: 2005/09/16 20:08:50 $

View File

@ -1,11 +1,120 @@
SENDMAIL RELEASE NOTES SENDMAIL RELEASE NOTES
$Id: RELEASE_NOTES,v 8.1730 2005/03/28 00:31:23 gshapiro Exp $ $Id: RELEASE_NOTES,v 8.1765 2006/03/08 02:15:03 ca Exp $
This listing shows the version of the sendmail binary, the version This listing shows the version of the sendmail binary, the version
of the sendmail configuration files, the date of release, and a of the sendmail configuration files, the date of release, and a
summary of the changes in that release. summary of the changes in that release.
8.13.6/8.13.6 2006/03/22
SECURITY: Replace unsafe use of setjmp(3)/longjmp(3) in the server
and client side of sendmail with timeouts in the libsm I/O
layer and fix problems in that code. Also fix handling of
a buffer in sm_syslog() which could have been used as an
attack vector to exploit the unsafe handling of
setjmp(3)/longjmp(3) in combination with signals.
Problem detected by Mark Dowd of ISS X-Force.
Handle theoretical integer overflows that could triggered if
the server accepted headers larger than the maximum
(signed) integer value. This is prevented in the default
configuration by restricting the size of a header, and on
most machines memory allocations would fail before reaching
those values. Problems found by Phil Brass of ISS.
If a server returns 421 for an RSET command when trying to start
another transaction in a session while sending mail, do
not trigger an internal consistency check. Problem found
by Allan E Johannesen of Worcester Polytechnic Institute.
If a server returns a 5xy error code (other than 501) in response
to a STARTTLS command despite the fact that it advertised
STARTTLS and that the code is not valid according to RFC
2487 treat it nevertheless as a permanent failure instead
of a protocol error (which has been changed to a
temporary error in 8.13.5). Problem reported by Jeff
A. Earickson of Colby College.
Clear SMTP state after a HELO/EHLO command. Patch from John
Myers of Proofpoint.
Observe MinQueueAge option when gathering entries from the queue
for sorting etc instead of waiting until the entries are
processed. Patch from Brian Fundakowski Feldman.
Set up TLS session cache to properly handle clients that try to
resume a stored TLS session.
Properly count the number of (direct) child processes such that
a configured value (MaxDaemonChildren) is not exceeded.
Based on patch from Attila Bruncsak.
LIBMILTER: Remove superfluous backslash in macro definition
(libmilter.h). Based on patch from Mike Kupfer of
Sun Microsystems.
LIBMILTER: Don't try to set SO_REUSEADDR on UNIX domain sockets.
This generates an error message from libmilter on
Solaris, though other systems appear to just discard the
request silently.
LIBMILTER: Deal with sigwait(2) implementations that return
-1 and set errno instead of returning an error code
directly. Patch from Chris Adams of HiWAAY Informations
Services.
Portability:
Fix compilation checks for closefrom(3) and statvfs(2)
in NetBSD. Problem noted by S. Moonesamy, patch from
Andrew Brown.
8.13.5/8.13.5 2005/09/16
Store the filesystem identifier of the df/ subdirectory (if it
exists) in an internal structure instead of the base
directory. This structure is used decide whether there
is enough free disk space when selecting a queue, hence
without this change queue selection could fail if a df/
subdirectory exists and is on a different filesystem
than the base directory.
Use the queue index of the df file (instead of the qf file) for
checking whether a link(2) operation can be used to split
an envelope across queue groups. Problem found by
Werner Wiethege.
If the list of items in the queue is larger than the maximum
number of items to process, sort the queue first and
then cut the list off instead of the other way around.
Patch from Matej Vela of Rudjer Boskovic Institute.
Fix helpfile to show full entry for ETRN. Problem noted by
Penelope Fudd, patch from Neil Rickert of Northern Illinois
University.
FallbackSmartHost should also be tried on temporary errors.
From John Beck of Sun Microsystems.
When a server responds with 421 to the STARTTLS command then treat
it as a temporary error, not as protocol error. Problem
noted by Andrey J. Melnikoff.
Properly define two functions in libsm as static because their
prototype used static too. Patch from Peter Klein.
Fix syntax errors in helpfile for MAIL and RCPT commands.
LIBMILTER: When smfi_replacebody() is called with bodylen equals
zero then do not silently ignore that call. Patch from
Gurusamy Sarathy of Active State.
LIBMILTER: Recognize "421" also in a multi-line reply to terminate
the SMTP session with that error. Fix from Brian Kantor.
Portability: New option HASSNPRINTF which can be set if the OS
has a properly working snprintf(3) to get rid
of the last two (safe) sprintf(3) calls in the
source code.
Add support for AIX 5.3.
Add support for SunOS 5.11 (aka Solaris 11).
Add support for Darwin 8.x. Patch from Lyndon Nerenberg.
OpenBSD 3.7 has removed support for NETISO.
CONFIG: Add OSTYPE(freebsd6) for FreeBSD 6.X.
Set DontBlameSendmail to AssumeSafeChown and
GroupWritableDirPathSafe for OSTYPE(darwin).
Patch from Lyndon Nerenberg.
Some features still used 4.7.1 as enhanced status code which
was supposed to be eliminated in 8.13.0 because some
broken systems misinterpret it as a permanent error.
Patch from Matej Vela of Rudjer Boskovic Institute.
Some default values in a generated cf file did not match
the defaults in the sendmail binary. Problem noted
by Mike Pechkin.
New Files:
cf/ostype/freebsd6.m4
devtools/OS/AIX.5.3
devtools/OS/Darwin.8.x
devtools/OS/SunOS.5.11
include/sm/time.h
8.13.4/8.13.4 2005/03/27 8.13.4/8.13.4 2005/03/27
The bug fixes in 8.13.3 for connection handling uncovered a The bug fixes in 8.13.3 for connection handling uncovered a
different error which could result in connections that different error which could result in connections that

View File

@ -77,7 +77,7 @@ Let's examine a typical .mc file:
divert(-1) divert(-1)
# #
# Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers. # Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers.
# All rights reserved. # All rights reserved.
# Copyright (c) 1983 Eric P. Allman. All rights reserved. # Copyright (c) 1983 Eric P. Allman. All rights reserved.
# Copyright (c) 1988, 1993 # Copyright (c) 1988, 1993
@ -492,11 +492,12 @@ QPAGE_MAILER_QGRP [undefined] The queue group for the qpage mailer.
LOCAL_PROG_QGRP [undefined] The queue group for the prog mailer. LOCAL_PROG_QGRP [undefined] The queue group for the prog mailer.
Note: to tweak Name_MAILER_FLAGS use the macro MODIFY_MAILER_FLAGS: Note: to tweak Name_MAILER_FLAGS use the macro MODIFY_MAILER_FLAGS:
MODIFY_MAILER_FLAGS(`Name', `change') where Name is the first part of MODIFY_MAILER_FLAGS(`Name', `change') where Name is the first part
the macro Name_MAILER_FLAGS and change can be: flags that should of the macro Name_MAILER_FLAGS (note: that means Name is entirely in
be used directly (thus overriding the default value), or if it upper case) and change can be: flags that should be used directly
starts with `+' (`-') then those flags are added to (removed from) (thus overriding the default value), or if it starts with `+' (`-')
the default value. Example: then those flags are added to (removed from) the default value.
Example:
MODIFY_MAILER_FLAGS(`LOCAL', `+e') MODIFY_MAILER_FLAGS(`LOCAL', `+e')
@ -958,7 +959,7 @@ generics_entire_domain
virtusertable A domain-specific form of aliasing, allowing multiple virtusertable A domain-specific form of aliasing, allowing multiple
virtual domains to be hosted on one machine. For example, virtual domains to be hosted on one machine. For example,
if the virtuser table contained: if the virtuser table contains:
info@foo.com foo-info info@foo.com foo-info
info@bar.com bar-info info@bar.com bar-info
@ -1186,7 +1187,7 @@ accept_unqualified_senders
Normally, MAIL FROM: commands in the SMTP session will be Normally, MAIL FROM: commands in the SMTP session will be
refused if the connection is a network connection and the refused if the connection is a network connection and the
sender address does not include a domain name. If your sender address does not include a domain name. If your
setup sends local mail unqualified (i.e., MAIL FROM: <joe>), setup sends local mail unqualified (i.e., MAIL FROM:<joe>),
you will need to use this feature to accept unqualified you will need to use this feature to accept unqualified
sender addresses. Setting the DaemonPortOptions modifier sender addresses. Setting the DaemonPortOptions modifier
'u' overrides the default behavior, i.e., unqualified 'u' overrides the default behavior, i.e., unqualified
@ -1872,7 +1873,8 @@ sections below).
See the file cf/sendmail.schema for the actual LDAP schemas. Note that See the file cf/sendmail.schema for the actual LDAP schemas. Note that
this schema (and therefore the lookups and examples below) is experimental this schema (and therefore the lookups and examples below) is experimental
at this point as it has had little public review. Therefore, it may change at this point as it has had little public review. Therefore, it may change
in future versions. Feedback via sendmail@sendmail.org is encouraged. in future versions. Feedback via sendmail-YYYY@support.sendmail.org is
encouraged (replace YYYY with the current year, e.g., 2005).
------- -------
Aliases Aliases
@ -2336,7 +2338,7 @@ without any prior arrangement). Along the same lines,
FEATURE(`relay_local_from') FEATURE(`relay_local_from')
will allow relaying if the sender specifies a return path (i.e. will allow relaying if the sender specifies a return path (i.e.
MAIL FROM: <user@domain>) domain which is a local domain. This is a MAIL FROM:<user@domain>) domain which is a local domain. This is a
dangerous feature as it will allow spammers to spam using your mail dangerous feature as it will allow spammers to spam using your mail
server by simply specifying a return address of user@your.domain.com. server by simply specifying a return address of user@your.domain.com.
It should not be used unless absolutely necessary. It should not be used unless absolutely necessary.
@ -2357,7 +2359,7 @@ allow relaying for roaming users.
If source routing is used in the recipient address (e.g., If source routing is used in the recipient address (e.g.,
RCPT TO: <user%site.com@othersite.com>), sendmail will check RCPT TO:<user%site.com@othersite.com>), sendmail will check
user@site.com for relaying if othersite.com is an allowed relay host user@site.com for relaying if othersite.com is an allowed relay host
in either class {R}, class {m} if FEATURE(`relay_entire_domain') is used, in either class {R}, class {m} if FEATURE(`relay_entire_domain') is used,
or the access database if FEATURE(`access_db') is used. To prevent or the access database if FEATURE(`access_db') is used. To prevent
@ -2522,15 +2524,30 @@ The value part of the map can contain:
it but causing the default action. it but causing the default action.
### any text where ### is an RFC 821 compliant error code and ### any text where ### is an RFC 821 compliant error code and
"any text" is a message to return for the command. "any text" is a message to return for the command.
The string should be quoted to avoid surprises, The entire string should be quoted to avoid
e.g., sendmail may remove spaces otherwise. surprises:
"### any text"
Otherwise sendmail formats the text as email
addresses, e.g., it may remove spaces.
This type is deprecated, use one of the two This type is deprecated, use one of the two
ERROR: entries below instead. ERROR: entries below instead.
ERROR:### any text ERROR:### any text
as above, but useful to mark error messages as such. as above, but useful to mark error messages as such.
If quotes need to be used to avoid modifications
(see above), they should be placed like this:
ERROR:"### any text"
ERROR:D.S.N:### any text ERROR:D.S.N:### any text
where D.S.N is an RFC 1893 compliant error code where D.S.N is an RFC 1893 compliant error code
and the rest as above. and the rest as above. If quotes need to be used
to avoid modifications, they should be placed
like this:
ERROR:D.S.N:"### any text"
QUARANTINE:any text QUARANTINE:any text
Quarantine the message using the given text as the Quarantine the message using the given text as the
quarantining reason. quarantining reason.
@ -2796,9 +2813,9 @@ That may cause problems with simple header checks due to the
tokenization. It might be simpler to use a regex map and apply it tokenization. It might be simpler to use a regex map and apply it
to $&{currHeader}. to $&{currHeader}.
2. There are no default rulesets coming with this distribution of 2. There are no default rulesets coming with this distribution of
sendmail. You can either write your own or you can search the sendmail. You can write your own, can search the WWW for examples,
WWW for examples, e.g., http://www.digitalanswers.org/check_local/ or take a look at cf/cf/knecht.mc.
3. When using a default ruleset for headers, the name of the header 3. When using a default ruleset for headers, the name of the header
currently being checked can be found in the $&{hdr_name} macro. currently being checked can be found in the $&{hdr_name} macro.
After all of the headers are read, the check_eoh ruleset will be called for After all of the headers are read, the check_eoh ruleset will be called for
@ -4011,12 +4028,17 @@ confDONT_INIT_GROUPS DontInitGroups [False] If set, the initgroups(3)
will only have their primary will only have their primary
(/etc/passwd) group permissions. (/etc/passwd) group permissions.
confUNSAFE_GROUP_WRITES UnsafeGroupWrites confUNSAFE_GROUP_WRITES UnsafeGroupWrites
[False] If set, group-writable [True] If set, group-writable
:include: and .forward files are :include: and .forward files are
considered "unsafe", that is, programs considered "unsafe", that is, programs
and files cannot be directly referenced and files cannot be directly referenced
from such files. World-writable files from such files. World-writable files
are always considered unsafe. are always considered unsafe.
Notice: this option is deprecated and
will be removed in future versions;
Set GroupWritableForwardFileSafe
and GroupWritableIncludeFileSafe in
DontBlameSendmail if required.
confCONNECT_ONLY_TO ConnectOnlyTo [undefined] override connection confCONNECT_ONLY_TO ConnectOnlyTo [undefined] override connection
address (for testing). address (for testing).
confCONTROL_SOCKET_NAME ControlSocketName confCONTROL_SOCKET_NAME ControlSocketName
@ -4183,7 +4205,7 @@ confNICE_QUEUE_RUN NiceQueueRun [undefined] If set, the priority of
confDIRECT_SUBMISSION_MODIFIERS DirectSubmissionModifiers confDIRECT_SUBMISSION_MODIFIERS DirectSubmissionModifiers
[undefined] Defines {daemon_flags} [undefined] Defines {daemon_flags}
for direct submissions. for direct submissions.
confUSE_MSP UseMSP [false] Use as mail submission confUSE_MSP UseMSP [undefined] Use as mail submission
program, see sendmail/SECURITY. program, see sendmail/SECURITY.
confDELIVER_BY_MIN DeliverByMin [0] Minimum time for Deliver By confDELIVER_BY_MIN DeliverByMin [0] Minimum time for Deliver By
SMTP Service Extension (RFC 2852). SMTP Service Extension (RFC 2852).
@ -4583,4 +4605,4 @@ M4 DIVERSIONS
8 DNS based blacklists 8 DNS based blacklists
9 special local rulesets (1 and 2) 9 special local rulesets (1 and 2)
$Revision: 8.694 $, Last updated $Date: 2005/03/23 21:41:09 $ $Revision: 8.704 $, Last updated $Date: 2006/02/15 05:49:31 $

View File

@ -1,7 +1,7 @@
# #
# Makefile for configuration files. # Makefile for configuration files.
# #
# $Id: Makefile,v 8.59 2004/08/06 03:54:05 gshapiro Exp $ # $Id: Makefile,v 8.60 2005/06/14 02:16:34 gshapiro Exp $
# #
# #
@ -168,6 +168,7 @@ M4FILES=\
${CFDIR}/ostype/dynix3.2.m4 \ ${CFDIR}/ostype/dynix3.2.m4 \
${CFDIR}/ostype/freebsd4.m4 \ ${CFDIR}/ostype/freebsd4.m4 \
${CFDIR}/ostype/freebsd5.m4 \ ${CFDIR}/ostype/freebsd5.m4 \
${CFDIR}/ostype/freebsd6.m4 \
${CFDIR}/ostype/gnu.m4 \ ${CFDIR}/ostype/gnu.m4 \
${CFDIR}/ostype/hpux10.m4 \ ${CFDIR}/ostype/hpux10.m4 \
${CFDIR}/ostype/hpux11.m4 \ ${CFDIR}/ostype/hpux11.m4 \

View File

@ -1,6 +1,6 @@
divert(-1) divert(-1)
# #
# Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers. # Copyright (c) 1998-2001, 2004, 2005 Sendmail, Inc. and its suppliers.
# All rights reserved. # All rights reserved.
# Copyright (c) 1983 Eric P. Allman. All rights reserved. # Copyright (c) 1983 Eric P. Allman. All rights reserved.
# Copyright (c) 1988, 1993 # Copyright (c) 1988, 1993
@ -19,7 +19,7 @@ divert(-1)
# #
divert(0) divert(0)
VERSIONID(`$Id: knecht.mc,v 8.58 2004/01/28 00:54:41 eric Exp $') VERSIONID(`$Id: knecht.mc,v 8.61 2005/10/06 05:56:03 ca Exp $')
OSTYPE(bsd4.4) OSTYPE(bsd4.4)
DOMAIN(generic) DOMAIN(generic)
@ -43,10 +43,11 @@ define(`confCLIENT_KEY', `CERT_DIR/MYkey.pem')
define(`CYRUS_MAILER_PATH', `/usr/local/cyrus/bin/deliver') define(`CYRUS_MAILER_PATH', `/usr/local/cyrus/bin/deliver')
FEATURE(access_db) FEATURE(`access_db')
FEATURE(local_lmtp) FEATURE(`blacklist_recipients')
FEATURE(virtusertable) FEATURE(`local_lmtp')
FEATURE(mailertable) FEATURE(`virtusertable')
FEATURE(`mailertable')
FEATURE(`nocanonify', `canonify_hosts') FEATURE(`nocanonify', `canonify_hosts')
CANONIFY_DOMAIN(`sendmail.org') CANONIFY_DOMAIN(`sendmail.org')
@ -67,9 +68,16 @@ QUEUE_GROUP(`mqueue', `P=/var/spool/mqueue, R=5, r=15, F=f')
dnl # enable spam assassin dnl # enable spam assassin
INPUT_MAIL_FILTER(`spamassassin', `S=local:/var/run/spamass-milter.sock, F=, T=C:15m;S:4m;R:4m;E:10m') INPUT_MAIL_FILTER(`spamassassin', `S=local:/var/run/spamass-milter.sock, F=, T=C:15m;S:4m;R:4m;E:10m')
MAILER(local) dnl # enable some DNSBLs
MAILER(smtp) dnl FEATURE(`dnsbl', `dnsbl.sorbs.net', `"550 Mail from " $`'&{client_addr} " refused - see http://www.dnsbl.sorbs.net/"')
MAILER(cyrus) FEATURE(`dnsbl', `sbl-xbl.spamhaus.org', `"550 Mail from " $`'&{client_addr} " refused - see http://www.spamhaus.org/sbl/"')
FEATURE(`dnsbl', `list.dsbl.org', `"550 Mail from " $`'&{client_addr} " refused - see http://dsbl.org/"')
FEATURE(`dnsbl', `bl.spamcop.net', `"450 Mail from " $`'&{client_addr} " refused - see http://spamcop.net/bl.shtml"')
MAILER(`local')
MAILER(`smtp')
MAILER(`cyrus')
LOCAL_RULE_0 LOCAL_RULE_0
Rcyrus.$+ + $+ < @ $=w . > $#cyrus $@ $2 $: $1 Rcyrus.$+ + $+ < @ $=w . > $#cyrus $@ $2 $: $1

View File

@ -16,8 +16,8 @@
##### #####
##### SENDMAIL CONFIGURATION FILE ##### SENDMAIL CONFIGURATION FILE
##### #####
##### built by ca@wiz.smi.sendmail.com on Sun Mar 27 16:38:48 PST 2005 ##### built by ca@wiz.smi.sendmail.com on Sun Mar 19 22:37:26 PST 2006
##### in /extra/home/ca/sm-8.13.4/OpenSource/sendmail-8.13.4/cf/cf ##### in /extra/home/ca/sm-8.13.6/OpenSource/sendmail-8.13.6/cf/cf
##### using ../ as configuration include directory ##### using ../ as configuration include directory
##### #####
###################################################################### ######################################################################
@ -35,7 +35,7 @@
##### $Id: no_default_msa.m4,v 8.2 2001/02/14 05:03:22 gshapiro Exp $ ##### ##### $Id: no_default_msa.m4,v 8.2 2001/02/14 05:03:22 gshapiro Exp $ #####
##### $Id: proto.m4,v 8.711 2004/08/04 21:29:55 ca Exp $ ##### ##### $Id: proto.m4,v 8.718 2005/08/24 18:07:23 ca Exp $ #####
# level 10 config file format # level 10 config file format
V10/Berkeley V10/Berkeley
@ -114,7 +114,7 @@ D{MTAHost}[127.0.0.1]
# Configuration version number # Configuration version number
DZ8.13.4/Submit DZ8.13.6/Submit
############### ###############
@ -252,7 +252,7 @@ O PrivacyOptions=goaway,noetrn,restrictqrun
#O MinQueueAge=30m #O MinQueueAge=30m
# how many jobs can you process in the queue? # how many jobs can you process in the queue?
#O MaxQueueRunSize=10000 #O MaxQueueRunSize=0
# perform initial split of envelope without checking MX records # perform initial split of envelope without checking MX records
#O FastSplit=1 #O FastSplit=1
@ -380,13 +380,13 @@ O TimeZoneSpec=
#O HostsFile=/etc/hosts #O HostsFile=/etc/hosts
# dialup line delay on connection failure # dialup line delay on connection failure
#O DialDelay=10s #O DialDelay=0s
# action to take if there are no recipients in the message # action to take if there are no recipients in the message
#O NoRecipientAction=add-to-undisclosed #O NoRecipientAction=none
# chrooted environment for writing to files # chrooted environment for writing to files
#O SafeFileEnvironment=/arch #O SafeFileEnvironment
# are colons OK in addresses? # are colons OK in addresses?
#O ColonOkInAddr=True #O ColonOkInAddr=True

View File

@ -1,6 +1,6 @@
divert(-1) divert(-1)
# #
# Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers. # Copyright (c) 1998-2002, 2005 Sendmail, Inc. and its suppliers.
# All rights reserved. # All rights reserved.
# #
# By using this file, you agree to the terms and conditions set # By using this file, you agree to the terms and conditions set
@ -12,7 +12,7 @@ divert(-1)
ifdef(`DNSBL_MAP', `', `define(`DNSBL_MAP', `dns -R A')') ifdef(`DNSBL_MAP', `', `define(`DNSBL_MAP', `dns -R A')')
divert(0) divert(0)
ifdef(`_DNSBL_R_',`dnl',`dnl ifdef(`_DNSBL_R_',`dnl',`dnl
VERSIONID(`$Id: dnsbl.m4,v 8.29 2002/08/09 21:02:08 ca Exp $') VERSIONID(`$Id: dnsbl.m4,v 8.30 2005/07/25 20:56:53 ca Exp $')
define(`_DNSBL_R_',`') define(`_DNSBL_R_',`')
LOCAL_CONFIG LOCAL_CONFIG
# map for DNS based blacklist lookups # map for DNS based blacklist lookups
@ -28,6 +28,6 @@ R$-.$-.$-.$- $: <?> $(dnsbl $4.$3.$2.$1._DNSBL_SRV_. $: OK $)
R<?>OK $: OKSOFAR R<?>OK $: OKSOFAR
ifelse(len(X`'_ARG3_),`1', ifelse(len(X`'_ARG3_),`1',
`R<?>$+<TMP> $: TMPOK', `R<?>$+<TMP> $: TMPOK',
`R<?>$+<TMP> $#error $@ 4.7.1 $: _DNSBL_MSG_TMP_') `R<?>$+<TMP> $#error $@ 4.4.3 $: _DNSBL_MSG_TMP_')
R<?>$+ $#error $@ 5.7.1 $: _DNSBL_MSG_ R<?>$+ $#error $@ 5.7.1 $: _DNSBL_MSG_
divert(-1) divert(-1)

View File

@ -1,6 +1,6 @@
divert(-1) divert(-1)
# #
# Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers. # Copyright (c) 2000-2002, 2005 Sendmail, Inc. and its suppliers.
# All rights reserved. # All rights reserved.
# #
# By using this file, you agree to the terms and conditions set # By using this file, you agree to the terms and conditions set
@ -11,7 +11,7 @@ divert(-1)
divert(0) divert(0)
ifdef(`_EDNSBL_R_',`dnl',`dnl ifdef(`_EDNSBL_R_',`dnl',`dnl
VERSIONID(`$Id: enhdnsbl.m4,v 1.9 2002/05/19 21:27:29 gshapiro Exp $') VERSIONID(`$Id: enhdnsbl.m4,v 1.10 2005/07/25 20:56:53 ca Exp $')
LOCAL_CONFIG LOCAL_CONFIG
define(`_EDNSBL_R_',`')dnl define(`_EDNSBL_R_',`')dnl
# map for enhanced DNS based blacklist lookups # map for enhanced DNS based blacklist lookups
@ -29,7 +29,7 @@ R$-.$-.$-.$- $: <?> $(ednsbl $4.$3.$2.$1._EDNSBL_SRV_. $: OK $)
R<?>OK $: OKSOFAR R<?>OK $: OKSOFAR
ifelse(len(X`'_ARG3_),`1', ifelse(len(X`'_ARG3_),`1',
`R<?>$+<TMP> $: TMPOK', `R<?>$+<TMP> $: TMPOK',
`R<?>$+<TMP> $#error $@ 4.7.1 $: _EDNSBL_MSG_TMP_') `R<?>$+<TMP> $#error $@ 4.4.3 $: _EDNSBL_MSG_TMP_')
R<?>_EDNSBL_MATCH_ $#error $@ 5.7.1 $: _EDNSBL_MSG_ R<?>_EDNSBL_MATCH_ $#error $@ 5.7.1 $: _EDNSBL_MSG_
ifelse(len(X`'_ARG5_),`1',`dnl', ifelse(len(X`'_ARG5_),`1',`dnl',
`R<?>_ARG5_ $#error $@ 5.7.1 $: _EDNSBL_MSG_') `R<?>_ARG5_ $#error $@ 5.7.1 $: _EDNSBL_MSG_')

View File

@ -1,6 +1,6 @@
divert(-1) divert(-1)
# #
# Copyright (c) 2004 Sendmail, Inc. and its suppliers. # Copyright (c) 2004, 2005 Sendmail, Inc. and its suppliers.
# All rights reserved. # All rights reserved.
# #
# By using this file, you agree to the terms and conditions set # By using this file, you agree to the terms and conditions set
@ -11,7 +11,7 @@ divert(-1)
divert(0) divert(0)
ifdef(`_MTAMARK_R',`dnl',`dnl ifdef(`_MTAMARK_R',`dnl',`dnl
VERSIONID(`$Id: mtamark.m4,v 1.1 2004/03/22 19:22:40 ca Exp $') VERSIONID(`$Id: mtamark.m4,v 1.2 2005/07/25 20:56:53 ca Exp $')
LOCAL_CONFIG LOCAL_CONFIG
define(`_MTAMARK_R',`')dnl define(`_MTAMARK_R',`')dnl
# map for MTA mark # map for MTA mark
@ -29,5 +29,5 @@ R<?>1. $: OKSOFAR
R<?>0. $#error $@ 5.7.1 $: _MTAMARK_MSG_ R<?>0. $#error $@ 5.7.1 $: _MTAMARK_MSG_
ifelse(len(X`'_ARG2_),`1', ifelse(len(X`'_ARG2_),`1',
`R<?>$+<TMP> $: TMPOK', `R<?>$+<TMP> $: TMPOK',
`R<?>$+<TMP> $#error $@ 4.7.1 $: _MTAMARK_MSG_TMP_') `R<?>$+<TMP> $#error $@ 4.4.3 $: _MTAMARK_MSG_TMP_')
divert(-1) divert(-1)

View File

@ -1,6 +1,6 @@
divert(-1) divert(-1)
# #
# Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers. # Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers.
# All rights reserved. # All rights reserved.
# Copyright (c) 1983, 1995 Eric P. Allman. All rights reserved. # Copyright (c) 1983, 1995 Eric P. Allman. All rights reserved.
# Copyright (c) 1988, 1993 # Copyright (c) 1988, 1993
@ -13,7 +13,7 @@ divert(-1)
# #
divert(0) divert(0)
VERSIONID(`$Id: proto.m4,v 8.711 2004/08/04 21:29:55 ca Exp $') VERSIONID(`$Id: proto.m4,v 8.718 2005/08/24 18:07:23 ca Exp $')
# level CF_LEVEL config file format # level CF_LEVEL config file format
V`'CF_LEVEL/ifdef(`VENDOR_NAME', `VENDOR_NAME', `Berkeley') V`'CF_LEVEL/ifdef(`VENDOR_NAME', `VENDOR_NAME', `Berkeley')
@ -388,7 +388,7 @@ _OPTION(QueueSortOrder, `confQUEUE_SORT_ORDER', `priority')
_OPTION(MinQueueAge, `confMIN_QUEUE_AGE', `30m') _OPTION(MinQueueAge, `confMIN_QUEUE_AGE', `30m')
# how many jobs can you process in the queue? # how many jobs can you process in the queue?
_OPTION(MaxQueueRunSize, `confMAX_QUEUE_RUN_SIZE', `10000') _OPTION(MaxQueueRunSize, `confMAX_QUEUE_RUN_SIZE', `0')
# perform initial split of envelope without checking MX records # perform initial split of envelope without checking MX records
_OPTION(FastSplit, `confFAST_SPLIT', `1') _OPTION(FastSplit, `confFAST_SPLIT', `1')
@ -520,13 +520,13 @@ _OPTION(ServiceSwitchFile, `confSERVICE_SWITCH_FILE', `MAIL_SETTINGS_DIR`'servic
_OPTION(HostsFile, `confHOSTS_FILE', `/etc/hosts') _OPTION(HostsFile, `confHOSTS_FILE', `/etc/hosts')
# dialup line delay on connection failure # dialup line delay on connection failure
_OPTION(DialDelay, `confDIAL_DELAY', `10s') _OPTION(DialDelay, `confDIAL_DELAY', `0s')
# action to take if there are no recipients in the message # action to take if there are no recipients in the message
_OPTION(NoRecipientAction, `confNO_RCPT_ACTION', `add-to-undisclosed') _OPTION(NoRecipientAction, `confNO_RCPT_ACTION', `none')
# chrooted environment for writing to files # chrooted environment for writing to files
_OPTION(SafeFileEnvironment, `confSAFE_FILE_ENV', `/arch') _OPTION(SafeFileEnvironment, `confSAFE_FILE_ENV', `')
# are colons OK in addresses? # are colons OK in addresses?
_OPTION(ColonOkInAddr, `confCOLON_OK_IN_ADDR', `True') _OPTION(ColonOkInAddr, `confCOLON_OK_IN_ADDR', `True')
@ -2698,6 +2698,11 @@ RSOFTWARE $| <$-:$+> $* $#error $@ $2 $: $1 " TLS handshake failed."
dnl no <reply:dns> i.e. not requirements in the access map dnl no <reply:dns> i.e. not requirements in the access map
dnl use default error dnl use default error
RSOFTWARE $| $* $#error $@ ifdef(`TLS_PERM_ERR', `5.7.0', `4.7.0') $: "ifdef(`TLS_PERM_ERR', `503', `403') TLS handshake failed." RSOFTWARE $| $* $#error $@ ifdef(`TLS_PERM_ERR', `5.7.0', `4.7.0') $: "ifdef(`TLS_PERM_ERR', `503', `403') TLS handshake failed."
# deal with TLS protocol errors: abort
RPROTOCOL $| <$-:$+> $* $#error $@ $2 $: $1 " STARTTLS failed."
dnl no <reply:dns> i.e. not requirements in the access map
dnl use default error
RPROTOCOL $| $* $#error $@ ifdef(`TLS_PERM_ERR', `5.7.0', `4.7.0') $: "ifdef(`TLS_PERM_ERR', `503', `403') STARTTLS failed."
R$* $| <$*> <VERIFY> $: <$2> <VERIFY> <> $1 R$* $| <$*> <VERIFY> $: <$2> <VERIFY> <> $1
dnl separate optional requirements dnl separate optional requirements
R$* $| <$*> <VERIFY + $+> $: <$2> <VERIFY> <$3> $1 R$* $| <$*> <VERIFY + $+> $: <$2> <VERIFY> <$3> $1

View File

@ -1,6 +1,6 @@
divert(-1) divert(-1)
# #
# Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers. # Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
# All rights reserved. # All rights reserved.
# Copyright (c) 1983 Eric P. Allman. All rights reserved. # Copyright (c) 1983 Eric P. Allman. All rights reserved.
# Copyright (c) 1988, 1993 # Copyright (c) 1988, 1993
@ -11,8 +11,8 @@ divert(-1)
# the sendmail distribution. # the sendmail distribution.
# #
# #
VERSIONID(`$Id: version.m4,v 8.132 2005/03/25 18:44:45 ca Exp $') VERSIONID(`$Id: version.m4,v 8.147 2006/03/08 19:21:23 ca Exp $')
# #
divert(0) divert(0)
# Configuration version number # Configuration version number
DZ8.13.4`'ifdef(`confCF_VERSION', `/confCF_VERSION') DZ8.13.6`'ifdef(`confCF_VERSION', `/confCF_VERSION')

View File

@ -10,9 +10,10 @@ divert(-1)
# #
divert(0) divert(0)
VERSIONID(`$Id: darwin.m4,v 8.3 2002/03/05 01:55:40 ca Exp $') VERSIONID(`$Id: darwin.m4,v 8.4 2005/06/30 01:16:04 ca Exp $')
ifdef(`STATUS_FILE',, `define(`STATUS_FILE', `/var/log/sendmail.st')')dnl ifdef(`STATUS_FILE',, `define(`STATUS_FILE', `/var/log/sendmail.st')')dnl
dnl turn on S flag for local mailer dnl turn on S flag for local mailer
MODIFY_MAILER_FLAGS(`LOCAL', `+S')dnl MODIFY_MAILER_FLAGS(`LOCAL', `+S')dnl
ifdef(`LOCAL_MAILER_PATH',, `define(`LOCAL_MAILER_PATH', /usr/libexec/mail.local)')dnl ifdef(`LOCAL_MAILER_PATH',, `define(`LOCAL_MAILER_PATH', /usr/libexec/mail.local)')dnl
ifdef(`UUCP_MAILER_ARGS',, `define(`UUCP_MAILER_ARGS', `uux - -r -z -a$g $h!rmail ($u)')')dnl ifdef(`UUCP_MAILER_ARGS',, `define(`UUCP_MAILER_ARGS', `uux - -r -z -a$g $h!rmail ($u)')')dnl
define(`confDONT_BLAME_SENDMAIL', `AssumeSafeChown,GroupWritableDirPathSafe')dnl

View File

@ -1,15 +1,16 @@
# Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers. # Copyright (c) 2000-2002, 2005 Sendmail, Inc. and its suppliers.
# All rights reserved. # All rights reserved.
# #
# By using this file, you agree to the terms and conditions set # By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of # forth in the LICENSE file which can be found at the top level of
# the sendmail distribution. # the sendmail distribution.
# #
# $Id: sendmail.schema,v 8.21 2002/11/20 23:13:50 gshapiro Exp $ # $Id: sendmail.schema,v 8.22 2005/09/16 20:18:14 ca Exp $
# Note that this schema is experimental at this point as it has had little # Note that this schema is experimental at this point as it has had little
# public review. Therefore, it may change in future versions. Feedback # public review. Therefore, it may change in future versions. Feedback
# via sendmail@sendmail.org is encouraged. # via sendmail-YYYY@support.sendmail.org is encouraged (replace YYYY with
# the current year, e.g., 2005).
# OID arcs for Sendmail # OID arcs for Sendmail
# enterprise: 1.3.6.1.4.1 # enterprise: 1.3.6.1.4.1

View File

@ -1,6 +1,6 @@
divert(-1) divert(-1)
# #
# Copyright (c) 2001-2002 Sendmail, Inc. and its suppliers. # Copyright (c) 2001-2002, 2005 Sendmail, Inc. and its suppliers.
# All rights reserved. # All rights reserved.
# #
# By using this file, you agree to the terms and conditions set # By using this file, you agree to the terms and conditions set
@ -59,7 +59,7 @@ dnl ## address returned does not begin 127, then the mail is
dnl ## processed as if the HACK line were not present. dnl ## processed as if the HACK line were not present.
divert(0) divert(0)
VERSIONID(`$Id: dnsblaccess.m4,v 1.5 2002/05/19 21:30:06 gshapiro Exp $') VERSIONID(`$Id: dnsblaccess.m4,v 1.6 2005/07/25 23:32:05 ca Exp $')
ifdef(`_ACCESS_TABLE_', `dnl', ifdef(`_ACCESS_TABLE_', `dnl',
`errprint(`*** ERROR: dnsblaccess requires FEATURE(`access_db') `errprint(`*** ERROR: dnsblaccess requires FEATURE(`access_db')
')') ')')
@ -85,7 +85,7 @@ R<?>$* $- .<>$* <$(access _EDNSBL_KEY_`:'$1$2 $@$3 $@`'_EDNSBL_SRV_ $: ? $)> $1
R<?>$* <>$* $:<$(access _EDNSBL_KEY_`:' $@$2 $@`'_EDNSBL_SRV_ $: ? $)> <>$2 R<?>$* <>$* $:<$(access _EDNSBL_KEY_`:' $@$2 $@`'_EDNSBL_SRV_ $: ? $)> <>$2
ifelse(len(X`'_ARG3_),`1', ifelse(len(X`'_ARG3_),`1',
`R<$*<TMPF>>$* $: TMPOK', `R<$*<TMPF>>$* $: TMPOK',
`R<$*<TMPF>>$* $#error $@ 4.7.1 $: _EDNSBL_MSG_TMP_') `R<$*<TMPF>>$* $#error $@ 4.4.3 $: _EDNSBL_MSG_TMP_')
R<$={Accept}>$* $: OKSOFAR R<$={Accept}>$* $: OKSOFAR
R<ERROR:$-.$-.$-:$+> $* $#error $@ $1.$2.$3 $: $4 R<ERROR:$-.$-.$-:$+> $* $#error $@ $1.$2.$3 $: $4
R<ERROR:$+> $* $#error $: $1 R<ERROR:$+> $* $#error $: $1

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 8.15 2004/07/20 20:25:10 ca Exp $ # $Id: Makefile,v 8.16 2006/01/05 22:03:31 ca Exp $
DIR= smm/08.sendmailop DIR= smm/08.sendmailop
SRCS= op.me SRCS= op.me
@ -22,6 +22,7 @@ all: ${OBJS}
op.ps: ${SRCS} op.ps: ${SRCS}
rm -f $@ rm -f $@
${PIC} ${SRCS} | ${EQNPS} | ${ROFFPS} > $@ ${PIC} ${SRCS} | ${EQNPS} | ${ROFFPS} > $@
test -s $@ || ${ROFFPS} -p -e ${SRCS} > $@
op.txt: ${SRCS} op.txt: ${SRCS}
rm -f $@ rm -f $@

View File

@ -9,7 +9,7 @@
.\" the sendmail distribution. .\" the sendmail distribution.
.\" .\"
.\" .\"
.\" $Id: op.me,v 8.704 2005/02/01 00:40:57 ca Exp $ .\" $Id: op.me,v 8.708 2005/11/12 02:08:04 ca Exp $
.\" .\"
.\" eqn op.me | pic | troff -me .\" eqn op.me | pic | troff -me
.\" .\"
@ -90,7 +90,7 @@ Sendmail, Inc.
.de Ve .de Ve
Version \\$2 Version \\$2
.. ..
.Ve $Revision: 8.704 $ .Ve $Revision: 8.708 $
.rm Ve .rm Ve
.sp .sp
For Sendmail Version 8.13 For Sendmail Version 8.13
@ -1475,6 +1475,18 @@ option, so that it may be shared between several invocations of
.i sendmail . .i sendmail .
This allows mail to be queued immediately or skipped during a queue run if This allows mail to be queued immediately or skipped during a queue run if
there has been a recent failure in connecting to a remote machine. there has been a recent failure in connecting to a remote machine.
Note: information about a remote system is stored in a file
whose pathname consists of the components of the hostname in reverse order.
For example, the information for
.b host.example.com
is stored in
.b com./example./host .
For top-level domains like
.b com
this can create a large number of subdirectories
which on some filesystems can exhaust some limits.
Moreover, the performance of lookups in directory with thousands of entries
can be fairly slow depending on the filesystem implementation.
.pp .pp
Additionally enabling Additionally enabling
.b SingleThreadDelivery .b SingleThreadDelivery
@ -7282,6 +7294,16 @@ will refuse connections when it has more than
.i N .i N
children processing incoming mail or automatic queue runs. children processing incoming mail or automatic queue runs.
This does not limit the number of outgoing connections. This does not limit the number of outgoing connections.
If the default
.b DeliveryMode
(background) is used, then
.i sendmail
may create an almost unlimited number of children
(depending on the number of transactions and the
relative execution times of mail receiption and mail delivery).
If the limit should be enforced, then a
.b DeliveryMode
other than background must be used.
If not set, there is no limit to the number of children -- If not set, there is no limit to the number of children --
that is, the system load averaging controls this. that is, the system load averaging controls this.
.ip MaxHeadersLength=\fIN\fP .ip MaxHeadersLength=\fIN\fP
@ -9086,7 +9108,7 @@ For example,
.)b .)b
is equivalent to is equivalent to
.(b .(b
-H ldap://server.example.com:389/dc=example,dc=com -H ldap://server.example.com:389 -b dc=example,dc=com
.)b .)b
If the LDAP library supports it, If the LDAP library supports it,
the LDAP URI format however can also request LDAP over SSL by using the LDAP URI format however can also request LDAP over SSL by using
@ -9095,13 +9117,13 @@ instead of
.b ldap:// . .b ldap:// .
For example: For example:
.(b .(b
O LDAPDefaultSpec=-H ldaps://ldap.example.com/dc=example,dc=com O LDAPDefaultSpec=-H ldaps://ldap.example.com -b dc=example,dc=com
.)b .)b
Similarly, if the LDAP library supports it, Similarly, if the LDAP library supports it,
It can also be used to specify a UNIX domain socket using It can also be used to specify a UNIX domain socket using
.b ldapi:// : .b ldapi:// :
.(b .(b
O LDAPDefaultSpec=-H ldapi://socketfile/dc=example,dc=com O LDAPDefaultSpec=-H ldapi://socketfile -b dc=example,dc=com
.)b .)b
.ip "\-b\fIbase\fP" .ip "\-b\fIbase\fP"
LDAP search base. LDAP search base.
@ -11317,7 +11339,7 @@ replace it with a blank sheet for double-sided output.
.\".sz 10 .\".sz 10
.\"Eric Allman .\"Eric Allman
.\".sp .\".sp
.\"Version $Revision: 8.704 $ .\"Version $Revision: 8.708 $
.\".ce 0 .\".ce 0
.bp 3 .bp 3
.ce .ce

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999-2004 Sendmail, Inc. and its suppliers. * Copyright (c) 1999-2005 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* *
* By using this file, you agree to the terms and conditions set * By using this file, you agree to the terms and conditions set
@ -7,7 +7,7 @@
* the sendmail distribution. * the sendmail distribution.
* *
* *
* $Id: mfdef.h,v 8.21 2004/07/07 21:41:31 ca Exp $ * $Id: mfdef.h,v 8.22 2005/08/05 21:49:04 ca Exp $
*/ */
/* /*
@ -61,6 +61,7 @@
# define SMFIR_REPLBODY 'b' /* replace body (chunk) */ # define SMFIR_REPLBODY 'b' /* replace body (chunk) */
# define SMFIR_CONTINUE 'c' /* continue */ # define SMFIR_CONTINUE 'c' /* continue */
# define SMFIR_DISCARD 'd' /* discard */ # define SMFIR_DISCARD 'd' /* discard */
# define SMFIR_CONN_FAIL 'f' /* cause a connection failure */
# define SMFIR_CHGHEADER 'm' /* change header */ # define SMFIR_CHGHEADER 'm' /* change header */
# define SMFIR_PROGRESS 'p' /* progress */ # define SMFIR_PROGRESS 'p' /* progress */
# define SMFIR_REJECT 'r' /* reject */ # define SMFIR_REJECT 'r' /* reject */
@ -82,13 +83,17 @@
# if _FFR_MILTER_NOHDR_RESP # if _FFR_MILTER_NOHDR_RESP
# define SMFIP_NOHREPL 0x00000080L /* No reply for headers */ # define SMFIP_NOHREPL 0x00000080L /* No reply for headers */
# endif /* _FFR_MILTER_NOHDR_RESP */ # endif /* _FFR_MILTER_NOHDR_RESP */
# define SMFIP_NOUNKNOWN 0x00000100L /* MTA should not send unknown command */
# define SMFIP_NODATA 0x00000200L /* MTA should not send DATA */
# define SMFI_V1_PROT 0x0000003FL /* The protocol of V1 filter */ # define SMFI_V1_PROT 0x0000003FL /* The protocol of V1 filter */
# define SMFI_V2_PROT 0x0000007FL /* The protocol of V2 filter */ # define SMFI_V2_PROT 0x0000007FL /* The protocol of V2 filter */
/* Note: the "current" version is now determined dynamically in milter.c */
# if _FFR_MILTER_NOHDR_RESP # if _FFR_MILTER_NOHDR_RESP
# define SMFI_CURR_PROT 0x000000FFL /* The current version */ # define SMFI_CURR_PROT 0x000000FFL
# else /* _FFR_MILTER_NOHDR_RESP */ # else /* _FFR_MILTER_NOHDR_RESP */
# define SMFI_CURR_PROT SMFI_V2_PROT /* The current version */ # define SMFI_CURR_PROT SMFI_V2_PROT
# endif /* _FFR_MILTER_NOHDR_RESP */ # endif /* _FFR_MILTER_NOHDR_RESP */
#endif /* !_LIBMILTER_MFDEF_H */ #endif /* !_LIBMILTER_MFDEF_H */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -10,7 +10,7 @@
* the sendmail distribution. * the sendmail distribution.
* *
* *
* $Id: conf.h,v 1.120 2005/03/22 22:07:53 ca Exp $ * $Id: conf.h,v 1.128 2006/01/27 18:43:44 ca Exp $
*/ */
/* /*
@ -406,6 +406,9 @@ typedef int pid_t;
# if SOLARIS >= 20500 || (SOLARIS < 10000 && SOLARIS >= 205) # if SOLARIS >= 20500 || (SOLARIS < 10000 && SOLARIS >= 205)
# define HASSETREUID 1 /* setreuid works as of 2.5 */ # define HASSETREUID 1 /* setreuid works as of 2.5 */
# define HASSETREGID 1 /* use setregid(2) to set saved gid */ # define HASSETREGID 1 /* use setregid(2) to set saved gid */
# if SOLARIS >= 20600 || (SOLARIS < 10000 && SOLARIS >= 206)
# define HASSNPRINTF 1 /* has snprintf(3c) starting in 2.6 */
# endif /* SOLARIS >= 20600 || (SOLARIS < 10000 && SOLARIS >= 206) */
# if SOLARIS < 207 || (SOLARIS > 10000 && SOLARIS < 20700) # if SOLARIS < 207 || (SOLARIS > 10000 && SOLARIS < 20700)
# ifndef LA_TYPE # ifndef LA_TYPE
# define LA_TYPE LA_KSTAT /* use kstat(3k) -- may work in < 2.5 */ # define LA_TYPE LA_KSTAT /* use kstat(3k) -- may work in < 2.5 */
@ -734,8 +737,8 @@ typedef int pid_t;
# define HASFLOCK 1 /* has flock(2) */ # define HASFLOCK 1 /* has flock(2) */
# define HASUNAME 1 /* has uname(2) */ # define HASUNAME 1 /* has uname(2) */
# define HASUNSETENV 1 /* has unsetenv(3) */ # define HASUNSETENV 1 /* has unsetenv(3) */
# define HASSETSID 1 /* has POSIX setsid(2) call */ # define HASSETSID 1 /* has POSIX setsid(2) call */
# define HASINITGROUPS 1 /* has initgroups(3) */ # define HASINITGROUPS 1 /* has initgroups(3) */
# define HASSETVBUF 1 /* has setvbuf (3) */ # define HASSETVBUF 1 /* has setvbuf (3) */
# define HASSETREUID 0 /* setreuid(2) unusable */ # define HASSETREUID 0 /* setreuid(2) unusable */
# define HASSETEUID 1 /* has seteuid(2) */ # define HASSETEUID 1 /* has seteuid(2) */
@ -748,13 +751,22 @@ typedef int pid_t;
# define HASWAITPID 1 /* has waitpid(2) */ # define HASWAITPID 1 /* has waitpid(2) */
# define HASGETDTABLESIZE 1 /* has getdtablesize(2) */ # define HASGETDTABLESIZE 1 /* has getdtablesize(2) */
# define HAS_ST_GEN 1 /* has st_gen field in struct stat */ # define HAS_ST_GEN 1 /* has st_gen field in struct stat */
# define HASURANDOMDEV 1 /* has urandom(4) */ # define HASURANDOMDEV 1 /* has urandom(4) */
# define HASSTRERROR 1 /* has strerror(3) */ # define HASSTRERROR 1 /* has strerror(3) */
# define HASGETUSERSHELL 1 /* had getusershell(3) */ # define HASGETUSERSHELL 1 /* had getusershell(3) */
# define GIDSET_T gid_t /* getgroups(2) takes gid_t */ # define GIDSET_T gid_t /* getgroups(2) takes gid_t */
# define LA_TYPE LA_SUBR /* use getloadavg(3) */ # define LA_TYPE LA_SUBR /* use getloadavg(3) */
# define SFS_TYPE SFS_MOUNT /* use <sys/mount.h> statfs() impl */ # define SFS_TYPE SFS_MOUNT /* use <sys/mount.h> statfs() impl */
# define SPT_TYPE SPT_PSSTRINGS /* use magic PS_STRINGS pointer for setproctitle */ # if DARWIN >= 70000
# define SOCKADDR_LEN_T socklen_t
# endif
# if DARWIN >= 80000
# define SPT_TYPE SPT_REUSEARGV
# define SPT_PADCHAR '\0'
# define SOCKOPT_LEN_T socklen_t
# else
# define SPT_TYPE SPT_PSSTRINGS /* use magic PS_STRINGS pointer for setproctitle */
# endif
# define ERRLIST_PREDEFINED /* don't declare sys_errlist */ # define ERRLIST_PREDEFINED /* don't declare sys_errlist */
# define BSD4_4_SOCKADDR /* struct sockaddr has sa_len */ # define BSD4_4_SOCKADDR /* struct sockaddr has sa_len */
# define SAFENFSPATHCONF 0 /* unverified: pathconf(2) doesn't work on NFS */ # define SAFENFSPATHCONF 0 /* unverified: pathconf(2) doesn't work on NFS */
@ -773,7 +785,7 @@ extern unsigned int sleepX __P((unsigned int seconds));
** See also BSD defines. ** See also BSD defines.
*/ */
# if defined(BSD4_4) && !defined(__bsdi__) && !defined(__GNU__) # if defined(BSD4_4) && !defined(__bsdi__) && !defined(__GNU__) && !defined(DARWIN)
# include <paths.h> # include <paths.h>
# define HASUNSETENV 1 /* has unsetenv(3) call */ # define HASUNSETENV 1 /* has unsetenv(3) call */
# define USESETEUID 1 /* has usable seteuid(2) call */ # define USESETEUID 1 /* has usable seteuid(2) call */
@ -791,7 +803,7 @@ extern unsigned int sleepX __P((unsigned int seconds));
# endif /* ! LA_TYPE */ # endif /* ! LA_TYPE */
# define SFS_TYPE SFS_MOUNT /* use <sys/mount.h> statfs() impl */ # define SFS_TYPE SFS_MOUNT /* use <sys/mount.h> statfs() impl */
# define SPT_TYPE SPT_PSSTRINGS /* use PS_STRINGS pointer */ # define SPT_TYPE SPT_PSSTRINGS /* use PS_STRINGS pointer */
# endif /* defined(BSD4_4) && !defined(__bsdi__) && !defined(__GNU__) */ # endif /* defined(BSD4_4) && !defined(__bsdi__) && !defined(__GNU__) && !defined(DARWIN)*/
/* /*
@ -899,11 +911,14 @@ extern unsigned int sleepX __P((unsigned int seconds));
# define NETLINK 1 /* supports AF_LINK */ # define NETLINK 1 /* supports AF_LINK */
# define SAFENFSPATHCONF 1 /* pathconf(2) pessimizes on NFS filesystems */ # define SAFENFSPATHCONF 1 /* pathconf(2) pessimizes on NFS filesystems */
# define GIDSET_T gid_t # define GIDSET_T gid_t
# define QUAD_T unsigned long long # define QUAD_T unsigned long long
# define HASSNPRINTF 1 /* has snprintf(3) (all versions?) */
# ifndef LA_TYPE # ifndef LA_TYPE
# define LA_TYPE LA_SUBR # define LA_TYPE LA_SUBR
# endif /* ! LA_TYPE */ # endif /* ! LA_TYPE */
# if defined(__NetBSD__) && defined(__NetBSD_Version__) && __NetBSD_Version__ >= 200040000 # if defined(__NetBSD__) && defined(__NetBSD_Version__) && \
((__NetBSD_Version__ >= 200040000 && __NetBSD_Version__ < 200090000) || \
(__NetBSD_Version__ >= 299000900))
# undef SFS_TYPE # undef SFS_TYPE
# define SFS_TYPE SFS_STATVFS # define SFS_TYPE SFS_STATVFS
# else # else
@ -919,7 +934,9 @@ extern unsigned int sleepX __P((unsigned int seconds));
# if defined(__NetBSD__) && defined(__NetBSD_Version__) && __NetBSD_Version__ >= 104170000 # if defined(__NetBSD__) && defined(__NetBSD_Version__) && __NetBSD_Version__ >= 104170000
# define HASSETUSERCONTEXT 1 /* BSDI-style login classes */ # define HASSETUSERCONTEXT 1 /* BSDI-style login classes */
# endif # endif
# if defined(__NetBSD__) && defined(__NetBSD_Version__) && __NetBSD_Version__ >= 200060000 # if defined(__NetBSD__) && defined(__NetBSD_Version__) && \
((__NetBSD_Version__ >= 200060000 && __NetBSD_Version__ < 200090000) || \
(__NetBSD_Version__ >= 299000900))
# define HASCLOSEFROM 1 /* closefrom(3) added in 2.0F */ # define HASCLOSEFROM 1 /* closefrom(3) added in 2.0F */
# endif # endif
# if defined(__NetBSD__) # if defined(__NetBSD__)
@ -994,6 +1011,9 @@ extern unsigned int sleepX __P((unsigned int seconds));
# if OpenBSD >= 200405 # if OpenBSD >= 200405
# define HASCLOSEFROM 1 /* closefrom(3) added in 3.5 */ # define HASCLOSEFROM 1 /* closefrom(3) added in 3.5 */
# endif /* OpenBSD >= 200405 */ # endif /* OpenBSD >= 200405 */
# if OpenBSD >= 200505
# undef NETISO /* iso.h removed in 3.7 */
# endif /* OpenBSD >= 200505 */
# endif /* defined(__OpenBSD__) */ # endif /* defined(__OpenBSD__) */
# endif /* defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) */ # endif /* defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) */

View File

@ -1,12 +1,12 @@
/* /*
* Copyright (c) 2001-2002 Sendmail, Inc. and its suppliers. * Copyright (c) 2001-2003, 2005 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* *
* By using this file, you agree to the terms and conditions set * By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of * forth in the LICENSE file which can be found at the top level of
* the sendmail distribution. * the sendmail distribution.
* *
* $Id: ldap.h,v 1.27 2003/12/20 09:23:47 gshapiro Exp $ * $Id: ldap.h,v 1.28 2005/06/23 23:11:21 ca Exp $
*/ */
#ifndef SM_LDAP_H #ifndef SM_LDAP_H
@ -44,6 +44,7 @@
# define SM_LDAP_SINGLEMATCH 0x0001 # define SM_LDAP_SINGLEMATCH 0x0001
# define SM_LDAP_MATCHONLY 0x0002 # define SM_LDAP_MATCHONLY 0x0002
# define SM_LDAP_USE_ALLATTR 0x0004 # define SM_LDAP_USE_ALLATTR 0x0004
# define SM_LDAP_SINGLEDN 0x0008
struct sm_ldap_struct struct sm_ldap_struct
{ {

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2005 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
* $Id: time.h,v 1.1 2005/06/14 23:07:19 ca Exp $
*/
#ifndef SM_TIME_H
# define SM_TIME_H 1
# include <sm/config.h>
# include <sys/time.h>
/* should be defined in sys/time.h */
#ifndef timersub
# define timersub(tvp, uvp, vvp) \
do \
{ \
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
if ((vvp)->tv_usec < 0) \
{ \
(vvp)->tv_sec--; \
(vvp)->tv_usec += 1000000; \
} \
} while (0)
#endif /* !timersub */
#ifndef timeradd
# define timeradd(tvp, uvp, vvp) \
do \
{ \
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
if ((vvp)->tv_usec >= 1000000) \
{ \
(vvp)->tv_sec++; \
(vvp)->tv_usec -= 1000000; \
} \
} while (0)
#endif /* !timeradd */
#ifndef timercmp
# define timercmp(tvp, uvp, cmp) \
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
((tvp)->tv_sec cmp (uvp)->tv_sec))
#endif /* !timercmp */
#endif /* ! SM_TIME_H */

View File

@ -12,6 +12,9 @@ issuing the './Build' command in SRCDIR/libmilter .
Starting with 8.13 sendmail is compiled by default with support for Starting with 8.13 sendmail is compiled by default with support for
the milter API. the milter API.
Note: if you want to write a milter in Java, then see
http://sendmail-jilter.sourceforge.net/
+----------------+ +----------------+
| SECURITY HINTS | | SECURITY HINTS |
+----------------+ +----------------+
@ -466,4 +469,4 @@ main(argc, argv)
/* eof */ /* eof */
$Revision: 8.40 $, Last updated $Date: 2003/12/11 18:14:34 $ $Revision: 8.41 $, Last updated $Date: 2005/04/27 22:47:42 $

View File

@ -2,7 +2,7 @@
<head><title>smfi_stop</title></head> <head><title>smfi_stop</title></head>
<body> <body>
<!-- <!--
$Id: smfi_stop.html,v 1.2 2003/11/24 23:38:26 ca Exp $ $Id: smfi_stop.html,v 1.3 2005/10/27 06:08:57 ca Exp $
--> -->
<h1>smfi_stop</h1> <h1>smfi_stop</h1>
@ -13,8 +13,8 @@ $Id: smfi_stop.html,v 1.2 2003/11/24 23:38:26 ca Exp $
#include &lt;libmilter/mfapi.h&gt; #include &lt;libmilter/mfapi.h&gt;
int smfi_stop(void); int smfi_stop(void);
</pre> </pre>
Start an orderly shutdown of the milter. No connections will be accepted Shutdown the milter.
after this call. No connections will be accepted after this call.
</td></tr> </td></tr>
<!----------- Description ----------> <!----------- Description ---------->
@ -27,10 +27,11 @@ or any error-handling routines at any time.</td>
</tr> </tr>
<tr align="left" valign=top> <tr align="left" valign=top>
<th width="80">Effects</th> <th width="80">Effects</th>
<td>The smfi_stop routine <td>The smfi_stop routine prevents that new connections
causes each thread to finish its current connection, then exit. will be accepted,
When all threads have exited, the call however, it does not wait for existing connections (threads) to terminate.
to <a href="smfi_main.html">smfi_main</a> returns to your calling program, It will cause
<a href="smfi_main.html">smfi_main</a> to return to the calling program,
which may then exit or warm-restart. which may then exit or warm-restart.
</td> </td>
</tr> </tr>
@ -63,7 +64,7 @@ which may then exit or warm-restart.
<hr size="1"> <hr size="1">
<font size="-1"> <font size="-1">
Copyright (c) 2003 Sendmail, Inc. and its suppliers. Copyright (c) 2003, 2005 Sendmail, Inc. and its suppliers.
All rights reserved. All rights reserved.
<br> <br>
By using this file, you agree to the terms and conditions set By using this file, you agree to the terms and conditions set

View File

@ -2,7 +2,7 @@
<head><title>xxfi_helo</title></head> <head><title>xxfi_helo</title></head>
<body> <body>
<!-- <!--
$Id: xxfi_helo.html,v 1.8 2003/03/05 19:57:55 ca Exp $ $Id: xxfi_helo.html,v 1.9 2005/08/30 23:41:45 ca Exp $
--> -->
<h1>xxfi_helo</h1> <h1>xxfi_helo</h1>
@ -24,8 +24,10 @@ Handle the HELO/EHLO command.
<table border="1" cellspacing=1 cellpadding=4> <table border="1" cellspacing=1 cellpadding=4>
<tr align="left" valign=top> <tr align="left" valign=top>
<th width="80">Called When</th> <td>xxfi_helo is called whenever the client <th width="80">Called When</th> <td>xxfi_helo is called whenever the client
sends a HELO/EHLO command. It may therefore be called between zero and sends a HELO/EHLO command.
three times</td> It may therefore be called several times or even not at all;
some restrictions can be imposed by the MTA configuration.
</td>
</tr> </tr>
<tr align="left" valign=top> <tr align="left" valign=top>
<th>Default Behavior</th> <th>Default Behavior</th>
@ -52,7 +54,7 @@ three times</td>
<hr size="1"> <hr size="1">
<font size="-1"> <font size="-1">
Copyright (c) 2000, 2003 Sendmail, Inc. and its suppliers. Copyright (c) 2000, 2003, 2005 Sendmail, Inc. and its suppliers.
All rights reserved. All rights reserved.
<br> <br>
By using this file, you agree to the terms and conditions set By using this file, you agree to the terms and conditions set

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999-2003 Sendmail, Inc. and its suppliers. * Copyright (c) 1999-2003, 2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* *
* By using this file, you agree to the terms and conditions set * By using this file, you agree to the terms and conditions set
@ -19,7 +19,7 @@
#ifdef _DEFINE #ifdef _DEFINE
# define EXTERN # define EXTERN
# define INIT(x) = x # define INIT(x) = x
SM_IDSTR(MilterlId, "@(#)$Id: libmilter.h,v 8.50 2003/12/11 18:14:34 ca Exp $") SM_IDSTR(MilterlId, "@(#)$Id: libmilter.h,v 8.51 2006/01/04 02:24:37 ca Exp $")
#else /* _DEFINE */ #else /* _DEFINE */
# define EXTERN extern # define EXTERN extern
# define INIT(x) # define INIT(x)
@ -102,7 +102,7 @@ typedef pthread_mutex_t smutex_t;
# define FD_WR_INIT(sd, wrs) \ # define FD_WR_INIT(sd, wrs) \
FD_ZERO(&(wrs)); \ FD_ZERO(&(wrs)); \
FD_SET((unsigned int) (sd), &(wrs)); \ FD_SET((unsigned int) (sd), &(wrs))
# define FD_IS_RD_EXC(sd, rds, excs) FD_ISSET(sd, &(excs)) # define FD_IS_RD_EXC(sd, rds, excs) FD_ISSET(sd, &(excs))
# define FD_IS_WR_RDY(sd, wrs) FD_ISSET((sd), &(wrs)) # define FD_IS_WR_RDY(sd, wrs) FD_ISSET((sd), &(wrs))

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999-2004 Sendmail, Inc. and its suppliers. * Copyright (c) 1999-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* *
* By using this file, you agree to the terms and conditions set * By using this file, you agree to the terms and conditions set
@ -9,7 +9,7 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: listener.c,v 8.111 2004/09/20 21:11:15 msk Exp $") SM_RCSID("@(#)$Id: listener.c,v 8.115 2006/01/24 00:48:39 ca Exp $")
/* /*
** listener.c -- threaded network listener ** listener.c -- threaded network listener
@ -458,11 +458,15 @@ mi_milteropen(conn, backlog, rmsocket, name)
return INVALID_SOCKET; return INVALID_SOCKET;
} }
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &sockopt, if (
#if NETUNIX
addr.sa.sa_family != AF_UNIX &&
#endif /* NETUNIX */
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &sockopt,
sizeof(sockopt)) == -1) sizeof(sockopt)) == -1)
{ {
smi_log(SMI_LOG_ERR, smi_log(SMI_LOG_ERR,
"%s: Unable to setsockopt: %s", name, "%s: set reuseaddr failed (%s)", name,
sm_errstring(errno)); sm_errstring(errno));
(void) closesocket(sock); (void) closesocket(sock);
return INVALID_SOCKET; return INVALID_SOCKET;
@ -565,9 +569,6 @@ mi_thread_handle_wrapper(arg)
/* /*
** MI_CLOSENER -- close listen socket ** MI_CLOSENER -- close listen socket
** **
** NOTE: It is assumed that this function is called from a
** function that has a mutex lock (currently mi_stop_milters()).
**
** Parameters: ** Parameters:
** none. ** none.
** **
@ -872,7 +873,8 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
if (setsockopt(connfd, SOL_SOCKET, SO_KEEPALIVE, if (setsockopt(connfd, SOL_SOCKET, SO_KEEPALIVE,
(void *) &sockopt, sizeof sockopt) < 0) (void *) &sockopt, sizeof sockopt) < 0)
{ {
smi_log(SMI_LOG_WARN, "%s: setsockopt() failed (%s)", smi_log(SMI_LOG_WARN,
"%s: set keepalive failed (%s)",
smfi->xxfi_name, sm_errstring(errno)); smfi->xxfi_name, sm_errstring(errno));
/* XXX: continue? */ /* XXX: continue? */
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999-2004 Sendmail, Inc. and its suppliers. * Copyright (c) 1999-2004, 2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* *
* By using this file, you agree to the terms and conditions set * By using this file, you agree to the terms and conditions set
@ -9,7 +9,7 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: signal.c,v 8.42 2004/08/20 21:10:30 ca Exp $") SM_RCSID("@(#)$Id: signal.c,v 8.44 2006/03/03 03:42:04 ca Exp $")
#include "libmilter.h" #include "libmilter.h"
@ -90,7 +90,7 @@ static void *
mi_signal_thread(name) mi_signal_thread(name)
void *name; void *name;
{ {
int sig, errs; int sig, errs, sigerr;
sigset_t set; sigset_t set;
(void) sigemptyset(&set); (void) sigemptyset(&set);
@ -103,19 +103,23 @@ mi_signal_thread(name)
for (;;) for (;;)
{ {
sig = 0; sigerr = sig = 0;
#if defined(SOLARIS) || defined(__svr5__) #if defined(SOLARIS) || defined(__svr5__)
if ((sig = sigwait(&set)) < 0) if ((sig = sigwait(&set)) < 0)
#else /* defined(SOLARIS) || defined(__svr5__) */ #else /* defined(SOLARIS) || defined(__svr5__) */
if (sigwait(&set, &sig) != 0) if ((sigerr = sigwait(&set, &sig)) != 0)
#endif /* defined(SOLARIS) || defined(__svr5__) */ #endif /* defined(SOLARIS) || defined(__svr5__) */
{ {
/* some OS return -1 and set errno: copy it */
if (sigerr <= 0)
sigerr = errno;
/* this can happen on OSF/1 (at least) */ /* this can happen on OSF/1 (at least) */
if (errno == EINTR) if (sigerr == EINTR)
continue; continue;
smi_log(SMI_LOG_ERR, smi_log(SMI_LOG_ERR,
"%s: sigwait returned error: %d", "%s: sigwait returned error: %d",
(char *)name, errno); (char *)name, sigerr);
if (++errs > MAX_FAILS_T) if (++errs > MAX_FAILS_T)
{ {
mi_stop_milters(MILTER_ABRT); mi_stop_milters(MILTER_ABRT);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999-2004 Sendmail, Inc. and its suppliers. * Copyright (c) 1999-2005 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* *
* By using this file, you agree to the terms and conditions set * By using this file, you agree to the terms and conditions set
@ -9,7 +9,7 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: smfi.c,v 8.73 2004/09/20 21:26:57 ca Exp $") SM_RCSID("@(#)$Id: smfi.c,v 8.74 2005/03/30 00:44:07 ca Exp $")
#include <sm/varargs.h> #include <sm/varargs.h>
#include "libmilter.h" #include "libmilter.h"
@ -242,7 +242,7 @@ smfi_replacebody(ctx, bodyp, bodylen)
/* split body chunk if necessary */ /* split body chunk if necessary */
off = 0; off = 0;
while (bodylen > 0) do
{ {
len = (bodylen >= MILTER_CHUNK_SIZE) ? MILTER_CHUNK_SIZE : len = (bodylen >= MILTER_CHUNK_SIZE) ? MILTER_CHUNK_SIZE :
bodylen; bodylen;
@ -251,7 +251,7 @@ smfi_replacebody(ctx, bodyp, bodylen)
return r; return r;
off += len; off += len;
bodylen -= len; bodylen -= len;
} } while (bodylen > 0);
return MI_SUCCESS; return MI_SUCCESS;
} }

View File

@ -1,11 +1,11 @@
dnl $Id: Makefile.m4,v 1.68 2005/02/17 23:34:25 ca Exp $ dnl $Id: Makefile.m4,v 1.70 2005/12/22 18:31:11 ca Exp $
define(`confREQUIRE_LIBUNIX') define(`confREQUIRE_LIBUNIX')
include(confBUILDTOOLSDIR`/M4/switch.m4') include(confBUILDTOOLSDIR`/M4/switch.m4')
define(`confREQUIRE_LIBSM', `true') define(`confREQUIRE_LIBSM', `true')
PREPENDDEF(`confENVDEF', `confMAPDEF') PREPENDDEF(`confENVDEF', `confMAPDEF')
bldPRODUCT_START(`library', `libsm') bldPRODUCT_START(`library', `libsm')
define(`bldSOURCES', ` assert.c debug.c errstring.c exc.c heap.c match.c rpool.c strdup.c strerror.c strl.c clrerr.c fclose.c feof.c ferror.c fflush.c fget.c fpos.c findfp.c flags.c fopen.c fprintf.c fpurge.c fput.c fread.c fscanf.c fseek.c fvwrite.c fwalk.c fwrite.c get.c makebuf.c put.c refill.c rewind.c setvbuf.c smstdio.c snprintf.c sscanf.c stdio.c strio.c ungetc.c vasprintf.c vfprintf.c vfscanf.c vprintf.c vsnprintf.c wbuf.c wsetup.c string.c stringf.c xtrap.c strto.c test.c path.c strcasecmp.c strrevcmp.c signal.c clock.c config.c shm.c sem.c mbdb.c strexit.c cf.c ldap.c niprop.c mpeix.c ') define(`bldSOURCES', ` assert.c debug.c errstring.c exc.c heap.c match.c rpool.c strdup.c strerror.c strl.c clrerr.c fclose.c feof.c ferror.c fflush.c fget.c fpos.c findfp.c flags.c fopen.c fprintf.c fpurge.c fput.c fread.c fscanf.c fseek.c fvwrite.c fwalk.c fwrite.c get.c makebuf.c put.c refill.c rewind.c setvbuf.c smstdio.c snprintf.c sscanf.c stdio.c strio.c ungetc.c vasprintf.c vfprintf.c vfscanf.c vprintf.c vsnprintf.c wbuf.c wsetup.c string.c stringf.c xtrap.c strto.c test.c path.c strcasecmp.c strrevcmp.c signal.c clock.c config.c shm.c sem.c mbdb.c strexit.c cf.c ldap.c niprop.c mpeix.c memstat.c ')
bldPRODUCT_END bldPRODUCT_END
dnl msg.c dnl msg.c
dnl syslogio.c dnl syslogio.c
@ -33,5 +33,6 @@ smtest(`t-cf')
smtest(`b-strcmp') smtest(`b-strcmp')
dnl SM_CONF_STRL cannot be turned off dnl SM_CONF_STRL cannot be turned off
dnl smtest(`b-strl') dnl smtest(`b-strl')
smtest(`t-memstat')
bldFINISH bldFINISH

View File

@ -8,12 +8,12 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: b-strcmp.c,v 1.13 2004/08/03 20:07:59 ca Exp $") SM_RCSID("@(#)$Id: b-strcmp.c,v 1.14 2005/06/14 23:07:20 ca Exp $")
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sm/time.h>
#include <sm/string.h> #include <sm/string.h>
#define toseconds(x, y) (x.tv_sec - y.tv_sec) #define toseconds(x, y) (x.tv_sec - y.tv_sec)

View File

@ -19,12 +19,12 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: b-strl.c,v 1.24 2001/09/11 04:04:47 gshapiro Exp $") SM_RCSID("@(#)$Id: b-strl.c,v 1.25 2005/06/14 23:07:20 ca Exp $")
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sm/time.h>
#include <sm/string.h> #include <sm/string.h>
#define SRC_SIZE 512 #define SRC_SIZE 512

View File

@ -12,12 +12,12 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: clock.c,v 1.46 2004/08/03 19:57:22 ca Exp $") SM_RCSID("@(#)$Id: clock.c,v 1.47 2005/06/14 23:07:20 ca Exp $")
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#include <errno.h> #include <errno.h>
#if SM_CONF_SETITIMER #if SM_CONF_SETITIMER
# include <sys/time.h> # include <sm/time.h>
#endif /* SM_CONF_SETITIMER */ #endif /* SM_CONF_SETITIMER */
#include <sm/heap.h> #include <sm/heap.h>
#include <sm/debug.h> #include <sm/debug.h>

View File

@ -13,10 +13,10 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: fclose.c,v 1.43 2004/08/03 20:17:38 ca Exp $") SM_RCSID("@(#)$Id: fclose.c,v 1.44 2005/06/14 23:07:20 ca Exp $")
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sm/time.h>
#include <setjmp.h> #include <setjmp.h>
#include <sm/io.h> #include <sm/io.h>
#include <sm/assert.h> #include <sm/assert.h>

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. * Copyright (c) 2000-2001, 2005, 2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1990, 1993 * Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -13,10 +13,10 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: fflush.c,v 1.43 2001/09/11 04:04:48 gshapiro Exp $") SM_RCSID("@(#)$Id: fflush.c,v 1.45 2006/03/03 22:25:00 ca Exp $")
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sys/time.h> #include <sm/time.h>
#include <signal.h> #include <signal.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
@ -145,6 +145,7 @@ sm_flush(fp, timeout)
return SM_IO_EOF; return SM_IO_EOF;
} }
SM_IO_WR_TIMEOUT(fp, fd, *timeout); SM_IO_WR_TIMEOUT(fp, fd, *timeout);
t = 0;
} }
} }
return 0; return 0;

View File

@ -13,10 +13,10 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: fopen.c,v 1.61 2004/08/03 20:17:38 ca Exp $") SM_RCSID("@(#)$Id: fopen.c,v 1.62 2005/06/14 23:07:20 ca Exp $")
#include <errno.h> #include <errno.h>
#include <setjmp.h> #include <setjmp.h>
#include <sys/time.h> #include <sm/time.h>
#include <sm/heap.h> #include <sm/heap.h>
#include <sm/signal.h> #include <sm/signal.h>
#include <sm/assert.h> #include <sm/assert.h>

View File

@ -13,10 +13,10 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: fpos.c,v 1.38 2004/08/03 20:17:38 ca Exp $") SM_RCSID("@(#)$Id: fpos.c,v 1.39 2005/06/14 23:07:20 ca Exp $")
#include <errno.h> #include <errno.h>
#include <setjmp.h> #include <setjmp.h>
#include <sys/time.h> #include <sm/time.h>
#include <sm/heap.h> #include <sm/heap.h>
#include <sm/signal.h> #include <sm/signal.h>
#include <sm/clock.h> #include <sm/clock.h>

View File

@ -13,14 +13,14 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: fseek.c,v 1.46 2004/08/03 20:17:38 ca Exp $") SM_RCSID("@(#)$Id: fseek.c,v 1.47 2005/06/14 23:07:20 ca Exp $")
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <setjmp.h> #include <setjmp.h>
#include <sys/time.h> #include <sm/time.h>
#include <sm/signal.h> #include <sm/signal.h>
#include <sm/io.h> #include <sm/io.h>
#include <sm/assert.h> #include <sm/assert.h>

View File

@ -8,7 +8,7 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: ldap.c,v 1.62 2005/02/24 00:30:01 ca Exp $") SM_RCSID("@(#)$Id: ldap.c,v 1.67 2005/12/14 00:08:03 ca Exp $")
#if LDAPMAP #if LDAPMAP
# include <sys/types.h> # include <sys/types.h>
@ -47,6 +47,18 @@ static SM_LDAP_RECURSE_ENTRY *sm_ldap_add_recurse __P((SM_LDAP_RECURSE_LIST **,
** **
*/ */
#if _FFR_LDAP_VERSION
# if defined(LDAP_VERSION_MAX) && _FFR_LDAP_VERSION > LDAP_VERSION_MAX
ERROR FFR_LDAP_VERSION > _LDAP_VERSION_MAX
# endif /* defined(LDAP_VERSION_MAX) && _FFR_LDAP_VERSION > LDAP_VERSION_MAX */
# if defined(LDAP_VERSION_MIN) && _FFR_LDAP_VERSION < LDAP_VERSION_MIN
ERROR FFR_LDAP_VERSION < _LDAP_VERSION_MIN
# endif /* defined(LDAP_VERSION_MIN) && _FFR_LDAP_VERSION < LDAP_VERSION_MIN */
# define SM_LDAP_VERSION_DEFAULT _FFR_LDAP_VERSION
#else /* _FFR_LDAP_VERSION */
# define SM_LDAP_VERSION_DEFAULT 0
#endif /* _FFR_LDAP_VERSION */
void void
sm_ldap_clear(lmap) sm_ldap_clear(lmap)
SM_LDAP_STRUCT *lmap; SM_LDAP_STRUCT *lmap;
@ -57,7 +69,7 @@ sm_ldap_clear(lmap)
lmap->ldap_host = NULL; lmap->ldap_host = NULL;
lmap->ldap_port = LDAP_PORT; lmap->ldap_port = LDAP_PORT;
lmap->ldap_uri = NULL; lmap->ldap_uri = NULL;
lmap->ldap_version = 0; lmap->ldap_version = SM_LDAP_VERSION_DEFAULT;
lmap->ldap_deref = LDAP_DEREF_NEVER; lmap->ldap_deref = LDAP_DEREF_NEVER;
lmap->ldap_timelimit = LDAP_NO_LIMIT; lmap->ldap_timelimit = LDAP_NO_LIMIT;
lmap->ldap_sizelimit = LDAP_NO_LIMIT; lmap->ldap_sizelimit = LDAP_NO_LIMIT;
@ -615,6 +627,16 @@ sm_ldap_results(lmap, msgid, flags, delim, rpool, result,
continue; continue;
} }
#if _FFR_LDAP_SINGLEDN
if (bitset(SM_LDAP_SINGLEDN, flags) && *result != NULL)
{
/* only wanted one match */
SM_LDAP_ERROR_CLEANUP();
errno = ENOENT;
return EX_NOTFOUND;
}
#endif /* _FFR_LDAP_SINGLEDN */
/* record completed DN's to prevent loops */ /* record completed DN's to prevent loops */
dn = ldap_get_dn(lmap->ldap_ld, entry); dn = ldap_get_dn(lmap->ldap_ld, entry);
if (dn == NULL) if (dn == NULL)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000-2002, 2004 Sendmail, Inc. and its suppliers. * Copyright (c) 2000-2002, 2004-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1990, 1993 * Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -11,7 +11,7 @@
* forth in the LICENSE file which can be found at the top level of * forth in the LICENSE file which can be found at the top level of
* the sendmail distribution. * the sendmail distribution.
* *
* $Id: local.h,v 1.53 2004/01/09 18:34:22 ca Exp $ * $Id: local.h,v 1.57 2006/02/28 18:48:25 ca Exp $
*/ */
/* /*
@ -19,7 +19,7 @@
** in particular, macros and private variables. ** in particular, macros and private variables.
*/ */
#include <sys/time.h> #include <sm/time.h>
#if !SM_CONF_MEMCHR #if !SM_CONF_MEMCHR
# include <memory.h> # include <memory.h>
#endif /* !SM_CONF_MEMCHR */ #endif /* !SM_CONF_MEMCHR */
@ -75,42 +75,6 @@ int sm_syslogopen __P((SM_FILE_T *, const void *, int, const void *));
int sm_syslogsetinfo __P((SM_FILE_T *, int , void *)); int sm_syslogsetinfo __P((SM_FILE_T *, int , void *));
int sm_sysloggetinfo __P((SM_FILE_T *, int , void *)); int sm_sysloggetinfo __P((SM_FILE_T *, int , void *));
/* should be defined in sys/time.h */
#ifndef timersub
# define timersub(tvp, uvp, vvp) \
do \
{ \
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
if ((vvp)->tv_usec < 0) \
{ \
(vvp)->tv_sec--; \
(vvp)->tv_usec += 1000000; \
} \
} while (0)
#endif /* !timersub */
#ifndef timeradd
# define timeradd(tvp, uvp, vvp) \
do \
{ \
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
if ((vvp)->tv_usec >= 1000000) \
{ \
(vvp)->tv_sec++; \
(vvp)->tv_usec -= 1000000; \
} \
} while (0)
#endif /* !timeradd */
#ifndef timercmp
# define timercmp(tvp, uvp, cmp) \
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
((tvp)->tv_sec cmp (uvp)->tv_sec))
#endif /* !timercmp */
extern bool Sm_IO_DidInit; extern bool Sm_IO_DidInit;
/* Return true iff the given SM_FILE_T cannot be written now. */ /* Return true iff the given SM_FILE_T cannot be written now. */
@ -192,7 +156,7 @@ extern const char SmFileMagic[];
else \ else \
{ \ { \
(time)->tv_sec = (val) / 1000; \ (time)->tv_sec = (val) / 1000; \
(time)->tv_usec = ((val) - ((time)->tv_sec * 1000)) * 10; \ (time)->tv_usec = ((val) - ((time)->tv_sec * 1000)) * 1000; \
} \ } \
if ((val) == SM_TIME_FOREVER) \ if ((val) == SM_TIME_FOREVER) \
{ \ { \
@ -276,7 +240,7 @@ extern const char SmFileMagic[];
else \ else \
{ \ { \
sm_io_to.tv_sec = (to) / 1000; \ sm_io_to.tv_sec = (to) / 1000; \
sm_io_to.tv_usec = ((to) - (sm_io_to.tv_sec * 1000)) * 10; \ sm_io_to.tv_usec = ((to) - (sm_io_to.tv_sec * 1000)) * 1000; \
} \ } \
if (FD_SETSIZE > 0 && (fd) >= FD_SETSIZE) \ if (FD_SETSIZE > 0 && (fd) >= FD_SETSIZE) \
{ \ { \
@ -289,8 +253,11 @@ extern const char SmFileMagic[];
FD_SET((fd), &sm_io_x_mask); \ FD_SET((fd), &sm_io_x_mask); \
if (gettimeofday(&sm_io_to_before, NULL) < 0) \ if (gettimeofday(&sm_io_to_before, NULL) < 0) \
return SM_IO_EOF; \ return SM_IO_EOF; \
sm_io_to_sel = select((fd) + 1, NULL, &sm_io_to_mask, &sm_io_x_mask, \ do \
&sm_io_to); \ { \
sm_io_to_sel = select((fd) + 1, NULL, &sm_io_to_mask, \
&sm_io_x_mask, &sm_io_to); \
} while (sm_io_to_sel < 0 && errno == EINTR); \
if (sm_io_to_sel < 0) \ if (sm_io_to_sel < 0) \
{ \ { \
/* something went wrong, errno set */ \ /* something went wrong, errno set */ \
@ -305,10 +272,9 @@ extern const char SmFileMagic[];
/* else loop again */ \ /* else loop again */ \
if (gettimeofday(&sm_io_to_after, NULL) < 0) \ if (gettimeofday(&sm_io_to_after, NULL) < 0) \
return SM_IO_EOF; \ return SM_IO_EOF; \
timersub(&sm_io_to_before, &sm_io_to_after, &sm_io_to_diff); \ timersub(&sm_io_to_after, &sm_io_to_before, &sm_io_to_diff); \
timersub(&sm_io_to, &sm_io_to_diff, &sm_io_to); \ (to) -= (sm_io_to_diff.tv_sec * 1000); \
(to) -= (sm_io_to.tv_sec * 1000); \ (to) -= (sm_io_to_diff.tv_usec / 1000); \
(to) -= (sm_io_to.tv_usec / 10); \
if ((to) < 0) \ if ((to) < 0) \
(to) = 0; \ (to) = 0; \
} }

View File

@ -0,0 +1,333 @@
/*
* Copyright (c) 2005 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*/
#include <sm/gen.h>
SM_RCSID("@(#)$Id: memstat.c,v 1.4 2005/12/10 00:38:48 ca Exp $")
#include <errno.h>
#if USESWAPCTL
#include <sys/stat.h>
#include <sys/swap.h>
static long sc_page_size;
/*
** SM_MEMSTAT_OPEN -- open memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
sm_memstat_open()
{
sc_page_size = sysconf(_SC_PAGE_SIZE);
if (sc_page_size == -1)
return (errno != 0) ? errno : -1;
return 0;
}
/*
** SM_MEMSTAT_CLOSE -- close memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
sm_memstat_close()
{
return 0;
}
/*
** SM_MEMSTAT_GET -- get memory statistics
**
** Parameters:
** resource -- resource to look up
** pvalue -- (pointer to) memory statistics value (output)
**
** Results:
** 0: success
** !=0: error
*/
int
sm_memstat_get(resource, pvalue)
char *resource;
long *pvalue;
{
int r;
struct anoninfo ai;
r = swapctl(SC_AINFO, &ai);
if (r == -1)
return (errno != 0) ? errno : -1;
r = ai.ani_max - ai.ani_resv;
r *= sc_page_size >> 10;
*pvalue = r;
return 0;
}
#elif USEKSTAT
#include <kstat.h>
#include <sys/sysinfo.h>
static kstat_ctl_t *kc;
static kstat_t *kst;
/*
** SM_MEMSTAT_OPEN -- open memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
sm_memstat_open()
{
kstat_named_t *kn;
kc = kstat_open();
if (kc == NULL)
return (errno != 0) ? errno : -1;
kst = kstat_lookup(kc, "unix", 0,
(name != NULL) ? name : "system_pages");
if (kst == 0)
return (errno != 0) ? errno : -2;
return 0;
}
/*
** SM_MEMSTAT_CLOSE -- close memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
sm_memstat_close()
{
int r;
if (kc == NULL)
return 0;
r = kstat_close(kc);
if (r != 0)
return (errno != 0) ? errno : -1;
return 0;
}
/*
** SM_MEMSTAT_GET -- get memory statistics
**
** Parameters:
** resource -- resource to look up
** pvalue -- (pointer to) memory statistics value (output)
**
** Results:
** 0: success
** !=0: error
*/
int
sm_memstat_get(resource, pvalue)
char *resource;
long *pvalue;
{
int r;
kstat_named_t *kn;
if (kc == NULL || kst == NULL)
return -1;
if (kstat_read(kc, kst, NULL) == -1)
return (errno != 0) ? errno : -2;
kn = kstat_data_lookup(kst,
(resource != NULL) ? resource: "freemem");
if (kn == NULL)
return (errno != 0) ? errno : -3;
*pvalue = kn->value.ul;
return 0;
}
#elif USEPROCMEMINFO
/*
/proc/meminfo?
total: used: free: shared: buffers: cached:
Mem: 261468160 252149760 9318400 0 3854336 109813760
Swap: 1052794880 62185472 990609408
MemTotal: 255340 kB
MemFree: 9100 kB
MemShared: 0 kB
Buffers: 3764 kB
Cached: 107240 kB
Active: 104340 kB
Inact_dirty: 4220 kB
Inact_clean: 2444 kB
Inact_target: 4092 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 255340 kB
LowFree: 9100 kB
SwapTotal: 1028120 kB
SwapFree: 967392 kB
*/
#include <stdio.h>
#include <string.h>
static FILE *fp;
/*
** SM_MEMSTAT_OPEN -- open memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
sm_memstat_open()
{
fp = fopen("/proc/meminfo", "r");
return (fp != NULL) ? 0 : errno;
}
/*
** SM_MEMSTAT_CLOSE -- close memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
sm_memstat_close()
{
if (fp != NULL)
{
fclose(fp);
fp = NULL;
}
return 0;
}
/*
** SM_MEMSTAT_GET -- get memory statistics
**
** Parameters:
** resource -- resource to look up
** pvalue -- (pointer to) memory statistics value (output)
**
** Results:
** 0: success
** !=0: error
*/
int
sm_memstat_get(resource, pvalue)
char *resource;
long *pvalue;
{
int r;
size_t l;
char buf[80];
if (resource == NULL)
return EINVAL;
if (pvalue == NULL)
return EINVAL;
if (fp == NULL)
return -1; /* try to reopen? */
rewind(fp);
l = strlen(resource);
while (fgets(buf, sizeof(buf), fp) != NULL)
{
if (strncmp(buf, resource, l) == 0 && buf[l] == ':')
{
r = sscanf(buf + l + 1, "%ld", pvalue);
return (r > 0) ? 0 : -1;
}
}
return 0;
}
#else /* USEPROCMEMINFO */
/*
** SM_MEMSTAT_OPEN -- open memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
sm_memstat_open()
{
return -1;
}
/*
** SM_MEMSTAT_CLOSE -- close memory statistics
**
** Parameters:
** none
**
** Results:
** errno as error code, 0: ok
*/
int
sm_memstat_close()
{
return 0;
}
/*
** SM_MEMSTAT_GET -- get memory statistics
**
** Parameters:
** resource -- resource to look up
** pvalue -- (pointer to) memory statistics value (output)
**
** Results:
** 0: success
** !=0: error
*/
int
sm_memstat_get(resource, pvalue)
char *resource;
long *pvalue;
{
return -1;
}
#endif /* USEKSTAT */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. * Copyright (c) 2000-2001, 2005-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1990, 1993 * Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -13,13 +13,13 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: refill.c,v 1.50 2002/09/09 21:50:10 gshapiro Exp $") SM_RCSID("@(#)$Id: refill.c,v 1.53 2006/02/28 18:48:25 ca Exp $")
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <setjmp.h> #include <setjmp.h>
#include <signal.h> #include <signal.h>
#include <sys/time.h> #include <sm/time.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <sm/io.h> #include <sm/io.h>
@ -76,8 +76,11 @@ static int sm_lflush __P((SM_FILE_T *, int *));
FD_SET((fd), &sm_io_x_mask); \ FD_SET((fd), &sm_io_x_mask); \
if (gettimeofday(&sm_io_to_before, NULL) < 0) \ if (gettimeofday(&sm_io_to_before, NULL) < 0) \
return SM_IO_EOF; \ return SM_IO_EOF; \
(sel_ret) = select((fd) + 1, &sm_io_to_mask, NULL, \ do \
&sm_io_x_mask, (to)); \ { \
(sel_ret) = select((fd) + 1, &sm_io_to_mask, NULL, \
&sm_io_x_mask, (to)); \
} while ((sel_ret) < 0 && errno == EINTR); \
if ((sel_ret) < 0) \ if ((sel_ret) < 0) \
{ \ { \
/* something went wrong, errno set */ \ /* something went wrong, errno set */ \
@ -94,7 +97,7 @@ static int sm_lflush __P((SM_FILE_T *, int *));
/* calulate wall-clock time used */ \ /* calulate wall-clock time used */ \
if (gettimeofday(&sm_io_to_after, NULL) < 0) \ if (gettimeofday(&sm_io_to_after, NULL) < 0) \
return SM_IO_EOF; \ return SM_IO_EOF; \
timersub(&sm_io_to_before, &sm_io_to_after, &sm_io_to_diff); \ timersub(&sm_io_to_after, &sm_io_to_before, &sm_io_to_diff); \
timersub((to), &sm_io_to_diff, (to)); \ timersub((to), &sm_io_to_diff, (to)); \
} }

View File

@ -8,13 +8,14 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: sem.c,v 1.12 2005/03/25 21:27:02 ca Exp $") SM_RCSID("@(#)$Id: sem.c,v 1.13 2005/08/12 20:39:59 ca Exp $")
#if SM_CONF_SEM #if SM_CONF_SEM
# include <stdlib.h> # include <stdlib.h>
# include <unistd.h> # include <unistd.h>
# include <sm/sem.h> # include <sm/sem.h>
# include <sm/heap.h> # include <sm/heap.h>
# include <errno.h>
/* /*
** SM_SEM_START -- initialize semaphores ** SM_SEM_START -- initialize semaphores
@ -37,7 +38,7 @@ sm_sem_start(key, nsem, semflg, owner)
int semflg; int semflg;
bool owner; bool owner;
{ {
int semid, i; int semid, i, err;
unsigned short *semvals; unsigned short *semvals;
semvals = NULL; semvals = NULL;
@ -67,11 +68,12 @@ sm_sem_start(key, nsem, semflg, owner)
return semid; return semid;
error: error:
err = errno;
if (semvals != NULL) if (semvals != NULL)
sm_free(semvals); sm_free(semvals);
if (semid >= 0) if (semid >= 0)
sm_sem_stop(semid); sm_sem_stop(semid);
return -1; return (err > 0) ? (0 - err) : -1;
} }
/* /*

View File

@ -8,12 +8,13 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: shm.c,v 1.18 2005/02/09 01:54:51 ca Exp $") SM_RCSID("@(#)$Id: shm.c,v 1.19 2005/07/14 22:34:28 ca Exp $")
#if SM_CONF_SHM #if SM_CONF_SHM
# include <stdlib.h> # include <stdlib.h>
# include <unistd.h> # include <unistd.h>
# include <errno.h> # include <errno.h>
# include <sm/string.h>
# include <sm/shm.h> # include <sm/shm.h>

View File

@ -8,10 +8,10 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: signal.c,v 1.16 2001/09/11 04:04:49 gshapiro Exp $") SM_RCSID("@(#)$Id: signal.c,v 1.17 2005/06/14 23:07:20 ca Exp $")
#if SM_CONF_SETITIMER #if SM_CONF_SETITIMER
# include <sys/time.h> # include <sm/time.h>
#endif /* SM_CONF_SETITIMER */ #endif /* SM_CONF_SETITIMER */
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000-2004 Sendmail, Inc. and its suppliers. * Copyright (c) 2000-2005 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1990, 1993 * Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -13,13 +13,13 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: stdio.c,v 1.69 2004/08/03 20:46:34 ca Exp $") SM_RCSID("@(#)$Id: stdio.c,v 1.71 2005/06/14 23:07:20 ca Exp $")
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> /* FreeBSD: FD_ZERO needs <string.h> */ #include <string.h> /* FreeBSD: FD_ZERO needs <string.h> */
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h> #include <sm/time.h>
#include <sm/heap.h> #include <sm/heap.h>
#include <sm/assert.h> #include <sm/assert.h>
#include <sm/varargs.h> #include <sm/varargs.h>
@ -221,7 +221,7 @@ sm_stdclose(fp)
** Failure: -1 and sets errno ** Failure: -1 and sets errno
*/ */
int static int
sm_stdsetmode(fp, mode) sm_stdsetmode(fp, mode)
SM_FILE_T *fp; SM_FILE_T *fp;
const int *mode; const int *mode;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000-2002, 2004 Sendmail, Inc. and its suppliers. * Copyright (c) 2000-2002, 2004, 2005 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1990, 1993 * Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -13,7 +13,7 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_IDSTR(id, "@(#)$Id: strio.c,v 1.43 2004/08/03 20:48:30 ca Exp $") SM_IDSTR(id, "@(#)$Id: strio.c,v 1.44 2005/06/09 21:40:19 ca Exp $")
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
@ -359,7 +359,7 @@ sm_strsetmode(fp, mode)
** Failure: -1 and sets errno ** Failure: -1 and sets errno
*/ */
int static int
sm_strgetmode(fp, mode) sm_strgetmode(fp, mode)
SM_FILE_T *fp; SM_FILE_T *fp;
int *mode; int *mode;

View File

@ -8,7 +8,7 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: t-event.c,v 1.12 2004/08/03 20:50:32 ca Exp $") SM_RCSID("@(#)$Id: t-event.c,v 1.13 2005/06/14 23:07:20 ca Exp $")
#include <stdio.h> #include <stdio.h>
@ -16,7 +16,7 @@ SM_RCSID("@(#)$Id: t-event.c,v 1.12 2004/08/03 20:50:32 ca Exp $")
#include <unistd.h> #include <unistd.h>
# include <sys/wait.h> # include <sys/wait.h>
#if SM_CONF_SETITIMER #if SM_CONF_SETITIMER
# include <sys/time.h> # include <sm/time.h>
#endif /* SM_CONF_SETITIMER */ #endif /* SM_CONF_SETITIMER */
#include <sm/clock.h> #include <sm/clock.h>

View File

@ -0,0 +1,91 @@
/*
* Copyright (c) 2005 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*/
#include <sm/gen.h>
SM_IDSTR(id, "@(#)$Id: t-memstat.c,v 1.5 2005/12/22 19:05:42 ca Exp $")
/*
** Simple test program for memstat
*/
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <strings.h>
int
main(argc, argv)
int argc;
char **argv;
{
int r, r2, i, l, slp, sz;
long v;
char *resource;
l = 1;
sz = slp = 0;
resource = NULL;
while ((r = getopt(argc, argv, "l:m:r:s:")) != -1)
{
switch ((char) r)
{
case 'l':
l = strtol(optarg, NULL, 0);
break;
case 'm':
sz = strtol(optarg, NULL, 0);
break;
case 'r':
resource = strdup(optarg);
break;
case 's':
slp = strtol(optarg, NULL, 0);
break;
default:
break;
}
}
r = sm_memstat_open();
r2 = -1;
for (i = 0; i < l; i++)
{
char *mem;
r2 = sm_memstat_get(resource, &v);
if (slp > 0 && i + 1 < l && 0 == r)
{
printf("open=%d, memstat=%d, %s=%ld\n", r, r2,
resource != NULL ? resource : "default-value",
v);
sleep(slp);
if (sz > 0)
{
/*
** Just allocate some memory to test the
** values that are returned.
** Note: this is a memory leak, but that
** doesn't matter here.
*/
mem = malloc(sz);
if (NULL == mem)
printf("malloc(%d) failed\n", sz);
}
}
}
printf("open=%d, memstat=%d, %s=%ld\n", r, r2,
resource != NULL ? resource : "default-value", v);
r = sm_memstat_close();
return r;
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. * Copyright (c) 2000-2001, 2005-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* *
* By using this file, you agree to the terms and conditions set * By using this file, you agree to the terms and conditions set
@ -8,7 +8,7 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: t-sem.c,v 1.14 2005/03/25 21:27:41 ca Exp $") SM_RCSID("@(#)$Id: t-sem.c,v 1.15 2006/03/13 20:40:43 msk Exp $")
#include <stdio.h> #include <stdio.h>
@ -307,7 +307,7 @@ main(argc, argv)
pid_t pid; pid_t pid;
printf("This test takes about 8 seconds.\n"); printf("This test takes about 8 seconds.\n");
printf("If it takes longer than 30 second, please interrupt it\n"); printf("If it takes longer than 30 seconds, please interrupt it\n");
printf("and compile again without semaphore support, i.e.,"); printf("and compile again without semaphore support, i.e.,");
printf("-DSM_CONF_SEM=0\n"); printf("-DSM_CONF_SEM=0\n");
if ((pid = fork()) < 0) if ((pid = fork()) < 0)

View File

@ -13,12 +13,12 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_IDSTR(id, "@(#)$Id: ungetc.c,v 1.29 2004/08/03 20:54:49 ca Exp $") SM_IDSTR(id, "@(#)$Id: ungetc.c,v 1.30 2005/06/14 23:07:20 ca Exp $")
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <sys/time.h> #include <sm/time.h>
#include <errno.h> #include <errno.h>
#include <sm/io.h> #include <sm/io.h>
#include <sm/heap.h> #include <sm/heap.h>

View File

@ -13,7 +13,7 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_IDSTR(id, "@(#)$Id: vfprintf.c,v 1.53 2004/08/03 20:54:49 ca Exp $") SM_IDSTR(id, "@(#)$Id: vfprintf.c,v 1.54 2005/05/16 03:52:00 ca Exp $")
/* /*
** Overall: ** Overall:
@ -535,9 +535,19 @@ reswitch: switch (ch)
if (prec > 120) if (prec > 120)
prec = 120; prec = 120;
if (prec >= 0) if (prec >= 0)
#if HASSNPRINTF
snprintf(out, sizeof(out), fmt, width,
prec, val);
#else /* HASSNPRINTF */
sprintf(out, fmt, width, prec, val); sprintf(out, fmt, width, prec, val);
#endif /* HASSNPRINTF */
else else
#if HASSNPRINTF
snprintf(out, sizeof(out), fmt, width,
val);
#else /* HASSNPRINTF */
sprintf(out, fmt, width, val); sprintf(out, fmt, width, val);
#endif /* HASSNPRINTF */
len = strlen(out); len = strlen(out);
PRINT(out, len); PRINT(out, len);
FLUSH(); FLUSH();

View File

@ -13,13 +13,13 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_IDSTR(id, "@(#)$Id: vfscanf.c,v 1.52 2004/08/03 20:56:32 ca Exp $") SM_IDSTR(id, "@(#)$Id: vfscanf.c,v 1.53 2005/06/14 23:07:20 ca Exp $")
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <setjmp.h> #include <setjmp.h>
#include <sys/time.h> #include <sm/time.h>
#include <sm/varargs.h> #include <sm/varargs.h>
#include <sm/config.h> #include <sm/config.h>
#include <sm/io.h> #include <sm/io.h>

View File

@ -9,7 +9,7 @@
# the sendmail distribution. # the sendmail distribution.
# #
# #
# $Id: README,v 8.386 2005/03/04 23:24:08 ca Exp $ # $Id: README,v 8.388 2005/07/26 05:45:39 ca Exp $
# #
This directory contains the source files for sendmail(TM). This directory contains the source files for sendmail(TM).
@ -502,6 +502,12 @@ NEEDINTERRNO Set this if <errno.h> does not declare errno, i.e., if an
extern int errno; extern int errno;
USE_TTYPATH Set this to 1 to enable ErrorMode=write. USE_TTYPATH Set this to 1 to enable ErrorMode=write.
USESYSCTL Use sysctl(3) to determine the number of CPUs in a system. USESYSCTL Use sysctl(3) to determine the number of CPUs in a system.
HASSNPRINTF Set this to 1 if your OS has a working snprintf(3), i.e.,
it properly obeys the size of the buffer and returns the
number of characters that would have been printed if the
size were unlimited.
LDAP_REFERRALS Set this if you want to use the -R flag (do not auto chase
referrals) for LDAP maps (requires -DLDAPMAP).
+-----------------------+ +-----------------------+
@ -1826,4 +1832,4 @@ util.c Some general purpose routines used by sendmail.
version.c The version number and information about this version.c The version number and information about this
version of sendmail. version of sendmail.
(Version $Revision: 8.386 $, last update $Date: 2005/03/04 23:24:08 $ ) (Version $Revision: 8.388 $, last update $Date: 2005/07/26 05:45:39 $ )

View File

@ -1,4 +1,4 @@
# $Id: TRACEFLAGS,v 8.43 2005/02/16 23:38:51 ca Exp $ # $Id: TRACEFLAGS,v 8.44 2006/02/27 18:52:41 ca Exp $
0, 4 main.c main canonical name, UUCP node name, a.k.a.s 0, 4 main.c main canonical name, UUCP node name, a.k.a.s
0, 15 main.c main print configuration 0, 15 main.c main print configuration
0, 44 util.c printav print address of each string 0, 44 util.c printav print address of each string
@ -86,6 +86,8 @@
73 queue.c shared memory updates 73 queue.c shared memory updates
80 content length 80 content length
81 sun remote mode 81 sun remote mode
83 collect.c timeout
84 deliver.c timeout
91 mci.c syslogging of MCI cache information 91 mci.c syslogging of MCI cache information
93,>99 * Prevent daemon connection fork for profiling/debugging 93,>99 * Prevent daemon connection fork for profiling/debugging
94,>99 srvrsmtp.c cause commands to fail (for protocol testing) 94,>99 srvrsmtp.c cause commands to fail (for protocol testing)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -13,9 +13,8 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: collect.c,v 8.261 2005/02/16 23:38:51 ca Exp $") SM_RCSID("@(#)$Id: collect.c,v 8.272 2006/03/02 19:09:26 ca Exp $")
static void collecttimeout __P((int));
static void eatfrom __P((char *volatile, ENVELOPE *)); static void eatfrom __P((char *volatile, ENVELOPE *));
static void collect_doheader __P((ENVELOPE *)); static void collect_doheader __P((ENVELOPE *));
static SM_FILE_T *collect_dfopen __P((ENVELOPE *)); static SM_FILE_T *collect_dfopen __P((ENVELOPE *));
@ -263,10 +262,6 @@ collect_dfopen(e)
** If data file cannot be created, the process is terminated. ** If data file cannot be created, the process is terminated.
*/ */
static jmp_buf CtxCollectTimeout;
static bool volatile CollectProgress;
static SM_EVENT *volatile CollectTimeout = NULL;
/* values for input state machine */ /* values for input state machine */
#define IS_NORM 0 /* middle of line */ #define IS_NORM 0 /* middle of line */
#define IS_BOL 1 /* beginning of line */ #define IS_BOL 1 /* beginning of line */
@ -288,27 +283,31 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
register ENVELOPE *e; register ENVELOPE *e;
bool rsetsize; bool rsetsize;
{ {
register SM_FILE_T *volatile df; register SM_FILE_T *df;
volatile bool ignrdot; bool ignrdot;
volatile int dbto; int dbto;
register char *volatile bp; register char *bp;
volatile int c; int c;
volatile bool inputerr; bool inputerr;
bool headeronly; bool headeronly;
char *volatile buf; char *buf;
volatile int buflen; int buflen;
volatile int istate; int istate;
volatile int mstate; int mstate;
volatile int hdrslen; int hdrslen;
volatile int numhdrs; int numhdrs;
volatile int afd; int afd;
unsigned char *volatile pbp; unsigned char *pbp;
unsigned char peekbuf[8]; unsigned char peekbuf[8];
char bufbuf[MAXLINE]; char bufbuf[MAXLINE];
df = NULL; df = NULL;
ignrdot = smtpmode ? false : IgnrDot; ignrdot = smtpmode ? false : IgnrDot;
dbto = smtpmode ? (int) TimeOuts.to_datablock : 0;
/* timeout for I/O functions is in milliseconds */
dbto = smtpmode ? ((int) TimeOuts.to_datablock * 1000)
: SM_TIME_FOREVER;
sm_io_setinfo(fp, SM_IO_WHAT_TIMEOUT, &dbto);
c = SM_IO_EOF; c = SM_IO_EOF;
inputerr = false; inputerr = false;
headeronly = hdrp != NULL; headeronly = hdrp != NULL;
@ -320,7 +319,6 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
pbp = peekbuf; pbp = peekbuf;
istate = IS_BOL; istate = IS_BOL;
mstate = SaveFrom ? MS_HEADER : MS_UFROM; mstate = SaveFrom ? MS_HEADER : MS_UFROM;
CollectProgress = false;
/* /*
** Tell ARPANET to go ahead. ** Tell ARPANET to go ahead.
@ -329,6 +327,10 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
if (smtpmode) if (smtpmode)
message("354 Enter mail, end with \".\" on a line by itself"); message("354 Enter mail, end with \".\" on a line by itself");
/* simulate an I/O timeout when used as sink */
if (tTd(83, 101))
sleep(319);
if (tTd(30, 2)) if (tTd(30, 2))
sm_dprintf("collect\n"); sm_dprintf("collect\n");
@ -341,32 +343,6 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
** the larger picture (e.g., header versus body). ** the larger picture (e.g., header versus body).
*/ */
if (dbto != 0)
{
/* handle possible input timeout */
if (setjmp(CtxCollectTimeout) != 0)
{
if (LogLevel > 2)
sm_syslog(LOG_NOTICE, e->e_id,
"timeout waiting for input from %s during message collect",
CURHOSTNAME);
errno = 0;
if (smtpmode)
{
/*
** Override e_message in usrerr() as this
** is the reason for failure that should
** be logged for undelivered recipients.
*/
e->e_message = NULL;
}
usrerr("451 4.4.1 timeout waiting for input during message collect");
goto readerr;
}
CollectTimeout = sm_setevent(dbto, collecttimeout, dbto);
}
if (rsetsize) if (rsetsize)
e->e_msgsize = 0; e->e_msgsize = 0;
for (;;) for (;;)
@ -390,9 +366,26 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
sm_io_clearerr(fp); sm_io_clearerr(fp);
continue; continue;
} }
/* timeout? */
if (c == SM_IO_EOF && errno == EAGAIN
&& smtpmode)
{
/*
** Override e_message in
** usrerr() as this is the
** reason for failure that
** should be logged for
** undelivered recipients.
*/
e->e_message = NULL;
errno = 0;
inputerr = true;
goto readabort;
}
break; break;
} }
CollectProgress = true;
if (TrafficLogFile != NULL && !headeronly) if (TrafficLogFile != NULL && !headeronly)
{ {
if (istate == IS_BOL) if (istate == IS_BOL)
@ -446,7 +439,8 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
OpMode != MD_ARPAFTP)) OpMode != MD_ARPAFTP))
{ {
SM_ASSERT(pbp < peekbuf + sizeof(peekbuf)); SM_ASSERT(pbp < peekbuf +
sizeof(peekbuf));
*pbp++ = c; *pbp++ = c;
c = '.'; c = '.';
} }
@ -458,7 +452,8 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
else else
{ {
/* push back the ".\rx" */ /* push back the ".\rx" */
SM_ASSERT(pbp < peekbuf + sizeof(peekbuf)); SM_ASSERT(pbp < peekbuf +
sizeof(peekbuf));
*pbp++ = c; *pbp++ = c;
if (OpMode != MD_SMTP && if (OpMode != MD_SMTP &&
OpMode != MD_DAEMON && OpMode != MD_DAEMON &&
@ -538,6 +533,18 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
buflen *= 2; buflen *= 2;
else else
buflen += MEMCHUNKSIZE; buflen += MEMCHUNKSIZE;
if (buflen <= 0)
{
sm_syslog(LOG_NOTICE, e->e_id,
"header overflow from %s during message collect",
CURHOSTNAME);
errno = 0;
e->e_flags |= EF_CLRQUEUE;
e->e_status = "5.6.0";
usrerrenh(e->e_status,
"552 Headers too large");
goto discard;
}
buf = xalloc(buflen); buf = xalloc(buflen);
memmove(buf, obuf, bp - obuf); memmove(buf, obuf, bp - obuf);
bp = &buf[bp - obuf]; bp = &buf[bp - obuf];
@ -581,6 +588,7 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
usrerrenh(e->e_status, usrerrenh(e->e_status,
"552 Headers too large (%d max)", "552 Headers too large (%d max)",
MaxHeadersLength); MaxHeadersLength);
discard:
mstate = MS_DISCARD; mstate = MS_DISCARD;
} }
} }
@ -620,6 +628,24 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
sm_io_clearerr(fp); sm_io_clearerr(fp);
errno = 0; errno = 0;
c = sm_io_getc(fp, SM_TIME_DEFAULT); c = sm_io_getc(fp, SM_TIME_DEFAULT);
/* timeout? */
if (c == SM_IO_EOF && errno == EAGAIN
&& smtpmode)
{
/*
** Override e_message in
** usrerr() as this is the
** reason for failure that
** should be logged for
** undelivered recipients.
*/
e->e_message = NULL;
errno = 0;
inputerr = true;
goto readabort;
}
} while (c == SM_IO_EOF && errno == EINTR); } while (c == SM_IO_EOF && errno == EINTR);
if (c != SM_IO_EOF) if (c != SM_IO_EOF)
(void) sm_io_ungetc(fp, SM_TIME_DEFAULT, c); (void) sm_io_ungetc(fp, SM_TIME_DEFAULT, c);
@ -629,8 +655,12 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
continue; continue;
} }
/* trim off trailing CRLF or NL */
SM_ASSERT(bp > buf); SM_ASSERT(bp > buf);
/* guaranteed by isheader(buf) */
SM_ASSERT(*(bp - 1) != '\n' || bp > buf + 1);
/* trim off trailing CRLF or NL */
if (*--bp != '\n' || *--bp != '\r') if (*--bp != '\n' || *--bp != '\r')
bp++; bp++;
*bp = '\0'; *bp = '\0';
@ -696,10 +726,6 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
inputerr = true; inputerr = true;
} }
/* reset global timer */
if (CollectTimeout != NULL)
sm_clrevent(CollectTimeout);
if (headeronly) if (headeronly)
return; return;
@ -786,6 +812,7 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
} }
/* An EOF when running SMTP is an error */ /* An EOF when running SMTP is an error */
readabort:
if (inputerr && (OpMode == MD_SMTP || OpMode == MD_DAEMON)) if (inputerr && (OpMode == MD_SMTP || OpMode == MD_DAEMON))
{ {
char *host; char *host;
@ -808,13 +835,14 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
problem, host, problem, host,
shortenstring(e->e_from.q_paddr, MAXSHORTSTR)); shortenstring(e->e_from.q_paddr, MAXSHORTSTR));
if (sm_io_eof(fp)) if (sm_io_eof(fp))
usrerr("451 4.4.1 collect: %s on connection from %s, from=%s", usrerr("421 4.4.1 collect: %s on connection from %s, from=%s",
problem, host, problem, host,
shortenstring(e->e_from.q_paddr, MAXSHORTSTR)); shortenstring(e->e_from.q_paddr, MAXSHORTSTR));
else else
syserr("451 4.4.1 collect: %s on connection from %s, from=%s", syserr("421 4.4.1 collect: %s on connection from %s, from=%s",
problem, host, problem, host,
shortenstring(e->e_from.q_paddr, MAXSHORTSTR)); shortenstring(e->e_from.q_paddr, MAXSHORTSTR));
flush_errors(true);
/* don't return an error indication */ /* don't return an error indication */
e->e_to = NULL; e->e_to = NULL;
@ -907,39 +935,6 @@ collect(fp, smtpmode, hdrp, e, rsetsize)
} }
} }
static void
collecttimeout(timeout)
int timeout;
{
int save_errno = errno;
/*
** NOTE: THIS CAN BE CALLED FROM A SIGNAL HANDLER. DO NOT ADD
** ANYTHING TO THIS ROUTINE UNLESS YOU KNOW WHAT YOU ARE
** DOING.
*/
if (CollectProgress)
{
/* reset the timeout */
CollectTimeout = sm_sigsafe_setevent(timeout, collecttimeout,
timeout);
CollectProgress = false;
}
else
{
/* event is done */
CollectTimeout = NULL;
}
/* if no progress was made or problem resetting event, die now */
if (CollectTimeout == NULL)
{
errno = ETIMEDOUT;
longjmp(CtxCollectTimeout, 1);
}
errno = save_errno;
}
/* /*
** DFERROR -- signal error on writing the data file. ** DFERROR -- signal error on writing the data file.
** **

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -13,13 +13,21 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: conf.c,v 8.1061 2005/03/07 17:18:44 ca Exp $") SM_RCSID("@(#)$Id: conf.c,v 8.1081 2006/02/24 02:21:53 ca Exp $")
#include <sendmail/pathnames.h> #include <sendmail/pathnames.h>
#if NEWDB #if NEWDB
# include "sm/bdb.h" # include "sm/bdb.h"
#endif /* NEWDB */ #endif /* NEWDB */
#ifdef DEC
# if NETINET6
/* for the IPv6 device lookup */
# define _SOCKADDR_LEN
# include <macros.h>
# endif /* NETINET6 */
#endif /* DEC */
# include <sys/ioctl.h> # include <sys/ioctl.h>
# include <sys/param.h> # include <sys/param.h>
@ -344,6 +352,7 @@ setdefaults(e)
MaxMimeFieldLength = MaxMimeHeaderLength / 2; MaxMimeFieldLength = MaxMimeHeaderLength / 2;
MaxForwardEntries = 0; MaxForwardEntries = 0;
FastSplit = 1; FastSplit = 1;
MaxNOOPCommands = MAXNOOPCOMMANDS;
#if SASL #if SASL
AuthMechanisms = newstr(AUTH_MECHANISMS); AuthMechanisms = newstr(AUTH_MECHANISMS);
AuthRealm = NULL; AuthRealm = NULL;
@ -2174,10 +2183,25 @@ shouldqueue(pri, ct)
time_t ct; time_t ct;
{ {
bool rval; bool rval;
#if _FFR_MEMSTAT
long memfree;
#endif /* _FFR_MEMSTAT */
if (tTd(3, 30)) if (tTd(3, 30))
sm_dprintf("shouldqueue: CurrentLA=%d, pri=%ld: ", sm_dprintf("shouldqueue: CurrentLA=%d, pri=%ld: ",
CurrentLA, pri); CurrentLA, pri);
#if _FFR_MEMSTAT
if (QueueLowMem > 0 &&
sm_memstat_get(MemoryResource, &memfree) >= 0 &&
memfree < QueueLowMem)
{
if (tTd(3, 30))
sm_dprintf("true (memfree=%ld < QueueLowMem)\n",
memfree, QueueLowMem);
return true;
}
#endif /* _FFR_MEMSTAT */
if (CurrentLA < QueueLA) if (CurrentLA < QueueLA)
{ {
if (tTd(3, 30)) if (tTd(3, 30))
@ -2226,6 +2250,9 @@ refuseconnections(name, e, d, active)
static int conncnt[MAXDAEMONS]; static int conncnt[MAXDAEMONS];
static time_t firstrejtime[MAXDAEMONS]; static time_t firstrejtime[MAXDAEMONS];
static time_t nextlogtime[MAXDAEMONS]; static time_t nextlogtime[MAXDAEMONS];
#if _FFR_MEMSTAT
long memfree;
#endif /* _FFR_MEMSTAT */
#if XLA #if XLA
if (!xla_smtp_ok()) if (!xla_smtp_ok())
@ -2262,6 +2289,19 @@ refuseconnections(name, e, d, active)
conncnt[d] = 0; conncnt[d] = 0;
} }
#if _FFR_MEMSTAT
if (RefuseLowMem > 0 &&
sm_memstat_get(MemoryResource, &memfree) >= 0 &&
memfree < RefuseLowMem)
{
# define R_MSG_LM "rejecting connections on daemon %s: free memory: %ld"
sm_setproctitle(true, e, R_MSG_LM, name, memfree);
if (LogLevel > 8)
sm_syslog(LOG_NOTICE, NOQID, R_MSG_LM, name, memfree);
return true;
}
#endif /* _FFR_MEMSTAT */
sm_getla(); sm_getla();
if (RefuseLA > 0 && CurrentLA >= RefuseLA) if (RefuseLA > 0 && CurrentLA >= RefuseLA)
{ {
@ -3731,7 +3771,7 @@ chownsafe(fd, safedir)
#if HASSETRLIMIT #if HASSETRLIMIT
# ifdef RLIMIT_NEEDS_SYS_TIME_H # ifdef RLIMIT_NEEDS_SYS_TIME_H
# include <sys/time.h> # include <sm/time.h>
# endif /* RLIMIT_NEEDS_SYS_TIME_H */ # endif /* RLIMIT_NEEDS_SYS_TIME_H */
# include <sys/resource.h> # include <sys/resource.h>
#endif /* HASSETRLIMIT */ #endif /* HASSETRLIMIT */
@ -3793,6 +3833,13 @@ setvendor(vendor)
return true; return true;
} }
#endif /* SUN_EXTENSIONS */ #endif /* SUN_EXTENSIONS */
#ifdef DEC
if (sm_strcasecmp(vendor, "Digital") == 0)
{
VendorCode = VENDOR_DEC;
return true;
}
#endif /* DEC */
#if defined(VENDOR_NAME) && defined(VENDOR_CODE) #if defined(VENDOR_NAME) && defined(VENDOR_CODE)
if (sm_strcasecmp(vendor, VENDOR_NAME) == 0) if (sm_strcasecmp(vendor, VENDOR_NAME) == 0)
@ -3884,8 +3931,8 @@ vendor_pre_defaults(e)
** /etc/mail/sendmail.cf without this ** /etc/mail/sendmail.cf without this
*/ */
setuserenv("ISP", NULL); sm_setuserenv("ISP", NULL);
setuserenv("SYSTYPE", NULL); sm_setuserenv("SYSTYPE", NULL);
#endif /* apollo */ #endif /* apollo */
} }
@ -3899,7 +3946,7 @@ vendor_post_defaults(e)
/* Makes sure the SOCK environment variable remains */ /* Makes sure the SOCK environment variable remains */
if (p = getextenv("SOCK")) if (p = getextenv("SOCK"))
setuserenv("SOCK", p); sm_setuserenv("SOCK", p);
#endif /* __QNX__ */ #endif /* __QNX__ */
#if defined(SUN_EXTENSIONS) && defined(SUN_DEFAULT_VALUES) #if defined(SUN_EXTENSIONS) && defined(SUN_DEFAULT_VALUES)
sun_post_defaults(e); sun_post_defaults(e);
@ -4675,7 +4722,7 @@ add_hostnames(sa)
struct rtentry; struct rtentry;
struct mbuf; struct mbuf;
# ifndef SUNOS403 # ifndef SUNOS403
# include <sys/time.h> # include <sm/time.h>
# endif /* ! SUNOS403 */ # endif /* ! SUNOS403 */
# if (_AIX4 >= 40300) && !defined(_NET_IF_H) # if (_AIX4 >= 40300) && !defined(_NET_IF_H)
# undef __P # undef __P
@ -4816,7 +4863,13 @@ load_if_names()
i += sizeof ifr->lifr_name + sa->sa.sa_len; i += sizeof ifr->lifr_name + sa->sa.sa_len;
else else
# endif /* BSD4_4_SOCKADDR */ # endif /* BSD4_4_SOCKADDR */
# ifdef DEC
/* fix for IPv6 size differences */
i += sizeof ifr->ifr_name +
max(sizeof(ifr->ifr_addr), ifr->ifr_addr.sa_len);
# else /* DEC */
i += sizeof *ifr; i += sizeof *ifr;
# endif /* DEC */
if (tTd(0, 20)) if (tTd(0, 20))
sm_dprintf("%s\n", anynet_ntoa(sa)); sm_dprintf("%s\n", anynet_ntoa(sa));
@ -5309,8 +5362,8 @@ sm_syslog(level, id, fmt, va_alist)
va_dcl va_dcl
#endif /* __STDC__ */ #endif /* __STDC__ */
{ {
static char *buf = NULL; char *buf;
static size_t bufsize; size_t bufsize;
char *begin, *end; char *begin, *end;
int save_errno; int save_errno;
int seq = 1; int seq = 1;
@ -5334,11 +5387,8 @@ sm_syslog(level, id, fmt, va_alist)
else else
idlen = strlen(id) + SyslogPrefixLen; idlen = strlen(id) + SyslogPrefixLen;
if (buf == NULL) buf = buf0;
{ bufsize = sizeof buf0;
buf = buf0;
bufsize = sizeof buf0;
}
for (;;) for (;;)
{ {
@ -5380,8 +5430,8 @@ sm_syslog(level, id, fmt, va_alist)
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: %s\n", id, newstring); "%s: %s\n", id, newstring);
#endif /* LOG */ #endif /* LOG */
if (buf == buf0) if (buf != buf0)
buf = NULL; sm_free(buf);
errno = save_errno; errno = save_errno;
return; return;
} }
@ -5445,8 +5495,8 @@ sm_syslog(level, id, fmt, va_alist)
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s[%d]: %s\n", id, seq, begin); "%s[%d]: %s\n", id, seq, begin);
#endif /* LOG */ #endif /* LOG */
if (buf == buf0) if (buf != buf0)
buf = NULL; sm_free(buf);
errno = save_errno; errno = save_errno;
} }
/* /*
@ -5656,6 +5706,9 @@ char *CompileOptions[] =
#if LDAPMAP #if LDAPMAP
"LDAPMAP", "LDAPMAP",
#endif /* LDAPMAP */ #endif /* LDAPMAP */
#if LDAP_REFERRALS
"LDAP_REFERRALS",
#endif /* LDAP_REFERRALS */
#if LOG #if LOG
"LOG", "LOG",
#endif /* LOG */ #endif /* LOG */
@ -6046,6 +6099,10 @@ char *FFRCompileOptions[] =
/* What it says :-) */ /* What it says :-) */
"_FFR_DEPRECATE_MAILER_FLAG_I", "_FFR_DEPRECATE_MAILER_FLAG_I",
#endif /* _FFR_DEPRECATE_MAILER_FLAG_I */ #endif /* _FFR_DEPRECATE_MAILER_FLAG_I */
#if _FFR_DM_ONE
/* deliver first TA in background, then queue */
"_FFR_DM_ONE",
#endif /* _FFR_DM_ONE */
#if _FFR_DIGUNIX_SAFECHOWN #if _FFR_DIGUNIX_SAFECHOWN
/* Properly set SAFECHOWN (include/sm/conf.h) for Digital UNIX */ /* Properly set SAFECHOWN (include/sm/conf.h) for Digital UNIX */
/* Problem noted by Anne Bennett of Concordia University */ /* Problem noted by Anne Bennett of Concordia University */
@ -6109,6 +6166,10 @@ char *FFRCompileOptions[] =
/* Generate a ORCPT DSN arg if not already provided */ /* Generate a ORCPT DSN arg if not already provided */
"_FFR_GEN_ORCPT", "_FFR_GEN_ORCPT",
#endif /* _FFR_GEN_ORCPT */ #endif /* _FFR_GEN_ORCPT */
#if _FFR_LOG_GREET_PAUSE
/* log time for greet_pause delay; from Nik Clayton */
"_FFR_LOG_GREET_PAUSE",
#endif /* _FFR_LOG_GREET_PAUSE */
#if _FFR_GROUPREADABLEAUTHINFOFILE #if _FFR_GROUPREADABLEAUTHINFOFILE
/* Allow group readable DefaultAuthInfo file. */ /* Allow group readable DefaultAuthInfo file. */
"_FFR_GROUPREADABLEAUTHINFOFILE", "_FFR_GROUPREADABLEAUTHINFOFILE",
@ -6158,10 +6219,22 @@ char *FFRCompileOptions[] =
/* Randall S. Winchester of the University of Maryland */ /* Randall S. Winchester of the University of Maryland */
"_FFR_MAX_FORWARD_ENTRIES", "_FFR_MAX_FORWARD_ENTRIES",
#endif /* _FFR_MAX_FORWARD_ENTRIES */ #endif /* _FFR_MAX_FORWARD_ENTRIES */
#if _FFR_MAXKEY
/* increase key size for LDAP lookups, see conf.h */
"_FFR_MAXKEY",
#endif /* _FFR_MAXKEY */
#if _FFR_MAXNOOPCOMMANDS
/* runtime option for "MaxNOOPCommands" */
"_FFR_MAXNOOPCOMMANDS",
#endif /* _FFR_MAXNOOPCOMMANDS */
#if _FFR_MAX_SLEEP_TIME #if _FFR_MAX_SLEEP_TIME
/* Limit sleep(2) time in libsm/clock.c */ /* Limit sleep(2) time in libsm/clock.c */
"_FFR_MAX_SLEEP_TIME", "_FFR_MAX_SLEEP_TIME",
#endif /* _FFR_MAX_SLEEP_TIME */ #endif /* _FFR_MAX_SLEEP_TIME */
#if _FFR_MEMSTAT
/* Check free memory */
"_FFR_MEMSTAT",
#endif /* _FFR_MEMSTAT */
#if _FFR_MILTER_NAGLE #if _FFR_MILTER_NAGLE
/* milter: turn off Nagle ("cork" on Linux) */ /* milter: turn off Nagle ("cork" on Linux) */
/* John Gardiner Myers of Proofpoint */ /* John Gardiner Myers of Proofpoint */
@ -6176,6 +6249,10 @@ char *FFRCompileOptions[] =
/* Old mime7to8 code, the new is broken for at least one example. */ /* Old mime7to8 code, the new is broken for at least one example. */
"_FFR_MIME7TO8_OLD", "_FFR_MIME7TO8_OLD",
#endif /* _FFR_MAX_SLEEP_TIME */ #endif /* _FFR_MAX_SLEEP_TIME */
#if _FFR_MSG_ACCEPT
/* allow to override "Message accepted for delivery" */
"_FFR_MSG_ACCEPT",
#endif /* _FFR_MSG_ACCEPT */
#if _FFR_NODELAYDSN_ON_HOLD #if _FFR_NODELAYDSN_ON_HOLD
/* Do not issue a DELAY DSN for mailers that use the hold flag. */ /* Do not issue a DELAY DSN for mailers that use the hold flag. */
/* Steven Pitzl */ /* Steven Pitzl */
@ -6191,9 +6268,9 @@ char *FFRCompileOptions[] =
#endif /* _FFR_LOG_NTRIES */ #endif /* _FFR_LOG_NTRIES */
#if _FFR_PRIV_NOACTUALRECIPIENT #if _FFR_PRIV_NOACTUALRECIPIENT
/* /*
** PrivacyOptions=noactualrecipient stops sendmail from putting ** PrivacyOptions=noactualrecipient stops sendmail from putting
** X-Actual-Recipient lines in DSNs revealing the actual ** X-Actual-Recipient lines in DSNs revealing the actual
** account that addresses map to. Patch from Dan Harkless. ** account that addresses map to. Patch from Dan Harkless.
*/ */
"_FFR_PRIV_NOACTUALRECIPIENT", "_FFR_PRIV_NOACTUALRECIPIENT",
@ -6212,7 +6289,7 @@ char *FFRCompileOptions[] =
"_FFR_QUEUE_MACRO", "_FFR_QUEUE_MACRO",
#endif /* _FFR_QUEUE_MACRO */ #endif /* _FFR_QUEUE_MACRO */
#if _FFR_QUEUE_RUN_PARANOIA #if _FFR_QUEUE_RUN_PARANOIA
/* Additional checks when doing queue runs. */ /* Additional checks when doing queue runs; interval of checks */
"_FFR_QUEUE_RUN_PARANOIA", "_FFR_QUEUE_RUN_PARANOIA",
#endif /* _FFR_QUEUE_RUN_PARANOIA */ #endif /* _FFR_QUEUE_RUN_PARANOIA */
#if _FFR_QUEUE_SCHED_DBG #if _FFR_QUEUE_SCHED_DBG
@ -6244,6 +6321,25 @@ char *FFRCompileOptions[] =
/* Donated code (unused). */ /* Donated code (unused). */
"_FFR_SHM_STATUS", "_FFR_SHM_STATUS",
#endif /* _FFR_SHM_STATUS */ #endif /* _FFR_SHM_STATUS */
#if _FFR_LDAP_SINGLEDN
/*
** The LDAP database map code in Sendmail 8.12.10, when
** given the -1 switch, would match only a single DN,
** but was able to return multiple attributes for that
** DN. In Sendmail 8.13 this "bug" was corrected to
** only return if exactly one attribute matched.
**
** Unfortunately, our configuration uses the former
** behaviour. Attached is a relatively simple patch
** to 8.13.4 which adds a -2 switch (for lack of a
** better option) which returns the single dn/multiple
** attributes.
**
** Jeffrey T. Eaton, Carnegie-Mellon University
*/
"_FFR_LDAP_SINGLEDN",
#endif /* _FFR_LDAP_SINGLEDN */
#if _FFR_SKIP_DOMAINS #if _FFR_SKIP_DOMAINS
/* process every N'th domain instead of every N'th message */ /* process every N'th domain instead of every N'th message */
"_FFR_SKIP_DOMAINS", "_FFR_SKIP_DOMAINS",

View File

@ -10,7 +10,7 @@
* the sendmail distribution. * the sendmail distribution.
* *
* *
* $Id: conf.h,v 8.567 2004/07/23 20:45:01 gshapiro Exp $ * $Id: conf.h,v 8.570 2005/12/09 18:37:27 ca Exp $
*/ */
/* /*
@ -59,31 +59,40 @@ struct rusage; /* forward declaration to get gcc to shut up in wait.h */
** If you do, be careful, none should be set anywhere near INT_MAX ** If you do, be careful, none should be set anywhere near INT_MAX
**********************************************************************/ **********************************************************************/
#define MAXLINE 2048 /* max line length */ #define MAXLINE 2048 /* max line length */
#define MAXNAME 256 /* max length of a name */ #define MAXNAME 256 /* max length of a name */
#ifndef MAXAUTHINFO #ifndef MAXAUTHINFO
# define MAXAUTHINFO 100 /* max length of authinfo token */ # define MAXAUTHINFO 100 /* max length of authinfo token */
#endif /* ! MAXAUTHINFO */ #endif /* ! MAXAUTHINFO */
#define MAXPV 256 /* max # of parms to mailers */ #define MAXPV 256 /* max # of parms to mailers */
#define MAXATOM 1000 /* max atoms per address */ #define MAXATOM 1000 /* max atoms per address */
#define MAXRWSETS 200 /* max # of sets of rewriting rules */ #define MAXRWSETS 200 /* max # of sets of rewriting rules */
#define MAXPRIORITIES 25 /* max values for Precedence: field */ #define MAXPRIORITIES 25 /* max values for Precedence: field */
#define MAXMXHOSTS 100 /* max # of MX records for one host */ #define MAXMXHOSTS 100 /* max # of MX records for one host */
#define SMTPLINELIM 990 /* maximum SMTP line length */ #define SMTPLINELIM 990 /* max SMTP line length */
#define MAXKEY 128 /* maximum size of a database key */ #define MAXUDBKEY 128 /* max size of a database key (udb only) */
#define MEMCHUNKSIZE 1024 /* chunk size for memory allocation */ #if _FFR_MAXKEY
#define MAXUSERENVIRON 100 /* max envars saved, must be >= 3 */ # define MAXKEY 1024 /* max size of a database key */
#define MAXMAPSTACK 12 /* max # of stacked or sequenced maps */ #else /* _FFR_MAXKEY */
# define MAXKEY (MAXNAME + 1) /* max size of a database key */
#endif /* _FFR_MAXKEY */
#define MEMCHUNKSIZE 1024 /* chunk size for memory allocation */
#define MAXUSERENVIRON 100 /* max envars saved, must be >= 3 */
#define MAXMAPSTACK 12 /* max # of stacked or sequenced maps */
#if MILTER #if MILTER
# define MAXFILTERS 25 /* max # of milter filters */ # define MAXFILTERS 25 /* max # of milter filters */
# define MAXFILTERMACROS 50 /* max # of macros per milter cmd */ # define MAXFILTERMACROS 50 /* max # of macros per milter cmd */
#endif /* MILTER */ #endif /* MILTER */
#define MAXSMTPARGS 20 /* max # of ESMTP args for MAIL/RCPT */ #define MAXSMTPARGS 20 /* max # of ESMTP args for MAIL/RCPT */
#define MAXTOCLASS 8 /* max # of message timeout classes */ #define MAXTOCLASS 8 /* max # of message timeout classes */
#define MAXRESTOTYPES 3 /* max # of resolver timeout types */ #define MAXRESTOTYPES 3 /* max # of resolver timeout types */
#define MAXMIMEARGS 20 /* max args in Content-Type: */ #define MAXMIMEARGS 20 /* max args in Content-Type: */
#define MAXMIMENESTING 20 /* max MIME multipart nesting */ #define MAXMIMENESTING 20 /* max MIME multipart nesting */
#define QUEUESEGSIZE 1000 /* increment for queue size */ #define QUEUESEGSIZE 1000 /* increment for queue size */
#ifndef MAXNOOPCOMMANDS
# define MAXNOOPCOMMANDS 20 /* max "noise" commands before slowdown */
#endif /* ! MAXNOOPCOMMANDS */
/* /*
** MAXQFNAME == 2 (size of "qf", "df" prefix) ** MAXQFNAME == 2 (size of "qf", "df" prefix)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -13,7 +13,7 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: daemon.c,v 8.658 2005/02/02 18:19:28 ca Exp $") SM_RCSID("@(#)$Id: daemon.c,v 8.665 2006/03/02 19:12:00 ca Exp $")
#if defined(SOCK_STREAM) || defined(__GNU_LIBRARY__) #if defined(SOCK_STREAM) || defined(__GNU_LIBRARY__)
# define USE_SOCK_STREAM 1 # define USE_SOCK_STREAM 1
@ -34,7 +34,7 @@ SM_RCSID("@(#)$Id: daemon.c,v 8.658 2005/02/02 18:19:28 ca Exp $")
# include <openssl/rand.h> # include <openssl/rand.h>
#endif /* STARTTLS */ #endif /* STARTTLS */
#include <sys/time.h> #include <sm/time.h>
#if IP_SRCROUTE && NETINET #if IP_SRCROUTE && NETINET
# include <netinet/in_systm.h> # include <netinet/in_systm.h>
@ -90,9 +90,6 @@ typedef struct daemon DAEMON_T;
#define SAFE_NOTSET (-1) /* SuperSafe (per daemon) option not set */ #define SAFE_NOTSET (-1) /* SuperSafe (per daemon) option not set */
/* see also sendmail.h: SuperSafe values */ /* see also sendmail.h: SuperSafe values */
#define DM_NOTSET (-1) /* DeliveryMode (per daemon) option not set */
/* see also sendmail.h: values for e_sendmode -- send modes */
static void connecttimeout __P((int)); static void connecttimeout __P((int));
static int opendaemonsocket __P((DAEMON_T *, bool)); static int opendaemonsocket __P((DAEMON_T *, bool));
static unsigned short setupdaemon __P((SOCKADDR *)); static unsigned short setupdaemon __P((SOCKADDR *));
@ -390,8 +387,8 @@ getrequests(e)
#endif /* _FFR_QUEUE_RUN_PARANOIA */ #endif /* _FFR_QUEUE_RUN_PARANOIA */
} }
#if _FFR_QUEUE_RUN_PARANOIA #if _FFR_QUEUE_RUN_PARANOIA
else if (QueueIntvl > 0 && else if (CheckQueueRunners > 0 && QueueIntvl > 0 &&
lastrun + QueueIntvl + 60 < now) lastrun + QueueIntvl + CheckQueueRunners < now)
{ {
/* /*
@ -764,7 +761,6 @@ getrequests(e)
set_delivery_mode( set_delivery_mode(
Daemons[curdaemon].d_dm, e); Daemons[curdaemon].d_dm, e);
#endif /* _FFR_DM_PER_DAEMON */ #endif /* _FFR_DM_PER_DAEMON */
sm_setproctitle(true, e, "startup with %s", sm_setproctitle(true, e, "startup with %s",
anynet_ntoa(&RealHostAddr)); anynet_ntoa(&RealHostAddr));
@ -1455,6 +1451,12 @@ setsockaddroptions(p, d)
if (d->d_addr.sa.sa_family == AF_UNSPEC) if (d->d_addr.sa.sa_family == AF_UNSPEC)
d->d_addr.sa.sa_family = AF_INET; d->d_addr.sa.sa_family = AF_INET;
#endif /* NETINET */ #endif /* NETINET */
#if _FFR_SS_PER_DAEMON
d->d_supersafe = SAFE_NOTSET;
#endif /* _FFR_SS_PER_DAEMON */
#if _FFR_DM_PER_DAEMON
d->d_dm = DM_NOTSET;
#endif /* _FFR_DM_PER_DAEMON */
while (p != NULL) while (p != NULL)
{ {
@ -1476,12 +1478,6 @@ setsockaddroptions(p, d)
continue; continue;
if (isascii(*f) && islower(*f)) if (isascii(*f) && islower(*f))
*f = toupper(*f); *f = toupper(*f);
#if _FFR_SS_PER_DAEMON
d->d_supersafe = SAFE_NOTSET;
#endif /* _FFR_SS_PER_DAEMON */
#if _FFR_DM_PER_DAEMON
d->d_dm = DM_NOTSET;
#endif /* _FFR_DM_PER_DAEMON */
switch (*f) switch (*f)
{ {
@ -1496,7 +1492,7 @@ setsockaddroptions(p, d)
case SM_QUEUE: case SM_QUEUE:
case SM_DEFER: case SM_DEFER:
case SM_DELIVER: case SM_DELIVER:
case SM_FORK: case SM_FORK:
d->d_dm = *v; d->d_dm = *v;
break; break;
default: default:

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -12,9 +12,9 @@
*/ */
#include <sendmail.h> #include <sendmail.h>
#include <sys/time.h> #include <sm/time.h>
SM_RCSID("@(#)$Id: deliver.c,v 8.986 2005/03/05 02:28:50 ca Exp $") SM_RCSID("@(#)$Id: deliver.c,v 8.1000 2006/03/02 01:37:39 ca Exp $")
#if HASSETUSERCONTEXT #if HASSETUSERCONTEXT
# include <login_cap.h> # include <login_cap.h>
@ -1201,13 +1201,13 @@ should_try_fbsh(e, tried_fallbacksmarthost, hostbuf, hbsz, status)
int status; int status;
{ {
/* /*
** If the host was not found and a FallbackSmartHost is defined ** If the host was not found or a temporary failure occurred
** (and we have not yet tried it), then make one last try with ** and a FallbackSmartHost is defined (and we have not yet
** it as the host. ** tried it), then make one last try with it as the host.
*/ */
if (status == EX_NOHOST && FallbackSmartHost != NULL && if ((status == EX_NOHOST || status == EX_TEMPFAIL) &&
!*tried_fallbacksmarthost) FallbackSmartHost != NULL && !*tried_fallbacksmarthost)
{ {
*tried_fallbacksmarthost = true; *tried_fallbacksmarthost = true;
expand(FallbackSmartHost, hostbuf, hbsz, e); expand(FallbackSmartHost, hostbuf, hbsz, e);
@ -2992,6 +2992,9 @@ deliver(e, firstto)
case EX_SOFTWARE: case EX_SOFTWARE:
s = "SOFTWARE"; s = "SOFTWARE";
break; break;
case EX_UNAVAILABLE:
s = "NONE";
break;
/* everything else is a failure */ /* everything else is a failure */
default: default:
@ -3257,16 +3260,33 @@ deliver(e, firstto)
} }
else if (!clever) else if (!clever)
{ {
bool ok;
/* /*
** Format and send message. ** Format and send message.
*/ */
putfromline(mci, e); rcode = EX_OK;
(*e->e_puthdr)(mci, e->e_header, e, M87F_OUTER); errno = 0;
(*e->e_putbody)(mci, e, NULL); ok = putfromline(mci, e);
if (ok)
ok = (*e->e_puthdr)(mci, e->e_header, e, M87F_OUTER);
if (ok)
ok = (*e->e_putbody)(mci, e, NULL);
/* get the exit status */ /*
** Ignore an I/O error that was caused by EPIPE.
** Some broken mailers don't read the entire body
** but just exit() thus causing an I/O error.
*/
if (!ok && (sm_io_error(mci->mci_out) && errno == EPIPE))
ok = true;
/* (always) get the exit status */
rcode = endmailer(mci, e, pv); rcode = endmailer(mci, e, pv);
if (!ok)
rcode = EX_TEMPFAIL;
if (rcode == EX_TEMPFAIL && SmtpError[0] == '\0') if (rcode == EX_TEMPFAIL && SmtpError[0] == '\0')
{ {
/* /*
@ -4430,13 +4450,13 @@ logdelivery(m, mci, dsn, status, ctladdr, xstart, e)
** e -- the envelope. ** e -- the envelope.
** **
** Returns: ** Returns:
** none ** true iff line was written successfully
** **
** Side Effects: ** Side Effects:
** outputs some text to fp. ** outputs some text to fp.
*/ */
void bool
putfromline(mci, e) putfromline(mci, e)
register MCI *mci; register MCI *mci;
ENVELOPE *e; ENVELOPE *e;
@ -4446,7 +4466,7 @@ putfromline(mci, e)
char xbuf[MAXLINE]; char xbuf[MAXLINE];
if (bitnset(M_NHDR, mci->mci_mailer->m_flags)) if (bitnset(M_NHDR, mci->mci_mailer->m_flags))
return; return true;
mci->mci_flags |= MCIF_INHEADER; mci->mci_flags |= MCIF_INHEADER;
@ -4487,8 +4507,9 @@ putfromline(mci, e)
} }
} }
expand(template, buf, sizeof buf, e); expand(template, buf, sizeof buf, e);
putxline(buf, strlen(buf), mci, PXLF_HEADER); return putxline(buf, strlen(buf), mci, PXLF_HEADER);
} }
/* /*
** PUTBODY -- put the body of a message. ** PUTBODY -- put the body of a message.
** **
@ -4499,24 +4520,26 @@ putfromline(mci, e)
** not be permitted in the resulting message. ** not be permitted in the resulting message.
** **
** Returns: ** Returns:
** none. ** true iff message was written successfully
** **
** Side Effects: ** Side Effects:
** The message is written onto fp. ** The message is written onto fp.
*/ */
/* values for output state variable */ /* values for output state variable */
#define OS_HEAD 0 /* at beginning of line */ #define OSTATE_HEAD 0 /* at beginning of line */
#define OS_CR 1 /* read a carriage return */ #define OSTATE_CR 1 /* read a carriage return */
#define OS_INLINE 2 /* putting rest of line */ #define OSTATE_INLINE 2 /* putting rest of line */
void bool
putbody(mci, e, separator) putbody(mci, e, separator)
register MCI *mci; register MCI *mci;
register ENVELOPE *e; register ENVELOPE *e;
char *separator; char *separator;
{ {
bool dead = false; bool dead = false;
bool ioerr = false;
int save_errno;
char buf[MAXLINE]; char buf[MAXLINE];
#if MIME8TO7 #if MIME8TO7
char *boundaries[MAXMIMENESTING + 1]; char *boundaries[MAXMIMENESTING + 1];
@ -4546,10 +4569,12 @@ putbody(mci, e, separator)
{ {
if (bitset(MCIF_INHEADER, mci->mci_flags)) if (bitset(MCIF_INHEADER, mci->mci_flags))
{ {
putline("", mci); if (!putline("", mci))
goto writeerr;
mci->mci_flags &= ~MCIF_INHEADER; mci->mci_flags &= ~MCIF_INHEADER;
} }
putline("<<< No Message Collected >>>", mci); if (!putline("<<< No Message Collected >>>", mci))
goto writeerr;
goto endofmessage; goto endofmessage;
} }
@ -4570,6 +4595,10 @@ putbody(mci, e, separator)
/* paranoia: the data file should always be in a rewound state */ /* paranoia: the data file should always be in a rewound state */
(void) bfrewind(e->e_dfp); (void) bfrewind(e->e_dfp);
/* simulate an I/O timeout when used as source */
if (tTd(84, 101))
sleep(319);
#if MIME8TO7 #if MIME8TO7
if (bitset(MCIF_CVT8TO7, mci->mci_flags)) if (bitset(MCIF_CVT8TO7, mci->mci_flags))
{ {
@ -4578,26 +4607,31 @@ putbody(mci, e, separator)
*/ */
/* make sure it looks like a MIME message */ /* make sure it looks like a MIME message */
if (hvalue("MIME-Version", e->e_header) == NULL) if (hvalue("MIME-Version", e->e_header) == NULL &&
putline("MIME-Version: 1.0", mci); !putline("MIME-Version: 1.0", mci))
goto writeerr;
if (hvalue("Content-Type", e->e_header) == NULL) if (hvalue("Content-Type", e->e_header) == NULL)
{ {
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"Content-Type: text/plain; charset=%s", "Content-Type: text/plain; charset=%s",
defcharset(e)); defcharset(e));
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
/* now do the hard work */ /* now do the hard work */
boundaries[0] = NULL; boundaries[0] = NULL;
mci->mci_flags |= MCIF_INHEADER; mci->mci_flags |= MCIF_INHEADER;
(void) mime8to7(mci, e->e_header, e, boundaries, M87F_OUTER); if (mime8to7(mci, e->e_header, e, boundaries, M87F_OUTER) ==
SM_IO_EOF)
goto writeerr;
} }
# if MIME7TO8 # if MIME7TO8
else if (bitset(MCIF_CVT7TO8, mci->mci_flags)) else if (bitset(MCIF_CVT7TO8, mci->mci_flags))
{ {
(void) mime7to8(mci, e->e_header, e); if (!mime7to8(mci, e->e_header, e))
goto writeerr;
} }
# endif /* MIME7TO8 */ # endif /* MIME7TO8 */
else if (MaxMimeHeaderLength > 0 || MaxMimeFieldLength > 0) else if (MaxMimeHeaderLength > 0 || MaxMimeFieldLength > 0)
@ -4619,8 +4653,9 @@ putbody(mci, e, separator)
if (bitset(EF_DONT_MIME, e->e_flags)) if (bitset(EF_DONT_MIME, e->e_flags))
SuprErrs = true; SuprErrs = true;
(void) mime8to7(mci, e->e_header, e, boundaries, if (mime8to7(mci, e->e_header, e, boundaries,
M87F_OUTER|M87F_NO8TO7); M87F_OUTER|M87F_NO8TO7) == SM_IO_EOF)
goto writeerr;
/* restore SuprErrs */ /* restore SuprErrs */
SuprErrs = oldsuprerrs; SuprErrs = oldsuprerrs;
@ -4640,7 +4675,8 @@ putbody(mci, e, separator)
if (bitset(MCIF_INHEADER, mci->mci_flags)) if (bitset(MCIF_INHEADER, mci->mci_flags))
{ {
putline("", mci); if (!putline("", mci))
goto writeerr;
mci->mci_flags &= ~MCIF_INHEADER; mci->mci_flags &= ~MCIF_INHEADER;
} }
@ -4651,7 +4687,7 @@ putbody(mci, e, separator)
buflim = &buf[mci->mci_mailer->m_linelimit - 1]; buflim = &buf[mci->mci_mailer->m_linelimit - 1];
/* copy temp file to output with mapping */ /* copy temp file to output with mapping */
ostate = OS_HEAD; ostate = OSTATE_HEAD;
bp = buf; bp = buf;
pbp = peekbuf; pbp = peekbuf;
while (!sm_io_error(mci->mci_out) && !dead) while (!sm_io_error(mci->mci_out) && !dead)
@ -4665,7 +4701,7 @@ putbody(mci, e, separator)
c &= 0x7f; c &= 0x7f;
switch (ostate) switch (ostate)
{ {
case OS_HEAD: case OSTATE_HEAD:
if (c == '\0' && if (c == '\0' &&
bitnset(M_NONULLS, bitnset(M_NONULLS,
mci->mci_mailer->m_flags)) mci->mci_mailer->m_flags))
@ -4731,11 +4767,6 @@ putbody(mci, e, separator)
dead = true; dead = true;
continue; continue;
} }
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
pos++; pos++;
} }
for (xp = buf; xp < bp; xp++) for (xp = buf; xp < bp; xp++)
@ -4748,11 +4779,6 @@ putbody(mci, e, separator)
dead = true; dead = true;
break; break;
} }
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
} }
if (dead) if (dead)
continue; continue;
@ -4763,11 +4789,6 @@ putbody(mci, e, separator)
mci->mci_mailer->m_eol) mci->mci_mailer->m_eol)
== SM_IO_EOF) == SM_IO_EOF)
break; break;
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
pos = 0; pos = 0;
} }
else else
@ -4785,14 +4806,14 @@ putbody(mci, e, separator)
/* determine next state */ /* determine next state */
if (c == '\n') if (c == '\n')
ostate = OS_HEAD; ostate = OSTATE_HEAD;
else if (c == '\r') else if (c == '\r')
ostate = OS_CR; ostate = OSTATE_CR;
else else
ostate = OS_INLINE; ostate = OSTATE_INLINE;
continue; continue;
case OS_CR: case OSTATE_CR:
if (c == '\n') if (c == '\n')
{ {
/* got CRLF */ /* got CRLF */
@ -4801,11 +4822,6 @@ putbody(mci, e, separator)
mci->mci_mailer->m_eol) mci->mci_mailer->m_eol)
== SM_IO_EOF) == SM_IO_EOF)
continue; continue;
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
if (TrafficLogFile != NULL) if (TrafficLogFile != NULL)
{ {
@ -4813,7 +4829,7 @@ putbody(mci, e, separator)
SM_TIME_DEFAULT, SM_TIME_DEFAULT,
mci->mci_mailer->m_eol); mci->mci_mailer->m_eol);
} }
ostate = OS_HEAD; ostate = OSTATE_HEAD;
continue; continue;
} }
@ -4821,13 +4837,13 @@ putbody(mci, e, separator)
SM_ASSERT(pbp < peekbuf + sizeof(peekbuf)); SM_ASSERT(pbp < peekbuf + sizeof(peekbuf));
*pbp++ = c; *pbp++ = c;
c = '\r'; c = '\r';
ostate = OS_INLINE; ostate = OSTATE_INLINE;
goto putch; goto putch;
case OS_INLINE: case OSTATE_INLINE:
if (c == '\r') if (c == '\r')
{ {
ostate = OS_CR; ostate = OSTATE_CR;
continue; continue;
} }
if (c == '\0' && if (c == '\0' &&
@ -4867,11 +4883,6 @@ putbody(mci, e, separator)
dead = true; dead = true;
continue; continue;
} }
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
pos++; pos++;
continue; continue;
} }
@ -4887,11 +4898,6 @@ putbody(mci, e, separator)
dead = true; dead = true;
continue; continue;
} }
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
if (TrafficLogFile != NULL) if (TrafficLogFile != NULL)
{ {
@ -4900,7 +4906,7 @@ putbody(mci, e, separator)
"!%s", "!%s",
mci->mci_mailer->m_eol); mci->mci_mailer->m_eol);
} }
ostate = OS_HEAD; ostate = OSTATE_HEAD;
SM_ASSERT(pbp < peekbuf + SM_ASSERT(pbp < peekbuf +
sizeof(peekbuf)); sizeof(peekbuf));
*pbp++ = c; *pbp++ = c;
@ -4917,13 +4923,8 @@ putbody(mci, e, separator)
mci->mci_mailer->m_eol) mci->mci_mailer->m_eol)
== SM_IO_EOF) == SM_IO_EOF)
continue; continue;
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
pos = 0; pos = 0;
ostate = OS_HEAD; ostate = OSTATE_HEAD;
} }
else else
{ {
@ -4939,13 +4940,8 @@ putbody(mci, e, separator)
dead = true; dead = true;
continue; continue;
} }
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
pos++; pos++;
ostate = OS_INLINE; ostate = OSTATE_INLINE;
} }
break; break;
} }
@ -4970,11 +4966,6 @@ putbody(mci, e, separator)
dead = true; dead = true;
break; break;
} }
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
} }
pos += bp - buf; pos += bp - buf;
} }
@ -4984,11 +4975,9 @@ putbody(mci, e, separator)
(void) sm_io_fputs(TrafficLogFile, (void) sm_io_fputs(TrafficLogFile,
SM_TIME_DEFAULT, SM_TIME_DEFAULT,
mci->mci_mailer->m_eol); mci->mci_mailer->m_eol);
(void) sm_io_fputs(mci->mci_out, SM_TIME_DEFAULT, if (sm_io_fputs(mci->mci_out, SM_TIME_DEFAULT,
mci->mci_mailer->m_eol); mci->mci_mailer->m_eol) == SM_IO_EOF)
goto writeerr;
/* record progress for DATA timeout */
DataProgress = true;
} }
} }
@ -4998,6 +4987,7 @@ putbody(mci, e, separator)
qid_printqueue(e->e_dfqgrp, e->e_dfqdir), qid_printqueue(e->e_dfqgrp, e->e_dfqdir),
DATAFL_LETTER, e->e_id); DATAFL_LETTER, e->e_id);
ExitStat = EX_IOERR; ExitStat = EX_IOERR;
ioerr = true;
} }
endofmessage: endofmessage:
@ -5012,23 +5002,35 @@ putbody(mci, e, separator)
** offset to match. ** offset to match.
*/ */
save_errno = errno;
if (e->e_dfp != NULL) if (e->e_dfp != NULL)
(void) bfrewind(e->e_dfp); (void) bfrewind(e->e_dfp);
/* some mailers want extra blank line at end of message */ /* some mailers want extra blank line at end of message */
if (!dead && bitnset(M_BLANKEND, mci->mci_mailer->m_flags) && if (!dead && bitnset(M_BLANKEND, mci->mci_mailer->m_flags) &&
buf[0] != '\0' && buf[0] != '\n') buf[0] != '\0' && buf[0] != '\n')
putline("", mci);
(void) sm_io_flush(mci->mci_out, SM_TIME_DEFAULT);
if (sm_io_error(mci->mci_out) && errno != EPIPE)
{ {
syserr("putbody: write error"); if (!putline("", mci))
ExitStat = EX_IOERR; goto writeerr;
} }
errno = 0; if (!dead &&
(sm_io_flush(mci->mci_out, SM_TIME_DEFAULT) == SM_IO_EOF ||
(sm_io_error(mci->mci_out) && errno != EPIPE)))
{
save_errno = errno;
syserr("putbody: write error");
ExitStat = EX_IOERR;
ioerr = true;
}
errno = save_errno;
return !dead && !ioerr;
writeerr:
return false;
} }
/* /*
** MAILFILE -- Send a message to a file. ** MAILFILE -- Send a message to a file.
** **
@ -5559,14 +5561,14 @@ mailfile(filename, mailer, ctladdr, sfflags, e)
} }
#endif /* MIME7TO8 */ #endif /* MIME7TO8 */
putfromline(&mcibuf, e); if (!putfromline(&mcibuf, e) ||
(*e->e_puthdr)(&mcibuf, e->e_header, e, M87F_OUTER); !(*e->e_puthdr)(&mcibuf, e->e_header, e, M87F_OUTER) ||
(*e->e_putbody)(&mcibuf, e, NULL); !(*e->e_putbody)(&mcibuf, e, NULL) ||
putline("\n", &mcibuf); !putline("\n", &mcibuf) ||
if (sm_io_flush(f, SM_TIME_DEFAULT) != 0 || (sm_io_flush(f, SM_TIME_DEFAULT) != 0 ||
(SuperSafe != SAFE_NO && (SuperSafe != SAFE_NO &&
fsync(sm_io_getinfo(f, SM_IO_WHAT_FD, NULL)) < 0) || fsync(sm_io_getinfo(f, SM_IO_WHAT_FD, NULL)) < 0) ||
sm_io_error(f)) sm_io_error(f)))
{ {
setstat(EX_IOERR); setstat(EX_IOERR);
#if !NOFTRUNCATE #if !NOFTRUNCATE
@ -6079,12 +6081,16 @@ starttls(m, mci, e)
XS_STARTTLS); XS_STARTTLS);
/* check return code from server */ /* check return code from server */
if (smtpresult == 454) if (REPLYTYPE(smtpresult) == 4)
return EX_TEMPFAIL; return EX_TEMPFAIL;
if (smtpresult == 501) if (smtpresult == 501)
return EX_USAGE; return EX_USAGE;
if (smtpresult == -1) if (smtpresult == -1)
return smtpresult; return smtpresult;
/* not an expected reply but we have to deal with it */
if (REPLYTYPE(smtpresult) == 5)
return EX_UNAVAILABLE;
if (smtpresult != 220) if (smtpresult != 220)
return EX_PROTOCOL; return EX_PROTOCOL;
@ -6128,86 +6134,23 @@ starttls(m, mci, e)
ssl_retry: ssl_retry:
if ((result = SSL_connect(clt_ssl)) <= 0) if ((result = SSL_connect(clt_ssl)) <= 0)
{ {
int i; int i, ssl_err;
bool timedout;
time_t left;
time_t now = curtime();
struct timeval tv;
/* what to do in this case? */ ssl_err = SSL_get_error(clt_ssl, result);
i = SSL_get_error(clt_ssl, result); i = tls_retry(clt_ssl, rfd, wfd, tlsstart,
TimeOuts.to_starttls, ssl_err, "client");
if (i > 0)
goto ssl_retry;
/*
** For SSL_ERROR_WANT_{READ,WRITE}:
** There is not a complete SSL record available yet
** or there is only a partial SSL record removed from
** the network (socket) buffer into the SSL buffer.
** The SSL_connect will only succeed when a full
** SSL record is available (assuming a "real" error
** doesn't happen). To handle when a "real" error
** does happen the select is set for exceptions too.
** The connection may be re-negotiated during this time
** so both read and write "want errors" need to be handled.
** A select() exception loops back so that a proper SSL
** error message can be gotten.
*/
left = TimeOuts.to_starttls - (now - tlsstart);
timedout = left <= 0;
if (!timedout)
{
tv.tv_sec = left;
tv.tv_usec = 0;
}
if (!timedout && FD_SETSIZE > 0 &&
(rfd >= FD_SETSIZE ||
(i == SSL_ERROR_WANT_WRITE && wfd >= FD_SETSIZE)))
{
if (LogLevel > 5)
{
sm_syslog(LOG_ERR, e->e_id,
"STARTTLS=client, error: fd %d/%d too large",
rfd, wfd);
if (LogLevel > 8)
tlslogerr("client");
}
errno = EINVAL;
goto tlsfail;
}
if (!timedout && i == SSL_ERROR_WANT_READ)
{
fd_set ssl_maskr, ssl_maskx;
FD_ZERO(&ssl_maskr);
FD_SET(rfd, &ssl_maskr);
FD_ZERO(&ssl_maskx);
FD_SET(rfd, &ssl_maskx);
if (select(rfd + 1, &ssl_maskr, NULL, &ssl_maskx, &tv)
> 0)
goto ssl_retry;
}
if (!timedout && i == SSL_ERROR_WANT_WRITE)
{
fd_set ssl_maskw, ssl_maskx;
FD_ZERO(&ssl_maskw);
FD_SET(wfd, &ssl_maskw);
FD_ZERO(&ssl_maskx);
FD_SET(rfd, &ssl_maskx);
if (select(wfd + 1, NULL, &ssl_maskw, &ssl_maskx, &tv)
> 0)
goto ssl_retry;
}
if (LogLevel > 5) if (LogLevel > 5)
{ {
sm_syslog(LOG_ERR, e->e_id, sm_syslog(LOG_WARNING, NOQID,
"STARTTLS=client, error: connect failed=%d, SSL_error=%d, timedout=%d, errno=%d", "STARTTLS=client, error: connect failed=%d, SSL_error=%d, errno=%d, retry=%d",
result, i, (int) timedout, errno); result, ssl_err, errno, i);
if (LogLevel > 8) if (LogLevel > 8)
tlslogerr("client"); tlslogerr("client");
} }
tlsfail:
SSL_free(clt_ssl); SSL_free(clt_ssl);
clt_ssl = NULL; clt_ssl = NULL;
return EX_SOFTWARE; return EX_SOFTWARE;

View File

@ -13,7 +13,7 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: envelope.c,v 8.294 2005/02/16 23:38:51 ca Exp $") SM_RCSID("@(#)$Id: envelope.c,v 8.295 2005/06/15 20:32:18 ca Exp $")
/* /*
** CLRSESSENVELOPE -- clear session oriented data in an envelope ** CLRSESSENVELOPE -- clear session oriented data in an envelope
@ -75,6 +75,10 @@ newenvelope(e, parent, rpool)
register ENVELOPE *parent; register ENVELOPE *parent;
SM_RPOOL_T *rpool; SM_RPOOL_T *rpool;
{ {
#if _FFR_DM_PER_DAEMON
int sendmode;
#endif /* _FFR_DM_PER_DAEMON */
/* /*
** This code used to read: ** This code used to read:
** if (e == parent && e->e_parent != NULL) ** if (e == parent && e->e_parent != NULL)
@ -84,6 +88,13 @@ newenvelope(e, parent, rpool)
** This meant macvalue() could go into an infinite loop. ** This meant macvalue() could go into an infinite loop.
*/ */
#if _FFR_DM_PER_DAEMON
if (parent != NULL)
sendmode = parent->e_sendmode;
else
sendmode = DM_NOTSET;
#endif /* _FFR_DM_PER_DAEMON */
if (e == parent) if (e == parent)
parent = e->e_parent; parent = e->e_parent;
clearenvelope(e, true, rpool); clearenvelope(e, true, rpool);
@ -119,6 +130,10 @@ newenvelope(e, parent, rpool)
e->e_putbody = putbody; e->e_putbody = putbody;
if (CurEnv->e_xfp != NULL) if (CurEnv->e_xfp != NULL)
(void) sm_io_flush(CurEnv->e_xfp, SM_TIME_DEFAULT); (void) sm_io_flush(CurEnv->e_xfp, SM_TIME_DEFAULT);
#if _FFR_DM_PER_DAEMON
if (sendmode != DM_NOTSET)
e->e_sendmode = sendmode;
#endif /* _FFR_DM_PER_DAEMON */
return e; return e;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2004, 2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -13,12 +13,12 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: headers.c,v 8.287 2004/12/03 18:29:51 ca Exp $") SM_RCSID("@(#)$Id: headers.c,v 8.290 2006/02/25 02:16:52 ca Exp $")
static HDR *allocheader __P((char *, char *, int, SM_RPOOL_T *)); static HDR *allocheader __P((char *, char *, int, SM_RPOOL_T *));
static size_t fix_mime_header __P((HDR *, ENVELOPE *)); static size_t fix_mime_header __P((HDR *, ENVELOPE *));
static int priencode __P((char *)); static int priencode __P((char *));
static void put_vanilla_header __P((HDR *, char *, MCI *)); static bool put_vanilla_header __P((HDR *, char *, MCI *));
/* /*
** SETUPHEADERS -- initialize headers in symbol table ** SETUPHEADERS -- initialize headers in symbol table
@ -993,7 +993,6 @@ logsender(e, msgid)
char *name; char *name;
register char *sbp; register char *sbp;
register char *p; register char *p;
int l;
char hbuf[MAXNAME + 1]; char hbuf[MAXNAME + 1];
char sbuf[MAXLINE + 1]; char sbuf[MAXLINE + 1];
char mbuf[MAXNAME + 1]; char mbuf[MAXNAME + 1];
@ -1002,6 +1001,8 @@ logsender(e, msgid)
/* XXX do we still need this? sm_syslog() replaces control chars */ /* XXX do we still need this? sm_syslog() replaces control chars */
if (msgid != NULL) if (msgid != NULL)
{ {
size_t l;
l = strlen(msgid); l = strlen(msgid);
if (l > sizeof mbuf - 1) if (l > sizeof mbuf - 1)
l = sizeof mbuf - 1; l = sizeof mbuf - 1;
@ -1541,13 +1542,13 @@ crackaddr(addr, e)
** flags -- MIME conversion flags. ** flags -- MIME conversion flags.
** **
** Returns: ** Returns:
** none. ** success
** **
** Side Effects: ** Side Effects:
** none. ** none.
*/ */
void bool
putheader(mci, hdr, e, flags) putheader(mci, hdr, e, flags)
register MCI *mci; register MCI *mci;
HDR *hdr; HDR *hdr;
@ -1682,7 +1683,8 @@ putheader(mci, hdr, e, flags)
{ {
if (tTd(34, 11)) if (tTd(34, 11))
sm_dprintf("\n"); sm_dprintf("\n");
put_vanilla_header(h, p, mci); if (!put_vanilla_header(h, p, mci))
goto writeerr;
continue; continue;
} }
@ -1741,7 +1743,8 @@ putheader(mci, hdr, e, flags)
/* no other recipient headers: truncate value */ /* no other recipient headers: truncate value */
(void) sm_strlcpyn(obuf, sizeof obuf, 2, (void) sm_strlcpyn(obuf, sizeof obuf, 2,
h->h_field, ":"); h->h_field, ":");
putline(obuf, mci); if (!putline(obuf, mci))
goto writeerr;
} }
continue; continue;
} }
@ -1760,7 +1763,8 @@ putheader(mci, hdr, e, flags)
} }
else else
{ {
put_vanilla_header(h, p, mci); if (!put_vanilla_header(h, p, mci))
goto writeerr;
} }
} }
@ -1777,18 +1781,25 @@ putheader(mci, hdr, e, flags)
!bitset(MCIF_CVT8TO7|MCIF_CVT7TO8|MCIF_INMIME, mci->mci_flags) && !bitset(MCIF_CVT8TO7|MCIF_CVT7TO8|MCIF_INMIME, mci->mci_flags) &&
hvalue("MIME-Version", e->e_header) == NULL) hvalue("MIME-Version", e->e_header) == NULL)
{ {
putline("MIME-Version: 1.0", mci); if (!putline("MIME-Version: 1.0", mci))
goto writeerr;
if (hvalue("Content-Type", e->e_header) == NULL) if (hvalue("Content-Type", e->e_header) == NULL)
{ {
(void) sm_snprintf(obuf, sizeof obuf, (void) sm_snprintf(obuf, sizeof obuf,
"Content-Type: text/plain; charset=%s", "Content-Type: text/plain; charset=%s",
defcharset(e)); defcharset(e));
putline(obuf, mci); if (!putline(obuf, mci))
goto writeerr;
} }
if (hvalue("Content-Transfer-Encoding", e->e_header) == NULL) if (hvalue("Content-Transfer-Encoding", e->e_header) == NULL
putline("Content-Transfer-Encoding: 8bit", mci); && !putline("Content-Transfer-Encoding: 8bit", mci))
goto writeerr;
} }
#endif /* MIME8TO7 */ #endif /* MIME8TO7 */
return true;
writeerr:
return false;
} }
/* /*
** PUT_VANILLA_HEADER -- output a fairly ordinary header ** PUT_VANILLA_HEADER -- output a fairly ordinary header
@ -1799,10 +1810,10 @@ putheader(mci, hdr, e, flags)
** mci -- the connection info for output ** mci -- the connection info for output
** **
** Returns: ** Returns:
** none. ** success
*/ */
static void static bool
put_vanilla_header(h, v, mci) put_vanilla_header(h, v, mci)
HDR *h; HDR *h;
char *v; char *v;
@ -1833,7 +1844,8 @@ put_vanilla_header(h, v, mci)
l = SPACELEFT(obuf, obp) - 1; l = SPACELEFT(obuf, obp) - 1;
(void) sm_snprintf(obp, SPACELEFT(obuf, obp), "%.*s", l, v); (void) sm_snprintf(obp, SPACELEFT(obuf, obp), "%.*s", l, v);
putxline(obuf, strlen(obuf), mci, putflags); if (!putxline(obuf, strlen(obuf), mci, putflags))
goto writeerr;
v += l + 1; v += l + 1;
obp = obuf; obp = obuf;
if (*v != ' ' && *v != '\t') if (*v != ' ' && *v != '\t')
@ -1843,7 +1855,10 @@ put_vanilla_header(h, v, mci)
/* XXX This is broken for SPACELEFT()==0 */ /* XXX This is broken for SPACELEFT()==0 */
(void) sm_snprintf(obp, SPACELEFT(obuf, obp), "%.*s", (void) sm_snprintf(obp, SPACELEFT(obuf, obp), "%.*s",
(int) (SPACELEFT(obuf, obp) - 1), v); (int) (SPACELEFT(obuf, obp) - 1), v);
putxline(obuf, strlen(obuf), mci, putflags); return putxline(obuf, strlen(obuf), mci, putflags);
writeerr:
return false;
} }
/* /*
** COMMAIZE -- output a header field, making a comma-translated list. ** COMMAIZE -- output a header field, making a comma-translated list.
@ -1856,13 +1871,13 @@ put_vanilla_header(h, v, mci)
** e -- the envelope containing the message. ** e -- the envelope containing the message.
** **
** Returns: ** Returns:
** none. ** success
** **
** Side Effects: ** Side Effects:
** outputs "p" to file "fp". ** outputs "p" to file "fp".
*/ */
void bool
commaize(h, p, oldstyle, mci, e) commaize(h, p, oldstyle, mci, e)
register HDR *h; register HDR *h;
register char *p; register char *p;
@ -2001,13 +2016,6 @@ commaize(h, p, oldstyle, mci, e)
} }
name = denlstring(name, false, true); name = denlstring(name, false, true);
/*
** record data progress so DNS timeouts
** don't cause DATA timeouts
*/
DataProgress = true;
/* output the name with nice formatting */ /* output the name with nice formatting */
opos += strlen(name); opos += strlen(name);
if (!firstone) if (!firstone)
@ -2015,7 +2023,8 @@ commaize(h, p, oldstyle, mci, e)
if (opos > omax && !firstone) if (opos > omax && !firstone)
{ {
(void) sm_strlcpy(obp, ",\n", SPACELEFT(obuf, obp)); (void) sm_strlcpy(obp, ",\n", SPACELEFT(obuf, obp));
putxline(obuf, strlen(obuf), mci, putflags); if (!putxline(obuf, strlen(obuf), mci, putflags))
goto writeerr;
obp = obuf; obp = obuf;
(void) sm_strlcpy(obp, " ", sizeof obuf); (void) sm_strlcpy(obp, " ", sizeof obuf);
opos = strlen(obp); opos = strlen(obp);
@ -2037,8 +2046,12 @@ commaize(h, p, oldstyle, mci, e)
*obp = '\0'; *obp = '\0';
else else
obuf[sizeof obuf - 1] = '\0'; obuf[sizeof obuf - 1] = '\0';
putxline(obuf, strlen(obuf), mci, putflags); return putxline(obuf, strlen(obuf), mci, putflags);
writeerr:
return false;
} }
/* /*
** COPYHEADER -- copy header list ** COPYHEADER -- copy header list
** **

View File

@ -1,6 +1,6 @@
#vers 2 #vers 2
cpyr cpyr
cpyr Copyright (c) 1998-2000, 2002, 2004 Sendmail, Inc. and its suppliers. cpyr Copyright (c) 1998-2000, 2002, 2004, 2005 Sendmail, Inc. and its suppliers.
cpyr All rights reserved. cpyr All rights reserved.
cpyr Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. cpyr Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
cpyr Copyright (c) 1988, 1993 cpyr Copyright (c) 1988, 1993
@ -11,7 +11,7 @@ cpyr By using this file, you agree to the terms and conditions set
cpyr forth in the LICENSE file which can be found at the top level of cpyr forth in the LICENSE file which can be found at the top level of
cpyr the sendmail distribution. cpyr the sendmail distribution.
cpyr cpyr
cpyr $$Id: helpfile,v 8.43 2004/10/29 18:05:39 ca Exp $$ cpyr $$Id: helpfile,v 8.45 2005/09/13 00:05:23 ca Exp $$
cpyr cpyr
smtp This is sendmail version $v smtp This is sendmail version $v
smtp Topics: smtp Topics:
@ -48,10 +48,10 @@ ehlo STARTTLS Secure SMTP [RFC2487]
ehlo AUTH Authentication [RFC2554] ehlo AUTH Authentication [RFC2554]
ehlo ENHANCEDSTATUSCODES Enhanced status codes [RFC2034] ehlo ENHANCEDSTATUSCODES Enhanced status codes [RFC2034]
ehlo DELIVERBY Deliver By [RFC2852] ehlo DELIVERBY Deliver By [RFC2852]
mail MAIL FROM: <sender> [ <parameters> ] mail MAIL From:<sender> [ <parameters> ]
mail Specifies the sender. Parameters are ESMTP extensions. mail Specifies the sender. Parameters are ESMTP extensions.
mail See "HELP DSN" for details. mail See "HELP DSN" for details.
rcpt RCPT TO: <recipient> [ <parameters> ] rcpt RCPT To:<recipient> [ <parameters> ]
rcpt Specifies the recipient. Can be used any number of times. rcpt Specifies the recipient. Can be used any number of times.
rcpt Parameters are ESMTP extensions. See "HELP DSN" for details. rcpt Parameters are ESMTP extensions. See "HELP DSN" for details.
data DATA data DATA
@ -91,7 +91,7 @@ saml implementation.
turn TURN turn TURN
turn Reverses the direction of the connection. Not currently turn Reverses the direction of the connection. Not currently
turn implemented. turn implemented.
etrn ETRN [ <hostname> | @<domain> | #<queuename> ] etrn ETRN [ <hostname> | @<domain> | \#<queuename> ]
etrn Run the queue for the specified <hostname>, or etrn Run the queue for the specified <hostname>, or
etrn all hosts within a given <domain>, or a specially-named etrn all hosts within a given <domain>, or a specially-named
etrn <queuename> (implementation-specific). etrn <queuename> (implementation-specific).

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -25,7 +25,7 @@ SM_UNUSED(static char copyright[]) =
The Regents of the University of California. All rights reserved.\n"; The Regents of the University of California. All rights reserved.\n";
#endif /* ! lint */ #endif /* ! lint */
SM_RCSID("@(#)$Id: main.c,v 8.939 2004/06/17 16:39:21 ca Exp $") SM_RCSID("@(#)$Id: main.c,v 8.942 2005/12/26 04:39:13 ca Exp $")
#if NETINET || NETINET6 #if NETINET || NETINET6
@ -649,7 +649,7 @@ main(argc, argv, envp)
} }
/* prime the child environment */ /* prime the child environment */
setuserenv("AGENT", "sendmail"); sm_setuserenv("AGENT", "sendmail");
(void) sm_signal(SIGPIPE, SIG_IGN); (void) sm_signal(SIGPIPE, SIG_IGN);
OldUmask = umask(022); OldUmask = umask(022);
@ -1318,9 +1318,9 @@ main(argc, argv, envp)
if (TimeZoneSpec == NULL) if (TimeZoneSpec == NULL)
unsetenv("TZ"); unsetenv("TZ");
else if (TimeZoneSpec[0] != '\0') else if (TimeZoneSpec[0] != '\0')
setuserenv("TZ", TimeZoneSpec); sm_setuserenv("TZ", TimeZoneSpec);
else else
setuserenv("TZ", NULL); sm_setuserenv("TZ", NULL);
tzset(); tzset();
/* initialize mailbox database */ /* initialize mailbox database */
@ -1462,6 +1462,16 @@ main(argc, argv, envp)
"Warning: HostStatusDirectory required for SingleThreadDelivery\n"); "Warning: HostStatusDirectory required for SingleThreadDelivery\n");
} }
#if _FFR_MEMSTAT
j = sm_memstat_open();
if (j < 0 && (RefuseLowMem > 0 || QueueLowMem > 0) && LogLevel > 4)
{
sm_syslog(LOG_WARNING, NOQID,
"cannot get memory statistics, settings ignored, error=%d"
, j);
}
#endif /* _FFR_MEMSTAT */
/* check for permissions */ /* check for permissions */
if (RealUid != 0 && if (RealUid != 0 &&
RealUid != TrustedUid) RealUid != TrustedUid)
@ -2949,6 +2959,9 @@ finis(drop, cleanup, exitstat)
/* reset uid for process accounting */ /* reset uid for process accounting */
endpwent(); endpwent();
sm_mbdb_terminate(); sm_mbdb_terminate();
#if _FFR_MEMSTAT
(void) sm_memstat_close();
#endif /* _FFR_MEMSTAT */
(void) setuid(RealUid); (void) setuid(RealUid);
#if SM_HEAP_CHECK #if SM_HEAP_CHECK
/* dump the heap, if we are checking for memory leaks */ /* dump the heap, if we are checking for memory leaks */
@ -3439,21 +3452,21 @@ getextenv(envar)
return NULL; return NULL;
} }
/* /*
** SETUSERENV -- set an environment in the propagated environment ** SM_SETUSERENV -- set an environment variable in the propagated environment
** **
** Parameters: ** Parameters:
** envar -- the name of the environment variable. ** envar -- the name of the environment variable.
** value -- the value to which it should be set. If ** value -- the value to which it should be set. If
** null, this is extracted from the incoming ** null, this is extracted from the incoming
** environment. If that is not set, the call ** environment. If that is not set, the call
** to setuserenv is ignored. ** to sm_setuserenv is ignored.
** **
** Returns: ** Returns:
** none. ** none.
*/ */
void void
setuserenv(envar, value) sm_setuserenv(envar, value)
const char *envar; const char *envar;
const char *value; const char *value;
{ {
@ -3488,7 +3501,7 @@ setuserenv(envar, value)
/* make sure it is in our environment as well */ /* make sure it is in our environment as well */
if (putenv(p) < 0) if (putenv(p) < 0)
syserr("setuserenv: putenv(%s) failed", p); syserr("sm_setuserenv: putenv(%s) failed", p);
} }
/* /*
** DUMPSTATE -- dump state ** DUMPSTATE -- dump state

View File

@ -13,7 +13,7 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: map.c,v 8.669 2005/02/09 01:46:35 ca Exp $") SM_RCSID("@(#)$Id: map.c,v 8.671 2005/10/25 17:55:50 ca Exp $")
#if LDAPMAP #if LDAPMAP
# include <sm/ldap.h> # include <sm/ldap.h>
@ -3493,7 +3493,7 @@ ldapmap_lookup(map, name, av, statp)
char *result = NULL; char *result = NULL;
SM_RPOOL_T *rpool; SM_RPOOL_T *rpool;
SM_LDAP_STRUCT *lmap = NULL; SM_LDAP_STRUCT *lmap = NULL;
char keybuf[MAXNAME + 1]; char keybuf[MAXKEY];
if (tTd(38, 20)) if (tTd(38, 20))
sm_dprintf("ldapmap_lookup(%s, %s)\n", map->map_mname, name); sm_dprintf("ldapmap_lookup(%s, %s)\n", map->map_mname, name);
@ -3551,6 +3551,10 @@ ldapmap_lookup(map, name, av, statp)
flags |= SM_LDAP_SINGLEMATCH; flags |= SM_LDAP_SINGLEMATCH;
if (bitset(MF_MATCHONLY, map->map_mflags)) if (bitset(MF_MATCHONLY, map->map_mflags))
flags |= SM_LDAP_MATCHONLY; flags |= SM_LDAP_MATCHONLY;
# if _FFR_LDAP_SINGLEDN
if (bitset(MF_SINGLEDN, map->map_mflags))
flags |= SM_LDAP_SINGLEDN;
# endif /* _FFR_LDAP_SINGLEDN */
/* Create an rpool for search related memory usage */ /* Create an rpool for search related memory usage */
rpool = sm_rpool_new_x(NULL); rpool = sm_rpool_new_x(NULL);
@ -3911,6 +3915,12 @@ ldapmap_parseargs(map, args)
map->map_mflags |= MF_SINGLEMATCH; map->map_mflags |= MF_SINGLEMATCH;
break; break;
# if _FFR_LDAP_SINGLEDN
case '2':
map->map_mflags |= MF_SINGLEDN;
break;
# endif /* _FFR_LDAP_SINGLEDN */
/* args stolen from ldapsearch.c */ /* args stolen from ldapsearch.c */
case 'R': /* don't auto chase referrals */ case 'R': /* don't auto chase referrals */
# ifdef LDAP_REFERRALS # ifdef LDAP_REFERRALS

View File

@ -13,7 +13,7 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: mci.c,v 8.214 2005/02/04 22:01:45 ca Exp $") SM_RCSID("@(#)$Id: mci.c,v 8.216 2005/07/12 22:27:44 ca Exp $")
#if NETINET || NETINET6 #if NETINET || NETINET6
# include <arpa/inet.h> # include <arpa/inet.h>
@ -47,11 +47,9 @@ static int mci_read_persistent __P((SM_FILE_T *, MCI *));
** MciCacheTimeout is the time (in seconds) that a connection ** MciCacheTimeout is the time (in seconds) that a connection
** is permitted to survive without activity. ** is permitted to survive without activity.
** **
** We actually try any cached connections by sending a NOOP ** We actually try any cached connections by sending a RSET
** before we use them; if the NOOP fails we close down the ** before we use them; if the RSET fails we close down the
** connection and reopen it. Note that this means that a ** connection and reopen it (see smtpprobe()).
** server SMTP that doesn't support NOOP will hose the
** algorithm -- but that doesn't seem too likely.
** **
** The persistent MCI code is donated by Mark Lovell and Paul ** The persistent MCI code is donated by Mark Lovell and Paul
** Vixie. It is based on the long term host status code in KJS ** Vixie. It is based on the long term host status code in KJS
@ -1126,6 +1124,9 @@ mci_traverse_persistent(action, pathname)
char *newptr; char *newptr;
struct dirent *e; struct dirent *e;
char newpath[MAXPATHLEN]; char newpath[MAXPATHLEN];
#if MAXPATHLEN <= MAXNAMLEN - 3
ERROR "MAXPATHLEN <= MAXNAMLEN - 3"
#endif /* MAXPATHLEN <= MAXNAMLEN - 3 */
if ((d = opendir(pathname)) == NULL) if ((d = opendir(pathname)) == NULL)
{ {

View File

@ -10,14 +10,14 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: milter.c,v 8.229 2005/03/02 02:32:34 ca Exp $") SM_RCSID("@(#)$Id: milter.c,v 8.232 2005/08/05 21:49:04 ca Exp $")
#if MILTER #if MILTER
# include <libmilter/mfapi.h> # include <libmilter/mfapi.h>
# include <libmilter/mfdef.h> # include <libmilter/mfdef.h>
# include <errno.h> # include <errno.h>
# include <sys/time.h> # include <sm/time.h>
# include <sys/uio.h> # include <sys/uio.h>
# if NETINET || NETINET6 # if NETINET || NETINET6
@ -1962,11 +1962,20 @@ milter_send_command(m, command, data, sz, e, state)
#if SMFI_VERSION > 2 #if SMFI_VERSION > 2
case SMFIC_UNKNOWN: case SMFIC_UNKNOWN:
skipflag = SMFIP_NOUNKNOWN;
action = "unknown"; action = "unknown";
defresponse = "550 5.7.1 Command rejected"; defresponse = "550 5.7.1 Command rejected";
break; break;
#endif /* SMFI_VERSION > 2 */ #endif /* SMFI_VERSION > 2 */
#if SMFI_VERSION > 3
case SMFIC_DATA:
skipflag = SMFIP_NODATA;
action = "data";
defresponse = "550 5.7.1 Command rejected";
break;
#endif /* SMFI_VERSION > 3 */
case SMFIC_BODYEOB: case SMFIC_BODYEOB:
case SMFIC_OPTNEG: case SMFIC_OPTNEG:
case SMFIC_MACRO: case SMFIC_MACRO:
@ -2184,8 +2193,9 @@ milter_negotiate(m, e)
mi_int32 fvers; mi_int32 fvers;
mi_int32 fflags; mi_int32 fflags;
mi_int32 pflags; mi_int32 pflags;
char *response; mi_int32 curr_prot;
ssize_t rlen; ssize_t rlen;
char *response;
char data[MILTER_OPTLEN]; char data[MILTER_OPTLEN];
/* sanity check */ /* sanity check */
@ -2201,7 +2211,18 @@ milter_negotiate(m, e)
fvers = htonl(SMFI_VERSION); fvers = htonl(SMFI_VERSION);
fflags = htonl(SMFI_CURR_ACTS); fflags = htonl(SMFI_CURR_ACTS);
pflags = htonl(SMFI_CURR_PROT); curr_prot = SMFI_V2_PROT
#if _FFR_MILTER_NOHDR_RESP
| SMFIP_NOHREPL
#endif /* _FFR_MILTER_NOHDR_RESP */
#if SMFI_VERSION >= 3
| SMFIP_NOUNKNOWN
# if SMFI_VERSION >= 4
| SMFIP_NODATA
# endif /* SMFI_VERSION >= 4 */
#endif /* SMFI_VERSION >= 3 */
;
pflags = htonl(curr_prot);
(void) memcpy(data, (char *) &fvers, MILTER_LEN_BYTES); (void) memcpy(data, (char *) &fvers, MILTER_LEN_BYTES);
(void) memcpy(data + MILTER_LEN_BYTES, (void) memcpy(data + MILTER_LEN_BYTES,
(char *) &fflags, MILTER_LEN_BYTES); (char *) &fflags, MILTER_LEN_BYTES);
@ -2310,21 +2331,26 @@ milter_negotiate(m, e)
} }
/* check for protocol feature mismatch */ /* check for protocol feature mismatch */
if ((m->mf_pflags & SMFI_CURR_PROT) != m->mf_pflags) if ((m->mf_pflags & curr_prot) != m->mf_pflags)
{ {
if (tTd(64, 5)) if (tTd(64, 5))
sm_dprintf("milter_negotiate(%s): protocol abilities 0x%x != MTA milter abilities 0x%lx\n", sm_dprintf("milter_negotiate(%s): protocol abilities 0x%x != MTA milter abilities 0x%lx\n",
m->mf_name, m->mf_pflags, m->mf_name, m->mf_pflags,
(unsigned long) SMFI_CURR_PROT); (unsigned long) curr_prot);
if (MilterLogLevel > 0) if (MilterLogLevel > 0)
sm_syslog(LOG_ERR, e->e_id, sm_syslog(LOG_ERR, e->e_id,
"Milter (%s): negotiate: protocol abilities 0x%x != MTA milter abilities 0x%lx", "Milter (%s): negotiate: protocol abilities 0x%x != MTA milter abilities 0x%lx",
m->mf_name, m->mf_pflags, m->mf_name, m->mf_pflags,
(unsigned long) SMFI_CURR_PROT); (unsigned long) curr_prot);
milter_error(m, e); milter_error(m, e);
return -1; return -1;
} }
if (m->mf_fvers <= 2)
m->mf_pflags |= SMFIP_NOUNKNOWN;
if (m->mf_fvers <= 3)
m->mf_pflags |= SMFIP_NODATA;
if (tTd(64, 5)) if (tTd(64, 5))
sm_dprintf("milter_negotiate(%s): version %u, fflags 0x%x, pflags 0x%x\n", sm_dprintf("milter_negotiate(%s): version %u, fflags 0x%x, pflags 0x%x\n",
m->mf_name, m->mf_fvers, m->mf_fflags, m->mf_pflags); m->mf_name, m->mf_fvers, m->mf_fflags, m->mf_pflags);
@ -2689,10 +2715,10 @@ milter_addheader(response, rlen, e)
** Returns: ** Returns:
** none ** none
** **
** Notes: ** Notes:
** Unlike milter_addheader(), this does not attempt to determine ** Unlike milter_addheader(), this does not attempt to determine
** if the header already exists in the envelope, even a ** if the header already exists in the envelope, even a
** deleted version. It just blindly inserts. ** deleted version. It just blindly inserts.
*/ */
static void static void
@ -2752,7 +2778,7 @@ milter_insheader(response, rlen, e)
sm_dprintf("Insert (%d) %s: %s\n", idx, response, val); sm_dprintf("Insert (%d) %s: %s\n", idx, response, val);
if (MilterLogLevel > 8) if (MilterLogLevel > 8)
sm_syslog(LOG_INFO, e->e_id, sm_syslog(LOG_INFO, e->e_id,
"Milter insert (%d): header: %s: %s", "Milter insert (%d): header: %s: %s",
idx, field, val); idx, field, val);
insheader(idx, newstr(field), val, H_USER, e); insheader(idx, newstr(field), val, H_USER, e);
} }

View File

@ -14,7 +14,7 @@
#include <sendmail.h> #include <sendmail.h>
#include <string.h> #include <string.h>
SM_RCSID("@(#)$Id: mime.c,v 8.137 2004/09/02 21:37:26 ca Exp $") SM_RCSID("@(#)$Id: mime.c,v 8.139 2006/03/01 18:07:45 ca Exp $")
/* /*
** MIME support. ** MIME support.
@ -86,6 +86,7 @@ static bool MapNLtoCRLF;
** MBT_FINAL -- the final boundary ** MBT_FINAL -- the final boundary
** MBT_INTERMED -- an intermediate boundary ** MBT_INTERMED -- an intermediate boundary
** MBT_NOTSEP -- an end of file ** MBT_NOTSEP -- an end of file
** SM_IO_EOF -- I/O error occurred
*/ */
struct args struct args
@ -298,7 +299,8 @@ mime8to7(mci, header, e, boundaries, flags)
mci->mci_flags |= MCIF_INMIME; mci->mci_flags |= MCIF_INMIME;
/* skip the early "comment" prologue */ /* skip the early "comment" prologue */
putline("", mci); if (!putline("", mci))
goto writeerr;
mci->mci_flags &= ~MCIF_INHEADER; mci->mci_flags &= ~MCIF_INHEADER;
bt = MBT_FINAL; bt = MBT_FINAL;
while (sm_io_fgets(e->e_dfp, SM_TIME_DEFAULT, buf, sizeof buf) while (sm_io_fgets(e->e_dfp, SM_TIME_DEFAULT, buf, sizeof buf)
@ -307,8 +309,9 @@ mime8to7(mci, header, e, boundaries, flags)
bt = mimeboundary(buf, boundaries); bt = mimeboundary(buf, boundaries);
if (bt != MBT_NOTSEP) if (bt != MBT_NOTSEP)
break; break;
putxline(buf, strlen(buf), mci, if (!putxline(buf, strlen(buf), mci,
PXLF_MAPFROM|PXLF_STRIP8BIT); PXLF_MAPFROM|PXLF_STRIP8BIT))
goto writeerr;
if (tTd(43, 99)) if (tTd(43, 99))
sm_dprintf(" ...%s", buf); sm_dprintf(" ...%s", buf);
} }
@ -319,19 +322,24 @@ mime8to7(mci, header, e, boundaries, flags)
auto HDR *hdr = NULL; auto HDR *hdr = NULL;
(void) sm_strlcpyn(buf, sizeof buf, 2, "--", bbuf); (void) sm_strlcpyn(buf, sizeof buf, 2, "--", bbuf);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
if (tTd(43, 35)) if (tTd(43, 35))
sm_dprintf(" ...%s\n", buf); sm_dprintf(" ...%s\n", buf);
collect(e->e_dfp, false, &hdr, e, false); collect(e->e_dfp, false, &hdr, e, false);
if (tTd(43, 101)) if (tTd(43, 101))
putline("+++after collect", mci); putline("+++after collect", mci);
putheader(mci, hdr, e, flags); if (!putheader(mci, hdr, e, flags))
goto writeerr;
if (tTd(43, 101)) if (tTd(43, 101))
putline("+++after putheader", mci); putline("+++after putheader", mci);
bt = mime8to7(mci, hdr, e, boundaries, flags); bt = mime8to7(mci, hdr, e, boundaries, flags);
if (bt == SM_IO_EOF)
goto writeerr;
} }
(void) sm_strlcpyn(buf, sizeof buf, 3, "--", bbuf, "--"); (void) sm_strlcpyn(buf, sizeof buf, 3, "--", bbuf, "--");
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
if (tTd(43, 35)) if (tTd(43, 35))
sm_dprintf(" ...%s\n", buf); sm_dprintf(" ...%s\n", buf);
boundaries[i] = NULL; boundaries[i] = NULL;
@ -344,8 +352,9 @@ mime8to7(mci, header, e, boundaries, flags)
bt = mimeboundary(buf, boundaries); bt = mimeboundary(buf, boundaries);
if (bt != MBT_NOTSEP) if (bt != MBT_NOTSEP)
break; break;
putxline(buf, strlen(buf), mci, if (!putxline(buf, strlen(buf), mci,
PXLF_MAPFROM|PXLF_STRIP8BIT); PXLF_MAPFROM|PXLF_STRIP8BIT))
goto writeerr;
if (tTd(43, 99)) if (tTd(43, 99))
sm_dprintf(" ...%s", buf); sm_dprintf(" ...%s", buf);
} }
@ -373,18 +382,21 @@ mime8to7(mci, header, e, boundaries, flags)
{ {
auto HDR *hdr = NULL; auto HDR *hdr = NULL;
putline("", mci); if (!putline("", mci))
goto writeerr;
mci->mci_flags |= MCIF_INMIME; mci->mci_flags |= MCIF_INMIME;
collect(e->e_dfp, false, &hdr, e, false); collect(e->e_dfp, false, &hdr, e, false);
if (tTd(43, 101)) if (tTd(43, 101))
putline("+++after collect", mci); putline("+++after collect", mci);
putheader(mci, hdr, e, flags); if (!putheader(mci, hdr, e, flags))
goto writeerr;
if (tTd(43, 101)) if (tTd(43, 101))
putline("+++after putheader", mci); putline("+++after putheader", mci);
if (hvalue("MIME-Version", hdr) == NULL && if (hvalue("MIME-Version", hdr) == NULL &&
!bitset(M87F_NO8TO7, flags)) !bitset(M87F_NO8TO7, flags) &&
putline("MIME-Version: 1.0", mci); !putline("MIME-Version: 1.0", mci))
goto writeerr;
bt = mime8to7(mci, hdr, e, boundaries, flags); bt = mime8to7(mci, hdr, e, boundaries, flags);
mci->mci_flags &= ~MCIF_INMIME; mci->mci_flags &= ~MCIF_INMIME;
return bt; return bt;
@ -480,11 +492,13 @@ mime8to7(mci, header, e, boundaries, flags)
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"Content-Transfer-Encoding: %.200s", cte); "Content-Transfer-Encoding: %.200s", cte);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
if (tTd(43, 36)) if (tTd(43, 36))
sm_dprintf(" ...%s\n", buf); sm_dprintf(" ...%s\n", buf);
} }
putline("", mci); if (!putline("", mci))
goto writeerr;
mci->mci_flags &= ~MCIF_INHEADER; mci->mci_flags &= ~MCIF_INHEADER;
while (sm_io_fgets(e->e_dfp, SM_TIME_DEFAULT, buf, sizeof buf) while (sm_io_fgets(e->e_dfp, SM_TIME_DEFAULT, buf, sizeof buf)
!= NULL) != NULL)
@ -492,7 +506,8 @@ mime8to7(mci, header, e, boundaries, flags)
bt = mimeboundary(buf, boundaries); bt = mimeboundary(buf, boundaries);
if (bt != MBT_NOTSEP) if (bt != MBT_NOTSEP)
break; break;
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
if (sm_io_eof(e->e_dfp)) if (sm_io_eof(e->e_dfp))
bt = MBT_FINAL; bt = MBT_FINAL;
@ -505,12 +520,13 @@ mime8to7(mci, header, e, boundaries, flags)
if (tTd(43, 36)) if (tTd(43, 36))
sm_dprintf(" ...Content-Transfer-Encoding: base64\n"); sm_dprintf(" ...Content-Transfer-Encoding: base64\n");
putline("Content-Transfer-Encoding: base64", mci); if (!putline("Content-Transfer-Encoding: base64", mci))
goto writeerr;
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"X-MIME-Autoconverted: from 8bit to base64 by %s id %s", "X-MIME-Autoconverted: from 8bit to base64 by %s id %s",
MyHostName, e->e_id); MyHostName, e->e_id);
putline(buf, mci); if (!putline(buf, mci) || !putline("", mci))
putline("", mci); goto writeerr;
mci->mci_flags &= ~MCIF_INHEADER; mci->mci_flags &= ~MCIF_INHEADER;
while ((c1 = mime_getchar_crlf(e->e_dfp, boundaries, &bt)) != while ((c1 = mime_getchar_crlf(e->e_dfp, boundaries, &bt)) !=
SM_IO_EOF) SM_IO_EOF)
@ -518,7 +534,8 @@ mime8to7(mci, header, e, boundaries, flags)
if (linelen > 71) if (linelen > 71)
{ {
*bp = '\0'; *bp = '\0';
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
linelen = 0; linelen = 0;
bp = buf; bp = buf;
} }
@ -548,7 +565,8 @@ mime8to7(mci, header, e, boundaries, flags)
*bp++ = Base64Code[c2 & 0x3f]; *bp++ = Base64Code[c2 & 0x3f];
} }
*bp = '\0'; *bp = '\0';
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
else else
{ {
@ -571,12 +589,14 @@ mime8to7(mci, header, e, boundaries, flags)
if (tTd(43, 36)) if (tTd(43, 36))
sm_dprintf(" ...Content-Transfer-Encoding: quoted-printable\n"); sm_dprintf(" ...Content-Transfer-Encoding: quoted-printable\n");
putline("Content-Transfer-Encoding: quoted-printable", mci); if (!putline("Content-Transfer-Encoding: quoted-printable",
mci))
goto writeerr;
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"X-MIME-Autoconverted: from 8bit to quoted-printable by %s id %s", "X-MIME-Autoconverted: from 8bit to quoted-printable by %s id %s",
MyHostName, e->e_id); MyHostName, e->e_id);
putline(buf, mci); if (!putline(buf, mci) || !putline("", mci))
putline("", mci); goto writeerr;
mci->mci_flags &= ~MCIF_INHEADER; mci->mci_flags &= ~MCIF_INHEADER;
fromstate = 0; fromstate = 0;
c2 = '\n'; c2 = '\n';
@ -598,7 +618,8 @@ mime8to7(mci, header, e, boundaries, flags)
*bp++ = Base16Code['.' & 0x0f]; *bp++ = Base16Code['.' & 0x0f];
} }
*bp = '\0'; *bp = '\0';
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
linelen = fromstate = 0; linelen = fromstate = 0;
bp = buf; bp = buf;
c2 = c1; c2 = c1;
@ -627,7 +648,8 @@ mime8to7(mci, header, e, boundaries, flags)
c2 = '\n'; c2 = '\n';
*bp++ = '='; *bp++ = '=';
*bp = '\0'; *bp = '\0';
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
linelen = fromstate = 0; linelen = fromstate = 0;
bp = buf; bp = buf;
if (c2 == '.') if (c2 == '.')
@ -665,13 +687,17 @@ mime8to7(mci, header, e, boundaries, flags)
if (linelen > 0 || boundaries[0] != NULL) if (linelen > 0 || boundaries[0] != NULL)
{ {
*bp = '\0'; *bp = '\0';
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
} }
if (tTd(43, 3)) if (tTd(43, 3))
sm_dprintf("\t\t\tmime8to7=>%s (basic)\n", MimeBoundaryNames[bt]); sm_dprintf("\t\t\tmime8to7=>%s (basic)\n", MimeBoundaryNames[bt]);
return bt; return bt;
writeerr:
return SM_IO_EOF;
} }
/* /*
** MIME_GETCHAR -- get a character for MIME processing ** MIME_GETCHAR -- get a character for MIME processing
@ -958,7 +984,7 @@ static int mime_fromqp __P((unsigned char *, unsigned char **, int));
** e -- envelope. ** e -- envelope.
** **
** Returns: ** Returns:
** none. ** true iff body was written successfully
*/ */
static char index_64[128] = static char index_64[128] =
@ -975,7 +1001,7 @@ static char index_64[128] =
# define CHAR64(c) (((c) < 0 || (c) > 127) ? -1 : index_64[(c)]) # define CHAR64(c) (((c) < 0 || (c) > 127) ? -1 : index_64[(c)])
void bool
mime7to8(mci, header, e) mime7to8(mci, header, e)
register MCI *mci; register MCI *mci;
HDR *header; HDR *header;
@ -1008,25 +1034,31 @@ mime7to8(mci, header, e)
{ {
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"Content-Transfer-Encoding: %s", p); "Content-Transfer-Encoding: %s", p);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
putline("", mci); if (!putline("", mci))
goto writeerr;
mci->mci_flags &= ~MCIF_INHEADER; mci->mci_flags &= ~MCIF_INHEADER;
while (sm_io_fgets(e->e_dfp, SM_TIME_DEFAULT, buf, sizeof buf) while (sm_io_fgets(e->e_dfp, SM_TIME_DEFAULT, buf, sizeof buf)
!= NULL) != NULL)
putline(buf, mci); {
return; if (!putline(buf, mci))
goto writeerr;
}
return true;
} }
cataddr(pvp, NULL, buf, sizeof buf, '\0'); cataddr(pvp, NULL, buf, sizeof buf, '\0');
cte = sm_rpool_strdup_x(e->e_rpool, buf); cte = sm_rpool_strdup_x(e->e_rpool, buf);
mci->mci_flags |= MCIF_INHEADER; mci->mci_flags |= MCIF_INHEADER;
putline("Content-Transfer-Encoding: 8bit", mci); if (!putline("Content-Transfer-Encoding: 8bit", mci))
goto writeerr;
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"X-MIME-Autoconverted: from %.200s to 8bit by %s id %s", "X-MIME-Autoconverted: from %.200s to 8bit by %s id %s",
cte, MyHostName, e->e_id); cte, MyHostName, e->e_id);
putline(buf, mci); if (!putline(buf, mci) || !putline("", mci))
putline("", mci); goto writeerr;
mci->mci_flags &= ~MCIF_INHEADER; mci->mci_flags &= ~MCIF_INHEADER;
/* /*
@ -1090,7 +1122,8 @@ mime7to8(mci, header, e)
if (*fbufp++ == '\n' || fbufp >= &fbuf[MAXLINE]) \ if (*fbufp++ == '\n' || fbufp >= &fbuf[MAXLINE]) \
{ \ { \
CHK_EOL; \ CHK_EOL; \
putxline((char *) fbuf, fbufp - fbuf, mci, pxflags); \ if (!putxline((char *) fbuf, fbufp - fbuf, mci, pxflags)) \
goto writeerr; \
pxflags &= ~PXLF_NOADDEOL; \ pxflags &= ~PXLF_NOADDEOL; \
fbufp = fbuf; \ fbufp = fbuf; \
} \ } \
@ -1127,8 +1160,11 @@ mime7to8(mci, header, e)
continue; continue;
if (fbufp - fbuf > 0) if (fbufp - fbuf > 0)
putxline((char *) fbuf, fbufp - fbuf - 1, mci, {
pxflags); if (!putxline((char *) fbuf, fbufp - fbuf - 1,
mci, pxflags))
goto writeerr;
}
fbufp = fbuf; fbufp = fbuf;
if (off >= 0 && buf[off] != '\0') if (off >= 0 && buf[off] != '\0')
{ {
@ -1144,7 +1180,8 @@ mime7to8(mci, header, e)
if (fbufp > fbuf) if (fbufp > fbuf)
{ {
*fbufp = '\0'; *fbufp = '\0';
putxline((char *) fbuf, fbufp - fbuf, mci, pxflags); if (!putxline((char *) fbuf, fbufp - fbuf, mci, pxflags))
goto writeerr;
} }
/* /*
@ -1154,10 +1191,15 @@ mime7to8(mci, header, e)
** but so is auto-converting MIME in the first place. ** but so is auto-converting MIME in the first place.
*/ */
putline("", mci); if (!putline("", mci))
goto writeerr;
if (tTd(43, 3)) if (tTd(43, 3))
sm_dprintf("\t\t\tmime7to8 => %s to 8bit done\n", cte); sm_dprintf("\t\t\tmime7to8 => %s to 8bit done\n", cte);
return true;
writeerr:
return false;
} }
/* /*
** The following is based on Borenstein's "codes.c" module, with simplifying ** The following is based on Borenstein's "codes.c" module, with simplifying

View File

@ -13,7 +13,7 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: parseaddr.c,v 8.381 2005/02/04 22:01:45 ca Exp $") SM_RCSID("@(#)$Id: parseaddr.c,v 8.383 2006/02/01 19:46:11 ca Exp $")
static void allocaddr __P((ADDRESS *, int, char *, ENVELOPE *)); static void allocaddr __P((ADDRESS *, int, char *, ENVELOPE *));
static int callsubr __P((char**, int, ENVELOPE *)); static int callsubr __P((char**, int, ENVELOPE *));
@ -1337,7 +1337,7 @@ rewrite(pvp, ruleset, reclevel, e, maxatom)
/* $&{x} replacement */ /* $&{x} replacement */
char *mval = macvalue(rp[1], e); char *mval = macvalue(rp[1], e);
char **xpvp; char **xpvp;
int trsize = 0; size_t trsize = 0;
static size_t pvpb1_size = 0; static size_t pvpb1_size = 0;
static char **pvpb1 = NULL; static char **pvpb1 = NULL;
char pvpbuf[PSBUFSIZE]; char pvpbuf[PSBUFSIZE];
@ -1352,7 +1352,7 @@ rewrite(pvp, ruleset, reclevel, e, maxatom)
/* save the remainder of the input */ /* save the remainder of the input */
for (xpvp = pvp; *xpvp != NULL; xpvp++) for (xpvp = pvp; *xpvp != NULL; xpvp++)
trsize += sizeof *xpvp; trsize += sizeof *xpvp;
if ((size_t) trsize > pvpb1_size) if (trsize > pvpb1_size)
{ {
if (pvpb1 != NULL) if (pvpb1 != NULL)
sm_free(pvpb1); sm_free(pvpb1);
@ -1407,7 +1407,7 @@ rewrite(pvp, ruleset, reclevel, e, maxatom)
{ {
char **hbrvp; char **hbrvp;
char **xpvp; char **xpvp;
int trsize; size_t trsize;
char *replac; char *replac;
int endtoken; int endtoken;
STAB *map; STAB *map;
@ -1415,7 +1415,7 @@ rewrite(pvp, ruleset, reclevel, e, maxatom)
char **key_rvp; char **key_rvp;
char **arg_rvp; char **arg_rvp;
char **default_rvp; char **default_rvp;
char cbuf[MAXNAME + 1]; char cbuf[MAXKEY];
char *pvpb1[MAXATOM + 1]; char *pvpb1[MAXATOM + 1];
char *argvect[MAX_MAP_ARGS]; char *argvect[MAX_MAP_ARGS];
char pvpbuf[PSBUFSIZE]; char pvpbuf[PSBUFSIZE];
@ -1509,7 +1509,7 @@ rewrite(pvp, ruleset, reclevel, e, maxatom)
*++arg_rvp = NULL; *++arg_rvp = NULL;
/* save the remainder of the input string */ /* save the remainder of the input string */
trsize = (int) (avp - rvp + 1) * sizeof *rvp; trsize = (avp - rvp + 1) * sizeof *rvp;
memmove((char *) pvpb1, (char *) rvp, trsize); memmove((char *) pvpb1, (char *) rvp, trsize);
/* look it up */ /* look it up */
@ -2949,7 +2949,7 @@ rscheck(rwset, p1, p2, e, flags, logl, host, logid)
char *logid; char *logid;
{ {
char *volatile buf; char *volatile buf;
int bufsize; size_t bufsize;
int saveexitstat; int saveexitstat;
int volatile rstat = EX_OK; int volatile rstat = EX_OK;
char **pvp; char **pvp;
@ -3163,7 +3163,7 @@ rscap(rwset, p1, p2, e, pvp, pvpbuf, size)
int size; int size;
{ {
char *volatile buf; char *volatile buf;
int bufsize; size_t bufsize;
int volatile rstat = EX_OK; int volatile rstat = EX_OK;
int rsno; int rsno;
bool saveQuickAbort = QuickAbort; bool saveQuickAbort = QuickAbort;

View File

@ -14,7 +14,7 @@
#include <sendmail.h> #include <sendmail.h>
#include <sm/sem.h> #include <sm/sem.h>
SM_RCSID("@(#)$Id: queue.c,v 8.944 2005/02/17 23:58:58 ca Exp $") SM_RCSID("@(#)$Id: queue.c,v 8.951 2006/03/02 19:13:38 ca Exp $")
#include <dirent.h> #include <dirent.h>
@ -2853,7 +2853,8 @@ gatherq(qgrp, qdir, doall, full, more)
if (cf != NULL) if (cf != NULL)
(void) sm_io_close(cf, SM_TIME_DEFAULT); (void) sm_io_close(cf, SM_TIME_DEFAULT);
if ((!doall && shouldqueue(w->w_pri, w->w_ctime)) || if ((!doall && (shouldqueue(w->w_pri, w->w_ctime) ||
w->w_tooyoung)) ||
bitset(HAS_QUARANTINE, i) || bitset(HAS_QUARANTINE, i) ||
bitset(NEED_QUARANTINE, i) || bitset(NEED_QUARANTINE, i) ||
bitset(NEED_R|NEED_S, i)) bitset(NEED_R|NEED_S, i))
@ -2931,10 +2932,6 @@ sortq(max)
if (WorkList == NULL || wc <= 0) if (WorkList == NULL || wc <= 0)
return 0; return 0;
/* Check if the per queue group item limit will be exceeded */
if (wc > max && max > 0)
wc = max;
/* /*
** The sort now takes place using all of the items in WorkList. ** The sort now takes place using all of the items in WorkList.
** The list gets trimmed to the most important items after the sort. ** The list gets trimmed to the most important items after the sort.
@ -3046,6 +3043,10 @@ sortq(max)
} }
/* else don't sort at all */ /* else don't sort at all */
/* Check if the per queue group item limit will be exceeded */
if (wc > max && max > 0)
wc = max;
/* /*
** Convert the work list into canonical form. ** Convert the work list into canonical form.
** Should be turning it into a list of envelopes here perhaps. ** Should be turning it into a list of envelopes here perhaps.
@ -3443,13 +3444,13 @@ init_shuffle_alphabet()
return; return;
/* fill the ShuffledAlphabet */ /* fill the ShuffledAlphabet */
for (i = 0; i < NCHAR; i++) for (i = 0; i < NASCII; i++)
ShuffledAlphabet[i] = i; ShuffledAlphabet[i] = i;
/* mix it */ /* mix it */
for (i = 1; i < NCHAR; i++) for (i = 1; i < NASCII; i++)
{ {
register int j = get_random() % NCHAR; register int j = get_random() % NASCII;
register int tmp; register int tmp;
tmp = ShuffledAlphabet[j]; tmp = ShuffledAlphabet[j];
@ -3462,8 +3463,8 @@ init_shuffle_alphabet()
ShuffledAlphabet[i] = ShuffledAlphabet[i + 'a' - 'A']; ShuffledAlphabet[i] = ShuffledAlphabet[i + 'a' - 'A'];
/* fill the upper part */ /* fill the upper part */
for (i = 0; i < NCHAR; i++) for (i = 0; i < NASCII; i++)
ShuffledAlphabet[i + NCHAR] = ShuffledAlphabet[i]; ShuffledAlphabet[i + NASCII] = ShuffledAlphabet[i];
init = true; init = true;
} }
@ -6266,7 +6267,8 @@ multiqueue_cache(basedir, blen, qg, qn, phash)
** If the directory does not exist, -1 is returned. ** If the directory does not exist, -1 is returned.
** **
** Parameters: ** Parameters:
** path -- pathname of directory ** name -- name of directory (must be persistent!)
** path -- pathname of directory (name plus maybe "/df")
** add -- add to structure if not found. ** add -- add to structure if not found.
** **
** Returns: ** Returns:
@ -6277,14 +6279,15 @@ multiqueue_cache(basedir, blen, qg, qn, phash)
** FSF_NOT_FOUND: not in list ** FSF_NOT_FOUND: not in list
*/ */
static short filesys_find __P((char *, bool)); static short filesys_find __P((char *, char *, bool));
#define FSF_NOT_FOUND (-1) #define FSF_NOT_FOUND (-1)
#define FSF_STAT_FAIL (-2) #define FSF_STAT_FAIL (-2)
#define FSF_TOO_MANY (-3) #define FSF_TOO_MANY (-3)
static short static short
filesys_find(path, add) filesys_find(name, path, add)
char *name;
char *path; char *path;
bool add; bool add;
{ {
@ -6310,7 +6313,7 @@ filesys_find(path, add)
return FSF_NOT_FOUND; return FSF_NOT_FOUND;
++NumFileSys; ++NumFileSys;
FILE_SYS_NAME(i) = path; FILE_SYS_NAME(i) = name;
FILE_SYS_DEV(i) = st.st_dev; FILE_SYS_DEV(i) = st.st_dev;
FILE_SYS_AVAIL(i) = 0; FILE_SYS_AVAIL(i) = 0;
FILE_SYS_BLKSIZE(i) = 1024; /* avoid divide by zero */ FILE_SYS_BLKSIZE(i) = 1024; /* avoid divide by zero */
@ -6350,8 +6353,12 @@ filesys_setup(add)
for (j = 0; j < Queue[i]->qg_numqueues; ++j) for (j = 0; j < Queue[i]->qg_numqueues; ++j)
{ {
QPATHS *qp = &Queue[i]->qg_qpaths[j]; QPATHS *qp = &Queue[i]->qg_qpaths[j];
char qddf[MAXPATHLEN];
fs = filesys_find(qp->qp_name, add); (void) sm_strlcpyn(qddf, sizeof qddf, 2, qp->qp_name,
(bitset(QP_SUBDF, qp->qp_subdirs)
? "/df" : ""));
fs = filesys_find(qp->qp_name, qddf, add);
if (fs >= 0) if (fs >= 0)
qp->qp_fsysidx = fs; qp->qp_fsysidx = fs;
else else
@ -6679,6 +6686,22 @@ write_key_file(keypath, key)
} }
else else
{ {
if (geteuid() == 0 && RunAsUid != 0)
{
# if HASFCHOWN
int fd;
fd = keyf->f_file;
if (fd >= 0 && fchown(fd, RunAsUid, -1) < 0)
{
int err = errno;
sm_syslog(LOG_ALERT, NOQID,
"ownership change on %s to %d failed: %s",
keypath, RunAsUid, sm_errstring(err));
}
# endif /* HASFCHOWN */
}
ok = sm_io_fprintf(keyf, SM_TIME_DEFAULT, "%ld\n", key) != ok = sm_io_fprintf(keyf, SM_TIME_DEFAULT, "%ld\n", key) !=
SM_IO_EOF; SM_IO_EOF;
ok = (sm_io_close(keyf, SM_TIME_DEFAULT) != SM_IO_EOF) && ok; ok = (sm_io_close(keyf, SM_TIME_DEFAULT) != SM_IO_EOF) && ok;
@ -6830,13 +6853,11 @@ init_shm(qn, owner, hash)
#endif /* _FFR_SELECT_SHM */ #endif /* _FFR_SELECT_SHM */
if (owner && RunAsUid != 0) if (owner && RunAsUid != 0)
{ {
i = sm_shmsetowner(ShmId, RunAsUid, RunAsGid, i = sm_shmsetowner(ShmId, RunAsUid, RunAsGid, 0660);
0660);
if (i != 0) if (i != 0)
sm_syslog(LOG_ERR, NOQID, sm_syslog(LOG_ERR, NOQID,
"key=%ld, sm_shmsetowner=%d, RunAsUid=%d, RunAsGid=%d", "key=%ld, sm_shmsetowner=%d, RunAsUid=%d, RunAsGid=%d",
(long) ShmKey, i, (long) ShmKey, i, RunAsUid, RunAsGid);
RunAsUid, RunAsGid);
} }
p = (int *) Pshm; p = (int *) Pshm;
if (owner) if (owner)
@ -7722,8 +7743,11 @@ dup_df(old, new)
** are on the same file system. ** are on the same file system.
*/ */
ofs = Queue[old->e_qgrp]->qg_qpaths[old->e_qdir].qp_fsysidx; SM_REQUIRE(ISVALIDQGRP(old->e_dfqgrp) && ISVALIDQDIR(old->e_dfqdir));
nfs = Queue[new->e_qgrp]->qg_qpaths[new->e_qdir].qp_fsysidx; SM_REQUIRE(ISVALIDQGRP(new->e_dfqgrp) && ISVALIDQDIR(new->e_dfqdir));
ofs = Queue[old->e_dfqgrp]->qg_qpaths[old->e_dfqdir].qp_fsysidx;
nfs = Queue[new->e_dfqgrp]->qg_qpaths[new->e_dfqdir].qp_fsysidx;
if (FILE_SYS_DEV(ofs) == FILE_SYS_DEV(nfs)) if (FILE_SYS_DEV(ofs) == FILE_SYS_DEV(nfs))
{ {
if (link(opath, npath) == 0) if (link(opath, npath) == 0)

View File

@ -45,7 +45,7 @@
*/ */
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: ratectrl.c,v 8.9 2004/07/07 21:23:57 ca Exp $") SM_RCSID("@(#)$Id: ratectrl.c,v 8.10 2005/06/14 23:07:23 ca Exp $")
/* /*
** stuff included - given some warnings (inet_ntoa) ** stuff included - given some warnings (inet_ntoa)
@ -56,7 +56,7 @@ SM_RCSID("@(#)$Id: ratectrl.c,v 8.9 2004/07/07 21:23:57 ca Exp $")
# include <arpa/inet.h> # include <arpa/inet.h>
#endif /* NETINET || NETINET6 */ #endif /* NETINET || NETINET6 */
#include <sys/time.h> #include <sm/time.h>
#ifndef HASH_ALG #ifndef HASH_ALG
# define HASH_ALG 2 # define HASH_ALG 2

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -13,7 +13,7 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: readcf.c,v 8.642 2004/08/04 21:17:57 ca Exp $") SM_RCSID("@(#)$Id: readcf.c,v 8.651 2006/03/02 19:17:09 ca Exp $")
#if NETINET || NETINET6 #if NETINET || NETINET6
# include <arpa/inet.h> # include <arpa/inet.h>
@ -679,7 +679,7 @@ readcf(cfname, safe, e)
p = strchr(bp, '='); p = strchr(bp, '=');
if (p != NULL) if (p != NULL)
*p++ = '\0'; *p++ = '\0';
setuserenv(&bp[1], p); sm_setuserenv(&bp[1], p);
break; break;
case 'X': /* mail filter */ case 'X': /* mail filter */
@ -2191,6 +2191,26 @@ static struct optioninfo
# define O_HELONAME 0xd8 # define O_HELONAME 0xd8
{ "HeloName", O_HELONAME, OI_NONE }, { "HeloName", O_HELONAME, OI_NONE },
#endif /* _FFR_HELONAME */ #endif /* _FFR_HELONAME */
#if _FFR_MEMSTAT
# define O_REFUSELOWMEM 0xd9
{ "RefuseLowMem", O_REFUSELOWMEM, OI_NONE },
# define O_QUEUELOWMEM 0xda
{ "QueueLowMem", O_QUEUELOWMEM, OI_NONE },
# define O_MEMRESOURCE 0xdb
{ "MemoryResource", O_MEMRESOURCE, OI_NONE },
#endif /* _FFR_MEMSTAT */
#if _FFR_MAXNOOPCOMMANDS
# define O_MAXNOOPCOMMANDS 0xdc
{ "MaxNOOPCommands", O_MAXNOOPCOMMANDS, OI_NONE },
#endif /* _FFR_MAXNOOPCOMMANDS */
#if _FFR_MSG_ACCEPT
# define O_MSG_ACCEPT 0xdd
{ "MessageAccept", O_MSG_ACCEPT, OI_NONE },
#endif /* _FFR_MSG_ACCEPT */
#if _FFR_QUEUE_RUN_PARANOIA
# define O_CHK_Q_RUNNERS 0xde
{ "CheckQueueRunners", O_CHK_Q_RUNNERS, OI_NONE },
#endif /* _FFR_QUEUE_RUN_PARANOIA */
{ NULL, '\0', OI_NONE } { NULL, '\0', OI_NONE }
}; };
@ -2231,10 +2251,10 @@ setoption(opt, val, safe, sticky, e)
#if _FFR_ALLOW_SASLINFO #if _FFR_ALLOW_SASLINFO
extern unsigned int SubmitMode; extern unsigned int SubmitMode;
#endif /* _FFR_ALLOW_SASLINFO */ #endif /* _FFR_ALLOW_SASLINFO */
#if STARTTLS #if STARTTLS || (_FFR_SELECT_SHM && SM_CONF_SHM)
char *newval; char *newval;
char exbuf[MAXLINE]; char exbuf[MAXLINE];
#endif /* STARTTLS */ #endif /* STARTTLS || (_FFR_SELECT_SHM && SM_CONF_SHM) */
errno = 0; errno = 0;
if (opt == ' ') if (opt == ' ')
@ -2472,6 +2492,10 @@ setoption(opt, val, safe, sticky, e)
case SM_DEFER: /* queue only and defer map lookups */ case SM_DEFER: /* queue only and defer map lookups */
case SM_DELIVER: /* do everything */ case SM_DELIVER: /* do everything */
case SM_FORK: /* fork after verification */ case SM_FORK: /* fork after verification */
#if _FFR_DM_ONE
/* deliver first TA in background, then queue */
case SM_DM_ONE:
#endif /* _FFR_DM_ONE */
set_delivery_mode(*val, e); set_delivery_mode(*val, e);
break; break;
@ -3707,9 +3731,38 @@ setoption(opt, val, safe, sticky, e)
#if _FFR_HELONAME #if _FFR_HELONAME
case O_HELONAME: case O_HELONAME:
HeloName = newstr(val); HeloName = newstr(val);
break; break;
#endif /* _FFR_HELONAME */ #endif /* _FFR_HELONAME */
#if _FFR_MEMSTAT
case O_REFUSELOWMEM:
RefuseLowMem = atoi(val);
break;
case O_QUEUELOWMEM:
QueueLowMem = atoi(val);
break;
case O_MEMRESOURCE:
MemoryResource = newstr(val);
break;
#endif /* _FFR_MEMSTAT */
#if _FFR_MAXNOOPCOMMANDS
case O_MAXNOOPCOMMANDS:
MaxNOOPCommands = atoi(val);
break;
#endif /* _FFR_MAXNOOPCOMMANDS */
#if _FFR_MSG_ACCEPT
case O_MSG_ACCEPT:
MessageAccept = newstr(val);
break;
#endif /* _FFR_MSG_ACCEPT */
#if _FFR_QUEUE_RUN_PARANOIA
case O_CHK_Q_RUNNERS:
CheckQueueRunners = atoi(val);
break;
#endif /* _FFR_QUEUE_RUN_PARANOIA */
default: default:
if (tTd(37, 1)) if (tTd(37, 1))

View File

@ -13,9 +13,9 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: savemail.c,v 8.304 2004/10/06 21:36:06 ca Exp $") SM_RCSID("@(#)$Id: savemail.c,v 8.306 2006/02/25 02:16:53 ca Exp $")
static void errbody __P((MCI *, ENVELOPE *, char *)); static bool errbody __P((MCI *, ENVELOPE *, char *));
static bool pruneroute __P((char *)); static bool pruneroute __P((char *));
/* /*
@ -432,12 +432,13 @@ savemail(e, sendbody)
p = macvalue('g', e); p = macvalue('g', e);
macdefine(&e->e_macro, A_PERM, 'g', e->e_sender); macdefine(&e->e_macro, A_PERM, 'g', e->e_sender);
putfromline(&mcibuf, e); if (!putfromline(&mcibuf, e) ||
(*e->e_puthdr)(&mcibuf, e->e_header, e, M87F_OUTER); !(*e->e_puthdr)(&mcibuf, e->e_header, e,
(*e->e_putbody)(&mcibuf, e, NULL); M87F_OUTER) ||
putline("\n", &mcibuf); /* XXX EOL from FileMailer? */ !(*e->e_putbody)(&mcibuf, e, NULL) ||
(void) sm_io_flush(fp, SM_TIME_DEFAULT); !putline("\n", &mcibuf) ||
if (sm_io_error(fp) || sm_io_flush(fp, SM_TIME_DEFAULT) == SM_IO_EOF ||
sm_io_error(fp) ||
sm_io_close(fp, SM_TIME_DEFAULT) < 0) sm_io_close(fp, SM_TIME_DEFAULT) < 0)
state = ESM_PANIC; state = ESM_PANIC;
else else
@ -732,14 +733,14 @@ returntosender(msg, returnq, flags, e)
** separator -- any possible MIME separator (unused). ** separator -- any possible MIME separator (unused).
** **
** Returns: ** Returns:
** none ** success
** **
** Side Effects: ** Side Effects:
** Outputs the body of an error message. ** Outputs the body of an error message.
*/ */
/* ARGSUSED2 */ /* ARGSUSED2 */
static void static bool
errbody(mci, e, separator) errbody(mci, e, separator)
register MCI *mci; register MCI *mci;
register ENVELOPE *e; register ENVELOPE *e;
@ -757,14 +758,16 @@ errbody(mci, e, separator)
if (bitset(MCIF_INHEADER, mci->mci_flags)) if (bitset(MCIF_INHEADER, mci->mci_flags))
{ {
putline("", mci); if (!putline("", mci))
goto writeerr;
mci->mci_flags &= ~MCIF_INHEADER; mci->mci_flags &= ~MCIF_INHEADER;
} }
if (e->e_parent == NULL) if (e->e_parent == NULL)
{ {
syserr("errbody: null parent"); syserr("errbody: null parent");
putline(" ----- Original message lost -----\n", mci); if (!putline(" ----- Original message lost -----\n", mci))
return; goto writeerr;
return true;
} }
/* /*
@ -773,11 +776,12 @@ errbody(mci, e, separator)
if (e->e_msgboundary != NULL) if (e->e_msgboundary != NULL)
{ {
putline("This is a MIME-encapsulated message", mci);
putline("", mci);
(void) sm_strlcpyn(buf, sizeof buf, 2, "--", e->e_msgboundary); (void) sm_strlcpyn(buf, sizeof buf, 2, "--", e->e_msgboundary);
putline(buf, mci); if (!putline("This is a MIME-encapsulated message", mci) ||
putline("", mci); !putline("", mci) ||
!putline(buf, mci) ||
!putline("", mci))
goto writeerr;
} }
/* /*
@ -799,31 +803,36 @@ errbody(mci, e, separator)
if (!pm_notify && q == NULL && if (!pm_notify && q == NULL &&
!bitset(EF_FATALERRS|EF_SENDRECEIPT, e->e_parent->e_flags)) !bitset(EF_FATALERRS|EF_SENDRECEIPT, e->e_parent->e_flags))
{ {
putline(" **********************************************", if (!putline(" **********************************************",
mci); mci) ||
putline(" ** THIS IS A WARNING MESSAGE ONLY **", !putline(" ** THIS IS A WARNING MESSAGE ONLY **",
mci); mci) ||
putline(" ** YOU DO NOT NEED TO RESEND YOUR MESSAGE **", !putline(" ** YOU DO NOT NEED TO RESEND YOUR MESSAGE **",
mci); mci) ||
putline(" **********************************************", !putline(" **********************************************",
mci); mci) ||
putline("", mci); !putline("", mci))
goto writeerr;
} }
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"The original message was received at %s", "The original message was received at %s",
arpadate(ctime(&e->e_parent->e_ctime))); arpadate(ctime(&e->e_parent->e_ctime)));
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
expand("from \201_", buf, sizeof buf, e->e_parent); expand("from \201_", buf, sizeof buf, e->e_parent);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
/* include id in postmaster copies */ /* include id in postmaster copies */
if (pm_notify && e->e_parent->e_id != NULL) if (pm_notify && e->e_parent->e_id != NULL)
{ {
(void) sm_strlcpyn(buf, sizeof buf, 2, "with id ", (void) sm_strlcpyn(buf, sizeof buf, 2, "with id ",
e->e_parent->e_id); e->e_parent->e_id);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
putline("", mci); if (!putline("", mci))
goto writeerr;
/* /*
** Output error message header (if specified and available). ** Output error message header (if specified and available).
@ -849,17 +858,19 @@ errbody(mci, e, separator)
{ {
translate_dollars(buf); translate_dollars(buf);
expand(buf, buf, sizeof buf, e); expand(buf, buf, sizeof buf, e);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
(void) sm_io_close(xfile, SM_TIME_DEFAULT); (void) sm_io_close(xfile, SM_TIME_DEFAULT);
putline("\n", mci); if (!putline("\n", mci))
goto writeerr;
} }
} }
else else
{ {
expand(ErrMsgFile, buf, sizeof buf, e); expand(ErrMsgFile, buf, sizeof buf, e);
putline(buf, mci); if (!putline(buf, mci) || !putline("", mci))
putline("", mci); goto writeerr;
} }
} }
@ -877,21 +888,24 @@ errbody(mci, e, separator)
if (printheader) if (printheader)
{ {
putline(" ----- The following addresses had permanent fatal errors -----", if (!putline(" ----- The following addresses had permanent fatal errors -----",
mci); mci))
goto writeerr;
printheader = false; printheader = false;
} }
(void) sm_strlcpy(buf, shortenstring(q->q_paddr, MAXSHORTSTR), (void) sm_strlcpy(buf, shortenstring(q->q_paddr, MAXSHORTSTR),
sizeof buf); sizeof buf);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
if (q->q_rstatus != NULL) if (q->q_rstatus != NULL)
{ {
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
" (reason: %s)", " (reason: %s)",
shortenstring(exitstat(q->q_rstatus), shortenstring(exitstat(q->q_rstatus),
MAXSHORTSTR)); MAXSHORTSTR));
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
if (q->q_alias != NULL) if (q->q_alias != NULL)
{ {
@ -899,11 +913,12 @@ errbody(mci, e, separator)
" (expanded from: %s)", " (expanded from: %s)",
shortenstring(q->q_alias->q_paddr, shortenstring(q->q_alias->q_paddr,
MAXSHORTSTR)); MAXSHORTSTR));
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
} }
if (!printheader) if (!printheader && !putline("", mci))
putline("", mci); goto writeerr;
/* transient non-fatal errors */ /* transient non-fatal errors */
printheader = true; printheader = true;
@ -917,25 +932,28 @@ errbody(mci, e, separator)
if (printheader) if (printheader)
{ {
putline(" ----- The following addresses had transient non-fatal errors -----", if (!putline(" ----- The following addresses had transient non-fatal errors -----",
mci); mci))
goto writeerr;
printheader = false; printheader = false;
} }
(void) sm_strlcpy(buf, shortenstring(q->q_paddr, MAXSHORTSTR), (void) sm_strlcpy(buf, shortenstring(q->q_paddr, MAXSHORTSTR),
sizeof buf); sizeof buf);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
if (q->q_alias != NULL) if (q->q_alias != NULL)
{ {
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
" (expanded from: %s)", " (expanded from: %s)",
shortenstring(q->q_alias->q_paddr, shortenstring(q->q_alias->q_paddr,
MAXSHORTSTR)); MAXSHORTSTR));
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
} }
if (!printheader) if (!printheader && !putline("", mci))
putline("", mci); goto writeerr;
/* successful delivery notifications */ /* successful delivery notifications */
printheader = true; printheader = true;
@ -968,25 +986,28 @@ errbody(mci, e, separator)
if (printheader) if (printheader)
{ {
putline(" ----- The following addresses had successful delivery notifications -----", if (!putline(" ----- The following addresses had successful delivery notifications -----",
mci); mci))
goto writeerr;
printheader = false; printheader = false;
} }
(void) sm_snprintf(buf, sizeof buf, "%s (%s)", (void) sm_snprintf(buf, sizeof buf, "%s (%s)",
shortenstring(q->q_paddr, MAXSHORTSTR), p); shortenstring(q->q_paddr, MAXSHORTSTR), p);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
if (q->q_alias != NULL) if (q->q_alias != NULL)
{ {
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
" (expanded from: %s)", " (expanded from: %s)",
shortenstring(q->q_alias->q_paddr, shortenstring(q->q_alias->q_paddr,
MAXSHORTSTR)); MAXSHORTSTR));
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
} }
if (!printheader) if (!printheader && !putline("", mci))
putline("", mci); goto writeerr;
/* /*
** Output transcript of errors ** Output transcript of errors
@ -995,8 +1016,9 @@ errbody(mci, e, separator)
(void) sm_io_flush(smioout, SM_TIME_DEFAULT); (void) sm_io_flush(smioout, SM_TIME_DEFAULT);
if (e->e_parent->e_xfp == NULL) if (e->e_parent->e_xfp == NULL)
{ {
putline(" ----- Transcript of session is unavailable -----\n", if (!putline(" ----- Transcript of session is unavailable -----\n",
mci); mci))
goto writeerr;
} }
else else
{ {
@ -1007,11 +1029,12 @@ errbody(mci, e, separator)
while (sm_io_fgets(e->e_parent->e_xfp, SM_TIME_DEFAULT, buf, while (sm_io_fgets(e->e_parent->e_xfp, SM_TIME_DEFAULT, buf,
sizeof buf) != NULL) sizeof buf) != NULL)
{ {
if (printheader) if (printheader && !putline(" ----- Transcript of session follows -----\n",
putline(" ----- Transcript of session follows -----\n", mci))
mci); goto writeerr;
printheader = false; printheader = false;
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
} }
errno = 0; errno = 0;
@ -1023,11 +1046,12 @@ errbody(mci, e, separator)
if (e->e_msgboundary != NULL) if (e->e_msgboundary != NULL)
{ {
putline("", mci);
(void) sm_strlcpyn(buf, sizeof buf, 2, "--", e->e_msgboundary); (void) sm_strlcpyn(buf, sizeof buf, 2, "--", e->e_msgboundary);
putline(buf, mci); if (!putline("", mci) ||
putline("Content-Type: message/delivery-status", mci); !putline(buf, mci) ||
putline("", mci); !putline("Content-Type: message/delivery-status", mci) ||
!putline("", mci))
goto writeerr;
/* /*
** Output per-message information. ** Output per-message information.
@ -1039,13 +1063,15 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"Original-Envelope-Id: %.800s", "Original-Envelope-Id: %.800s",
xuntextify(e->e_parent->e_envid)); xuntextify(e->e_parent->e_envid));
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
/* Reporting-MTA: is us (required) */ /* Reporting-MTA: is us (required) */
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"Reporting-MTA: dns; %.800s", MyHostName); "Reporting-MTA: dns; %.800s", MyHostName);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
/* DSN-Gateway: not relevant since we are not translating */ /* DSN-Gateway: not relevant since we are not translating */
@ -1059,13 +1085,15 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"Received-From-MTA: %s; %.800s", "Received-From-MTA: %s; %.800s",
p, RealHostName); p, RealHostName);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
/* Arrival-Date: -- when it arrived here */ /* Arrival-Date: -- when it arrived here */
(void) sm_strlcpyn(buf, sizeof buf, 2, "Arrival-Date: ", (void) sm_strlcpyn(buf, sizeof buf, 2, "Arrival-Date: ",
arpadate(ctime(&e->e_parent->e_ctime))); arpadate(ctime(&e->e_parent->e_ctime)));
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
/* Deliver-By-Date: -- when it should have been delivered */ /* Deliver-By-Date: -- when it should have been delivered */
if (IS_DLVR_BY(e->e_parent)) if (IS_DLVR_BY(e->e_parent))
@ -1076,7 +1104,8 @@ errbody(mci, e, separator)
(void) sm_strlcpyn(buf, sizeof buf, 2, (void) sm_strlcpyn(buf, sizeof buf, 2,
"Deliver-By-Date: ", "Deliver-By-Date: ",
arpadate(ctime(&dbyd))); arpadate(ctime(&dbyd)));
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
/* /*
@ -1119,7 +1148,8 @@ errbody(mci, e, separator)
else else
continue; continue;
putline("", mci); if (!putline("", mci))
goto writeerr;
/* Original-Recipient: -- passed from on high */ /* Original-Recipient: -- passed from on high */
if (q->q_orcpt != NULL) if (q->q_orcpt != NULL)
@ -1127,7 +1157,8 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"Original-Recipient: %.800s", "Original-Recipient: %.800s",
q->q_orcpt); q->q_orcpt);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
/* Figure out actual recipient */ /* Figure out actual recipient */
@ -1176,7 +1207,8 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"Final-Recipient: %s", "Final-Recipient: %s",
q->q_finalrcpt); q->q_finalrcpt);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
/* X-Actual-Recipient: -- the real problem address */ /* X-Actual-Recipient: -- the real problem address */
@ -1190,13 +1222,15 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"X-Actual-Recipient: %s", "X-Actual-Recipient: %s",
actual); actual);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
/* Action: -- what happened? */ /* Action: -- what happened? */
(void) sm_strlcpyn(buf, sizeof buf, 2, "Action: ", (void) sm_strlcpyn(buf, sizeof buf, 2, "Action: ",
action); action);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
/* Status: -- what _really_ happened? */ /* Status: -- what _really_ happened? */
if (q->q_status != NULL) if (q->q_status != NULL)
@ -1208,7 +1242,8 @@ errbody(mci, e, separator)
else else
p = "2.0.0"; p = "2.0.0";
(void) sm_strlcpyn(buf, sizeof buf, 2, "Status: ", p); (void) sm_strlcpyn(buf, sizeof buf, 2, "Status: ", p);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
/* Remote-MTA: -- who was I talking to? */ /* Remote-MTA: -- who was I talking to? */
if (q->q_statmta != NULL) if (q->q_statmta != NULL)
@ -1222,7 +1257,8 @@ errbody(mci, e, separator)
p = &buf[strlen(buf) - 1]; p = &buf[strlen(buf) - 1];
if (*p == '.') if (*p == '.')
*p = '\0'; *p = '\0';
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
/* Diagnostic-Code: -- actual result from other end */ /* Diagnostic-Code: -- actual result from other end */
@ -1234,7 +1270,8 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"Diagnostic-Code: %s; %.800s", "Diagnostic-Code: %s; %.800s",
p, q->q_rstatus); p, q->q_rstatus);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
/* Last-Attempt-Date: -- fine granularity */ /* Last-Attempt-Date: -- fine granularity */
@ -1243,7 +1280,8 @@ errbody(mci, e, separator)
(void) sm_strlcpyn(buf, sizeof buf, 2, (void) sm_strlcpyn(buf, sizeof buf, 2,
"Last-Attempt-Date: ", "Last-Attempt-Date: ",
arpadate(ctime(&q->q_statdate))); arpadate(ctime(&q->q_statdate)));
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
/* Will-Retry-Until: -- for delayed messages only */ /* Will-Retry-Until: -- for delayed messages only */
if (QS_IS_QUEUEUP(q->q_state)) if (QS_IS_QUEUEUP(q->q_state))
@ -1255,7 +1293,8 @@ errbody(mci, e, separator)
(void) sm_strlcpyn(buf, sizeof buf, 2, (void) sm_strlcpyn(buf, sizeof buf, 2,
"Will-Retry-Until: ", "Will-Retry-Until: ",
arpadate(ctime(&xdate))); arpadate(ctime(&xdate)));
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
} }
} }
@ -1265,7 +1304,8 @@ errbody(mci, e, separator)
** Output text of original message ** Output text of original message
*/ */
putline("", mci); if (!putline("", mci))
goto writeerr;
if (bitset(EF_HAS_DF, e->e_parent->e_flags)) if (bitset(EF_HAS_DF, e->e_parent->e_flags))
{ {
sendbody = !bitset(EF_NO_BODY_RETN, e->e_parent->e_flags) && sendbody = !bitset(EF_NO_BODY_RETN, e->e_parent->e_flags) &&
@ -1273,21 +1313,27 @@ errbody(mci, e, separator)
if (e->e_msgboundary == NULL) if (e->e_msgboundary == NULL)
{ {
if (sendbody) if (!putline(
putline(" ----- Original message follows -----\n", mci); sendbody
else ? " ----- Original message follows -----\n"
putline(" ----- Message header follows -----\n", mci); : " ----- Message header follows -----\n",
mci))
{
goto writeerr;
}
} }
else else
{ {
(void) sm_strlcpyn(buf, sizeof buf, 2, "--", (void) sm_strlcpyn(buf, sizeof buf, 2, "--",
e->e_msgboundary); e->e_msgboundary);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
(void) sm_strlcpyn(buf, sizeof buf, 2, "Content-Type: ", (void) sm_strlcpyn(buf, sizeof buf, 2, "Content-Type: ",
sendbody ? "message/rfc822" sendbody ? "message/rfc822"
: "text/rfc822-headers"); : "text/rfc822-headers");
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
p = hvalue("Content-Transfer-Encoding", p = hvalue("Content-Transfer-Encoding",
e->e_parent->e_header); e->e_parent->e_header);
@ -1301,43 +1347,62 @@ errbody(mci, e, separator)
(void) sm_snprintf(buf, sizeof buf, (void) sm_snprintf(buf, sizeof buf,
"Content-Transfer-Encoding: %s", "Content-Transfer-Encoding: %s",
p); p);
putline(buf, mci); if (!putline(buf, mci))
goto writeerr;
} }
} }
putline("", mci); if (!putline("", mci))
goto writeerr;
save_errno = errno; save_errno = errno;
putheader(mci, e->e_parent->e_header, e->e_parent, M87F_OUTER); if (!putheader(mci, e->e_parent->e_header, e->e_parent,
M87F_OUTER))
goto writeerr;
errno = save_errno; errno = save_errno;
if (sendbody) if (sendbody)
putbody(mci, e->e_parent, e->e_msgboundary); {
if (!putbody(mci, e->e_parent, e->e_msgboundary))
goto writeerr;
}
else if (e->e_msgboundary == NULL) else if (e->e_msgboundary == NULL)
{ {
putline("", mci); if (!putline("", mci) ||
putline(" ----- Message body suppressed -----", mci); !putline(" ----- Message body suppressed -----",
mci))
{
goto writeerr;
}
} }
} }
else if (e->e_msgboundary == NULL) else if (e->e_msgboundary == NULL)
{ {
putline(" ----- No message was collected -----\n", mci); if (!putline(" ----- No message was collected -----\n", mci))
goto writeerr;
} }
if (e->e_msgboundary != NULL) if (e->e_msgboundary != NULL)
{ {
putline("", mci);
(void) sm_strlcpyn(buf, sizeof buf, 3, "--", e->e_msgboundary, (void) sm_strlcpyn(buf, sizeof buf, 3, "--", e->e_msgboundary,
"--"); "--");
putline(buf, mci); if (!putline("", mci) || !putline(buf, mci))
goto writeerr;
} }
putline("", mci); if (!putline("", mci) ||
(void) sm_io_flush(mci->mci_out, SM_TIME_DEFAULT); sm_io_flush(mci->mci_out, SM_TIME_DEFAULT) == SM_IO_EOF)
goto writeerr;
/* /*
** Cleanup and exit ** Cleanup and exit
*/ */
if (errno != 0) if (errno != 0)
{
writeerr:
syserr("errbody: I/O error"); syserr("errbody: I/O error");
return false;
}
return true;
} }
/* /*
** SMTPTODSN -- convert SMTP to DSN status code ** SMTPTODSN -- convert SMTP to DSN status code
** **
@ -1402,9 +1467,9 @@ smtptodsn(smtpstat)
return "5.0.0"; return "5.0.0";
} }
if ((smtpstat / 100) == 2) if (REPLYTYPE(smtpstat) == 2)
return "2.0.0"; return "2.0.0";
if ((smtpstat / 100) == 4) if (REPLYTYPE(smtpstat) == 4)
return "4.0.0"; return "4.0.0";
return "5.0.0"; return "5.0.0";
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -52,7 +52,7 @@
#ifdef _DEFINE #ifdef _DEFINE
# ifndef lint # ifndef lint
SM_UNUSED(static char SmailId[]) = "@(#)$Id: sendmail.h,v 8.993 2005/03/07 18:03:17 ca Exp $"; SM_UNUSED(static char SmailId[]) = "@(#)$Id: sendmail.h,v 8.1006 2006/02/27 17:49:09 ca Exp $";
# endif /* ! lint */ # endif /* ! lint */
#endif /* _DEFINE */ #endif /* _DEFINE */
@ -809,13 +809,13 @@ extern struct hdrinfo HdrInfo[];
/* functions */ /* functions */
extern void addheader __P((char *, char *, int, ENVELOPE *)); extern void addheader __P((char *, char *, int, ENVELOPE *));
extern unsigned long chompheader __P((char *, int, HDR **, ENVELOPE *)); extern unsigned long chompheader __P((char *, int, HDR **, ENVELOPE *));
extern void commaize __P((HDR *, char *, bool, MCI *, ENVELOPE *)); extern bool commaize __P((HDR *, char *, bool, MCI *, ENVELOPE *));
extern HDR *copyheader __P((HDR *, SM_RPOOL_T *)); extern HDR *copyheader __P((HDR *, SM_RPOOL_T *));
extern void eatheader __P((ENVELOPE *, bool, bool)); extern void eatheader __P((ENVELOPE *, bool, bool));
extern char *hvalue __P((char *, HDR *)); extern char *hvalue __P((char *, HDR *));
extern void insheader __P((int, char *, char *, int, ENVELOPE *)); extern void insheader __P((int, char *, char *, int, ENVELOPE *));
extern bool isheader __P((char *)); extern bool isheader __P((char *));
extern void putfromline __P((MCI *, ENVELOPE *)); extern bool putfromline __P((MCI *, ENVELOPE *));
extern void setupheaders __P((void)); extern void setupheaders __P((void));
/* /*
@ -870,9 +870,9 @@ struct envelope
short e_sendmode; /* message send mode */ short e_sendmode; /* message send mode */
short e_errormode; /* error return mode */ short e_errormode; /* error return mode */
short e_timeoutclass; /* message timeout class */ short e_timeoutclass; /* message timeout class */
void (*e_puthdr)__P((MCI *, HDR *, ENVELOPE *, int)); bool (*e_puthdr)__P((MCI *, HDR *, ENVELOPE *, int));
/* function to put header of message */ /* function to put header of message */
void (*e_putbody)__P((MCI *, ENVELOPE *, char *)); bool (*e_putbody)__P((MCI *, ENVELOPE *, char *));
/* function to put body of message */ /* function to put body of message */
ENVELOPE *e_parent; /* the message this one encloses */ ENVELOPE *e_parent; /* the message this one encloses */
ENVELOPE *e_sibling; /* the next envelope of interest */ ENVELOPE *e_sibling; /* the next envelope of interest */
@ -965,8 +965,8 @@ extern void dropenvelope __P((ENVELOPE *, bool, bool));
extern ENVELOPE *newenvelope __P((ENVELOPE *, ENVELOPE *, SM_RPOOL_T *)); extern ENVELOPE *newenvelope __P((ENVELOPE *, ENVELOPE *, SM_RPOOL_T *));
extern void clrsessenvelope __P((ENVELOPE *)); extern void clrsessenvelope __P((ENVELOPE *));
extern void printenvflags __P((ENVELOPE *)); extern void printenvflags __P((ENVELOPE *));
extern void putbody __P((MCI *, ENVELOPE *, char *)); extern bool putbody __P((MCI *, ENVELOPE *, char *));
extern void putheader __P((MCI *, HDR *, ENVELOPE *, int)); extern bool putheader __P((MCI *, HDR *, ENVELOPE *, int));
/* /*
** Message priority classes. ** Message priority classes.
@ -1213,7 +1213,7 @@ MAP
#define MF_REGEX_NOT 0x00040000 /* regular expression negation */ #define MF_REGEX_NOT 0x00040000 /* regular expression negation */
#define MF_DEFER 0x00080000 /* don't lookup map in defer mode */ #define MF_DEFER 0x00080000 /* don't lookup map in defer mode */
#define MF_SINGLEMATCH 0x00100000 /* successful only if match one key */ #define MF_SINGLEMATCH 0x00100000 /* successful only if match one key */
/* 0x00200000 available for use */ #define MF_SINGLEDN 0x00200000 /* only one match, but multi values */
#define MF_FILECLASS 0x00400000 /* this is a file class map */ #define MF_FILECLASS 0x00400000 /* this is a file class map */
#define MF_OPENBOGUS 0x00800000 /* open failed, don't call map_close */ #define MF_OPENBOGUS 0x00800000 /* open failed, don't call map_close */
#define MF_CLOSING 0x01000000 /* map is being closed */ #define MF_CLOSING 0x01000000 /* map is being closed */
@ -1542,9 +1542,13 @@ extern void stabapply __P((void (*)(STAB *, int), int));
/* values for e_sendmode -- send modes */ /* values for e_sendmode -- send modes */
#define SM_DELIVER 'i' /* interactive delivery */ #define SM_DELIVER 'i' /* interactive delivery */
#define SM_FORK 'b' /* deliver in background */ #define SM_FORK 'b' /* deliver in background */
#if _FFR_DM_ONE
#define SM_DM_ONE 'o' /* deliver first TA in background, then queue */
#endif /* _FFR_DM_ONE */
#define SM_QUEUE 'q' /* queue, don't deliver */ #define SM_QUEUE 'q' /* queue, don't deliver */
#define SM_DEFER 'd' /* defer map lookups as well as queue */ #define SM_DEFER 'd' /* defer map lookups as well as queue */
#define SM_VERIFY 'v' /* verify only (used internally) */ #define SM_VERIFY 'v' /* verify only (used internally) */
#define DM_NOTSET (-1) /* DeliveryMode (per daemon) option not set */
#define WILL_BE_QUEUED(m) ((m) == SM_QUEUE || (m) == SM_DEFER) #define WILL_BE_QUEUED(m) ((m) == SM_QUEUE || (m) == SM_DEFER)
@ -1650,7 +1654,7 @@ EXTERN unsigned long PrivacyFlags; /* privacy flags */
#define M87F_NO8TO7 0x0004 /* don't do 8->7 bit conversions */ #define M87F_NO8TO7 0x0004 /* don't do 8->7 bit conversions */
/* functions */ /* functions */
extern void mime7to8 __P((MCI *, HDR *, ENVELOPE *)); extern bool mime7to8 __P((MCI *, HDR *, ENVELOPE *));
extern int mime8to7 __P((MCI *, HDR *, ENVELOPE *, char **, int)); extern int mime8to7 __P((MCI *, HDR *, ENVELOPE *, char **, int));
/* /*
@ -1820,11 +1824,12 @@ struct termescape
#define TLS_I_SRV_CERT (TLS_I_CERT_EX | TLS_I_KEY_EX | \ #define TLS_I_SRV_CERT (TLS_I_CERT_EX | TLS_I_KEY_EX | \
TLS_I_KEY_UNR | TLS_I_KEY_OUNR | \ TLS_I_KEY_UNR | TLS_I_KEY_OUNR | \
TLS_I_CERTP_EX | TLS_I_CERTF_EX | \ TLS_I_CERTP_EX | TLS_I_CERTF_EX | \
TLS_I_USE_KEY | TLS_I_USE_CERT) TLS_I_USE_KEY | TLS_I_USE_CERT | TLS_I_CACHE)
/* server requirements */ /* server requirements */
#define TLS_I_SRV (TLS_I_SRV_CERT | TLS_I_RSA_TMP | TLS_I_VRFY_PATH | \ #define TLS_I_SRV (TLS_I_SRV_CERT | TLS_I_RSA_TMP | TLS_I_VRFY_PATH | \
TLS_I_VRFY_LOC | TLS_I_TRY_DH | TLS_I_DH512) TLS_I_VRFY_LOC | TLS_I_TRY_DH | TLS_I_DH512 | \
TLS_I_CACHE)
/* client requirements */ /* client requirements */
#define TLS_I_CLT (TLS_I_KEY_UNR | TLS_I_KEY_OUNR) #define TLS_I_CLT (TLS_I_KEY_UNR | TLS_I_KEY_OUNR)
@ -1841,7 +1846,7 @@ extern void setclttls __P((bool));
extern bool initsrvtls __P((bool)); extern bool initsrvtls __P((bool));
extern int tls_get_info __P((SSL *, bool, char *, MACROS_T *, bool)); extern int tls_get_info __P((SSL *, bool, char *, MACROS_T *, bool));
extern int endtls __P((SSL *, char *)); extern int endtls __P((SSL *, char *));
extern void tlslogerr __P((char *)); extern void tlslogerr __P((const char *));
EXTERN char *CACertPath; /* path to CA certificates (dir. with hashes) */ EXTERN char *CACertPath; /* path to CA certificates (dir. with hashes) */
@ -2141,11 +2146,13 @@ extern unsigned char tTdvect[100]; /* trace vector */
EXTERN bool AllowBogusHELO; /* allow syntax errors on HELO command */ EXTERN bool AllowBogusHELO; /* allow syntax errors on HELO command */
EXTERN bool CheckAliases; /* parse addresses during newaliases */ EXTERN bool CheckAliases; /* parse addresses during newaliases */
#if _FFR_QUEUE_RUN_PARANOIA
EXTERN int CheckQueueRunners; /* check whether queue runners are OK */
#endif /* _FFR_QUEUE_RUN_PARANOIA */
EXTERN bool ColonOkInAddr; /* single colon legal in address */ EXTERN bool ColonOkInAddr; /* single colon legal in address */
#if !defined(_USE_SUN_NSSWITCH_) && !defined(_USE_DEC_SVC_CONF_) #if !defined(_USE_SUN_NSSWITCH_) && !defined(_USE_DEC_SVC_CONF_)
EXTERN bool ConfigFileRead; /* configuration file has been read */ EXTERN bool ConfigFileRead; /* configuration file has been read */
#endif /* !defined(_USE_SUN_NSSWITCH_) && !defined(_USE_DEC_SVC_CONF_) */ #endif /* !defined(_USE_SUN_NSSWITCH_) && !defined(_USE_DEC_SVC_CONF_) */
EXTERN bool volatile DataProgress; /* have we sent anything since last check */
EXTERN bool DisConnected; /* running with OutChannel redirect to transcript file */ EXTERN bool DisConnected; /* running with OutChannel redirect to transcript file */
EXTERN bool DontExpandCnames; /* do not $[...$] expand CNAMEs */ EXTERN bool DontExpandCnames; /* do not $[...$] expand CNAMEs */
EXTERN bool DontInitGroups; /* avoid initgroups() because of NIS cost */ EXTERN bool DontInitGroups; /* avoid initgroups() because of NIS cost */
@ -2212,9 +2219,14 @@ EXTERN int MaxHopCount; /* max # of hops until bounce */
EXTERN int MaxMacroRecursion; /* maximum depth of macro recursion */ EXTERN int MaxMacroRecursion; /* maximum depth of macro recursion */
EXTERN int MaxMimeFieldLength; /* maximum MIME field length */ EXTERN int MaxMimeFieldLength; /* maximum MIME field length */
EXTERN int MaxMimeHeaderLength; /* maximum MIME header length */ EXTERN int MaxMimeHeaderLength; /* maximum MIME header length */
EXTERN int MaxNOOPCommands; /* max "noise" commands before slowdown */
EXTERN int MaxRcptPerMsg; /* max recipients per SMTP message */ EXTERN int MaxRcptPerMsg; /* max recipients per SMTP message */
EXTERN int MaxRuleRecursion; /* maximum depth of ruleset recursion */ EXTERN int MaxRuleRecursion; /* maximum depth of ruleset recursion */
#if _FFR_MSG_ACCEPT
EXTERN char *MessageAccept;
#endif /* _FFR_MSG_ACCEPT */
EXTERN int MimeMode; /* MIME processing mode */ EXTERN int MimeMode; /* MIME processing mode */
EXTERN int NoRecipientAction; EXTERN int NoRecipientAction;
@ -2229,6 +2241,11 @@ EXTERN int NumFileSys; /* number of queue file systems */
EXTERN int QueueLA; /* load average starting forced queueing */ EXTERN int QueueLA; /* load average starting forced queueing */
EXTERN int RefuseLA; /* load average refusing connections */ EXTERN int RefuseLA; /* load average refusing connections */
EXTERN time_t RejectLogInterval; /* time btwn log msgs while refusing */ EXTERN time_t RejectLogInterval; /* time btwn log msgs while refusing */
#if _FFR_MEMSTAT
EXTERN long QueueLowMem; /* low memory starting forced queueing */
EXTERN long RefuseLowMem; /* low memory refusing connections */
EXTERN char *MemoryResource;/* memory resource to look up */
#endif /* _FFR_MEMSTAT */
EXTERN int SuperSafe; /* be extra careful, even if expensive */ EXTERN int SuperSafe; /* be extra careful, even if expensive */
EXTERN int VendorCode; /* vendor-specific operation enhancements */ EXTERN int VendorCode; /* vendor-specific operation enhancements */
EXTERN int Verbose; /* set if blow-by-blow desired */ EXTERN int Verbose; /* set if blow-by-blow desired */
@ -2371,6 +2388,7 @@ extern void smtpquit __P((MAILER *, MCI *, ENVELOPE *));
extern int smtprcpt __P((ADDRESS *, MAILER *, MCI *, ENVELOPE *, ADDRESS *, time_t)); extern int smtprcpt __P((ADDRESS *, MAILER *, MCI *, ENVELOPE *, ADDRESS *, time_t));
extern void smtprset __P((MAILER *, MCI *, ENVELOPE *)); extern void smtprset __P((MAILER *, MCI *, ENVELOPE *));
#define REPLYTYPE(r) ((r) / 100) /* first digit of reply code */
#define ISSMTPCODE(c) (isascii(c[0]) && isdigit(c[0]) && \ #define ISSMTPCODE(c) (isascii(c[0]) && isdigit(c[0]) && \
isascii(c[1]) && isdigit(c[1]) && \ isascii(c[1]) && isdigit(c[1]) && \
isascii(c[2]) && isdigit(c[2])) isascii(c[2]) && isdigit(c[2]))
@ -2519,8 +2537,8 @@ extern void printopenfds __P((bool));
extern void printqueue __P((void)); extern void printqueue __P((void));
extern void printrules __P((void)); extern void printrules __P((void));
extern pid_t prog_open __P((char **, int *, ENVELOPE *)); extern pid_t prog_open __P((char **, int *, ENVELOPE *));
extern void putline __P((char *, MCI *)); extern bool putline __P((char *, MCI *));
extern void putxline __P((char *, size_t, MCI *, int)); extern bool putxline __P((char *, size_t, MCI *, int));
extern void queueup_macros __P((int, SM_FILE_T *, ENVELOPE *)); extern void queueup_macros __P((int, SM_FILE_T *, ENVELOPE *));
extern void readcf __P((char *, bool, ENVELOPE *)); extern void readcf __P((char *, bool, ENVELOPE *));
extern SIGFUNC_DECL reapchild __P((int)); extern SIGFUNC_DECL reapchild __P((int));
@ -2540,7 +2558,7 @@ extern bool setvendor __P((char *));
extern void set_op_mode __P((int)); extern void set_op_mode __P((int));
extern void setoption __P((int, char *, bool, bool, ENVELOPE *)); extern void setoption __P((int, char *, bool, bool, ENVELOPE *));
extern sigfunc_t setsignal __P((int, sigfunc_t)); extern sigfunc_t setsignal __P((int, sigfunc_t));
extern void setuserenv __P((const char *, const char *)); extern void sm_setuserenv __P((const char *, const char *));
extern void settime __P((ENVELOPE *)); extern void settime __P((ENVELOPE *));
extern char *sfgets __P((char *, int, SM_FILE_T *, time_t, char *)); extern char *sfgets __P((char *, int, SM_FILE_T *, time_t, char *));
extern char *shortenstring __P((const char *, size_t)); extern char *shortenstring __P((const char *, size_t));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999-2004 Sendmail, Inc. and its suppliers. * Copyright (c) 1999-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* *
* By using this file, you agree to the terms and conditions set * By using this file, you agree to the terms and conditions set
@ -9,7 +9,7 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: sfsasl.c,v 8.101 2004/12/15 22:45:55 ca Exp $") SM_RCSID("@(#)$Id: sfsasl.c,v 8.113 2006/03/02 19:18:27 ca Exp $")
#include <stdlib.h> #include <stdlib.h>
#include <sendmail.h> #include <sendmail.h>
#include <errno.h> #include <errno.h>
@ -223,6 +223,9 @@ sasl_read(fp, buf, size)
(unsigned int) len, &outbuf, &outlen); (unsigned int) len, &outbuf, &outlen);
if (result != SASL_OK) if (result != SASL_OK)
{ {
if (LogLevel > 7)
sm_syslog(LOG_WARNING, NOQID,
"AUTH: sasl_decode error=%d", result);
outbuf = NULL; outbuf = NULL;
offset = 0; offset = 0;
outlen = 0; outlen = 0;
@ -304,7 +307,7 @@ sasl_write(fp, buf, size)
*/ */
result = sasl_getprop(so->conn, SASL_MAXOUTBUF, result = sasl_getprop(so->conn, SASL_MAXOUTBUF,
(const void **) &maxencode); (const void **) &maxencode);
if (result == SASL_OK && size > *maxencode && *maxencode > 0) if (result == SASL_OK && size > *maxencode && *maxencode > 0)
size = *maxencode; size = *maxencode;
@ -312,7 +315,12 @@ sasl_write(fp, buf, size)
(unsigned int) size, &outbuf, &outlen); (unsigned int) size, &outbuf, &outlen);
if (result != SASL_OK) if (result != SASL_OK)
{
if (LogLevel > 7)
sm_syslog(LOG_WARNING, NOQID,
"AUTH: sasl_encode error=%d", result);
return -1; return -1;
}
if (outbuf != NULL) if (outbuf != NULL)
{ {
@ -540,6 +548,125 @@ tls_close(fp)
/* maximum number of retries for TLS related I/O due to handshakes */ /* maximum number of retries for TLS related I/O due to handshakes */
# define MAX_TLS_IOS 4 # define MAX_TLS_IOS 4
/*
** TLS_RETRY -- check whether a failed SSL operation can be retried
**
** Parameters:
** ssl -- TLS structure
** rfd -- read fd
** wfd -- write fd
** tlsstart -- start time of TLS operation
** timeout -- timeout for TLS operation
** err -- SSL error
** where -- description of operation
**
** Results:
** >0 on success
** 0 on timeout
** <0 on error
*/
int
tls_retry(ssl, rfd, wfd, tlsstart, timeout, err, where)
SSL *ssl;
int rfd;
int wfd;
time_t tlsstart;
int timeout;
int err;
const char *where;
{
int ret;
time_t left;
time_t now = curtime();
struct timeval tv;
ret = -1;
/*
** For SSL_ERROR_WANT_{READ,WRITE}:
** There is not a complete SSL record available yet
** or there is only a partial SSL record removed from
** the network (socket) buffer into the SSL buffer.
** The SSL_connect will only succeed when a full
** SSL record is available (assuming a "real" error
** doesn't happen). To handle when a "real" error
** does happen the select is set for exceptions too.
** The connection may be re-negotiated during this time
** so both read and write "want errors" need to be handled.
** A select() exception loops back so that a proper SSL
** error message can be gotten.
*/
left = timeout - (now - tlsstart);
if (left <= 0)
return 0; /* timeout */
tv.tv_sec = left;
tv.tv_usec = 0;
if (LogLevel > 14)
{
sm_syslog(LOG_INFO, NOQID,
"STARTTLS=%s, info: fds=%d/%d, err=%d",
where, rfd, wfd, err);
}
if (FD_SETSIZE > 0 &&
((err == SSL_ERROR_WANT_READ && rfd >= FD_SETSIZE) ||
(err == SSL_ERROR_WANT_WRITE && wfd >= FD_SETSIZE)))
{
if (LogLevel > 5)
{
sm_syslog(LOG_ERR, NOQID,
"STARTTLS=%s, error: fd %d/%d too large",
where, rfd, wfd);
if (LogLevel > 8)
tlslogerr(where);
}
errno = EINVAL;
}
else if (err == SSL_ERROR_WANT_READ)
{
fd_set ssl_maskr, ssl_maskx;
FD_ZERO(&ssl_maskr);
FD_SET(rfd, &ssl_maskr);
FD_ZERO(&ssl_maskx);
FD_SET(rfd, &ssl_maskx);
do
{
ret = select(rfd + 1, &ssl_maskr, NULL, &ssl_maskx,
&tv);
} while (ret < 0 && errno == EINTR);
if (ret < 0 && errno > 0)
ret = -errno;
}
else if (err == SSL_ERROR_WANT_WRITE)
{
fd_set ssl_maskw, ssl_maskx;
FD_ZERO(&ssl_maskw);
FD_SET(wfd, &ssl_maskw);
FD_ZERO(&ssl_maskx);
FD_SET(rfd, &ssl_maskx);
do
{
ret = select(wfd + 1, NULL, &ssl_maskw, &ssl_maskx,
&tv);
} while (ret < 0 && errno == EINTR);
if (ret < 0 && errno > 0)
ret = -errno;
}
return ret;
}
/* errno to force refill() etc to stop (see IS_IO_ERROR()) */
#ifdef ETIMEDOUT
# define SM_ERR_TIMEOUT ETIMEDOUT
#else /* ETIMEDOUT */
# define SM_ERR_TIMEOUT EIO
#endif /* ETIMEDOUT */
/* /*
** TLS_READ -- read secured information for the caller ** TLS_READ -- read secured information for the caller
** **
@ -561,38 +688,42 @@ tls_read(fp, buf, size)
char *buf; char *buf;
size_t size; size_t size;
{ {
int r; int r, rfd, wfd, try, ssl_err;
static int again = MAX_TLS_IOS;
struct tls_obj *so = (struct tls_obj *) fp->f_cookie; struct tls_obj *so = (struct tls_obj *) fp->f_cookie;
time_t tlsstart;
char *err; char *err;
try = 99;
err = NULL;
tlsstart = curtime();
retry:
r = SSL_read(so->con, (char *) buf, size); r = SSL_read(so->con, (char *) buf, size);
if (r > 0) if (r > 0)
{
again = MAX_TLS_IOS;
return r; return r;
}
err = NULL; err = NULL;
switch (SSL_get_error(so->con, r)) switch (ssl_err = SSL_get_error(so->con, r))
{ {
case SSL_ERROR_NONE: case SSL_ERROR_NONE:
case SSL_ERROR_ZERO_RETURN: case SSL_ERROR_ZERO_RETURN:
again = MAX_TLS_IOS;
break; break;
case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_WRITE:
if (--again <= 0) err = "read W BLOCK";
err = "read W BLOCK"; /* FALLTHROUGH */
else
errno = EAGAIN;
break;
case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_READ:
if (--again <= 0) if (err == NULL)
err = "read R BLOCK"; err = "read R BLOCK";
else rfd = SSL_get_rfd(so->con);
errno = EAGAIN; wfd = SSL_get_wfd(so->con);
try = tls_retry(so->con, rfd, wfd, tlsstart,
TimeOuts.to_datablock, ssl_err, "read");
if (try > 0)
goto retry;
errno = SM_ERR_TIMEOUT;
break; break;
case SSL_ERROR_WANT_X509_LOOKUP: case SSL_ERROR_WANT_X509_LOOKUP:
err = "write X BLOCK"; err = "write X BLOCK";
break; break;
@ -625,15 +756,22 @@ tls_read(fp, buf, size)
int save_errno; int save_errno;
save_errno = (errno == 0) ? EIO : errno; save_errno = (errno == 0) ? EIO : errno;
again = MAX_TLS_IOS; if (try == 0 && save_errno == SM_ERR_TIMEOUT)
if (LogLevel > 9) {
if (LogLevel > 7)
sm_syslog(LOG_WARNING, NOQID,
"STARTTLS: read error=timeout");
}
else if (LogLevel > 8)
sm_syslog(LOG_WARNING, NOQID, sm_syslog(LOG_WARNING, NOQID,
"STARTTLS: read error=%s (%d), errno=%d, get_error=%s", "STARTTLS: read error=%s (%d), errno=%d, get_error=%s, retry=%d, ssl_err=%d",
err, r, errno, err, r, errno,
ERR_error_string(ERR_get_error(), NULL)); ERR_error_string(ERR_get_error(), NULL), try,
ssl_err);
else if (LogLevel > 7) else if (LogLevel > 7)
sm_syslog(LOG_WARNING, NOQID, sm_syslog(LOG_WARNING, NOQID,
"STARTTLS: read error=%s (%d)", err, r); "STARTTLS: read error=%s (%d), retry=%d, ssl_err=%d",
err, r, errno, try, ssl_err);
errno = save_errno; errno = save_errno;
} }
return r; return r;
@ -660,36 +798,39 @@ tls_write(fp, buf, size)
const char *buf; const char *buf;
size_t size; size_t size;
{ {
int r; int r, rfd, wfd, try, ssl_err;
static int again = MAX_TLS_IOS;
struct tls_obj *so = (struct tls_obj *) fp->f_cookie; struct tls_obj *so = (struct tls_obj *) fp->f_cookie;
time_t tlsstart;
char *err; char *err;
try = 99;
err = NULL;
tlsstart = curtime();
retry:
r = SSL_write(so->con, (char *) buf, size); r = SSL_write(so->con, (char *) buf, size);
if (r > 0) if (r > 0)
{
again = MAX_TLS_IOS;
return r; return r;
}
err = NULL; err = NULL;
switch (SSL_get_error(so->con, r)) switch (ssl_err = SSL_get_error(so->con, r))
{ {
case SSL_ERROR_NONE: case SSL_ERROR_NONE:
case SSL_ERROR_ZERO_RETURN: case SSL_ERROR_ZERO_RETURN:
again = MAX_TLS_IOS;
break; break;
case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_WRITE:
if (--again <= 0) err = "read W BLOCK";
err = "write W BLOCK"; /* FALLTHROUGH */
else
errno = EAGAIN;
break;
case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_READ:
if (--again <= 0) if (err == NULL)
err = "write R BLOCK"; err = "read R BLOCK";
else rfd = SSL_get_rfd(so->con);
errno = EAGAIN; wfd = SSL_get_wfd(so->con);
try = tls_retry(so->con, rfd, wfd, tlsstart,
DATA_PROGRESS_TIMEOUT, ssl_err, "write");
if (try > 0)
goto retry;
errno = SM_ERR_TIMEOUT;
break; break;
case SSL_ERROR_WANT_X509_LOOKUP: case SSL_ERROR_WANT_X509_LOOKUP:
err = "write X BLOCK"; err = "write X BLOCK";
@ -722,15 +863,22 @@ tls_write(fp, buf, size)
int save_errno; int save_errno;
save_errno = (errno == 0) ? EIO : errno; save_errno = (errno == 0) ? EIO : errno;
again = MAX_TLS_IOS; if (try == 0 && save_errno == SM_ERR_TIMEOUT)
if (LogLevel > 9) {
if (LogLevel > 7)
sm_syslog(LOG_WARNING, NOQID,
"STARTTLS: write error=timeout");
}
else if (LogLevel > 8)
sm_syslog(LOG_WARNING, NOQID, sm_syslog(LOG_WARNING, NOQID,
"STARTTLS: write error=%s (%d), errno=%d, get_error=%s", "STARTTLS: write error=%s (%d), errno=%d, get_error=%s, retry=%d, ssl_err=%d",
err, r, errno, err, r, errno,
ERR_error_string(ERR_get_error(), NULL)); ERR_error_string(ERR_get_error(), NULL), try,
ssl_err);
else if (LogLevel > 7) else if (LogLevel > 7)
sm_syslog(LOG_WARNING, NOQID, sm_syslog(LOG_WARNING, NOQID,
"STARTTLS: write error=%s (%d)", err, r); "STARTTLS: write error=%s (%d), errno=%d, retry=%d, ssl_err=%d",
err, r, errno, try, ssl_err);
errno = save_errno; errno = save_errno;
} }
return r; return r;

View File

@ -1,12 +1,12 @@
/* /*
* Copyright (c) 1999, 2000 Sendmail, Inc. and its suppliers. * Copyright (c) 1999, 2000, 2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* *
* By using this file, you agree to the terms and conditions set * By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of * forth in the LICENSE file which can be found at the top level of
* the sendmail distribution. * the sendmail distribution.
* *
* $Id: sfsasl.h,v 8.17 2000/09/19 21:30:49 ca Exp $" * $Id: sfsasl.h,v 8.19 2006/02/27 19:53:37 ca Exp $"
*/ */
#ifndef SFSASL_H #ifndef SFSASL_H
@ -17,6 +17,8 @@ extern int sfdcsasl __P((SM_FILE_T **, SM_FILE_T **, sasl_conn_t *));
#endif /* SASL */ #endif /* SASL */
# if STARTTLS # if STARTTLS
extern int tls_retry __P((SSL *, int, int, time_t, int, int,
const char *));
extern int sfdctls __P((SM_FILE_T **, SM_FILE_T **, SSL *)); extern int sfdctls __P((SM_FILE_T **, SM_FILE_T **, SSL *));
# endif /* STARTTLS */ # endif /* STARTTLS */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -17,9 +17,9 @@
# include <libmilter/mfdef.h> # include <libmilter/mfdef.h>
#endif /* MILTER */ #endif /* MILTER */
SM_RCSID("@(#)$Id: srvrsmtp.c,v 8.906 2005/03/16 00:36:09 ca Exp $") SM_RCSID("@(#)$Id: srvrsmtp.c,v 8.922 2006/02/28 00:42:13 ca Exp $")
#include <sys/time.h> #include <sm/time.h>
#include <sm/fdset.h> #include <sm/fdset.h>
#if SASL || STARTTLS #if SASL || STARTTLS
@ -36,6 +36,9 @@ static SSL_CTX *srv_ctx = NULL; /* TLS server context */
static SSL *srv_ssl = NULL; /* per connection context */ static SSL *srv_ssl = NULL; /* per connection context */
static bool tls_ok_srv = false; static bool tls_ok_srv = false;
#if _FFR_DM_ONE
static bool NotFirstDelivery = false;
#endif /* _FFR_DM_ONE */
extern void tls_set_verify __P((SSL_CTX *, SSL *, bool)); extern void tls_set_verify __P((SSL_CTX *, SSL *, bool));
# define TLS_VERIFY_CLIENT() tls_set_verify(srv_ctx, srv_ssl, \ # define TLS_VERIFY_CLIENT() tls_set_verify(srv_ctx, srv_ssl, \
@ -221,9 +224,6 @@ static char *CurSmtpClient; /* who's at the other end of channel */
#ifndef MAXBADCOMMANDS #ifndef MAXBADCOMMANDS
# define MAXBADCOMMANDS 25 /* maximum number of bad commands */ # define MAXBADCOMMANDS 25 /* maximum number of bad commands */
#endif /* ! MAXBADCOMMANDS */ #endif /* ! MAXBADCOMMANDS */
#ifndef MAXNOOPCOMMANDS
# define MAXNOOPCOMMANDS 20 /* max "noise" commands before slowdown */
#endif /* ! MAXNOOPCOMMANDS */
#ifndef MAXHELOCOMMANDS #ifndef MAXHELOCOMMANDS
# define MAXHELOCOMMANDS 3 /* max HELO/EHLO commands before slowdown */ # define MAXHELOCOMMANDS 3 /* max HELO/EHLO commands before slowdown */
#endif /* ! MAXHELOCOMMANDS */ #endif /* ! MAXHELOCOMMANDS */
@ -292,6 +292,24 @@ static bool smtp_data __P((SMTP_T *, ENVELOPE *));
\ \
switch (state) \ switch (state) \
{ \ { \
case SMFIR_SHUTDOWN: \
if (MilterLogLevel > 3) \
{ \
sm_syslog(LOG_INFO, e->e_id, \
"Milter: %s=%s, reject=421, errormode=4", \
str, addr); \
LogUsrErrs = false; \
} \
{ \
bool tsave = QuickAbort; \
\
QuickAbort = false; \
usrerr("421 4.3.0 closing connection"); \
QuickAbort = tsave; \
e->e_sendqueue = NULL; \
goto doquit; \
} \
break; \
case SMFIR_REPLYCODE: \ case SMFIR_REPLYCODE: \
if (MilterLogLevel > 3) \ if (MilterLogLevel > 3) \
{ \ { \
@ -300,7 +318,8 @@ static bool smtp_data __P((SMTP_T *, ENVELOPE *));
str, addr, response); \ str, addr, response); \
LogUsrErrs = false; \ LogUsrErrs = false; \
} \ } \
if (strncmp(response, "421 ", 4) == 0) \ if (strncmp(response, "421 ", 4) == 0 \
|| strncmp(response, "421-", 4) == 0) \
{ \ { \
bool tsave = QuickAbort; \ bool tsave = QuickAbort; \
\ \
@ -504,7 +523,6 @@ smtp(nullserver, d_flags, e)
#endif /* SASL */ #endif /* SASL */
int r; int r;
#if STARTTLS #if STARTTLS
int fdfl;
int rfd, wfd; int rfd, wfd;
volatile bool tls_active = false; volatile bool tls_active = false;
volatile bool smtps = bitnset(D_SMTPS, d_flags); volatile bool smtps = bitnset(D_SMTPS, d_flags);
@ -810,6 +828,19 @@ smtp(nullserver, d_flags, e)
tempfail = true; tempfail = true;
smtp.sm_milterize = false; smtp.sm_milterize = false;
break; break;
case SMFIR_SHUTDOWN:
if (MilterLogLevel > 3)
sm_syslog(LOG_INFO, e->e_id,
"Milter: initialization failed, closing connection");
tempfail = true;
smtp.sm_milterize = false;
message("421 4.7.0 %s closing connection",
MyHostName);
/* arrange to ignore send list */
e->e_sendqueue = NULL;
goto doquit;
} }
} }
@ -896,6 +927,9 @@ smtp(nullserver, d_flags, e)
int fd; int fd;
fd_set readfds; fd_set readfds;
struct timeval timeout; struct timeval timeout;
#if _FFR_LOG_GREET_PAUSE
struct timeval bp, ep, tp; /* {begin,end,total}pause */
#endif /* _FFR_LOG_GREET_PAUSE */
/* pause for a moment */ /* pause for a moment */
timeout.tv_sec = msecs / 1000; timeout.tv_sec = msecs / 1000;
@ -912,16 +946,32 @@ smtp(nullserver, d_flags, e)
fd = sm_io_getinfo(InChannel, SM_IO_WHAT_FD, NULL); fd = sm_io_getinfo(InChannel, SM_IO_WHAT_FD, NULL);
FD_ZERO(&readfds); FD_ZERO(&readfds);
SM_FD_SET(fd, &readfds); SM_FD_SET(fd, &readfds);
#if _FFR_LOG_GREET_PAUSE
gettimeofday(&bp, NULL);
#endif /* _FFR_LOG_GREET_PAUSE */
if (select(fd + 1, FDSET_CAST &readfds, if (select(fd + 1, FDSET_CAST &readfds,
NULL, NULL, &timeout) > 0 && NULL, NULL, &timeout) > 0 &&
FD_ISSET(fd, &readfds)) FD_ISSET(fd, &readfds))
{ {
#if _FFR_LOG_GREET_PAUSE
gettimeofday(&ep, NULL);
timersub(&ep, &bp, &tp);
#endif /* _FFR_LOG_GREET_PAUSE */
greetcode = "554"; greetcode = "554";
nullserver = "Command rejected"; nullserver = "Command rejected";
sm_syslog(LOG_INFO, e->e_id, sm_syslog(LOG_INFO, e->e_id,
#if _FFR_LOG_GREET_PAUSE
"rejecting commands from %s [%s] after %d seconds due to pre-greeting traffic",
#else /* _FFR_LOG_GREET_PAUSE */
"rejecting commands from %s [%s] due to pre-greeting traffic", "rejecting commands from %s [%s] due to pre-greeting traffic",
#endif /* _FFR_LOG_GREET_PAUSE */
peerhostname, peerhostname,
anynet_ntoa(&RealHostAddr)); anynet_ntoa(&RealHostAddr)
#if _FFR_LOG_GREET_PAUSE
, (int) tp.tv_sec +
(tp.tv_usec >= 500000 ? 1 : 0)
#endif /* _FFR_LOG_GREET_PAUSE */
);
} }
} }
} }
@ -1693,97 +1743,26 @@ smtp(nullserver, d_flags, e)
# define SSL_ACC(s) SSL_accept(s) # define SSL_ACC(s) SSL_accept(s)
tlsstart = curtime(); tlsstart = curtime();
fdfl = fcntl(rfd, F_GETFL);
if (fdfl != -1)
fcntl(rfd, F_SETFL, fdfl|O_NONBLOCK);
ssl_retry: ssl_retry:
if ((r = SSL_ACC(srv_ssl)) <= 0) if ((r = SSL_ACC(srv_ssl)) <= 0)
{ {
int i; int i, ssl_err;
bool timedout;
time_t left;
time_t now = curtime();
struct timeval tv;
/* what to do in this case? */ ssl_err = SSL_get_error(srv_ssl, r);
i = SSL_get_error(srv_ssl, r); i = tls_retry(srv_ssl, rfd, wfd, tlsstart,
TimeOuts.to_starttls, ssl_err,
"server");
if (i > 0)
goto ssl_retry;
/*
** For SSL_ERROR_WANT_{READ,WRITE}:
** There is no SSL record available yet
** or there is only a partial SSL record
** removed from the network (socket) buffer
** into the SSL buffer. The SSL_accept will
** only succeed when a full SSL record is
** available (assuming a "real" error
** doesn't happen). To handle when a "real"
** error does happen the select is set for
** exceptions too.
** The connection may be re-negotiated
** during this time so both read and write
** "want errors" need to be handled.
** A select() exception loops back so that
** a proper SSL error message can be gotten.
*/
left = TimeOuts.to_starttls - (now - tlsstart);
timedout = left <= 0;
if (!timedout)
{
tv.tv_sec = left;
tv.tv_usec = 0;
}
if (!timedout && FD_SETSIZE > 0 &&
(rfd >= FD_SETSIZE ||
(i == SSL_ERROR_WANT_WRITE &&
wfd >= FD_SETSIZE)))
{
if (LogLevel > 5)
{
sm_syslog(LOG_ERR, NOQID,
"STARTTLS=server, error: fd %d/%d too large",
rfd, wfd);
if (LogLevel > 8)
tlslogerr("server");
}
goto tlsfail;
}
/* XXX what about SSL_pending() ? */
if (!timedout && i == SSL_ERROR_WANT_READ)
{
fd_set ssl_maskr, ssl_maskx;
FD_ZERO(&ssl_maskr);
FD_SET(rfd, &ssl_maskr);
FD_ZERO(&ssl_maskx);
FD_SET(rfd, &ssl_maskx);
if (select(rfd + 1, &ssl_maskr, NULL,
&ssl_maskx, &tv) > 0)
goto ssl_retry;
}
if (!timedout && i == SSL_ERROR_WANT_WRITE)
{
fd_set ssl_maskw, ssl_maskx;
FD_ZERO(&ssl_maskw);
FD_SET(wfd, &ssl_maskw);
FD_ZERO(&ssl_maskx);
FD_SET(rfd, &ssl_maskx);
if (select(wfd + 1, NULL, &ssl_maskw,
&ssl_maskx, &tv) > 0)
goto ssl_retry;
}
if (LogLevel > 5) if (LogLevel > 5)
{ {
sm_syslog(LOG_WARNING, NOQID, sm_syslog(LOG_WARNING, NOQID,
"STARTTLS=server, error: accept failed=%d, SSL_error=%d, timedout=%d, errno=%d", "STARTTLS=server, error: accept failed=%d, SSL_error=%d, errno=%d, retry=%d",
r, i, (int) timedout, errno); r, ssl_err, errno, i);
if (LogLevel > 8) if (LogLevel > 8)
tlslogerr("server"); tlslogerr("server");
} }
tlsfail:
tls_ok_srv = false; tls_ok_srv = false;
SSL_free(srv_ssl); SSL_free(srv_ssl);
srv_ssl = NULL; srv_ssl = NULL;
@ -1798,9 +1777,6 @@ smtp(nullserver, d_flags, e)
goto doquit; goto doquit;
} }
if (fdfl != -1)
fcntl(rfd, F_SETFL, fdfl);
/* ignore return code for now, it's in {verify} */ /* ignore return code for now, it's in {verify} */
(void) tls_get_info(srv_ssl, true, (void) tls_get_info(srv_ssl, true,
CurSmtpClient, CurSmtpClient,
@ -1998,10 +1974,8 @@ smtp(nullserver, d_flags, e)
q = "accepting invalid domain name"; q = "accepting invalid domain name";
} }
if (gothello) if (gothello || smtp.sm_gotmail)
{
CLEAR_STATE(cmdbuf); CLEAR_STATE(cmdbuf);
}
#if MILTER #if MILTER
if (smtp.sm_milterlist && smtp.sm_milterize && if (smtp.sm_milterlist && smtp.sm_milterize &&
@ -2039,6 +2013,19 @@ smtp(nullserver, d_flags, e)
tempfail = true; tempfail = true;
smtp.sm_milterize = false; smtp.sm_milterize = false;
break; break;
case SMFIR_SHUTDOWN:
if (MilterLogLevel > 3)
sm_syslog(LOG_INFO, e->e_id,
"Milter: Milter: helo=%s, reject=421 4.7.0 %s closing connection",
p, MyHostName);
tempfail = true;
smtp.sm_milterize = false;
message("421 4.7.0 %s closing connection",
MyHostName);
/* arrange to ignore send list */
e->e_sendqueue = NULL;
goto doquit;
} }
if (response != NULL) if (response != NULL)
sm_free(response); sm_free(response);
@ -2475,7 +2462,11 @@ smtp(nullserver, d_flags, e)
goto rcpt_done; goto rcpt_done;
} }
if (e->e_sendmode != SM_DELIVER) if (e->e_sendmode != SM_DELIVER
#if _FFR_DM_ONE
&& (NotFirstDelivery || SM_DM_ONE != e->e_sendmode)
#endif /* _FFR_DM_ONE */
)
e->e_flags |= EF_VRFYONLY; e->e_flags |= EF_VRFYONLY;
#if MILTER #if MILTER
@ -2900,7 +2891,7 @@ smtp(nullserver, d_flags, e)
case CMDNOOP: /* noop -- do nothing */ case CMDNOOP: /* noop -- do nothing */
DELAY_CONN("NOOP"); DELAY_CONN("NOOP");
STOP_IF_ATTACK(checksmtpattack(&n_noop, MAXNOOPCOMMANDS, STOP_IF_ATTACK(checksmtpattack(&n_noop, MaxNOOPCommands,
true, "NOOP", e)); true, "NOOP", e));
message("250 2.0.0 OK"); message("250 2.0.0 OK");
break; break;
@ -2974,6 +2965,9 @@ smtp(nullserver, d_flags, e)
finis(true, true, ExitStat); finis(true, true, ExitStat);
/* NOTREACHED */ /* NOTREACHED */
/* just to avoid bogus warning from some compilers */
exit(EX_OSERR);
case CMDVERB: /* set verbose mode */ case CMDVERB: /* set verbose mode */
DELAY_CONN("VERB"); DELAY_CONN("VERB");
if (!bitset(SRV_OFFER_EXPN, features) || if (!bitset(SRV_OFFER_EXPN, features) ||
@ -2983,7 +2977,7 @@ smtp(nullserver, d_flags, e)
message("502 5.7.0 Verbose unavailable"); message("502 5.7.0 Verbose unavailable");
break; break;
} }
STOP_IF_ATTACK(checksmtpattack(&n_noop, MAXNOOPCOMMANDS, STOP_IF_ATTACK(checksmtpattack(&n_noop, MaxNOOPCommands,
true, "VERB", e)); true, "VERB", e));
Verbose = 1; Verbose = 1;
set_delivery_mode(SM_DELIVER, e); set_delivery_mode(SM_DELIVER, e);
@ -3044,7 +3038,8 @@ smtp(nullserver, d_flags, e)
MILTER_REPLY("unknown"); MILTER_REPLY("unknown");
if (state == SMFIR_REPLYCODE || if (state == SMFIR_REPLYCODE ||
state == SMFIR_REJECT || state == SMFIR_REJECT ||
state == SMFIR_TEMPFAIL) state == SMFIR_TEMPFAIL ||
state == SMFIR_SHUTDOWN)
{ {
/* MILTER_REPLY already gave an error */ /* MILTER_REPLY already gave an error */
break; break;
@ -3111,6 +3106,7 @@ smtp_data(smtp, e)
char *id; char *id;
char *oldid; char *oldid;
char buf[32]; char buf[32];
bool rv = true;
SmtpPhase = "server DATA"; SmtpPhase = "server DATA";
if (!smtp->sm_gotmail) if (!smtp->sm_gotmail)
@ -3149,7 +3145,8 @@ smtp_data(smtp, e)
LogUsrErrs = false; LogUsrErrs = false;
} }
usrerr(response); usrerr(response);
if (strncmp(response, "421 ", 4) == 0) if (strncmp(response, "421 ", 4) == 0
|| strncmp(response, "421-", 4) == 0)
{ {
e->e_sendqueue = NULL; e->e_sendqueue = NULL;
return false; return false;
@ -3183,6 +3180,18 @@ smtp_data(smtp, e)
} }
usrerr(MSG_TEMPFAIL); usrerr(MSG_TEMPFAIL);
return true; return true;
case SMFIR_SHUTDOWN:
if (MilterLogLevel > 3)
{
sm_syslog(LOG_INFO, e->e_id,
"Milter: cmd=data, reject=421 4.7.0 %s closing connection",
MyHostName);
LogUsrErrs = false;
}
usrerr("421 4.7.0 %s closing connection", MyHostName);
e->e_sendqueue = NULL;
return false;
} }
LogUsrErrs = savelogusrerrs; LogUsrErrs = savelogusrerrs;
if (response != NULL) if (response != NULL)
@ -3273,6 +3282,16 @@ smtp_data(smtp, e)
milteraccept = false; milteraccept = false;
usrerr(MSG_TEMPFAIL); usrerr(MSG_TEMPFAIL);
break; break;
case SMFIR_SHUTDOWN:
if (MilterLogLevel > 3)
sm_syslog(LOG_INFO, e->e_id,
"Milter: data, reject=421 4.7.0 %s closing connection",
MyHostName);
milteraccept = false;
usrerr("421 4.7.0 %s closing connection", MyHostName);
rv = false;
break;
} }
if (response != NULL) if (response != NULL)
sm_free(response); sm_free(response);
@ -3451,8 +3470,26 @@ smtp_data(smtp, e)
} }
else else
{ {
int mode;
/* send to all recipients */ /* send to all recipients */
sendall(ee, SM_DEFAULT); mode = SM_DEFAULT;
#if _FFR_DM_ONE
if (SM_DM_ONE == e->e_sendmode)
{
if (NotFirstDelivery)
{
mode = SM_QUEUE;
e->e_sendmode = SM_QUEUE;
}
else
{
mode = SM_FORK;
NotFirstDelivery = true;
}
}
#endif /* _FFR_DM_ONE */
sendall(ee, mode);
} }
ee->e_to = NULL; ee->e_to = NULL;
} }
@ -3462,6 +3499,16 @@ smtp_data(smtp, e)
CurEnv->e_id = id; CurEnv->e_id = id;
/* issue success message */ /* issue success message */
#if _FFR_MSG_ACCEPT
if (MessageAccept != NULL && *MessageAccept != '\0')
{
char msg[MAXLINE];
expand(MessageAccept, msg, sizeof msg, e);
message("250 2.0.0 %s", msg);
}
else
#endif /* _FFR_MSG_ACCEPT */
message("250 2.0.0 %s Message accepted for delivery", id); message("250 2.0.0 %s Message accepted for delivery", id);
CurEnv->e_id = oldid; CurEnv->e_id = oldid;
@ -3566,7 +3613,7 @@ smtp_data(smtp, e)
macdefine(&e->e_macro, A_PERM, macdefine(&e->e_macro, A_PERM,
macid("{quarantine}"), e->e_quarmsg); macid("{quarantine}"), e->e_quarmsg);
} }
return true; return rv;
} }
/* /*
** LOGUNDELRCPTS -- log undelivered (or all) recipients. ** LOGUNDELRCPTS -- log undelivered (or all) recipients.

View File

@ -11,11 +11,11 @@
*/ */
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: timers.c,v 8.24 2001/09/11 04:05:17 gshapiro Exp $") SM_RCSID("@(#)$Id: timers.c,v 8.25 2005/06/14 23:07:23 ca Exp $")
#if _FFR_TIMERS #if _FFR_TIMERS
# include <sys/types.h> # include <sys/types.h>
# include <sys/time.h> # include <sm/time.h>
# include "sendmail.h" # include "sendmail.h"
# include <sys/resource.h> /* Must be after sendmail.h for NCR MP-RAS */ # include <sys/resource.h> /* Must be after sendmail.h for NCR MP-RAS */

View File

@ -10,7 +10,7 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: tls.c,v 8.97 2005/03/08 22:20:52 ca Exp $") SM_RCSID("@(#)$Id: tls.c,v 8.102 2006/03/02 19:18:27 ca Exp $")
#if STARTTLS #if STARTTLS
# include <openssl/err.h> # include <openssl/err.h>
@ -497,6 +497,15 @@ tls_safe_f(var, sff, srv)
** succeeded? ** succeeded?
*/ */
/*
** The session_id_context identifies the service that created a session.
** This information is used to distinguish between multiple TLS-based
** servers running on the same server. We use the name of the mail system.
** Note: the session cache is not persistent.
*/
static char server_session_id_context[] = "sendmail8";
bool bool
inittls(ctx, req, srv, certfile, keyfile, cacertpath, cacertfile, dhparam) inittls(ctx, req, srv, certfile, keyfile, cacertpath, cacertfile, dhparam)
SSL_CTX **ctx; SSL_CTX **ctx;
@ -972,8 +981,20 @@ inittls(ctx, req, srv, certfile, keyfile, cacertpath, cacertfile, dhparam)
/* XXX do we need this cache here? */ /* XXX do we need this cache here? */
if (bitset(TLS_I_CACHE, req)) if (bitset(TLS_I_CACHE, req))
SSL_CTX_sess_set_cache_size(*ctx, 128); {
/* timeout? SSL_CTX_set_timeout(*ctx, TimeOut...); */ SSL_CTX_sess_set_cache_size(*ctx, 1);
SSL_CTX_set_timeout(*ctx, 1);
SSL_CTX_set_session_id_context(*ctx,
(void *) &server_session_id_context,
sizeof(server_session_id_context));
(void) SSL_CTX_set_session_cache_mode(*ctx,
SSL_SESS_CACHE_SERVER);
}
else
{
(void) SSL_CTX_set_session_cache_mode(*ctx,
SSL_SESS_CACHE_OFF);
}
/* load certificate locations and default CA paths */ /* load certificate locations and default CA paths */
if (bitset(TLS_S_CERTP_EX, status) && bitset(TLS_S_CERTF_EX, status)) if (bitset(TLS_S_CERTP_EX, status) && bitset(TLS_S_CERTF_EX, status))
@ -1557,7 +1578,7 @@ tls_verify_cb(ctx, unused)
void void
tlslogerr(who) tlslogerr(who)
char *who; const char *who;
{ {
unsigned long l; unsigned long l;
int line, flags; int line, flags;

View File

@ -14,9 +14,9 @@
#include <sendmail.h> #include <sendmail.h>
#if USERDB #if USERDB
SM_RCSID("@(#)$Id: udb.c,v 8.160 2003/04/03 16:32:46 ca Exp $ (with USERDB)") SM_RCSID("@(#)$Id: udb.c,v 8.161 2005/08/31 21:34:20 ca Exp $ (with USERDB)")
#else /* USERDB */ #else /* USERDB */
SM_RCSID("@(#)$Id: udb.c,v 8.160 2003/04/03 16:32:46 ca Exp $ (without USERDB)") SM_RCSID("@(#)$Id: udb.c,v 8.161 2005/08/31 21:34:20 ca Exp $ (without USERDB)")
#endif /* USERDB */ #endif /* USERDB */
#if USERDB #if USERDB
@ -137,7 +137,7 @@ udbexpand(a, sendq, aliaslevel, e)
int keylen; int keylen;
int naddrs; int naddrs;
char *user; char *user;
char keybuf[MAXKEY]; char keybuf[MAXUDBKEY];
memset(&key, '\0', sizeof key); memset(&key, '\0', sizeof key);
memset(&info, '\0', sizeof info); memset(&info, '\0', sizeof info);
@ -597,7 +597,7 @@ udbmatch(user, field, rpool)
int i; int i;
int keylen; int keylen;
DBT key, info; DBT key, info;
char keybuf[MAXKEY]; char keybuf[MAXUDBKEY];
if (tTd(28, 1)) if (tTd(28, 1))
sm_dprintf("udbmatch(%s, %s)\n", user, field); sm_dprintf("udbmatch(%s, %s)\n", user, field);
@ -1232,7 +1232,7 @@ hes_udb_get(key, info)
{ {
char *name, *type; char *name, *type;
char **hp; char **hp;
char kbuf[MAXKEY + 1]; char kbuf[MAXUDBKEY + 1];
if (sm_strlcpy(kbuf, key->data, sizeof kbuf) >= sizeof kbuf) if (sm_strlcpy(kbuf, key->data, sizeof kbuf) >= sizeof kbuf)
return 0; return 0;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -13,12 +13,11 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: usersmtp.c,v 8.463 2005/03/16 00:36:09 ca Exp $") SM_RCSID("@(#)$Id: usersmtp.c,v 8.467 2006/03/19 06:07:56 ca Exp $")
#include <sysexits.h> #include <sysexits.h>
static void datatimeout __P((int));
static void esmtp_check __P((char *, bool, MAILER *, MCI *, ENVELOPE *)); static void esmtp_check __P((char *, bool, MAILER *, MCI *, ENVELOPE *));
static void helo_options __P((char *, bool, MAILER *, MCI *, ENVELOPE *)); static void helo_options __P((char *, bool, MAILER *, MCI *, ENVELOPE *));
static int smtprcptstat __P((ADDRESS *, MAILER *, MCI *, ENVELOPE *)); static int smtprcptstat __P((ADDRESS *, MAILER *, MCI *, ENVELOPE *));
@ -34,7 +33,6 @@ extern void sm_sasl_free __P((void *));
** This protocol is described in RFC821. ** This protocol is described in RFC821.
*/ */
#define REPLYTYPE(r) ((r) / 100) /* first digit of reply code */
#define REPLYCLASS(r) (((r) / 10) % 10) /* second digit of reply code */ #define REPLYCLASS(r) (((r) / 10) % 10) /* second digit of reply code */
#define SMTPCLOSING 421 /* "Service Shutting Down" */ #define SMTPCLOSING 421 /* "Service Shutting Down" */
@ -2491,9 +2489,6 @@ smtprcptstat(to, m, mci, e)
** exit status corresponding to DATA command. ** exit status corresponding to DATA command.
*/ */
static jmp_buf CtxDataTimeout;
static SM_EVENT *volatile DataTimeout = NULL;
int int
smtpdata(m, mci, e, ctladdr, xstart) smtpdata(m, mci, e, ctladdr, xstart)
MAILER *m; MAILER *m;
@ -2505,7 +2500,7 @@ smtpdata(m, mci, e, ctladdr, xstart)
register int r; register int r;
int rstat; int rstat;
int xstat; int xstat;
time_t timeout; int timeout;
char *enhsc; char *enhsc;
/* /*
@ -2629,43 +2624,22 @@ smtpdata(m, mci, e, ctladdr, xstart)
** factor. The main thing is that it should not be infinite. ** factor. The main thing is that it should not be infinite.
*/ */
if (setjmp(CtxDataTimeout) != 0)
{
mci->mci_errno = errno;
mci->mci_state = MCIS_ERROR;
mci_setstat(mci, EX_TEMPFAIL, "4.4.2", NULL);
/*
** If putbody() couldn't finish due to a timeout,
** rewind it here in the timeout handler. See
** comments at the end of putbody() for reasoning.
*/
if (e->e_dfp != NULL)
(void) bfrewind(e->e_dfp);
errno = mci->mci_errno;
syserr("451 4.4.1 timeout writing message to %s", CurHostName);
smtpquit(m, mci, e);
return EX_TEMPFAIL;
}
if (tTd(18, 101)) if (tTd(18, 101))
{ {
/* simulate a DATA timeout */ /* simulate a DATA timeout */
timeout = 1; timeout = 10;
} }
else else
timeout = DATA_PROGRESS_TIMEOUT; timeout = DATA_PROGRESS_TIMEOUT * 1000;
sm_io_setinfo(mci->mci_out, SM_IO_WHAT_TIMEOUT, &timeout);
DataTimeout = sm_setevent(timeout, datatimeout, 0);
/* /*
** Output the actual message. ** Output the actual message.
*/ */
(*e->e_puthdr)(mci, e->e_header, e, M87F_OUTER); if (!(*e->e_puthdr)(mci, e->e_header, e, M87F_OUTER))
goto writeerr;
if (tTd(18, 101)) if (tTd(18, 101))
{ {
@ -2673,14 +2647,13 @@ smtpdata(m, mci, e, ctladdr, xstart)
(void) sleep(2); (void) sleep(2);
} }
(*e->e_putbody)(mci, e, NULL); if (!(*e->e_putbody)(mci, e, NULL))
goto writeerr;
/* /*
** Cleanup after sending message. ** Cleanup after sending message.
*/ */
if (DataTimeout != NULL)
sm_clrevent(DataTimeout);
#if PIPELINING #if PIPELINING
} }
@ -2720,7 +2693,9 @@ smtpdata(m, mci, e, ctladdr, xstart)
} }
/* terminate the message */ /* terminate the message */
(void) sm_io_fprintf(mci->mci_out, SM_TIME_DEFAULT, ".%s", m->m_eol); if (sm_io_fprintf(mci->mci_out, SM_TIME_DEFAULT, ".%s", m->m_eol) ==
SM_IO_EOF)
goto writeerr;
if (TrafficLogFile != NULL) if (TrafficLogFile != NULL)
(void) sm_io_fprintf(TrafficLogFile, SM_TIME_DEFAULT, (void) sm_io_fprintf(TrafficLogFile, SM_TIME_DEFAULT,
"%05d >>> .\n", (int) CurrentPid); "%05d >>> .\n", (int) CurrentPid);
@ -2771,51 +2746,27 @@ smtpdata(m, mci, e, ctladdr, xstart)
shortenstring(SmtpReplyBuffer, 403)); shortenstring(SmtpReplyBuffer, 403));
} }
return rstat; return rstat;
}
static void writeerr:
datatimeout(ignore) mci->mci_errno = errno;
int ignore; mci->mci_state = MCIS_ERROR;
{ mci_setstat(mci, EX_TEMPFAIL, "4.4.2", NULL);
int save_errno = errno;
/* /*
** NOTE: THIS CAN BE CALLED FROM A SIGNAL HANDLER. DO NOT ADD ** If putbody() couldn't finish due to a timeout,
** ANYTHING TO THIS ROUTINE UNLESS YOU KNOW WHAT YOU ARE ** rewind it here in the timeout handler. See
** DOING. ** comments at the end of putbody() for reasoning.
*/ */
if (DataProgress) if (e->e_dfp != NULL)
{ (void) bfrewind(e->e_dfp);
time_t timeout;
/* check back again later */ errno = mci->mci_errno;
if (tTd(18, 101)) syserr("451 4.4.1 timeout writing message to %s", CurHostName);
{ smtpquit(m, mci, e);
/* simulate a DATA timeout */ return EX_TEMPFAIL;
timeout = 1;
}
else
timeout = DATA_PROGRESS_TIMEOUT;
/* reset the timeout */
DataTimeout = sm_sigsafe_setevent(timeout, datatimeout, 0);
DataProgress = false;
}
else
{
/* event is done */
DataTimeout = NULL;
}
/* if no progress was made or problem resetting event, die now */
if (DataTimeout == NULL)
{
errno = ETIMEDOUT;
longjmp(CtxDataTimeout, 1);
}
errno = save_errno;
} }
/* /*
** SMTPGETSTAT -- get status code from DATA in LMTP ** SMTPGETSTAT -- get status code from DATA in LMTP
** **
@ -3021,6 +2972,8 @@ smtprset(m, mci, e)
if (mci->mci_state != MCIS_SSD && mci->mci_state != MCIS_CLOSED) if (mci->mci_state != MCIS_SSD && mci->mci_state != MCIS_CLOSED)
mci->mci_state = MCIS_OPEN; mci->mci_state = MCIS_OPEN;
else if (mci->mci_exitstat == EX_OK)
mci_setstat(mci, EX_TEMPFAIL, "4.5.0", NULL);
} }
/* /*
** SMTPPROBE -- check the connection state ** SMTPPROBE -- check the connection state

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -13,7 +13,7 @@
#include <sendmail.h> #include <sendmail.h>
SM_RCSID("@(#)$Id: util.c,v 8.383 2004/08/02 18:50:59 ca Exp $") SM_RCSID("@(#)$Id: util.c,v 8.392 2006/03/09 19:49:35 ca Exp $")
#include <sysexits.h> #include <sysexits.h>
#include <sm/xtrap.h> #include <sm/xtrap.h>
@ -456,6 +456,8 @@ xalloc(sz)
{ {
register char *p; register char *p;
SM_REQUIRE(sz >= 0);
/* some systems can't handle size zero mallocs */ /* some systems can't handle size zero mallocs */
if (sz <= 0) if (sz <= 0)
sz = 1; sz = 1;
@ -970,18 +972,18 @@ fixcrlf(line, stripnl)
** mci -- the mailer connection information. ** mci -- the mailer connection information.
** **
** Returns: ** Returns:
** none ** true iff line was written successfully
** **
** Side Effects: ** Side Effects:
** output of l to mci->mci_out. ** output of l to mci->mci_out.
*/ */
void bool
putline(l, mci) putline(l, mci)
register char *l; register char *l;
register MCI *mci; register MCI *mci;
{ {
putxline(l, strlen(l), mci, PXLF_MAPFROM); return putxline(l, strlen(l), mci, PXLF_MAPFROM);
} }
/* /*
** PUTXLINE -- putline with flags bits. ** PUTXLINE -- putline with flags bits.
@ -1000,13 +1002,13 @@ putline(l, mci)
** PXLF_NOADDEOL -- don't add an EOL if one wasn't present. ** PXLF_NOADDEOL -- don't add an EOL if one wasn't present.
** **
** Returns: ** Returns:
** none ** true iff line was written successfully
** **
** Side Effects: ** Side Effects:
** output of l to mci->mci_out. ** output of l to mci->mci_out.
*/ */
void bool
putxline(l, len, mci, pxflags) putxline(l, len, mci, pxflags)
register char *l; register char *l;
size_t len; size_t len;
@ -1058,11 +1060,6 @@ putxline(l, len, mci, pxflags)
if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT, if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT,
'.') == SM_IO_EOF) '.') == SM_IO_EOF)
dead = true; dead = true;
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
if (TrafficLogFile != NULL) if (TrafficLogFile != NULL)
(void) sm_io_putc(TrafficLogFile, (void) sm_io_putc(TrafficLogFile,
SM_TIME_DEFAULT, '.'); SM_TIME_DEFAULT, '.');
@ -1075,11 +1072,6 @@ putxline(l, len, mci, pxflags)
if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT, if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT,
'>') == SM_IO_EOF) '>') == SM_IO_EOF)
dead = true; dead = true;
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
if (TrafficLogFile != NULL) if (TrafficLogFile != NULL)
(void) sm_io_putc(TrafficLogFile, (void) sm_io_putc(TrafficLogFile,
SM_TIME_DEFAULT, SM_TIME_DEFAULT,
@ -1091,16 +1083,11 @@ putxline(l, len, mci, pxflags)
while (l < q) while (l < q)
{ {
if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT, if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT,
(unsigned char) *l++) == SM_IO_EOF) (unsigned char) *l++) == SM_IO_EOF)
{ {
dead = true; dead = true;
break; break;
} }
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
} }
if (dead) if (dead)
break; break;
@ -1116,11 +1103,6 @@ putxline(l, len, mci, pxflags)
dead = true; dead = true;
break; break;
} }
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
if (TrafficLogFile != NULL) if (TrafficLogFile != NULL)
{ {
for (l = l_base; l < q; l++) for (l = l_base; l < q; l++)
@ -1144,11 +1126,9 @@ putxline(l, len, mci, pxflags)
{ {
if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT, '.') == if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT, '.') ==
SM_IO_EOF) SM_IO_EOF)
break;
else
{ {
/* record progress for DATA timeout */ dead = true;
DataProgress = true; break;
} }
if (TrafficLogFile != NULL) if (TrafficLogFile != NULL)
(void) sm_io_putc(TrafficLogFile, (void) sm_io_putc(TrafficLogFile,
@ -1161,11 +1141,9 @@ putxline(l, len, mci, pxflags)
{ {
if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT, '>') == if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT, '>') ==
SM_IO_EOF) SM_IO_EOF)
break;
else
{ {
/* record progress for DATA timeout */ dead = true;
DataProgress = true; break;
} }
if (TrafficLogFile != NULL) if (TrafficLogFile != NULL)
(void) sm_io_putc(TrafficLogFile, (void) sm_io_putc(TrafficLogFile,
@ -1183,11 +1161,6 @@ putxline(l, len, mci, pxflags)
dead = true; dead = true;
break; break;
} }
else
{
/* record progress for DATA timeout */
DataProgress = true;
}
} }
if (dead) if (dead)
break; break;
@ -1198,11 +1171,9 @@ putxline(l, len, mci, pxflags)
if ((!bitset(PXLF_NOADDEOL, pxflags) || !noeol) && if ((!bitset(PXLF_NOADDEOL, pxflags) || !noeol) &&
sm_io_fputs(mci->mci_out, SM_TIME_DEFAULT, sm_io_fputs(mci->mci_out, SM_TIME_DEFAULT,
mci->mci_mailer->m_eol) == SM_IO_EOF) mci->mci_mailer->m_eol) == SM_IO_EOF)
break;
else
{ {
/* record progress for DATA timeout */ dead = true;
DataProgress = true; break;
} }
if (l < end && *l == '\n') if (l < end && *l == '\n')
{ {
@ -1211,11 +1182,9 @@ putxline(l, len, mci, pxflags)
{ {
if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT, if (sm_io_putc(mci->mci_out, SM_TIME_DEFAULT,
' ') == SM_IO_EOF) ' ') == SM_IO_EOF)
break;
else
{ {
/* record progress for DATA timeout */ dead = true;
DataProgress = true; break;
} }
if (TrafficLogFile != NULL) if (TrafficLogFile != NULL)
@ -1224,10 +1193,10 @@ putxline(l, len, mci, pxflags)
} }
} }
/* record progress for DATA timeout */
DataProgress = true;
} while (l < end); } while (l < end);
return !dead;
} }
/* /*
** XUNLINK -- unlink a file, doing logging as appropriate. ** XUNLINK -- unlink a file, doing logging as appropriate.
** **
@ -2096,6 +2065,9 @@ prog_open(argv, pfd, e)
/* run as default user */ /* run as default user */
endpwent(); endpwent();
sm_mbdb_terminate(); sm_mbdb_terminate();
#if _FFR_MEMSTAT
(void) sm_memstat_close();
#endif /* _FFR_MEMSTAT */
if (setgid(DefGid) < 0 && geteuid() == 0) if (setgid(DefGid) < 0 && geteuid() == 0)
{ {
syserr("prog_open: setgid(%ld) failed", (long) DefGid); syserr("prog_open: setgid(%ld) failed", (long) DefGid);
@ -2433,6 +2405,7 @@ str2prt(s)
*h++ = 'r'; *h++ = 'r';
break; break;
default: default:
SM_ASSERT(l >= 2);
(void) sm_snprintf(h, l, "%03o", (void) sm_snprintf(h, l, "%03o",
(unsigned int)((unsigned char) c)); (unsigned int)((unsigned char) c));
@ -2669,11 +2642,11 @@ proc_list_drop(pid, st, other)
type = ProcListVec[i].proc_type; type = ProcListVec[i].proc_type;
if (other != NULL) if (other != NULL)
*other = ProcListVec[i].proc_other; *other = ProcListVec[i].proc_other;
if (CurChildren > 0)
CurChildren--;
break; break;
} }
} }
if (CurChildren > 0)
CurChildren--;
if (type == PROC_CONTROL && WIFEXITED(st)) if (type == PROC_CONTROL && WIFEXITED(st))
@ -2732,14 +2705,20 @@ proc_list_clear()
void void
proc_list_probe() proc_list_probe()
{ {
int i; int i, children;
int chldwasblocked;
pid_t pid;
children = 0;
chldwasblocked = sm_blocksignal(SIGCHLD);
/* start from 1 since 0 is the daemon itself */ /* start from 1 since 0 is the daemon itself */
for (i = 1; i < ProcListSize; i++) for (i = 1; i < ProcListSize; i++)
{ {
if (ProcListVec[i].proc_pid == NO_PID) pid = ProcListVec[i].proc_pid;
if (pid == NO_PID || pid == CurrentPid)
continue; continue;
if (kill(ProcListVec[i].proc_pid, 0) < 0) if (kill(pid, 0) < 0)
{ {
if (LogLevel > 3) if (LogLevel > 3)
sm_syslog(LOG_DEBUG, CurEnv->e_id, sm_syslog(LOG_DEBUG, CurEnv->e_id,
@ -2749,9 +2728,21 @@ proc_list_probe()
SM_FREE_CLR(ProcListVec[i].proc_task); SM_FREE_CLR(ProcListVec[i].proc_task);
CurChildren--; CurChildren--;
} }
else
{
++children;
}
} }
if (CurChildren < 0) if (CurChildren < 0)
CurChildren = 0; CurChildren = 0;
if (chldwasblocked == 0)
(void) sm_releasesignal(SIGCHLD);
if (LogLevel > 10 && children != CurChildren)
{
sm_syslog(LOG_ERR, NOQID,
"proc_list_probe: found %d children, expected %d",
children, CurChildren);
}
} }
/* /*
@ -2859,7 +2850,6 @@ count_open_connections(hostaddr)
{ {
if (ProcListVec[i].proc_pid == NO_PID) if (ProcListVec[i].proc_pid == NO_PID)
continue; continue;
if (hostaddr->sa.sa_family != if (hostaddr->sa.sa_family !=
ProcListVec[i].proc_hostaddr.sa.sa_family) ProcListVec[i].proc_hostaddr.sa.sa_family)
continue; continue;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998-2005 Sendmail, Inc. and its suppliers. * Copyright (c) 1998-2006 Sendmail, Inc. and its suppliers.
* All rights reserved. * All rights reserved.
* Copyright (c) 1983 Eric P. Allman. All rights reserved. * Copyright (c) 1983 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -13,6 +13,6 @@
#include <sm/gen.h> #include <sm/gen.h>
SM_RCSID("@(#)$Id: version.c,v 8.145 2005/03/25 18:44:44 ca Exp $") SM_RCSID("@(#)$Id: version.c,v 8.160 2006/03/08 19:21:21 ca Exp $")
char Version[] = "8.13.4"; char Version[] = "8.13.6";