summaryrefslogtreecommitdiff
path: root/contrib/sendmail/src
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/sendmail/src')
-rwxr-xr-xcontrib/sendmail/src/Build13
-rw-r--r--contrib/sendmail/src/bf_portable.c525
-rw-r--r--contrib/sendmail/src/bf_portable.h46
-rw-r--r--contrib/sendmail/src/bf_torek.c831
-rw-r--r--contrib/sendmail/src/bf_torek.h42
-rw-r--r--contrib/sendmail/src/cdefs.h123
-rw-r--r--contrib/sendmail/src/clock.c513
-rw-r--r--contrib/sendmail/src/ldap_map.h91
-rw-r--r--contrib/sendmail/src/mailstats.h34
-rwxr-xr-xcontrib/sendmail/src/makesendmail13
-rw-r--r--contrib/sendmail/src/pathnames.h32
-rw-r--r--contrib/sendmail/src/safefile.c751
-rw-r--r--contrib/sendmail/src/sendmail.hf124
-rw-r--r--contrib/sendmail/src/snprintf.c428
-rw-r--r--contrib/sendmail/src/useful.h58
15 files changed, 0 insertions, 3624 deletions
diff --git a/contrib/sendmail/src/Build b/contrib/sendmail/src/Build
deleted file mode 100755
index 72db61a2bda9e..0000000000000
--- a/contrib/sendmail/src/Build
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-# Copyright (c) 1999-2000 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: Build,v 8.5.2.1 2000/04/10 06:41:07 gshapiro Exp $
-
-exec sh ../devtools/bin/Build $*
diff --git a/contrib/sendmail/src/bf_portable.c b/contrib/sendmail/src/bf_portable.c
deleted file mode 100644
index f14077ff161c2..0000000000000
--- a/contrib/sendmail/src/bf_portable.c
+++ /dev/null
@@ -1,525 +0,0 @@
-/*
- * Copyright (c) 1999-2001 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.
- *
- * Contributed by Exactis.com, Inc.
- *
- */
-
-#ifndef lint
-static char id[] = "@(#)$Id: bf_portable.c,v 8.25.4.6 2001/05/03 17:24:01 gshapiro Exp $";
-#endif /* ! lint */
-
-#if SFIO
-# include <sfio/stdio.h>
-#endif /* SFIO */
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/uio.h>
-#include <errno.h>
-#if !SFIO
-# include <stdio.h>
-#endif /* !SFIO */
-#ifdef BF_STANDALONE
-# define sm_free free
-# define xalloc malloc
-#else /* BF_STANDALONE */
-# include "sendmail.h"
-#endif /* BF_STANDALONE */
-#include "bf_portable.h"
-#include "bf.h"
-
- /*
-** BFOPEN -- create a new buffered file
-**
-** Parameters:
-** filename -- the file's name
-** fmode -- what mode the file should be created as
-** bsize -- amount of buffer space to allocate (may be 0)
-** flags -- if running under sendmail, passed directly to safeopen
-**
-** Returns:
-** a FILE * which may then be used with stdio functions, or NULL
-** on failure. FILE * is opened for writing (mode "w+").
-**
-** Side Effects:
-** none.
-**
-** Sets errno:
-** ENOMEM -- out of memory
-** ENOENT -- illegal empty filename specified
-** any value of errno specified by open()
-** any value of errno specified by fdopen()
-** any value of errno specified by funopen()
-*/
-
-#ifdef BF_STANDALONE
-# define OPEN(fn, omode, cmode, sff) open(fn, omode, cmode)
-#else /* BF_STANDALONE */
-# define OPEN(fn, omode, cmode, sff) safeopen(fn, omode, cmode, sff)
-#endif /* BF_STANDALONE */
-
-/* List of currently-open buffered files */
-struct bf *bflist = NULL;
-
-FILE *
-bfopen(filename, fmode, bsize, flags)
- char *filename;
- int fmode;
- size_t bsize;
- long flags;
-{
- struct bf *bfp;
- FILE *retval;
- int fd, l;
-
- fd = OPEN(filename, O_RDWR | O_CREAT | O_TRUNC, fmode, flags);
- if (fd == -1)
- {
- /* errno is set implicitly by open */
- return NULL;
- }
-
- retval = fdopen(fd, "w+");
-
- /* If failure, return immediately */
- if (retval == NULL)
- {
- /* errno is set implicitly by fdopen */
- return NULL;
- }
-
- /* Allocate memory */
- bfp = (struct bf *)xalloc(sizeof(struct bf));
- if (bfp == NULL)
- {
- (void) fclose(retval);
-
- /* don't care about errors */
- (void) unlink(filename);
- errno = ENOMEM;
- return NULL;
- }
- if (tTd(58, 8))
- dprintf("bfopen(%s): malloced %ld\n",
- filename, (long) sizeof(struct bf));
-
- l = strlen(filename) + 1;
- bfp->bf_filename = (char *)xalloc(l);
- if (bfp->bf_filename == NULL)
- {
- sm_free(bfp);
- (void) fclose(retval);
-
- /* don't care about errors */
- (void) unlink(filename);
- errno = ENOMEM;
- return NULL;
- }
- (void) strlcpy(bfp->bf_filename, filename, l);
-
- /* Fill in the other fields, then add it to the list */
- bfp->bf_key = retval;
- bfp->bf_committed = FALSE;
- bfp->bf_refcount = 1;
-
- bfinsert(bfp);
-
- /* Whew. Nothing bad happened. We're okay. */
- return retval;
-}
- /*
-** BFDUP -- increase refcount on buffered file
-**
-** Parameters:
-** fp -- FILE * to "duplicate"
-**
-** Returns:
-** fp with increased refcount
-*/
-
-FILE *
-bfdup(fp)
- FILE *fp;
-{
- struct bf *bfp;
-
- /* Get associated bf structure */
- bfp = bflookup(fp);
-
- if (bfp == NULL)
- return NULL;
-
- /* Increase the refcount */
- bfp->bf_refcount++;
-
- return fp;
-}
-
- /*
-** BFCOMMIT -- "commits" the buffered file
-**
-** Parameters:
-** fp -- FILE * to commit to disk
-**
-** Returns:
-** 0 on success, -1 on error
-**
-** Side Effects:
-** Forces the given FILE * to be written to disk if it is not
-** already, and ensures that it will be kept after closing. If
-** fp is not a buffered file, this is a no-op.
-**
-** Sets errno:
-** any value of errno specified by open()
-** any value of errno specified by write()
-** any value of errno specified by lseek()
-*/
-
-int
-bfcommit(fp)
- FILE *fp;
-{
- struct bf *bfp;
-
- /* Get associated bf structure */
- bfp = bflookup(fp);
-
- /* If called on a normal FILE *, noop */
- if (bfp != NULL)
- bfp->bf_committed = TRUE;
-
- return 0;
-}
-
- /*
-** BFREWIND -- rewinds the FILE *
-**
-** Parameters:
-** fp -- FILE * to rewind
-**
-** Returns:
-** 0 on success, -1 on error
-**
-** Side Effects:
-** rewinds the FILE * and puts it into read mode. Normally one
-** would bfopen() a file, write to it, then bfrewind() and
-** fread(). If fp is not a buffered file, this is equivalent to
-** rewind().
-**
-** Sets errno:
-** any value of errno specified by fseek()
-*/
-
-int
-bfrewind(fp)
- FILE *fp;
-{
- int err;
-
- /* check to see if there is an error on the stream */
- err = ferror(fp);
- (void) fflush(fp);
-
- /*
- ** Clear error if tried to fflush()
- ** a read-only file pointer and
- ** there wasn't a previous error.
- */
-
- if (err == 0)
- clearerr(fp);
-
- /* errno is set implicitly by fseek() before return */
- return fseek(fp, 0, SEEK_SET);
-}
-
- /*
-** BFTRUNCATE -- rewinds and truncates the FILE *
-**
-** Parameters:
-** fp -- FILE * to truncate
-**
-** Returns:
-** 0 on success, -1 on error
-**
-** Side Effects:
-** rewinds the FILE *, truncates it to zero length, and puts it
-** into write mode. If fp is not a buffered file, this is
-** equivalent to a rewind() and then an ftruncate(fileno(fp), 0).
-**
-** Sets errno:
-** any value of errno specified by fseek()
-** any value of errno specified by ftruncate()
-*/
-
-int
-bftruncate(fp)
- FILE *fp;
-{
- int ret;
-
- if (bfrewind(fp) == -1)
- {
- /* errno is set implicitly by bfrewind() */
- return -1;
- }
-
-#if NOFTRUNCATE
- /* XXX */
- errno = EINVAL;
- ret = -1;
-#else /* NOFTRUNCATE */
- /* errno is set implicitly by ftruncate() before return */
- ret = ftruncate(fileno(fp), 0);
-#endif /* NOFTRUNCATE */
- return ret;
-}
-
- /*
-** BFFSYNC -- fsync the fd associated with the FILE *
-**
-** Parameters:
-** fp -- FILE * to fsync
-**
-** Returns:
-** 0 on success, -1 on error
-**
-** Sets errno:
-** EINVAL if FILE * not bfcommitted yet.
-** any value of errno specified by fsync()
-*/
-
-int
-bffsync(fp)
- FILE *fp;
-{
- int fd;
- struct bf *bfp;
-
- /* Get associated bf structure */
- bfp = bflookup(fp);
-
- /* If called on a normal FILE *, noop */
- if (bfp != NULL && !bfp->bf_committed)
- fd = -1;
- else
- fd = fileno(fp);
-
- if (tTd(58, 10))
- dprintf("bffsync: fd = %d\n", fd);
-
- if (fd < 0)
- {
- errno = EINVAL;
- return -1;
- }
- return fsync(fd);
-}
-
- /*
-** BFCLOSE -- close a buffered file
-**
-** Parameters:
-** fp -- FILE * to close
-**
-** Returns:
-** 0 on success, EOF on failure
-**
-** Side Effects:
-** Closes fp. If fp is a buffered file, unlink it if it has not
-** already been committed. If fp is not a buffered file, this is
-** equivalent to fclose().
-**
-** Sets errno:
-** any value of errno specified by fclose()
-*/
-
-int
-bfclose(fp)
- FILE *fp;
-{
- int retval;
- struct bf *bfp = NULL;
-
- /* Get associated bf structure */
- bfp = bflookup(fp);
-
- /* Decrement and check refcount */
- if (bfp != NULL && --bfp->bf_refcount > 0)
- return 0;
-
- /* If bf, get bf structure and remove from list */
- if (bfp != NULL)
- bfp = bfdelete(fp);
-
- if (fclose(fp) == EOF)
- {
- if (tTd(58, 8))
- dprintf("bfclose: fclose failed\n");
- /* errno is set implicitly by fclose() */
- return -1;
- }
-
- if (bfp == NULL)
- return 0;
-
- /* Success unless we determine otherwise in next block */
- retval = 0;
-
- if (bfp != NULL)
- {
- /* Might have to unlink; certainly will have to deallocate */
- if (!bfp->bf_committed)
- retval = unlink(bfp->bf_filename);
-
- sm_free(bfp->bf_filename);
- sm_free(bfp);
- if (tTd(58, 8))
- dprintf("bfclose: freed %ld\n",
- (long) sizeof(struct bf));
- }
- else
- {
- if (tTd(58, 8))
- dprintf("bfclose: bfp was NULL\n");
- }
-
- return retval;
-}
-
- /*
-** BFTEST -- test if a FILE * is a buffered file
-**
-** Parameters:
-** fp -- FILE * to test
-**
-** Returns:
-** TRUE if fp is a buffered file, FALSE otherwise.
-**
-** Side Effects:
-** none.
-**
-** Sets errno:
-** never.
-*/
-
-bool
-bftest(fp)
- FILE *fp;
-{
- return (bflookup(fp) != NULL);
-}
-
- /*
-** BFINSERT -- insert item in linking list
-**
-** Parameters:
-** datum -- item to insert
-**
-** Returns:
-** none.
-**
-** Side Effects:
-** none.
-**
-** Sets errno:
-** never.
-*/
-
-void
-bfinsert(datum)
- struct bf *datum;
-{
- datum->bf_cdr = bflist;
- bflist = datum;
-}
-
- /*
-** BFLOOKUP -- lookup FILE * in list
-**
-** Parameters:
-** fp -- FILE * to lookup
-**
-** Returns:
-** bf struct for the FILE *, NULL if not found
-**
-** Side Effects:
-** none.
-**
-** Sets errno:
-** never.
-*/
-
-struct bf *
-bflookup(key)
- FILE *key;
-{
- struct bf *t;
-
- for (t = bflist; t != NULL; t = t->bf_cdr)
- {
- if (t->bf_key == key)
- {
- return t;
- }
- }
-
- /* If we got this far, we didn't find it */
- return NULL;
-}
-
- /*
-** BFDELETE -- delete a FILE * in list
-**
-** Parameters:
-** fp -- FILE * to delete
-**
-** Returns:
-** bf struct for deleted FILE *, NULL if not found,
-**
-** Side Effects:
-** none.
-**
-** Sets errno:
-** never.
-*/
-
-struct bf *
-bfdelete(key)
- FILE *key;
-{
- struct bf *t, *u;
-
- if (bflist == NULL)
- return NULL;
-
- /* if first element, special case */
- if (bflist->bf_key == key)
- {
- u = bflist;
- bflist = bflist->bf_cdr;
- return u;
- }
-
- for (t = bflist; t->bf_cdr != NULL; t = t->bf_cdr)
- {
- if (t->bf_cdr->bf_key == key)
- {
- u = t->bf_cdr;
- t->bf_cdr = u->bf_cdr;
- return u;
- }
- }
-
- /* If we got this far, we didn't find it */
- return NULL;
-}
diff --git a/contrib/sendmail/src/bf_portable.h b/contrib/sendmail/src/bf_portable.h
deleted file mode 100644
index e319a740399cb..0000000000000
--- a/contrib/sendmail/src/bf_portable.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1999 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: bf_portable.h,v 8.6 1999/11/04 19:31:25 ca Exp $
- *
- * Contributed by Exactis.com, Inc.
- *
- */
-
-#ifndef BF_PORTABLE_H
-#define BF_PORTABLE_H 1
-/*
-** This implementation will behave differently from the Torek-based code in
-** the following major ways:
-** - The buffer size argument to bfopen() will be sent in, sent back,
-** queried, lost, found, subjected to public inquiry, lost again, and
-** finally buried in soft peat and recycled as firelighters.
-** - Errors in creating the file (but not necessarily writing to it) will
-** always be detected and reported synchronously with the bfopen()
-*/
-
-/* Linked structure for storing information about each buffered file */
-struct bf
-{
- FILE *bf_key; /* Unused except as a key for lookup */
- bool bf_committed; /* buffered file is on disk */
- char *bf_filename; /* Name of disk file */
- int bf_refcount; /* Reference count */
- struct bf *bf_cdr;
-};
-
-/*
-** Access routines for looking up bf structures
-**
-** maybe replace with a faster data structure later
-*/
-
-extern void bfinsert __P((struct bf *));
-extern struct bf *bflookup __P((FILE *));
-extern struct bf *bfdelete __P((FILE *));
-#endif /* BF_PORTABLE_H */
diff --git a/contrib/sendmail/src/bf_torek.c b/contrib/sendmail/src/bf_torek.c
deleted file mode 100644
index f74aecd413522..0000000000000
--- a/contrib/sendmail/src/bf_torek.c
+++ /dev/null
@@ -1,831 +0,0 @@
-/*
- * Copyright (c) 1999-2001 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.
- *
- * Contributed by Exactis.com, Inc.
- *
- */
-
-#ifndef lint
-static char id[] = "@(#)$Id: bf_torek.c,v 8.19.18.6 2001/05/08 06:52:19 gshapiro Exp $";
-#endif /* ! lint */
-
-#if SFIO
- ERROR README: Can not use bf_torek.c with SFIO.
-#endif /* SFIO */
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-#ifdef BF_STANDALONE
-# define sm_free free
-# define xalloc malloc
-#else /* BF_STANDALONE */
-# include "sendmail.h"
-#endif /* BF_STANDALONE */
-#include "bf_torek.h"
-#include "bf.h"
-
- /*
-** BFOPEN -- create a new buffered file
-**
-** Parameters:
-** filename -- the file's name
-** fmode -- what mode the file should be created as
-** bsize -- amount of buffer space to allocate (may be 0)
-** flags -- if running under sendmail, passed directly to safeopen
-**
-** Returns:
-** a FILE * which may then be used with stdio functions, or NULL
-** on failure. FILE * is opened for writing (mode "w+").
-**
-** Side Effects:
-** none.
-**
-** Sets errno:
-** ENOMEM -- out of memory
-** ENOENT -- illegal empty filename specified
-** any value of errno specified by open()
-** any value of errno specified by fdopen()
-** any value of errno specified by funopen()
-*/
-
-#ifdef BF_STANDALONE
-# define OPEN(fn, omode, cmode, sff) open(fn, omode, cmode)
-#else /* BF_STANDALONE */
-# define OPEN(fn, omode, cmode, sff) safeopen(fn, omode, cmode, sff)
-#endif /* BF_STANDALONE */
-
-FILE *
-bfopen(filename, fmode, bsize, flags)
- char *filename;
- int fmode;
- size_t bsize;
- long flags;
-{
- struct bf *bfp;
- FILE *retval;
- int save_errno, l;
- struct stat st;
-
- /* Sanity checks */
- /* Empty filename string */
- if (*filename == '\0')
- {
- errno = ENOENT;
- return NULL;
- }
-
- if (stat(filename, &st) == 0)
- {
- /* file already exists on disk */
- errno = EEXIST;
- return NULL;
- }
-
- /* Allocate memory */
- bfp = (struct bf *)xalloc(sizeof(struct bf));
- if (bfp == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
-
- /* A zero bsize is valid, just don't allocate memory */
- if (bsize > 0)
- {
- bfp->bf_buf = (char *)xalloc(bsize);
- if (bfp->bf_buf == NULL)
- {
- sm_free(bfp);
- errno = ENOMEM;
- return NULL;
- }
- }
- else
- bfp->bf_buf = NULL;
-
- /* Nearly home free, just set all the parameters now */
- bfp->bf_committed = FALSE;
- bfp->bf_ondisk = FALSE;
- bfp->bf_refcount = 1;
- bfp->bf_flags = flags;
- bfp->bf_bufsize = bsize;
- bfp->bf_buffilled = 0;
- l = strlen(filename) + 1;
- bfp->bf_filename = (char *)xalloc(l);
- if (bfp->bf_filename == NULL)
- {
- if (bfp->bf_buf != NULL)
- sm_free(bfp->bf_buf);
- sm_free(bfp);
- errno = ENOMEM;
- return NULL;
- }
- (void) strlcpy(bfp->bf_filename, filename, l);
- bfp->bf_filemode = fmode;
- bfp->bf_offset = 0;
- bfp->bf_size = 0;
-
- if (tTd(58, 8))
- dprintf("bfopen(%s, %d)\n", filename, bsize);
-
- /* The big test: will funopen accept it? */
- retval = funopen((void *)bfp, _bfread, _bfwrite, _bfseek, _bfclose);
- if (retval == NULL)
- {
- /* Just in case free() sets errno */
- save_errno = errno;
- sm_free(bfp->bf_filename);
- if (bfp->bf_buf != NULL)
- sm_free(bfp->bf_buf);
- sm_free(bfp);
- errno = save_errno;
- return NULL;
- }
- else
- {
- /* Success */
- return retval;
- }
-}
- /*
-** BFDUP -- increase refcount on buffered file
-**
-** Parameters:
-** fp -- FILE * to "duplicate"
-**
-** Returns:
-** If file is memory buffered, fp with increased refcount
-** If file is on disk, NULL (need to use link())
-*/
-
-FILE *
-bfdup(fp)
- FILE *fp;
-{
- struct bf *bfp;
-
- /* If called on a normal FILE *, noop */
- if (!bftest(fp))
- return NULL;
-
- /* Get associated bf structure */
- bfp = (struct bf *)fp->_cookie;
-
- /* Increase ref count */
- bfp->bf_refcount++;
-
- return fp;
-}
-
- /*
-** BFCOMMIT -- "commits" the buffered file
-**
-** Parameters:
-** fp -- FILE * to commit to disk
-**
-** Returns:
-** 0 on success, -1 on error
-**
-** Side Effects:
-** Forces the given FILE * to be written to disk if it is not
-** already, and ensures that it will be kept after closing. If
-** fp is not a buffered file, this is a no-op.
-**
-** Sets errno:
-** any value of errno specified by open()
-** any value of errno specified by write()
-** any value of errno specified by lseek()
-*/
-
-int
-bfcommit(fp)
- FILE *fp;
-{
- struct bf *bfp;
- int retval;
- int byteswritten;
-
- /* If called on a normal FILE *, noop */
- if (!bftest(fp))
- return 0;
-
- /* Get associated bf structure */
- bfp = (struct bf *)fp->_cookie;
-
- /* If already committed, noop */
- if (bfp->bf_committed)
- return 0;
-
- /* Do we need to open a file? */
- if (!bfp->bf_ondisk)
- {
- struct stat st;
-
- if (tTd(58, 8))
- dprintf("bfcommit(%s): to disk\n", bfp->bf_filename);
-
- if (stat(bfp->bf_filename, &st) == 0)
- {
- errno = EEXIST;
- return -1;
- }
-
- retval = OPEN(bfp->bf_filename, O_RDWR | O_CREAT | O_TRUNC,
- bfp->bf_filemode, bfp->bf_flags);
-
- /* Couldn't create file: failure */
- if (retval < 0)
- {
- /* errno is set implicitly by open() */
- return -1;
- }
-
- bfp->bf_disk_fd = retval;
- bfp->bf_ondisk = TRUE;
- }
-
- /* Write out the contents of our buffer, if we have any */
- if (bfp->bf_buffilled > 0)
- {
- byteswritten = 0;
-
- if (lseek(bfp->bf_disk_fd, 0, SEEK_SET) < 0)
- {
- /* errno is set implicitly by lseek() */
- return -1;
- }
-
- while (byteswritten < bfp->bf_buffilled)
- {
- retval = write(bfp->bf_disk_fd,
- bfp->bf_buf + byteswritten,
- bfp->bf_buffilled - byteswritten);
- if (retval < 0)
- {
- /* errno is set implicitly by write() */
- return -1;
- }
- else
- byteswritten += retval;
- }
- }
- bfp->bf_committed = TRUE;
-
- /* Invalidate buf; all goes to file now */
- bfp->bf_buffilled = 0;
- if (bfp->bf_bufsize > 0)
- {
- /* Don't need buffer anymore; free it */
- bfp->bf_bufsize = 0;
- sm_free(bfp->bf_buf);
- }
- return 0;
-}
-
- /*
-** BFREWIND -- rewinds the FILE *
-**
-** Parameters:
-** fp -- FILE * to rewind
-**
-** Returns:
-** 0 on success, -1 on error
-**
-** Side Effects:
-** rewinds the FILE * and puts it into read mode. Normally one
-** would bfopen() a file, write to it, then bfrewind() and
-** fread(). If fp is not a buffered file, this is equivalent to
-** rewind().
-**
-** Sets errno:
-** any value of errno specified by fseek()
-*/
-
-int
-bfrewind(fp)
- FILE *fp;
-{
- int err;
-
- /* check to see if there is an error on the stream */
- err = ferror(fp);
- (void) fflush(fp);
-
- /*
- ** Clear error if tried to fflush()
- ** a read-only file pointer and
- ** there wasn't a previous error.
- */
-
- if (err == 0)
- clearerr(fp);
-
- /* errno is set implicitly by fseek() before return */
- return fseek(fp, 0, SEEK_SET);
-}
-
- /*
-** BFTRUNCATE -- rewinds and truncates the FILE *
-**
-** Parameters:
-** fp -- FILE * to truncate
-**
-** Returns:
-** 0 on success, -1 on error
-**
-** Side Effects:
-** rewinds the FILE *, truncates it to zero length, and puts it
-** into write mode. If fp is not a buffered file, this is
-** equivalent to a rewind() and then an ftruncate(fileno(fp), 0).
-**
-** Sets errno:
-** any value of errno specified by fseek()
-** any value of errno specified by ftruncate()
-*/
-
-int
-bftruncate(fp)
- FILE *fp;
-{
- struct bf *bfp;
-
- if (bfrewind(fp) < 0)
- return -1;
-
- if (bftest(fp))
- {
- /* Get bf structure */
- bfp = (struct bf *)fp->_cookie;
- bfp->bf_buffilled = 0;
- bfp->bf_size = 0;
-
- /* Need to zero the buffer */
- if (bfp->bf_bufsize > 0)
- memset(bfp->bf_buf, '\0', bfp->bf_bufsize);
- if (bfp->bf_ondisk)
- return ftruncate(bfp->bf_disk_fd, 0);
- else
- return 0;
- }
- else
- return ftruncate(fileno(fp), 0);
-}
-
- /*
-** BFFSYNC -- fsync the fd associated with the FILE *
-**
-** Parameters:
-** fp -- FILE * to fsync
-**
-** Returns:
-** 0 on success, -1 on error
-**
-** Sets errno:
-** EINVAL if FILE * not bfcommitted yet.
-** any value of errno specified by fsync()
-*/
-
-int
-bffsync(fp)
- FILE *fp;
-{
- int fd;
- struct bf *bfp;
-
- if (bftest(fp))
- {
- /* Get bf structure */
- bfp = (struct bf *)fp->_cookie;
-
- if (bfp->bf_ondisk && bfp->bf_committed)
- fd = bfp->bf_disk_fd;
- else
- fd = -1;
- }
- else
- fd = fileno(fp);
-
- if (tTd(58, 10))
- dprintf("bffsync: fd = %d\n", fd);
-
- if (fd < 0)
- {
- errno = EINVAL;
- return -1;
- }
- return fsync(fd);
-}
-
- /*
-** BFCLOSE -- close a buffered file
-**
-** Parameters:
-** fp -- FILE * to close
-**
-** Returns:
-** 0 on success, EOF on failure
-**
-** Side Effects:
-** Closes fp. If fp is a buffered file, unlink it if it has not
-** already been committed. If fp is not a buffered file, this is
-** equivalent to fclose().
-**
-** Sets errno:
-** any value of errno specified by fclose()
-*/
-
-int
-bfclose(fp)
- FILE *fp;
-{
- struct bf *bfp;
-
- /* If called on a normal FILE *, call fclose() on it */
- if (!bftest(fp))
- return fclose(fp);
-
- /* Cast cookie back to correct type */
- bfp = (struct bf *)fp->_cookie;
-
- /* Check reference count to see if we actually want to close */
- if (bfp != NULL && --bfp->bf_refcount > 0)
- return 0;
-
- /*
- ** In this implementation, just call fclose--the _bfclose
- ** routine will be called by that
- */
-
- return fclose(fp);
-}
-
- /*
-** BFTEST -- test if a FILE * is a buffered file
-**
-** Parameters:
-** fp -- FILE * to test
-**
-** Returns:
-** TRUE if fp is a buffered file, FALSE otherwise.
-**
-** Side Effects:
-** none.
-**
-** Sets errno:
-** never.
-*/
-
-bool
-bftest(fp)
- FILE *fp;
-{
- /*
- ** Check to see if our special I/O routines are installed
- ** in this file structure
- */
-
- return ((fp->_close == _bfclose) &&
- (fp->_read == _bfread) &&
- (fp->_seek == _bfseek) &&
- (fp->_write == _bfwrite));
-}
-
- /*
-** _BFCLOSE -- close a buffered file
-**
-** Parameters:
-** cookie -- cookie of file to close
-**
-** Returns:
-** 0 to indicate success
-**
-** Side Effects:
-** deletes backing file, frees memory.
-**
-** Sets errno:
-** never.
-*/
-
-int
-_bfclose(cookie)
- void *cookie;
-{
- struct bf *bfp;
-
- /* Cast cookie back to correct type */
- bfp = (struct bf *)cookie;
-
- /* Need to clean up the file */
- if (bfp->bf_ondisk && !bfp->bf_committed)
- unlink(bfp->bf_filename);
-
- /* Need to free the buffer */
- if (bfp->bf_bufsize > 0)
- sm_free(bfp->bf_buf);
-
- /* Finally, free the structure */
- sm_free(bfp);
-
- return 0;
-}
-
- /*
-** _BFREAD -- read a buffered file
-**
-** Parameters:
-** cookie -- cookie of file to read
-** buf -- buffer to fill
-** nbytes -- how many bytes to read
-**
-** Returns:
-** number of bytes read or -1 indicate failure
-**
-** Side Effects:
-** none.
-**
-*/
-
-int
-_bfread(cookie, buf, nbytes)
- void *cookie;
- char *buf;
- int nbytes;
-{
- struct bf *bfp;
- int count = 0; /* Number of bytes put in buf so far */
- int retval;
-
- /* Cast cookie back to correct type */
- bfp = (struct bf *)cookie;
-
- if (bfp->bf_offset < bfp->bf_buffilled)
- {
- /* Need to grab some from buffer */
- count = nbytes;
- if ((bfp->bf_offset + count) > bfp->bf_buffilled)
- count = bfp->bf_buffilled - bfp->bf_offset;
-
- memcpy(buf, bfp->bf_buf + bfp->bf_offset, count);
- }
-
- if ((bfp->bf_offset + nbytes) > bfp->bf_buffilled)
- {
- /* Need to grab some from file */
-
- if (!bfp->bf_ondisk)
- {
- /* Oops, the file doesn't exist. EOF. */
- goto finished;
- }
-
- /* Catch a read() on an earlier failed write to disk */
- if (bfp->bf_disk_fd < 0)
- {
- errno = EIO;
- return -1;
- }
-
- if (lseek(bfp->bf_disk_fd,
- bfp->bf_offset + count, SEEK_SET) < 0)
- {
- if ((errno == EINVAL) || (errno == ESPIPE))
- {
- /*
- ** stdio won't be expecting these
- ** errnos from read()! Change them
- ** into something it can understand.
- */
-
- errno = EIO;
- }
- return -1;
- }
-
- while (count < nbytes)
- {
- retval = read(bfp->bf_disk_fd,
- buf + count,
- nbytes - count);
- if (retval < 0)
- {
- /* errno is set implicitly by read() */
- return -1;
- }
- else if (retval == 0)
- goto finished;
- else
- count += retval;
- }
- }
-
-finished:
- bfp->bf_offset += count;
- return count;
-}
-
- /*
-** _BFSEEK -- seek to a position in a buffered file
-**
-** Parameters:
-** cookie -- cookie of file to seek
-** offset -- position to seek to
-** whence -- how to seek
-**
-** Returns:
-** new file offset or -1 indicate failure
-**
-** Side Effects:
-** none.
-**
-*/
-
-fpos_t
-_bfseek(cookie, offset, whence)
- void *cookie;
- fpos_t offset;
- int whence;
-
-{
- struct bf *bfp;
-
- /* Cast cookie back to correct type */
- bfp = (struct bf *)cookie;
-
- switch (whence)
- {
- case SEEK_SET:
- bfp->bf_offset = offset;
- break;
-
- case SEEK_CUR:
- bfp->bf_offset += offset;
- break;
-
- case SEEK_END:
- bfp->bf_offset = bfp->bf_size + offset;
- break;
-
- default:
- errno = EINVAL;
- return -1;
- }
- return bfp->bf_offset;
-}
-
- /*
-** _BFWRITE -- write to a buffered file
-**
-** Parameters:
-** cookie -- cookie of file to write
-** buf -- data buffer
-** nbytes -- how many bytes to write
-**
-** Returns:
-** number of bytes written or -1 indicate failure
-**
-** Side Effects:
-** may create backing file if over memory limit for file.
-**
-*/
-
-int
-_bfwrite(cookie, buf, nbytes)
- void *cookie;
- const char *buf;
- int nbytes;
-{
- struct bf *bfp;
- int count = 0; /* Number of bytes written so far */
- int retval;
-
- /* Cast cookie back to correct type */
- bfp = (struct bf *)cookie;
-
- /* If committed, go straight to disk */
- if (bfp->bf_committed)
- {
- if (lseek(bfp->bf_disk_fd, bfp->bf_offset, SEEK_SET) < 0)
- {
- if ((errno == EINVAL) || (errno == ESPIPE))
- {
- /*
- ** stdio won't be expecting these
- ** errnos from write()! Change them
- ** into something it can understand.
- */
-
- errno = EIO;
- }
- return -1;
- }
-
- count = write(bfp->bf_disk_fd, buf, nbytes);
- if (count < 0)
- {
- /* errno is set implicitly by write() */
- return -1;
- }
- goto finished;
- }
-
- if (bfp->bf_offset < bfp->bf_bufsize)
- {
- /* Need to put some in buffer */
- count = nbytes;
- if ((bfp->bf_offset + count) > bfp->bf_bufsize)
- count = bfp->bf_bufsize - bfp->bf_offset;
-
- memcpy(bfp->bf_buf + bfp->bf_offset, buf, count);
- if ((bfp->bf_offset + count) > bfp->bf_buffilled)
- bfp->bf_buffilled = bfp->bf_offset + count;
- }
-
- if ((bfp->bf_offset + nbytes) > bfp->bf_bufsize)
- {
- /* Need to put some in file */
- if (!bfp->bf_ondisk)
- {
- /* Oops, the file doesn't exist. */
- if (tTd(58, 8))
- dprintf("_bfwrite(%s): to disk\n",
- bfp->bf_filename);
-
- retval = OPEN(bfp->bf_filename,
- O_RDWR | O_CREAT | O_TRUNC,
- bfp->bf_filemode, bfp->bf_flags);
-
- /* Couldn't create file: failure */
- if (retval < 0)
- {
- /*
- ** stdio may not be expecting these
- ** errnos from write()! Change to
- ** something which it can understand.
- ** Note that ENOSPC and EDQUOT are saved
- ** because they are actually valid for
- ** write().
- */
-
- if (!((errno == ENOSPC) || (errno == EDQUOT)))
- errno = EIO;
-
- return -1;
- }
- bfp->bf_disk_fd = retval;
- bfp->bf_ondisk = TRUE;
- }
-
- /* Catch a write() on an earlier failed write to disk */
- if (bfp->bf_ondisk && bfp->bf_disk_fd < 0)
- {
- errno = EIO;
- return -1;
- }
-
- if (lseek(bfp->bf_disk_fd,
- bfp->bf_offset + count, SEEK_SET) < 0)
- {
- if ((errno == EINVAL) || (errno == ESPIPE))
- {
- /*
- ** stdio won't be expecting these
- ** errnos from write()! Change them into
- ** something which it can understand.
- */
-
- errno = EIO;
- }
- return -1;
- }
-
- while (count < nbytes)
- {
- retval = write(bfp->bf_disk_fd, buf + count,
- nbytes - count);
- if (retval < 0)
- {
- /* errno is set implicitly by write() */
- return -1;
- }
- else
- count += retval;
- }
- }
-
-finished:
- bfp->bf_offset += count;
- if (bfp->bf_offset > bfp->bf_size)
- bfp->bf_size = bfp->bf_offset;
- return count;
-}
diff --git a/contrib/sendmail/src/bf_torek.h b/contrib/sendmail/src/bf_torek.h
deleted file mode 100644
index 48c3995b0d1f9..0000000000000
--- a/contrib/sendmail/src/bf_torek.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 1999 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: bf_torek.h,v 8.6 1999/11/04 19:31:25 ca Exp $
- *
- * Contributed by Exactis.com, Inc.
- *
- */
-
-#ifndef BF_TOREK_H
-#define BF_TOREK_H 1
-/*
-** Data structure for storing information about each buffered file
-*/
-
-struct bf
-{
- bool bf_committed; /* Has this buffered file been committed? */
- bool bf_ondisk; /* On disk: committed or buffer overflow */
- int bf_flags;
- int bf_disk_fd; /* If on disk, associated file descriptor */
- char *bf_buf; /* Memory buffer */
- int bf_bufsize; /* Length of above buffer */
- int bf_buffilled; /* Bytes of buffer actually filled */
- char *bf_filename; /* Name of buffered file, if ever committed */
- mode_t bf_filemode; /* Mode of buffered file, if ever committed */
- fpos_t bf_offset; /* Currect file offset */
- int bf_size; /* Total current size of file */
- int bf_refcount; /* Reference count */
-};
-
-/* Our lower-level I/O routines */
-extern int _bfclose __P((void *));
-extern int _bfread __P((void *, char *, int));
-extern fpos_t _bfseek __P((void *, fpos_t, int));
-extern int _bfwrite __P((void *, const char *, int));
-#endif /* BF_TOREK_H */
diff --git a/contrib/sendmail/src/cdefs.h b/contrib/sendmail/src/cdefs.h
deleted file mode 100644
index e586cbfaf7cb8..0000000000000
--- a/contrib/sendmail/src/cdefs.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Berkeley Software Design, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
- */
-
-#ifndef _CDEFS_H_
-#define _CDEFS_H_
-
-#if defined(__cplusplus)
-#define __BEGIN_DECLS extern "C" {
-#define __END_DECLS };
-#else
-#define __BEGIN_DECLS
-#define __END_DECLS
-#endif
-
-/*
- * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
- * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
- * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
- * in between its arguments. __CONCAT can also concatenate double-quoted
- * strings produced by the __STRING macro, but this only works with ANSI C.
- */
-#if defined(__STDC__) || defined(__cplusplus)
-#define __P(protos) protos /* full-blown ANSI C */
-#define __CONCAT(x,y) x ## y
-#define __STRING(x) #x
-
-#define __const const /* define reserved names to standard */
-#define __signed signed
-#define __volatile volatile
-#if defined(__cplusplus)
-#define __inline inline /* convert to C++ keyword */
-#else
-#ifndef __GNUC__
-#define __inline /* delete GCC keyword */
-#endif /* !__GNUC__ */
-#endif /* !__cplusplus */
-
-#else /* !(__STDC__ || __cplusplus) */
-#define __P(protos) () /* traditional C preprocessor */
-#define __CONCAT(x,y) x/**/y
-#define __STRING(x) "x"
-
-#ifndef __GNUC__
-#define __const /* delete pseudo-ANSI C keywords */
-#define __inline
-#define __signed
-#define __volatile
-/*
- * In non-ANSI C environments, new programs will want ANSI-only C keywords
- * deleted from the program and old programs will want them left alone.
- * When using a compiler other than gcc, programs using the ANSI C keywords
- * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
- * When using "gcc -traditional", we assume that this is the intent; if
- * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
- */
-#ifndef NO_ANSI_KEYWORDS
-#define const /* delete ANSI C keywords */
-#define inline
-#define signed
-#define volatile
-#endif
-#endif /* !__GNUC__ */
-#endif /* !(__STDC__ || __cplusplus) */
-
-/*
- * GCC1 and some versions of GCC2 declare dead (non-returning) and
- * pure (no side effects) functions using "volatile" and "const";
- * unfortunately, these then cause warnings under "-ansi -pedantic".
- * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of
- * these work for GNU C++ (modulo a slight glitch in the C++ grammar
- * in the distribution version of 2.5.5).
- */
-#if !defined(__GNUC__) || __GNUC__ < 2 || \
- (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-#define __dead __volatile
-#define __pure __const
-#endif
-#endif
-
-/* Delete pseudo-keywords wherever they are not available or needed. */
-#ifndef __dead
-#define __dead
-#define __pure
-#endif
-
-#endif /* !_CDEFS_H_ */
diff --git a/contrib/sendmail/src/clock.c b/contrib/sendmail/src/clock.c
deleted file mode 100644
index 0e3ec9493bc5e..0000000000000
--- a/contrib/sendmail/src/clock.c
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
- * Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.
- * All rights reserved.
- * Copyright (c) 1983, 1995-1997 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.
- *
- */
-
-#ifndef lint
-static char id[] = "@(#)$Id: clock.c,v 8.52.18.18 2001/08/14 16:07:04 ca Exp $";
-#endif /* ! lint */
-
-#include <sendmail.h>
-
-#ifndef sigmask
-# define sigmask(s) (1 << ((s) - 1))
-#endif /* ! sigmask */
-
-static SIGFUNC_DECL sm_tick __P((int));
-static void endsleep __P((void));
-
-
-/*
-** SETEVENT -- set an event to happen at a specific time.
-**
-** Events are stored in a sorted list for fast processing.
-** An event only applies to the process that set it.
-**
-** Parameters:
-** intvl -- intvl until next event occurs.
-** func -- function to call on event.
-** arg -- argument to func on event.
-**
-** Returns:
-** none.
-**
-** Side Effects:
-** none.
-*/
-
-static EVENT *volatile EventQueue; /* head of event queue */
-static EVENT *volatile FreeEventList; /* list of free events */
-
-EVENT *
-setevent(intvl, func, arg)
- time_t intvl;
- void (*func)();
- int arg;
-{
- register EVENT *ev;
-
- if (intvl <= 0)
- {
- syserr("554 5.3.0 setevent: intvl=%ld\n", intvl);
- return NULL;
- }
-
- ENTER_CRITICAL();
- if (FreeEventList == NULL)
- {
- FreeEventList = (EVENT *) xalloc(sizeof *FreeEventList);
- FreeEventList->ev_link = NULL;
- }
- LEAVE_CRITICAL();
-
- ev = sigsafe_setevent(intvl, func, arg);
-
- if (tTd(5, 5))
- dprintf("setevent: intvl=%ld, for=%ld, func=%lx, arg=%d, ev=%lx\n",
- (long) intvl, (long) (curtime() + intvl),
- (u_long) func, arg,
- ev == NULL ? 0 : (u_long) ev);
-
- return ev;
-}
-
-/*
-**
-** NOTE: THIS CAN BE CALLED FROM A SIGNAL HANDLER. DO NOT ADD
-** ANYTHING TO THIS ROUTINE UNLESS YOU KNOW WHAT YOU ARE
-** DOING.
-*/
-
-EVENT *
-sigsafe_setevent(intvl, func, arg)
- time_t intvl;
- void (*func)();
- int arg;
-{
- register EVENT **evp;
- register EVENT *ev;
- auto time_t now;
- int wasblocked;
-
- if (intvl <= 0)
- return NULL;
-
- wasblocked = blocksignal(SIGALRM);
- now = curtime();
-
- /* search event queue for correct position */
- for (evp = (EVENT **) (&EventQueue);
- (ev = *evp) != NULL;
- evp = &ev->ev_link)
- {
- if (ev->ev_time >= now + intvl)
- break;
- }
-
- ENTER_CRITICAL();
- if (FreeEventList == NULL)
- {
- /*
- ** This shouldn't happen. If called from setevent(),
- ** we have just malloced a FreeEventList entry. If
- ** called from a signal handler, it should have been
- ** from an existing event which sm_tick() just added to the
- ** FreeEventList.
- */
-
- LEAVE_CRITICAL();
- return NULL;
- }
- else
- {
- ev = FreeEventList;
- FreeEventList = ev->ev_link;
- }
- LEAVE_CRITICAL();
-
- /* insert new event */
- ev->ev_time = now + intvl;
- ev->ev_func = func;
- ev->ev_arg = arg;
- ev->ev_pid = getpid();
- ENTER_CRITICAL();
- ev->ev_link = *evp;
- *evp = ev;
- LEAVE_CRITICAL();
-
- (void) setsignal(SIGALRM, sm_tick);
- intvl = EventQueue->ev_time - now;
- (void) alarm((unsigned) intvl < 1 ? 1 : intvl);
- if (wasblocked == 0)
- (void) releasesignal(SIGALRM);
- return ev;
-}
- /*
-** CLREVENT -- remove an event from the event queue.
-**
-** Parameters:
-** ev -- pointer to event to remove.
-**
-** Returns:
-** none.
-**
-** Side Effects:
-** arranges for event ev to not happen.
-*/
-
-void
-clrevent(ev)
- register EVENT *ev;
-{
- register EVENT **evp;
- int wasblocked;
-
- if (tTd(5, 5))
- dprintf("clrevent: ev=%lx\n", (u_long) ev);
- if (ev == NULL)
- return;
-
- /* find the parent event */
- wasblocked = blocksignal(SIGALRM);
- for (evp = (EVENT **) (&EventQueue);
- *evp != NULL;
- evp = &(*evp)->ev_link)
- {
- if (*evp == ev)
- break;
- }
-
- /* now remove it */
- if (*evp != NULL)
- {
- ENTER_CRITICAL();
- *evp = ev->ev_link;
- ev->ev_link = FreeEventList;
- FreeEventList = ev;
- LEAVE_CRITICAL();
- }
-
- /* restore clocks and pick up anything spare */
- if (wasblocked == 0)
- (void) releasesignal(SIGALRM);
- if (EventQueue != NULL)
- (void) kill(getpid(), SIGALRM);
- else
- {
- /* nothing left in event queue, no need for an alarm */
- (void) alarm(0);
- }
-}
- /*
-** CLEAR_EVENTS -- remove all events from the event queue.
-**
-** Parameters:
-** none.
-**
-** Returns:
-** none.
-*/
-
-void
-clear_events()
-{
- register EVENT *ev;
- int wasblocked;
-
- if (tTd(5, 5))
- dprintf("clear_events: EventQueue=%lx\n", (u_long) EventQueue);
-
- if (EventQueue == NULL)
- return;
-
- /* nothing will be left in event queue, no need for an alarm */
- (void) alarm(0);
- wasblocked = blocksignal(SIGALRM);
-
- /* find the end of the EventQueue */
- for (ev = EventQueue; ev->ev_link != NULL; ev = ev->ev_link)
- continue;
-
- ENTER_CRITICAL();
- ev->ev_link = FreeEventList;
- FreeEventList = EventQueue;
- EventQueue = NULL;
- LEAVE_CRITICAL();
-
- /* restore clocks and pick up anything spare */
- if (wasblocked == 0)
- (void) releasesignal(SIGALRM);
-}
- /*
-** SM_TICK -- take a clock sm_tick
-**
-** Called by the alarm clock. This routine runs events as needed.
-** Always called as a signal handler, so we assume that SIGALRM
-** has been blocked.
-**
-** Parameters:
-** One that is ignored; for compatibility with signal handlers.
-**
-** Returns:
-** none.
-**
-** Side Effects:
-** calls the next function in EventQueue.
-**
-** NOTE: THIS CAN BE CALLED FROM A SIGNAL HANDLER. DO NOT ADD
-** ANYTHING TO THIS ROUTINE UNLESS YOU KNOW WHAT YOU ARE
-** DOING.
-*/
-
-/* ARGSUSED */
-static SIGFUNC_DECL
-sm_tick(sig)
- int sig;
-{
- register time_t now;
- register EVENT *ev;
- pid_t mypid;
- int save_errno = errno;
-
- (void) alarm(0);
-
- FIX_SYSV_SIGNAL(sig, sm_tick);
-
- errno = save_errno;
- CHECK_CRITICAL(sig);
-
- mypid = getpid();
- while (PendingSignal != 0)
- {
- int sigbit = 0;
- int sig = 0;
-
- if (bitset(PEND_SIGHUP, PendingSignal))
- {
- sigbit = PEND_SIGHUP;
- sig = SIGHUP;
- }
- else if (bitset(PEND_SIGINT, PendingSignal))
- {
- sigbit = PEND_SIGINT;
- sig = SIGINT;
- }
- else if (bitset(PEND_SIGTERM, PendingSignal))
- {
- sigbit = PEND_SIGTERM;
- sig = SIGTERM;
- }
- else if (bitset(PEND_SIGUSR1, PendingSignal))
- {
- sigbit = PEND_SIGUSR1;
- sig = SIGUSR1;
- }
- else
- {
- /* If we get here, we are in trouble */
- abort();
- }
- PendingSignal &= ~sigbit;
- kill(mypid, sig);
- }
-
- now = curtime();
- if (tTd(5, 4))
- dprintf("sm_tick: now=%ld\n", (long) now);
-
- while ((ev = EventQueue) != NULL &&
- (ev->ev_time <= now || ev->ev_pid != mypid))
- {
- void (*f)();
- int arg;
- pid_t pid;
-
- /* process the event on the top of the queue */
- ENTER_CRITICAL();
- ev = EventQueue;
- EventQueue = EventQueue->ev_link;
- LEAVE_CRITICAL();
- if (tTd(5, 6))
- dprintf("sm_tick: ev=%lx, func=%lx, arg=%d, pid=%d\n",
- (u_long) ev, (u_long) ev->ev_func,
- ev->ev_arg, ev->ev_pid);
-
- /* we must be careful in here because ev_func may not return */
- f = ev->ev_func;
- arg = ev->ev_arg;
- pid = ev->ev_pid;
- ENTER_CRITICAL();
- ev->ev_link = FreeEventList;
- FreeEventList = ev;
- LEAVE_CRITICAL();
- if (pid != mypid)
- continue;
- if (EventQueue != NULL)
- {
- if (EventQueue->ev_time > now)
- (void) alarm((unsigned) (EventQueue->ev_time - now));
- else
- (void) alarm(3);
- }
-
- /* call ev_func */
- errno = save_errno;
- (*f)(arg);
- (void) alarm(0);
- now = curtime();
- }
- if (EventQueue != NULL)
- (void) alarm((unsigned) (EventQueue->ev_time - now));
- errno = save_errno;
- return SIGFUNC_RETURN;
-}
- /*
-** PEND_SIGNAL -- Add a signal to the pending signal list
-**
-** Parameters:
-** sig -- signal to add
-**
-** Returns:
-** none.
-**
-** NOTE: THIS CAN BE CALLED FROM A SIGNAL HANDLER. DO NOT ADD
-** ANYTHING TO THIS ROUTINE UNLESS YOU KNOW WHAT YOU ARE
-** DOING.
-*/
-
-void
-pend_signal(sig)
- int sig;
-{
- int sigbit;
- int save_errno = errno;
-
- /*
- ** Don't want to interrupt something critical, hence delay
- ** the alarm for one second. Hopefully, by then we
- ** will be out of the critical section. If not, then
- ** we will just delay again. The events to be run will
- ** still all be run, maybe just a little bit late.
- */
-
- switch (sig)
- {
- case SIGHUP:
- sigbit = PEND_SIGHUP;
- break;
-
- case SIGINT:
- sigbit = PEND_SIGINT;
- break;
-
- case SIGTERM:
- sigbit = PEND_SIGTERM;
- break;
-
- case SIGUSR1:
- sigbit = PEND_SIGUSR1;
- break;
-
- case SIGALRM:
- /* don't have to pend these */
- sigbit = 0;
- break;
-
- default:
- /* If we get here, we are in trouble */
- abort();
-
- /* NOTREACHED */
- /* shut up stupid compiler warning on HP-UX 11 */
- sigbit = 0;
- break;
- }
-
- if (sigbit != 0)
- PendingSignal |= sigbit;
- (void) setsignal(SIGALRM, sm_tick);
- (void) alarm(1);
- errno = save_errno;
-}
- /*
-** SM_SIGNAL_NOOP -- A signal no-op function
-**
-** Parameters:
-** sig -- signal received
-**
-** Returns:
-** SIGFUNC_RETURN
-*/
-
-/* ARGSUSED */
-SIGFUNC_DECL
-sm_signal_noop(sig)
- int sig;
-{
- int save_errno = errno;
-
- FIX_SYSV_SIGNAL(sig, sm_signal_noop);
- errno = save_errno;
- return SIGFUNC_RETURN;
-}
- /*
-** SLEEP -- a version of sleep that works with this stuff
-**
-** Because sleep uses the alarm facility, I must reimplement
-** it here.
-**
-** Parameters:
-** intvl -- time to sleep.
-**
-** Returns:
-** none.
-**
-** Side Effects:
-** waits for intvl time. However, other events can
-** be run during that interval.
-*/
-
-
-static bool volatile SleepDone;
-
-#ifndef SLEEP_T
-# define SLEEP_T unsigned int
-#endif /* ! SLEEP_T */
-
-SLEEP_T
-sleep(intvl)
- unsigned int intvl;
-{
- int was_held;
-
- if (intvl == 0)
- return (SLEEP_T) 0;
- SleepDone = FALSE;
- (void) setevent((time_t) intvl, endsleep, 0);
- was_held = releasesignal(SIGALRM);
- while (!SleepDone)
- (void) pause();
- if (was_held > 0)
- (void) blocksignal(SIGALRM);
- return (SLEEP_T) 0;
-}
-
-static void
-endsleep()
-{
- /*
- ** NOTE: THIS CAN BE CALLED FROM A SIGNAL HANDLER. DO NOT ADD
- ** ANYTHING TO THIS ROUTINE UNLESS YOU KNOW WHAT YOU ARE
- ** DOING.
- */
-
- SleepDone = TRUE;
-}
diff --git a/contrib/sendmail/src/ldap_map.h b/contrib/sendmail/src/ldap_map.h
deleted file mode 100644
index 7d40329e1b5ea..0000000000000
--- a/contrib/sendmail/src/ldap_map.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 1998 Sendmail, Inc. 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.
- *
- */
-
-/*
-** Support for LDAP.
-**
-** Contributed by Booker C. Bense <bbense+ldap@stanford.edu>.
-** Please go to him for support -- since I (Eric) don't run LDAP, I
-** can't help you at all.
-**
-** @(#)ldap_map.h 8.12 (Berkeley) 2/2/1999
-*/
-
-#ifndef _LDAP_MAP_H
-#define _LDAP_MAP_H
-
-#include <sys/time.h>
-
-struct ldap_map_struct
-{
- /* needed for ldap_open */
- char *ldaphost;
- int ldapport;
-
- /* Options set in ld struct before ldap_bind_s */
- int deref;
- int timelimit;
- int sizelimit;
- int ldap_options;
-
- /* args for ldap_bind_s */
- LDAP *ld;
- char *binddn;
- char *passwd;
- int method;
-
- /* args for ldap_search_st */
- char *base;
- int scope;
- char *filter;
- char *attr[2];
- int attrsonly;
- struct timeval timeout;
- LDAPMessage *res;
-};
-
-typedef struct ldap_map_struct LDAP_MAP_STRUCT;
-
-#define DEFAULT_LDAP_MAP_PORT LDAP_PORT
-#define DEFAULT_LDAP_MAP_SCOPE LDAP_SCOPE_SUBTREE
-#define DEFAULT_LDAP_MAP_BINDDN NULL
-#define DEFAULT_LDAP_MAP_PASSWD NULL
-#define DEFAULT_LDAP_MAP_METHOD LDAP_AUTH_SIMPLE
-#define DEFAULT_LDAP_MAP_TIMELIMIT 5
-#define DEFAULT_LDAP_MAP_DEREF LDAP_DEREF_NEVER
-#define DEFAULT_LDAP_MAP_SIZELIMIT 0
-#define DEFAULT_LDAP_MAP_ATTRSONLY 0
-#define LDAP_MAP_MAX_FILTER 1024
-#ifdef LDAP_REFERRALS
-# define DEFAULT_LDAP_MAP_LDAP_OPTIONS LDAP_OPT_REFERRALS
-#else /* LDAP_REFERRALS */
-# define DEFAULT_LDAP_MAP_LDAP_OPTIONS 0
-#endif /* LDAP_REFERRALS */
-
-/*
-** ldap_init(3) is broken in Umich 3.x and OpenLDAP 1.0/1.1.
-** Use the lack of LDAP_OPT_SIZELIMIT to detect old API implementations
-** and assume (falsely) that all old API implementations are broken.
-** (OpenLDAP 1.2 and later have a working ldap_init(), add -DUSE_LDAP_INIT)
-*/
-
-#if defined(LDAP_OPT_SIZELIMIT) && !defined(USE_LDAP_INIT)
-# define USE_LDAP_INIT 1
-#endif
-
-/*
-** LDAP_OPT_SIZELIMIT is not defined under Umich 3.x nor OpenLDAP 1.x,
-** hence ldap_set_option() must not exist.
-*/
-
-#if defined(LDAP_OPT_SIZELIMIT) && !defined(USE_LDAP_SET_OPTION)
-# define USE_LDAP_SET_OPTION 1
-#endif
-
-#endif /* _LDAP_MAP_H */
diff --git a/contrib/sendmail/src/mailstats.h b/contrib/sendmail/src/mailstats.h
deleted file mode 100644
index 86390b3911a30..0000000000000
--- a/contrib/sendmail/src/mailstats.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 1998 Sendmail, Inc. 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.
- *
- *
- * @(#)mailstats.h 8.8 (Berkeley) 5/19/1998
- */
-
-#define STAT_VERSION 2
-#define STAT_MAGIC 0x1B1DE
-
-/*
-** Statistics structure.
-*/
-
-struct statistics
-{
- int stat_magic; /* magic number */
- int stat_version; /* stat file version */
- time_t stat_itime; /* file initialization time */
- short stat_size; /* size of this structure */
- long stat_nf[MAXMAILERS]; /* # msgs from each mailer */
- long stat_bf[MAXMAILERS]; /* kbytes from each mailer */
- long stat_nt[MAXMAILERS]; /* # msgs to each mailer */
- long stat_bt[MAXMAILERS]; /* kbytes to each mailer */
- long stat_nr[MAXMAILERS]; /* # rejects by each mailer */
- long stat_nd[MAXMAILERS]; /* # discards by each mailer */
-};
diff --git a/contrib/sendmail/src/makesendmail b/contrib/sendmail/src/makesendmail
deleted file mode 100755
index 9ca35206710f0..0000000000000
--- a/contrib/sendmail/src/makesendmail
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-# Copyright (c) 1999 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: makesendmail,v 8.4 1999/04/04 07:01:42 gshapiro Exp $
-
-exec ./Build $*
diff --git a/contrib/sendmail/src/pathnames.h b/contrib/sendmail/src/pathnames.h
deleted file mode 100644
index 7a06b120652c8..0000000000000
--- a/contrib/sendmail/src/pathnames.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * Copyright (c) 1998 Sendmail, Inc. All rights reserved.
- * Copyright (c) 1990, 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.
- *
- *
- * @(#)pathnames.h 8.8 (Berkeley) 5/19/1998
- */
-
-#ifndef _PATH_SENDMAILCF
-# if defined(USE_VENDOR_CF_PATH) && defined(_PATH_VENDOR_CF)
-# define _PATH_SENDMAILCF _PATH_VENDOR_CF
-# else
-# define _PATH_SENDMAILCF "/etc/sendmail.cf"
-# endif
-#endif
-
-#ifndef _PATH_SENDMAILPID
-# ifdef BSD4_4
-# define _PATH_SENDMAILPID "/var/run/sendmail.pid"
-# else
-# define _PATH_SENDMAILPID "/etc/sendmail.pid"
-# endif
-#endif
-
-#ifndef _PATH_HOSTS
-# define _PATH_HOSTS "/etc/hosts"
-#endif
diff --git a/contrib/sendmail/src/safefile.c b/contrib/sendmail/src/safefile.c
deleted file mode 100644
index ff94b3d243bf4..0000000000000
--- a/contrib/sendmail/src/safefile.c
+++ /dev/null
@@ -1,751 +0,0 @@
-/*
- * Copyright (c) 1998 Sendmail, Inc. All rights reserved.
- * Copyright (c) 1983, 1995-1997 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.
- *
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)safefile.c 8.43 (Berkeley) 10/13/1998";
-#endif /* not lint */
-
-# include "sendmail.h"
- /*
-** SAFEFILE -- return true if a file exists and is safe for a user.
-**
-** Parameters:
-** fn -- filename to check.
-** uid -- user id to compare against.
-** gid -- group id to compare against.
-** uname -- user name to compare against (used for group
-** sets).
-** flags -- modifiers:
-** SFF_MUSTOWN -- "uid" must own this file.
-** SFF_NOSLINK -- file cannot be a symbolic link.
-** mode -- mode bits that must match.
-** st -- if set, points to a stat structure that will
-** get the stat info for the file.
-**
-** Returns:
-** 0 if fn exists, is owned by uid, and matches mode.
-** An errno otherwise. The actual errno is cleared.
-**
-** Side Effects:
-** none.
-*/
-
-#include <grp.h>
-
-int
-safefile(fn, uid, gid, uname, flags, mode, st)
- char *fn;
- UID_T uid;
- GID_T gid;
- char *uname;
- int flags;
- int mode;
- struct stat *st;
-{
- register char *p;
- register struct group *gr = NULL;
- int file_errno = 0;
- bool checkpath;
- struct stat stbuf;
- struct stat fstbuf;
- char fbuf[MAXPATHLEN + 1];
-
- if (tTd(44, 4))
- printf("safefile(%s, uid=%d, gid=%d, flags=%x, mode=%o):\n",
- fn, (int) uid, (int) gid, flags, mode);
- errno = 0;
- if (st == NULL)
- st = &fstbuf;
- if (strlen(fn) > sizeof fbuf - 1)
- {
- if (tTd(44, 4))
- printf("\tpathname too long\n");
- return ENAMETOOLONG;
- }
- strcpy(fbuf, fn);
- fn = fbuf;
-
- /* ignore SFF_SAFEDIRPATH if we are debugging */
- if (RealUid != 0 && RunAsUid == RealUid)
- flags &= ~SFF_SAFEDIRPATH;
-
- /* first check to see if the file exists at all */
-#ifdef HASLSTAT
- if ((bitset(SFF_NOSLINK, flags) ? lstat(fn, st)
- : stat(fn, st)) < 0)
-#else
- if (stat(fn, st) < 0)
-#endif
- {
- file_errno = errno;
- }
- else if (bitset(SFF_SETUIDOK, flags) &&
- !bitset(S_IXUSR|S_IXGRP|S_IXOTH, st->st_mode) &&
- S_ISREG(st->st_mode))
- {
- /*
- ** If final file is setuid, run as the owner of that
- ** file. Gotta be careful not to reveal anything too
- ** soon here!
- */
-
-#ifdef SUID_ROOT_FILES_OK
- if (bitset(S_ISUID, st->st_mode))
-#else
- if (bitset(S_ISUID, st->st_mode) && st->st_uid != 0 &&
- st->st_uid != TrustedUid)
-#endif
- {
- uid = st->st_uid;
- uname = NULL;
- }
-#ifdef SUID_ROOT_FILES_OK
- if (bitset(S_ISGID, st->st_mode))
-#else
- if (bitset(S_ISGID, st->st_mode) && st->st_gid != 0)
-#endif
- gid = st->st_gid;
- }
-
- checkpath = !bitset(SFF_NOPATHCHECK, flags) ||
- (uid == 0 && !bitset(SFF_ROOTOK|SFF_OPENASROOT, flags));
- if (bitset(SFF_NOWLINK, flags) && !bitset(SFF_SAFEDIRPATH, flags))
- {
- int ret;
-
- /* check the directory */
- p = strrchr(fn, '/');
- if (p == NULL)
- {
- ret = safedirpath(".", uid, gid, uname, flags|SFF_SAFEDIRPATH);
- }
- else
- {
- *p = '\0';
- ret = safedirpath(fn, uid, gid, uname, flags|SFF_SAFEDIRPATH);
- *p = '/';
- }
- if (ret == 0)
- {
- /* directory is safe */
- checkpath = FALSE;
- }
- else
- {
-#ifdef HASLSTAT
- /* Need lstat() information if called stat() before */
- if (!bitset(SFF_NOSLINK, flags) && lstat(fn, st) < 0)
- {
- ret = errno;
- if (tTd(44, 4))
- printf("\t%s\n", errstring(ret));
- return ret;
- }
-#endif
- /* directory is writable: disallow links */
- flags |= SFF_NOLINK;
- }
- }
-
- if (checkpath)
- {
- int ret;
-
- p = strrchr(fn, '/');
- if (p == NULL)
- {
- ret = safedirpath(".", uid, gid, uname, flags);
- }
- else
- {
- *p = '\0';
- ret = safedirpath(fn, uid, gid, uname, flags);
- *p = '/';
- }
- if (ret != 0)
- return ret;
- }
-
- /*
- ** If the target file doesn't exist, check the directory to
- ** ensure that it is writable by this user.
- */
-
- if (file_errno != 0)
- {
- int ret = file_errno;
- char *dir = fn;
-
- if (tTd(44, 4))
- printf("\t%s\n", errstring(ret));
-
- errno = 0;
- if (!bitset(SFF_CREAT, flags) || file_errno != ENOENT)
- return ret;
-
- /* check to see if legal to create the file */
- p = strrchr(dir, '/');
- if (p == NULL)
- dir = ".";
- else if (p == dir)
- dir = "/";
- else
- *p = '\0';
- if (stat(dir, &stbuf) >= 0)
- {
- int md = S_IWRITE|S_IEXEC;
-
- if (stbuf.st_uid == uid)
- ;
- else if (uid == 0 && stbuf.st_uid == TrustedUid)
- ;
- else
- {
- md >>= 3;
- if (stbuf.st_gid == gid)
- ;
-#ifndef NO_GROUP_SET
- else if (uname != NULL && !DontInitGroups &&
- ((gr != NULL &&
- gr->gr_gid == stbuf.st_gid) ||
- (gr = getgrgid(stbuf.st_gid)) != NULL))
- {
- register char **gp;
-
- for (gp = gr->gr_mem; *gp != NULL; gp++)
- if (strcmp(*gp, uname) == 0)
- break;
- if (*gp == NULL)
- md >>= 3;
- }
-#endif
- else
- md >>= 3;
- }
- if ((stbuf.st_mode & md) != md)
- errno = EACCES;
- }
- ret = errno;
- if (tTd(44, 4))
- printf("\t[final dir %s uid %d mode %lo] %s\n",
- dir, (int) stbuf.st_uid, (u_long) stbuf.st_mode,
- errstring(ret));
- if (p != NULL)
- *p = '/';
- st->st_mode = ST_MODE_NOFILE;
- return ret;
- }
-
-#ifdef S_ISLNK
- if (bitset(SFF_NOSLINK, flags) && S_ISLNK(st->st_mode))
- {
- if (tTd(44, 4))
- printf("\t[slink mode %lo]\tE_SM_NOSLINK\n",
- (u_long) st->st_mode);
- return E_SM_NOSLINK;
- }
-#endif
- if (bitset(SFF_REGONLY, flags) && !S_ISREG(st->st_mode))
- {
- if (tTd(44, 4))
- printf("\t[non-reg mode %lo]\tE_SM_REGONLY\n",
- (u_long) st->st_mode);
- return E_SM_REGONLY;
- }
- if (bitset(SFF_NOGWFILES, flags) &&
- bitset(S_IWGRP, st->st_mode))
- {
- if (tTd(44, 4))
- printf("\t[write bits %lo]\tE_SM_GWFILE\n",
- (u_long) st->st_mode);
- return E_SM_GWFILE;
- }
- if (bitset(SFF_NOWWFILES, flags) &&
- bitset(S_IWOTH, st->st_mode))
- {
- if (tTd(44, 4))
- printf("\t[write bits %lo]\tE_SM_WWFILE\n",
- (u_long) st->st_mode);
- return E_SM_WWFILE;
- }
- if (bitset(S_IWUSR|S_IWGRP|S_IWOTH, mode) &&
- bitset(S_IXUSR|S_IXGRP|S_IXOTH, st->st_mode))
- {
- if (tTd(44, 4))
- printf("\t[exec bits %lo]\tE_SM_ISEXEC]\n",
- (u_long) st->st_mode);
- return E_SM_ISEXEC;
- }
- if (bitset(SFF_NOHLINK, flags) && st->st_nlink != 1)
- {
- if (tTd(44, 4))
- printf("\t[link count %d]\tE_SM_NOHLINK\n",
- (int) st->st_nlink);
- return E_SM_NOHLINK;
- }
-
- if (uid == 0 && bitset(SFF_OPENASROOT, flags))
- ;
- else if (uid == 0 && !bitset(SFF_ROOTOK, flags))
- mode >>= 6;
- else if (st->st_uid == uid)
- ;
- else if (uid == 0 && st->st_uid == TrustedUid)
- ;
- else
- {
- mode >>= 3;
- if (st->st_gid == gid)
- ;
-#ifndef NO_GROUP_SET
- else if (uname != NULL && !DontInitGroups &&
- ((gr != NULL && gr->gr_gid == st->st_gid) ||
- (gr = getgrgid(st->st_gid)) != NULL))
- {
- register char **gp;
-
- for (gp = gr->gr_mem; *gp != NULL; gp++)
- if (strcmp(*gp, uname) == 0)
- break;
- if (*gp == NULL)
- mode >>= 3;
- }
-#endif
- else
- mode >>= 3;
- }
- if (tTd(44, 4))
- printf("\t[uid %d, nlink %d, stat %lo, mode %lo] ",
- (int) st->st_uid, (int) st->st_nlink,
- (u_long) st->st_mode, (u_long) mode);
- if ((st->st_uid == uid || st->st_uid == 0 ||
- st->st_uid == TrustedUid ||
- !bitset(SFF_MUSTOWN, flags)) &&
- (st->st_mode & mode) == mode)
- {
- if (tTd(44, 4))
- printf("\tOK\n");
- return 0;
- }
- if (tTd(44, 4))
- printf("\tEACCES\n");
- return EACCES;
-}
- /*
-** SAFEDIRPATH -- check to make sure a path to a directory is safe
-**
-** Safe means not writable and owned by the right folks.
-**
-** Parameters:
-** fn -- filename to check.
-** uid -- user id to compare against.
-** gid -- group id to compare against.
-** uname -- user name to compare against (used for group
-** sets).
-** flags -- modifiers:
-** SFF_ROOTOK -- ok to use root permissions to open.
-** SFF_SAFEDIRPATH -- writable directories are considered
-** to be fatal errors.
-**
-** Returns:
-** 0 -- if the directory path is "safe".
-** else -- an error number associated with the path.
-*/
-
-int
-safedirpath(fn, uid, gid, uname, flags)
- char *fn;
- UID_T uid;
- GID_T gid;
- char *uname;
- int flags;
-{
- char *p;
- register struct group *gr = NULL;
- int ret = 0;
- int mode = S_IWOTH;
- struct stat stbuf;
-
- /* special case root directory */
- if (*fn == '\0')
- fn = "/";
-
- if (tTd(44, 4))
- printf("safedirpath(%s, uid=%ld, gid=%ld, flags=%x):\n",
- fn, (long) uid, (long) gid, flags);
-
- if (!bitset(DBS_GROUPWRITABLEDIRPATHSAFE, DontBlameSendmail))
- mode |= S_IWGRP;
-
- p = fn;
- do
- {
- if (*p == '\0')
- *p = '/';
- p = strchr(++p, '/');
- if (p != NULL)
- *p = '\0';
- if (stat(fn, &stbuf) < 0)
- {
- ret = errno;
- break;
- }
- if ((uid == 0 || bitset(SFF_SAFEDIRPATH, flags)) &&
- bitset(mode, stbuf.st_mode))
- {
- if (tTd(44, 4))
- printf("\t[dir %s] mode %lo\n",
- fn, (u_long) stbuf.st_mode);
- if (bitset(SFF_SAFEDIRPATH, flags))
- {
- if (bitset(S_IWOTH, stbuf.st_mode))
- ret = E_SM_WWDIR;
- else
- ret = E_SM_GWDIR;
- break;
- }
- if (Verbose > 1)
- message("051 WARNING: %s writable directory %s",
- bitset(S_IWOTH, stbuf.st_mode)
- ? "World"
- : "Group",
- fn);
- }
- if (uid == 0 && !bitset(SFF_ROOTOK|SFF_OPENASROOT, flags))
- {
- if (bitset(S_IXOTH, stbuf.st_mode))
- continue;
- ret = EACCES;
- break;
- }
-
- /*
- ** Let OS determine access to file if we are not
- ** running as a privileged user. This allows ACLs
- ** to work.
- */
- if (geteuid() != 0)
- continue;
-
- if (stbuf.st_uid == uid &&
- bitset(S_IXUSR, stbuf.st_mode))
- continue;
- if (stbuf.st_gid == gid &&
- bitset(S_IXGRP, stbuf.st_mode))
- continue;
-#ifndef NO_GROUP_SET
- if (uname != NULL && !DontInitGroups &&
- ((gr != NULL && gr->gr_gid == stbuf.st_gid) ||
- (gr = getgrgid(stbuf.st_gid)) != NULL))
- {
- register char **gp;
-
- for (gp = gr->gr_mem; gp != NULL && *gp != NULL; gp++)
- if (strcmp(*gp, uname) == 0)
- break;
- if (gp != NULL && *gp != NULL &&
- bitset(S_IXGRP, stbuf.st_mode))
- continue;
- }
-#endif
- if (!bitset(S_IXOTH, stbuf.st_mode))
- {
- ret = EACCES;
- break;
- }
- } while (p != NULL);
- if (ret != 0 && tTd(44, 4))
- printf("\t[dir %s] %s\n", fn, errstring(ret));
- if (p != NULL)
- *p = '/';
- return ret;
-}
- /*
-** SAFEOPEN -- do a file open with extra checking
-**
-** Parameters:
-** fn -- the file name to open.
-** omode -- the open-style mode flags.
-** cmode -- the create-style mode flags.
-** sff -- safefile flags.
-**
-** Returns:
-** Same as open.
-*/
-
-#ifndef O_ACCMODE
-# define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
-#endif
-
-int
-safeopen(fn, omode, cmode, sff)
- char *fn;
- int omode;
- int cmode;
- int sff;
-{
- int rval;
- int fd;
- int smode;
- struct stat stb;
-
- if (bitset(O_CREAT, omode))
- sff |= SFF_CREAT;
- omode &= ~O_CREAT;
- smode = 0;
- switch (omode & O_ACCMODE)
- {
- case O_RDONLY:
- smode = S_IREAD;
- break;
-
- case O_WRONLY:
- smode = S_IWRITE;
- break;
-
- case O_RDWR:
- smode = S_IREAD|S_IWRITE;
- break;
-
- default:
- smode = 0;
- break;
- }
- if (bitset(SFF_OPENASROOT, sff))
- rval = safefile(fn, RunAsUid, RunAsGid, RunAsUserName,
- sff, smode, &stb);
- else
- rval = safefile(fn, RealUid, RealGid, RealUserName,
- sff, smode, &stb);
- if (rval != 0)
- {
- errno = rval;
- return -1;
- }
- if (stb.st_mode == ST_MODE_NOFILE && bitset(SFF_CREAT, sff))
- omode |= O_EXCL|O_CREAT;
-
- fd = dfopen(fn, omode, cmode, sff);
- if (fd < 0)
- return fd;
- if (filechanged(fn, fd, &stb))
- {
- syserr("554 cannot open: file %s changed after open", fn);
- close(fd);
- errno = E_SM_FILECHANGE;
- return -1;
- }
- return fd;
-}
- /*
-** SAFEFOPEN -- do a file open with extra checking
-**
-** Parameters:
-** fn -- the file name to open.
-** omode -- the open-style mode flags.
-** cmode -- the create-style mode flags.
-** sff -- safefile flags.
-**
-** Returns:
-** Same as fopen.
-*/
-
-FILE *
-safefopen(fn, omode, cmode, sff)
- char *fn;
- int omode;
- int cmode;
- int sff;
-{
- int fd;
- FILE *fp;
- char *fmode;
-
- switch (omode & O_ACCMODE)
- {
- case O_RDONLY:
- fmode = "r";
- break;
-
- case O_WRONLY:
- if (bitset(O_APPEND, omode))
- fmode = "a";
- else
- fmode = "w";
- break;
-
- case O_RDWR:
- if (bitset(O_TRUNC, omode))
- fmode = "w+";
- else if (bitset(O_APPEND, omode))
- fmode = "a+";
- else
- fmode = "r+";
- break;
-
- default:
- syserr("safefopen: unknown omode %o", omode);
- fmode = "x";
- }
- fd = safeopen(fn, omode, cmode, sff);
- if (fd < 0)
- {
- if (tTd(44, 10))
- printf("safefopen: safeopen failed: %s\n",
- errstring(errno));
- return NULL;
- }
- fp = fdopen(fd, fmode);
- if (fp != NULL)
- return fp;
-
- if (tTd(44, 10))
- {
- printf("safefopen: fdopen(%s, %s) failed: omode=%x, sff=%x, err=%s\n",
- fn, fmode, omode, sff, errstring(errno));
-#ifndef NOT_SENDMAIL
- dumpfd(fd, TRUE, FALSE);
-#endif
- }
- (void) close(fd);
- return NULL;
-}
- /*
-** FILECHANGED -- check to see if file changed after being opened
-**
-** Parameters:
-** fn -- pathname of file to check.
-** fd -- file descriptor to check.
-** stb -- stat structure from before open.
-**
-** Returns:
-** TRUE -- if a problem was detected.
-** FALSE -- if this file is still the same.
-*/
-
-bool
-filechanged(fn, fd, stb)
- char *fn;
- int fd;
- struct stat *stb;
-{
- struct stat sta;
-
- if (stb->st_mode == ST_MODE_NOFILE)
- {
-#if HASLSTAT && BOGUS_O_EXCL
- /* only necessary if exclusive open follows symbolic links */
- if (lstat(fn, stb) < 0 || stb->st_nlink != 1)
- return TRUE;
-#else
- return FALSE;
-#endif
- }
- if (fstat(fd, &sta) < 0)
- return TRUE;
-
- if (sta.st_nlink != stb->st_nlink ||
- sta.st_dev != stb->st_dev ||
- sta.st_ino != stb->st_ino ||
-#if HAS_ST_GEN && 0 /* AFS returns garbage in st_gen */
- sta.st_gen != stb->st_gen ||
-#endif
- sta.st_uid != stb->st_uid ||
- sta.st_gid != stb->st_gid)
- {
- if (tTd(44, 8))
- {
- printf("File changed after opening:\n");
- printf(" nlink = %ld/%ld\n",
- (long) stb->st_nlink, (long) sta.st_nlink);
- printf(" dev = %ld/%ld\n",
- (long) stb->st_dev, (long) sta.st_dev);
- if (sizeof sta.st_ino > sizeof (long))
- {
- printf(" ino = %s/",
- quad_to_string(stb->st_ino));
- printf("%s\n",
- quad_to_string(sta.st_ino));
- }
- else
- printf(" ino = %lu/%lu\n",
- (unsigned long) stb->st_ino,
- (unsigned long) sta.st_ino);
-#if HAS_ST_GEN
- printf(" gen = %ld/%ld\n",
- (long) stb->st_gen, (long) sta.st_gen);
-#endif
- printf(" uid = %ld/%ld\n",
- (long) stb->st_uid, (long) sta.st_uid);
- printf(" gid = %ld/%ld\n",
- (long) stb->st_gid, (long) sta.st_gid);
- }
- return TRUE;
- }
-
- return FALSE;
-}
- /*
-** DFOPEN -- determined file open
-**
-** This routine has the semantics of open, except that it will
-** keep trying a few times to make this happen. The idea is that
-** on very loaded systems, we may run out of resources (inodes,
-** whatever), so this tries to get around it.
-*/
-
-int
-dfopen(filename, omode, cmode, sff)
- char *filename;
- int omode;
- int cmode;
- int sff;
-{
- register int tries;
- int fd;
- struct stat st;
-
- for (tries = 0; tries < 10; tries++)
- {
- sleep((unsigned) (10 * tries));
- errno = 0;
- fd = open(filename, omode, cmode);
- if (fd >= 0)
- break;
- switch (errno)
- {
- case ENFILE: /* system file table full */
- case EINTR: /* interrupted syscall */
-#ifdef ETXTBSY
- case ETXTBSY: /* Apollo: net file locked */
-#endif
- continue;
- }
- break;
- }
- if (!bitset(SFF_NOLOCK, sff) &&
- fd >= 0 &&
- fstat(fd, &st) >= 0 &&
- S_ISREG(st.st_mode))
- {
- int locktype;
-
- /* lock the file to avoid accidental conflicts */
- if ((omode & O_ACCMODE) != O_RDONLY)
- locktype = LOCK_EX;
- else
- locktype = LOCK_SH;
- (void) lockfile(fd, filename, NULL, locktype);
- errno = 0;
- }
- return fd;
-}
diff --git a/contrib/sendmail/src/sendmail.hf b/contrib/sendmail/src/sendmail.hf
deleted file mode 100644
index 0952963b8bd2d..0000000000000
--- a/contrib/sendmail/src/sendmail.hf
+++ /dev/null
@@ -1,124 +0,0 @@
-cpyr
-cpyr Copyright (c) 1998 Sendmail, Inc. All rights reserved.
-cpyr Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
-cpyr Copyright (c) 1988, 1993
-cpyr The Regents of the University of California. All rights reserved.
-cpyr
-cpyr
-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 the sendmail distribution.
-cpyr
-cpyr @(#)sendmail.hf 8.18 (Berkeley) 11/19/1998
-cpyr
-smtp Topics:
-smtp HELO EHLO MAIL RCPT DATA
-smtp RSET NOOP QUIT HELP VRFY
-smtp EXPN VERB ETRN DSN
-smtp For more info use "HELP <topic>".
-smtp To report bugs in the implementation send email to
-smtp sendmail-bugs@sendmail.org.
-smtp For local information send email to Postmaster at your site.
-help HELP [ <topic> ]
-help The HELP command gives help info.
-helo HELO <hostname>
-helo Introduce yourself.
-ehlo EHLO <hostname>
-ehlo Introduce yourself, and request extended SMTP mode.
-ehlo Possible replies include:
-ehlo SEND Send as mail [RFC821]
-ehlo SOML Send as mail or terminal [RFC821]
-ehlo SAML Send as mail and terminal [RFC821]
-ehlo EXPN Expand the mailing list [RFC821]
-ehlo HELP Supply helpful information [RFC821]
-ehlo TURN Turn the operation around [RFC821]
-ehlo 8BITMIME Use 8-bit data [RFC1652]
-ehlo SIZE Message size declaration [RFC1870]
-ehlo VERB Verbose [Allman]
-ehlo ONEX One message transaction only [Allman]
-ehlo CHUNKING Chunking [RFC1830]
-ehlo BINARYMIME Binary MIME [RFC1830]
-ehlo PIPELINING Command Pipelining [RFC1854]
-ehlo DSN Delivery Status Notification [RFC1891]
-ehlo ETRN Remote Message Queue Starting [RFC1985]
-ehlo XUSR Initial (user) submission [Allman]
-mail MAIL FROM: <sender> [ <parameters> ]
-mail Specifies the sender. Parameters are ESMTP extensions.
-mail See "HELP DSN" for details.
-rcpt RCPT TO: <recipient> [ <parameters> ]
-rcpt Specifies the recipient. Can be used any number of times.
-rcpt Parameters are ESMTP extensions. See "HELP DSN" for details.
-data DATA
-data Following text is collected as the message.
-data End with a single dot.
-rset RSET
-rset Resets the system.
-quit QUIT
-quit Exit sendmail (SMTP).
-verb VERB
-verb Go into verbose mode. This sends 0xy responses that are
-verb not RFC821 standard (but should be) They are recognized
-verb by humans and other sendmail implementations.
-vrfy VRFY <recipient>
-vrfy Verify an address. If you want to see what it aliases
-vrfy to, use EXPN instead.
-expn EXPN <recipient>
-expn Expand an address. If the address indicates a mailing
-expn list, return the contents of that list.
-noop NOOP
-noop Do nothing.
-send SEND FROM: <sender>
-send replaces the MAIL command, and can be used to send
-send directly to a users terminal. Not supported in this
-send implementation.
-soml SOML FROM: <sender>
-soml Send or mail. If the user is logged in, send directly,
-soml otherwise mail. Not supported in this implementation.
-saml SAML FROM: <sender>
-saml Send and mail. Send directly to the user's terminal,
-saml and also mail a letter. Not supported in this
-saml implementation.
-turn TURN
-turn Reverses the direction of the connection. Not currently
-turn implemented.
-etrn ETRN [ <hostname> | @<domain> | #<queuename> ]
-etrn Run the queue for the specified <hostname>, or
-etrn all hosts within a given <domain>, or a specially-named
-etrn <queuename> (implementation-specific).
-dsn MAIL FROM: <sender> [ RET={ FULL | HDRS} ] [ ENVID=<envid> ]
-dsn RCPT TO: <recipient> [ NOTIFY={NEVER,SUCCESS,FAILURE,DELAY} ]
-dsn [ ORCPT=<recipient> ]
-dsn SMTP Delivery Status Notifications.
-dsn Descriptions:
-dsn RET Return either the full message or only headers.
-dsn ENVID Sender's "envelope identifier" for tracking.
-dsn NOTIFY When to send a DSN. Multiple options are OK, comma-
-dsn delimited. NEVER must appear by itself.
-dsn ORCPT Original recipient.
--bt Help for test mode:
--bt ? :this help message.
--bt .Dmvalue :define macro `m' to `value'.
--bt .Ccvalue :add `value' to class `c'.
--bt =Sruleset :dump the contents of the indicated ruleset.
--bt =M :display the known mailers.
--bt -ddebug-spec :equivalent to the command-line -d debug flag.
--bt $m :print the value of macro $m.
--bt $=c :print the contents of class $=c.
--bt /mx host :returns the MX records for `host'.
--bt /parse address :parse address, returning the value of crackaddr, and
--bt the parsed address (same as -bv).
--bt /try mailer addr :rewrite address into the form it will have when
--bt presented to the indicated mailer.
--bt /tryflags flags :set flags used by parsing. The flags can be `H' for
--bt Header or `E' for Envelope, and `S' for Sender or `R'
--bt for Recipient. These can be combined, `HR' sets
--bt flags for header recipients.
--bt /canon hostname :try to canonify hostname.
--bt /map mapname key :look up `key' in the indicated `mapname'.
--bt rules addr :run the indicated address through the named rules.
--bt Rules can be a comma separated list of rules.
-control Help for smcontrol:
-control help This message.
-control restart Restart sendmail.
-control shutdown Shutdown sendmail.
-control status Show sendmail status.
diff --git a/contrib/sendmail/src/snprintf.c b/contrib/sendmail/src/snprintf.c
deleted file mode 100644
index 3e07e1b9920f8..0000000000000
--- a/contrib/sendmail/src/snprintf.c
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * Copyright (c) 1998 Sendmail, Inc. All rights reserved.
- * Copyright (c) 1997 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.
- *
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)snprintf.c 8.12 (Berkeley) 10/13/1998";
-#endif /* not lint */
-
-#include "sendmail.h"
-
- /*
-** SNPRINTF, VSNPRINT -- counted versions of printf
-**
-** These versions have been grabbed off the net. They have been
-** cleaned up to compile properly and support for .precision and
-** %lx has been added.
-*/
-
-/**************************************************************
- * Original:
- * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
- * A bombproof version of doprnt (sm_dopr) included.
- * Sigh. This sort of thing is always nasty do deal with. Note that
- * the version here does not include floating point...
- *
- * snprintf() is used instead of sprintf() as it does limit checks
- * for string length. This covers a nasty loophole.
- *
- * The other functions are there to prevent NULL pointers from
- * causing nast effects.
- **************************************************************/
-
-/*static char _id[] = "$Id: snprintf.c,v 1.2 1995/10/09 11:19:47 roberto Exp $";*/
-void sm_dopr();
-char *DoprEnd;
-int SnprfOverflow;
-
-#if !HASSNPRINTF
-
-/* VARARGS3 */
-int
-# ifdef __STDC__
-snprintf(char *str, size_t count, const char *fmt, ...)
-# else
-snprintf(str, count, fmt, va_alist)
- char *str;
- size_t count;
- const char *fmt;
- va_dcl
-#endif
-{
- int len;
- VA_LOCAL_DECL
-
- VA_START(fmt);
- len = vsnprintf(str, count, fmt, ap);
- VA_END;
- return len;
-}
-
-
-# ifndef luna2
-int
-vsnprintf(str, count, fmt, args)
- char *str;
- size_t count;
- const char *fmt;
- va_list args;
-{
- str[0] = 0;
- DoprEnd = str + count - 1;
- SnprfOverflow = 0;
- sm_dopr( str, fmt, args );
- if (count > 0)
- DoprEnd[0] = 0;
- if (SnprfOverflow && tTd(57, 2))
- printf("\nvsnprintf overflow, len = %ld, str = %s",
- (long) count, shortenstring(str, MAXSHORTSTR));
- return strlen(str);
-}
-
-# endif /* !luna2 */
-#endif /* !HASSNPRINTF */
-
-/*
- * sm_dopr(): poor man's version of doprintf
- */
-
-void fmtstr __P((char *value, int ljust, int len, int zpad, int maxwidth));
-void fmtnum __P((long value, int base, int dosign, int ljust, int len, int zpad));
-void dostr __P(( char * , int ));
-char *output;
-void dopr_outch __P(( int c ));
-int SyslogErrno;
-
-void
-sm_dopr( buffer, format, args )
- char *buffer;
- const char *format;
- va_list args;
-{
- int ch;
- long value;
- int longflag = 0;
- int pointflag = 0;
- int maxwidth = 0;
- char *strvalue;
- int ljust;
- int len;
- int zpad;
-# if !HASSTRERROR && !defined(ERRLIST_PREDEFINED)
- extern char *sys_errlist[];
- extern int sys_nerr;
-# endif
-
-
- output = buffer;
- while( (ch = *format++) != '\0' ){
- switch( ch ){
- case '%':
- ljust = len = zpad = maxwidth = 0;
- longflag = pointflag = 0;
- nextch:
- ch = *format++;
- switch( ch ){
- case 0:
- dostr( "**end of format**" , 0);
- return;
- case '-': ljust = 1; goto nextch;
- case '0': /* set zero padding if len not set */
- if(len==0 && !pointflag) zpad = '0';
- case '1': case '2': case '3':
- case '4': case '5': case '6':
- case '7': case '8': case '9':
- if (pointflag)
- maxwidth = maxwidth*10 + ch - '0';
- else
- len = len*10 + ch - '0';
- goto nextch;
- case '*':
- if (pointflag)
- maxwidth = va_arg( args, int );
- else
- len = va_arg( args, int );
- goto nextch;
- case '.': pointflag = 1; goto nextch;
- case 'l': longflag = 1; goto nextch;
- case 'u': case 'U':
- /*fmtnum(value,base,dosign,ljust,len,zpad) */
- if( longflag ){
- value = va_arg( args, long );
- } else {
- value = va_arg( args, int );
- }
- fmtnum( value, 10,0, ljust, len, zpad ); break;
- case 'o': case 'O':
- /*fmtnum(value,base,dosign,ljust,len,zpad) */
- if( longflag ){
- value = va_arg( args, long );
- } else {
- value = va_arg( args, int );
- }
- fmtnum( value, 8,0, ljust, len, zpad ); break;
- case 'd': case 'D':
- if( longflag ){
- value = va_arg( args, long );
- } else {
- value = va_arg( args, int );
- }
- fmtnum( value, 10,1, ljust, len, zpad ); break;
- case 'x':
- if( longflag ){
- value = va_arg( args, long );
- } else {
- value = va_arg( args, int );
- }
- fmtnum( value, 16,0, ljust, len, zpad ); break;
- case 'X':
- if( longflag ){
- value = va_arg( args, long );
- } else {
- value = va_arg( args, int );
- }
- fmtnum( value,-16,0, ljust, len, zpad ); break;
- case 's':
- strvalue = va_arg( args, char *);
- if (maxwidth > 0 || !pointflag) {
- if (pointflag && len > maxwidth)
- len = maxwidth; /* Adjust padding */
- fmtstr( strvalue,ljust,len,zpad, maxwidth);
- }
- break;
- case 'c':
- ch = va_arg( args, int );
- dopr_outch( ch ); break;
- case 'm':
-#if HASSTRERROR
- dostr(strerror(SyslogErrno), 0);
-#else
- if (SyslogErrno < 0 || SyslogErrno >= sys_nerr)
- {
- dostr("Error ", 0);
- fmtnum(SyslogErrno, 10, 0, 0, 0, 0);
- }
- else
- dostr((char *)sys_errlist[SyslogErrno], 0);
-#endif
- break;
-
- case '%': dopr_outch( ch ); continue;
- default:
- dostr( "???????" , 0);
- }
- break;
- default:
- dopr_outch( ch );
- break;
- }
- }
- *output = 0;
-}
-
-void
-fmtstr( value, ljust, len, zpad, maxwidth )
- char *value;
- int ljust, len, zpad, maxwidth;
-{
- int padlen, strlen; /* amount to pad */
-
- if( value == 0 ){
- value = "<NULL>";
- }
- for( strlen = 0; value[strlen]; ++ strlen ); /* strlen */
- if (strlen > maxwidth && maxwidth)
- strlen = maxwidth;
- padlen = len - strlen;
- if( padlen < 0 ) padlen = 0;
- if( ljust ) padlen = -padlen;
- while( padlen > 0 ) {
- dopr_outch( ' ' );
- --padlen;
- }
- dostr( value, maxwidth );
- while( padlen < 0 ) {
- dopr_outch( ' ' );
- ++padlen;
- }
-}
-
-void
-fmtnum( value, base, dosign, ljust, len, zpad )
- long value;
- int base, dosign, ljust, len, zpad;
-{
- int signvalue = 0;
- unsigned long uvalue;
- char convert[20];
- int place = 0;
- int padlen = 0; /* amount to pad */
- int caps = 0;
-
- /* DEBUGP(("value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n",
- value, base, dosign, ljust, len, zpad )); */
- uvalue = value;
- if( dosign ){
- if( value < 0 ) {
- signvalue = '-';
- uvalue = -value;
- }
- }
- if( base < 0 ){
- caps = 1;
- base = -base;
- }
- do{
- convert[place++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")
- [uvalue % (unsigned)base ];
- uvalue = (uvalue / (unsigned)base );
- }while(uvalue);
- convert[place] = 0;
- padlen = len - place;
- if( padlen < 0 ) padlen = 0;
- if( ljust ) padlen = -padlen;
- /* DEBUGP(( "str '%s', place %d, sign %c, padlen %d\n",
- convert,place,signvalue,padlen)); */
- if( zpad && padlen > 0 ){
- if( signvalue ){
- dopr_outch( signvalue );
- --padlen;
- signvalue = 0;
- }
- while( padlen > 0 ){
- dopr_outch( zpad );
- --padlen;
- }
- }
- while( padlen > 0 ) {
- dopr_outch( ' ' );
- --padlen;
- }
- if( signvalue ) dopr_outch( signvalue );
- while( place > 0 ) dopr_outch( convert[--place] );
- while( padlen < 0 ){
- dopr_outch( ' ' );
- ++padlen;
- }
-}
-
-void
-dostr( str , cut)
- char *str;
- int cut;
-{
- if (cut) {
- while(*str && cut-- > 0) dopr_outch(*str++);
- } else {
- while(*str) dopr_outch(*str++);
- }
-}
-
-void
-dopr_outch( c )
- int c;
-{
-#if 0
- if( iscntrl(c) && c != '\n' && c != '\t' ){
- c = '@' + (c & 0x1F);
- if( DoprEnd == 0 || output < DoprEnd )
- *output++ = '^';
- }
-#endif
- if( DoprEnd == 0 || output < DoprEnd )
- *output++ = c;
- else
- SnprfOverflow++;
-}
-
- /*
-** QUAD_TO_STRING -- Convert a quad type to a string.
-**
-** Convert a quad type to a string. This must be done
-** separately as %lld/%qd are not supported by snprint()
-** and adding support would slow down systems which only
-** emulate the data type.
-**
-** Parameters:
-** value -- number to convert to a string.
-**
-** Returns:
-** pointer to a string.
-*/
-
-char *
-quad_to_string(value)
- QUAD_T value;
-{
- char *fmtstr;
- static char buf[64];
-
- /*
- ** Use sprintf() instead of snprintf() since snprintf()
- ** does not support %qu or %llu. The buffer is large enough
- ** to hold the string so there is no danger of buffer
- ** overflow.
- */
-
-#if NEED_PERCENTQ
- fmtstr = "%qu";
-#else
- fmtstr = "%llu";
-#endif
- sprintf(buf, fmtstr, value);
- return buf;
-}
- /*
-** SHORTENSTRING -- return short version of a string
-**
-** If the string is already short, just return it. If it is too
-** long, return the head and tail of the string.
-**
-** Parameters:
-** s -- the string to shorten.
-** m -- the max length of the string.
-**
-** Returns:
-** Either s or a short version of s.
-*/
-
-char *
-shortenstring(s, m)
- register const char *s;
- int m;
-{
- int l;
- static char buf[MAXSHORTSTR + 1];
-
- l = strlen(s);
- if (l < m)
- return (char *) s;
- if (m > MAXSHORTSTR)
- m = MAXSHORTSTR;
- else if (m < 10)
- {
- if (m < 5)
- {
- strncpy(buf, s, m);
- buf[m] = '\0';
- return buf;
- }
- strncpy(buf, s, m - 3);
- strcpy(buf + m - 3, "...");
- return buf;
- }
- m = (m - 3) / 2;
- strncpy(buf, s, m);
- strcpy(buf + m, "...");
- strcpy(buf + m + 3, s + l - m);
- return buf;
-}
diff --git a/contrib/sendmail/src/useful.h b/contrib/sendmail/src/useful.h
deleted file mode 100644
index a19dd9e0305d6..0000000000000
--- a/contrib/sendmail/src/useful.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1998 Sendmail, Inc. All rights reserved.
- * Copyright (c) 1995-1997 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.
- *
- *
- * @(#)useful.h 8.12 (Berkeley) 5/19/1998
- */
-
-# include <sys/types.h>
-
-/* support for bool type */
-typedef int bool;
-#ifndef TRUE
-# define TRUE 1
-# define FALSE 0
-#endif
-
-# ifndef NULL
-# define NULL 0
-# endif /* NULL */
-
-/* bit hacking */
-# define bitset(bit, word) (((word) & (bit)) != 0)
-
-/* some simple functions */
-# ifndef max
-# define max(a, b) ((a) > (b) ? (a) : (b))
-# define min(a, b) ((a) < (b) ? (a) : (b))
-# endif
-
-/* assertions */
-# ifndef NASSERT
-# define ASSERT(expr, msg, parm)\
- if (!(expr))\
- {\
- fprintf(stderr, "assertion botch: %s:%d: ", __FILE__, __LINE__);\
- fprintf(stderr, msg, parm);\
- }
-# else /* NASSERT */
-# define ASSERT(expr, msg, parm)
-# endif /* NASSERT */
-
-/* sccs id's */
-# ifndef lint
-# ifdef __STDC__
-# define SCCSID(arg) static char SccsId[] = #arg;
-# else
-# define SCCSID(arg) static char SccsId[] = "arg";
-# endif
-# else
-# define SCCSID(arg)
-# endif