From b37a166a402ac326a03b91fa7302ad3db6e29b3b Mon Sep 17 00:00:00 2001 From: Gregory Neil Shapiro Date: Mon, 14 Feb 2005 02:58:21 +0000 Subject: [PATCH 1/2] Remove files no longer in vendor distribution from vendor branch --- contrib/sendmail/cf/feature/nodns.m4 | 22 ------ contrib/sendmail/contrib/oldbind.compat.c | 79 -------------------- contrib/sendmail/libsm/vsprintf.c | 66 ----------------- contrib/sendmail/libsm/vsscanf.c | 87 ----------------------- 4 files changed, 254 deletions(-) delete mode 100644 contrib/sendmail/cf/feature/nodns.m4 delete mode 100644 contrib/sendmail/contrib/oldbind.compat.c delete mode 100644 contrib/sendmail/libsm/vsprintf.c delete mode 100644 contrib/sendmail/libsm/vsscanf.c diff --git a/contrib/sendmail/cf/feature/nodns.m4 b/contrib/sendmail/cf/feature/nodns.m4 deleted file mode 100644 index c5acadf7eceb..000000000000 --- a/contrib/sendmail/cf/feature/nodns.m4 +++ /dev/null @@ -1,22 +0,0 @@ -divert(-1) -# -# Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers. -# All rights reserved. -# Copyright (c) 1983 Eric P. Allman. All rights reserved. -# Copyright (c) 1988, 1993 -# The Regents of the University of California. 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. -# -# - -divert(0) -VERSIONID(`$Id: nodns.m4,v 8.14 1999/07/22 17:55:35 gshapiro Exp $') -divert(-1) - -undefine(`confBIND_OPTS')dnl -errprint(`FEATURE(nodns) is no-op. -Use ServiceSwitchFile ('ifdef(`confSERVICE_SWITCH_FILE',confSERVICE_SWITCH_FILE,MAIL_SETTINGS_DIR`service.switch')`) if your OS does not provide its own instead. -') diff --git a/contrib/sendmail/contrib/oldbind.compat.c b/contrib/sendmail/contrib/oldbind.compat.c deleted file mode 100644 index 1621a7ba5e80..000000000000 --- a/contrib/sendmail/contrib/oldbind.compat.c +++ /dev/null @@ -1,79 +0,0 @@ -/* -** OLDBIND.COMPAT.C -** -** Very old systems do not have res_query(), res_querydomain() or -** res_search(), so emulate them here. -** -** You really ought to be upgrading to a newer version of BIND -** (4.8.2 or later) rather than be using this. -** -** J.R. Oldroyd -*/ - -#include -#include -#include -#include - -typedef union -{ - HEADER qb1; - char qb2[PACKETSZ]; -} querybuf; - -res_query(dname, class, type, data, datalen) - char * dname; - int class; - int type; - char * data; - int datalen; -{ - int n; - querybuf buf; - - n = res_mkquery(QUERY, dname, class, type, (char *) NULL, 0, - NULL, (char *) &buf, sizeof buf); - n = res_send((char *)&buf, n, data, datalen); - - return n; -} - -res_querydomain(host, dname, class, type, data, datalen) - char * host; - char * dname; - int class; - int type; - char * data; - int datalen; -{ - int n; - querybuf buf; - char dbuf[256]; - - strcpy(dbuf, host); - if (dbuf[strlen(dbuf)-1] != '.') - strcat(dbuf, "."); - strcat(dbuf, dname); - n = res_mkquery(QUERY, dbuf, class, type, (char *) NULL, 0, - NULL, (char *)&buf, sizeof buf); - n = res_send((char *) &buf, n, data, datalen); - - return n; -} - -res_search(dname, class, type, data, datalen) - char * dname; - int class; - int type; - char * data; - int datalen; -{ - int n; - querybuf buf; - - n = res_mkquery(QUERY, dname, class, type, (char *)NULL, 0, - NULL, (char *) &buf, sizeof buf); - n = res_send((char *) &buf, n, data, datalen); - - return n; -} diff --git a/contrib/sendmail/libsm/vsprintf.c b/contrib/sendmail/libsm/vsprintf.c deleted file mode 100644 index 827fcec5a955..000000000000 --- a/contrib/sendmail/libsm/vsprintf.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. - * All rights reserved. - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * 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_RCSID("@(#)$Id: vsprintf.c,v 1.21 2001/09/11 04:04:49 gshapiro Exp $") -#include -#include -#include "local.h" - -/* -** SM_VSPRINTF -- format data for "output" into a string -** -** Assigned 'str' to a "fake" file pointer. This allows common -** o/p formatting function sm_vprintf() to be used. -** -** Parameters: -** str -- location for output -** fmt -- format directives -** ap -- data unit vectors for use by 'fmt' -** -** Results: -** result from sm_io_vfprintf() -** -** Side Effects: -** Quietly limits the size to INT_MAX though this may -** not prevent SEGV's. -*/ - -int -sm_vsprintf(str, fmt, ap) - char *str; - const char *fmt; - SM_VA_LOCAL_DECL -{ - int ret; - SM_FILE_T fake; - - fake.sm_magic = SmFileMagic; - fake.f_file = -1; - fake.f_flags = SMWR | SMSTR; - fake.f_bf.smb_base = fake.f_p = (unsigned char *)str; - fake.f_bf.smb_size = fake.f_w = INT_MAX; - fake.f_timeout = SM_TIME_FOREVER; - fake.f_timeoutstate = SM_TIME_BLOCK; - fake.f_close = NULL; - fake.f_open = NULL; - fake.f_read = NULL; - fake.f_write = NULL; - fake.f_seek = NULL; - fake.f_setinfo = fake.f_getinfo = NULL; - fake.f_type = "sm_vsprintf:fake"; - ret = sm_io_vfprintf(&fake, SM_TIME_FOREVER, fmt, ap); - *fake.f_p = '\0'; - return ret; -} diff --git a/contrib/sendmail/libsm/vsscanf.c b/contrib/sendmail/libsm/vsscanf.c deleted file mode 100644 index 498f44992e45..000000000000 --- a/contrib/sendmail/libsm/vsscanf.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers. - * All rights reserved. - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Donn Seeley at UUNET Technologies, Inc. - * - * 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_RCSID("@(#)$Id: vsscanf.c,v 1.23 2002/02/01 02:28:00 ca Exp $") -#include -#include - -/* -** SM_EOFREAD -- dummy read function for faked file below -** -** Parameters: -** fp -- file pointer -** buf -- location to place read data -** len -- number of bytes to read -** -** Returns: -** 0 (zero) always -*/ - -/* type declaration for later use */ -static ssize_t sm_eofread __P((SM_FILE_T *, char *, size_t)); - -/* ARGSUSED0 */ -static ssize_t -sm_eofread(fp, buf, len) - SM_FILE_T *fp; - char *buf; - size_t len; -{ - return 0; -} - -/* -** SM_VSSCANF -- scan a string to find data units -** -** Parameters: -** str -- strings containing data -** fmt -- format directive for finding data units -** ap -- memory locations to place format found data units -** -** Returns: -** Failure: SM_IO_EOF -** Success: number of data units found -** -** Side Effects: -** Attempts to strlen() 'str'; if not a '\0' terminated string -** then the call may SEGV/fail. -** Faking the string 'str' as a file. -*/ - -int -sm_vsscanf(str, fmt, ap) - const char *str; - const char *fmt; - SM_VA_LOCAL_DECL -{ - SM_FILE_T fake; - - fake.sm_magic = SmFileMagic; - fake.f_timeout = SM_TIME_FOREVER; - fake.f_timeoutstate = SM_TIME_BLOCK; - fake.f_file = -1; - fake.f_flags = SMRD; - fake.f_bf.smb_base = fake.f_p = (unsigned char *)str; - fake.f_bf.smb_size = fake.f_r = strlen(str); - fake.f_read = sm_eofread; - fake.f_ub.smb_base = NULL; - fake.f_close = NULL; - fake.f_open = NULL; - fake.f_write = NULL; - fake.f_seek = NULL; - fake.f_setinfo = fake.f_getinfo = NULL; - fake.f_type = "sm_vsscanf:fake"; - return sm_vfscanf(&fake, SM_TIME_FOREVER, fmt, ap); -} From 27bec48138ffa668d5c5d3b1e87f82e533befb5c Mon Sep 17 00:00:00 2001 From: Gregory Neil Shapiro Date: Mon, 14 Feb 2005 03:04:18 +0000 Subject: [PATCH 2/2] Commit patch from sendmail.org web site for socket close bug: http://www.sendmail.org/patches/close_wait.p2 This is being put in the vendor branch as it is in the vendor's repo. --- contrib/sendmail/src/mci.c | 51 +++++++++++++++++++++++++++++++++ contrib/sendmail/src/sendmail.h | 1 + contrib/sendmail/src/usersmtp.c | 8 ++++-- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/contrib/sendmail/src/mci.c b/contrib/sendmail/src/mci.c index 4955197a6ebb..4ff75780bfbc 100644 --- a/contrib/sendmail/src/mci.c +++ b/contrib/sendmail/src/mci.c @@ -398,6 +398,57 @@ mci_get(host, m) return mci; } + +/* +** MCI_CLOSE -- (forcefully) close files used for a connection. +** Note: this is a last resort, usually smtpquit() or endmailer() +** should be used to close a connection. +** +** Parameters: +** mci -- the connection to close. +** where -- where has this been called? +** +** Returns: +** none. +*/ + +void +mci_close(mci, where) + MCI *mci; + char *where; +{ + bool dumped; + + if (mci == NULL) + return; + dumped = false; + if (mci->mci_out != NULL) + { + if (tTd(56, 1)) + { + sm_dprintf("mci_close: mci_out!=NULL, where=%s\n", + where); + mci_dump(sm_debug_file(), mci, false); + dumped = true; + } + (void) sm_io_close(mci->mci_out, SM_TIME_DEFAULT); + mci->mci_out = NULL; + } + if (mci->mci_in != NULL) + { + if (tTd(56, 1)) + { + sm_dprintf("mci_close: mci_in!=NULL, where=%s\n", + where); + if (!dumped) + mci_dump(sm_debug_file(), mci, false); + } + (void) sm_io_close(mci->mci_in, SM_TIME_DEFAULT); + mci->mci_in = NULL; + } + mci->mci_state = MCIS_CLOSED; +} + /* ** MCI_NEW -- allocate new MCI structure ** diff --git a/contrib/sendmail/src/sendmail.h b/contrib/sendmail/src/sendmail.h index 673cee5cf073..370fae856b89 100644 --- a/contrib/sendmail/src/sendmail.h +++ b/contrib/sendmail/src/sendmail.h @@ -728,6 +728,7 @@ MCI /* functions */ extern void mci_cache __P((MCI *)); +extern void mci_close __P((MCI *, char *where)); extern void mci_dump __P((SM_FILE_T *, MCI *, bool)); extern void mci_dump_all __P((SM_FILE_T *, bool)); extern void mci_flush __P((bool, MCI *)); diff --git a/contrib/sendmail/src/usersmtp.c b/contrib/sendmail/src/usersmtp.c index 0bcbcf51bbf1..24b09549a12a 100644 --- a/contrib/sendmail/src/usersmtp.c +++ b/contrib/sendmail/src/usersmtp.c @@ -89,6 +89,7 @@ smtpinit(m, mci, e, onlyhelo) */ SmtpError[0] = '\0'; + SmtpMsgBuffer[0] = '\0'; CurHostName = mci->mci_host; /* XXX UGLY XXX */ if (CurHostName == NULL) CurHostName = MyHostName; @@ -2899,7 +2900,10 @@ smtpquit(m, mci, e) char *oldcurhost; if (mci->mci_state == MCIS_CLOSED) + { + mci_close(mci, "smtpquit:1"); return; + } oldcurhost = CurHostName; CurHostName = mci->mci_host; /* XXX UGLY XXX */ @@ -3133,7 +3137,7 @@ reply(m, mci, e, timeout, pfunc, enhstat, rtype) if (strncmp(SmtpMsgBuffer, "QUIT", 4) == 0) { errno = mci->mci_errno; - mci->mci_state = MCIS_CLOSED; + mci_close(mci, "reply:1"); return -1; } mci->mci_state = MCIS_ERROR; @@ -3158,7 +3162,7 @@ reply(m, mci, e, timeout, pfunc, enhstat, rtype) /* errors on QUIT should be ignored */ if (strncmp(SmtpMsgBuffer, "QUIT", 4) == 0) { - mci->mci_state = MCIS_CLOSED; + mci_close(mci, "reply:2"); return -1; }