diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2003-09-19 23:11:30 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2003-09-19 23:11:30 +0000 |
commit | 96b960fca637a0765d566591885b7d42576e723f (patch) | |
tree | e6205d213aedfefacf00b4211611f436bae5e680 /contrib/sendmail/libsm | |
parent | ac5ff30ae19ff6f7473f23c0d36d94301124b150 (diff) | |
download | FreeBSD-src-96b960fca637a0765d566591885b7d42576e723f.zip FreeBSD-src-96b960fca637a0765d566591885b7d42576e723f.tar.gz |
Import sendmail 8.12.10
Diffstat (limited to 'contrib/sendmail/libsm')
-rw-r--r-- | contrib/sendmail/libsm/clock.c | 116 | ||||
-rw-r--r-- | contrib/sendmail/libsm/errstring.c | 10 | ||||
-rw-r--r-- | contrib/sendmail/libsm/flags.c | 8 | ||||
-rw-r--r-- | contrib/sendmail/libsm/ldap.c | 4 | ||||
-rw-r--r-- | contrib/sendmail/libsm/shm.c | 9 | ||||
-rw-r--r-- | contrib/sendmail/libsm/smstdio.c | 19 | ||||
-rw-r--r-- | contrib/sendmail/libsm/stdio.c | 16 | ||||
-rw-r--r-- | contrib/sendmail/libsm/vasprintf.c | 33 |
8 files changed, 175 insertions, 40 deletions
diff --git a/contrib/sendmail/libsm/clock.c b/contrib/sendmail/libsm/clock.c index 970bb1f..4d70cb8 100644 --- a/contrib/sendmail/libsm/clock.c +++ b/contrib/sendmail/libsm/clock.c @@ -12,7 +12,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: clock.c,v 1.35.2.3 2003/03/03 19:57:40 ca Exp $") +SM_RCSID("@(#)$Id: clock.c,v 1.35.2.10 2003/06/26 16:36:49 ca Exp $") #include <unistd.h> #include <time.h> #include <errno.h> @@ -24,13 +24,17 @@ SM_RCSID("@(#)$Id: clock.c,v 1.35.2.3 2003/03/03 19:57:40 ca Exp $") #include <sm/bitops.h> #include <sm/clock.h> #include "local.h" +#if _FFR_SLEEP_USE_SELECT > 0 +# include <sys/types.h> +#endif /* _FFR_SLEEP_USE_SELECT > 0 */ +#if defined(_FFR_MAX_SLEEP_TIME) && _FFR_MAX_SLEEP_TIME > 2 +# include <syslog.h> +#endif /* defined(_FFR_MAX_SLEEP_TIME) && _FFR_MAX_SLEEP_TIME > 2 */ #ifndef sigmask # define sigmask(s) (1 << ((s) - 1)) #endif /* ! sigmask */ -static void sm_endsleep __P((void)); - /* ** SM_SETEVENTM -- set an event to happen at a specific time in milliseconds. @@ -136,6 +140,8 @@ sm_sigsafe_seteventm(intvl, func, arg) */ LEAVE_CRITICAL(); + if (wasblocked == 0) + (void) sm_releasesignal(SIGALRM); return NULL; } else @@ -490,7 +496,10 @@ sm_tick(sig) */ +# if !HAVE_NANOSLEEP +static void sm_endsleep __P((void)); static bool volatile SmSleepDone; +# endif /* !HAVE_NANOSLEEP */ #ifndef SLEEP_T # define SLEEP_T unsigned int @@ -500,20 +509,118 @@ SLEEP_T sleep(intvl) unsigned int intvl; { +#if HAVE_NANOSLEEP + struct timespec rqtp; + + if (intvl == 0) + return (SLEEP_T) 0; + rqtp.tv_sec = intvl; + rqtp.tv_nsec = 0; + nanosleep(&rqtp, NULL); + return (SLEEP_T) 0; +#else /* HAVE_NANOSLEEP */ int was_held; + SM_EVENT *ev; +#if _FFR_SLEEP_USE_SELECT > 0 + int r; +#endif /* _FFR_SLEEP_USE_SELECT > 0 */ +#if SM_CONF_SETITIMER + struct timeval now, begin, diff; +# if _FFR_SLEEP_USE_SELECT > 0 + struct timeval sm_io_to, slpv; +# endif /* _FFR_SLEEP_USE_SELECT > 0 */ +#else /* SM_CONF_SETITIMER */ + time_t begin, now; +#endif /* SM_CONF_SETITIMER */ if (intvl == 0) return (SLEEP_T) 0; +#if defined(_FFR_MAX_SLEEP_TIME) && _FFR_MAX_SLEEP_TIME > 2 + if (intvl > _FFR_MAX_SLEEP_TIME) + { + syslog(LOG_ERR, "sleep: interval=%u exceeds max value %d", + intvl, _FFR_MAX_SLEEP_TIME); +# if 0 + SM_ASSERT(intvl < (unsigned int) INT_MAX); +# endif /* 0 */ + intvl = _FFR_MAX_SLEEP_TIME; + } +#endif /* defined(_FFR_MAX_SLEEP_TIME) && _FFR_MAX_SLEEP_TIME > 2 */ SmSleepDone = false; - (void) sm_setevent((time_t) intvl, sm_endsleep, 0); + +#if SM_CONF_SETITIMER +# if _FFR_SLEEP_USE_SELECT > 0 + slpv.tv_sec = intvl; + slpv.tv_usec = 0; +# endif /* _FFR_SLEEP_USE_SELECT > 0 */ + (void) gettimeofday(&now, NULL); + begin = now; +#else /* SM_CONF_SETITIMER */ + now = begin = time(NULL); +#endif /* SM_CONF_SETITIMER */ + + ev = sm_setevent((time_t) intvl, sm_endsleep, 0); + if (ev == NULL) + { + /* COMPLAIN */ +#if 0 + syslog(LOG_ERR, "sleep: sm_setevent(%u) failed", intvl); +#endif /* 0 */ + SmSleepDone = true; + } was_held = sm_releasesignal(SIGALRM); + while (!SmSleepDone) + { +#if SM_CONF_SETITIMER + (void) gettimeofday(&now, NULL); + timersub(&now, &begin, &diff); + if (diff.tv_sec < 0 || + (diff.tv_sec == 0 && diff.tv_usec == 0)) + break; +# if _FFR_SLEEP_USE_SELECT > 0 + timersub(&slpv, &diff, &sm_io_to); +# endif /* _FFR_SLEEP_USE_SELECT > 0 */ +#else /* SM_CONF_SETITIMER */ + now = time(NULL); + + /* + ** Check whether time expired before signal is released. + ** Due to the granularity of time() add 1 to be on the + ** safe side. + */ + + if (!(begin + (time_t) intvl + 1 > now)) + break; +# if _FFR_SLEEP_USE_SELECT > 0 + sm_io_to.tv_sec = intvl - (now - begin); + if (sm_io_to.tv_sec <= 0) + sm_io_to.tv_sec = 1; + sm_io_to.utv_sec = 0; +# endif /* _FFR_SLEEP_USE_SELECT > 0 */ +#endif /* SM_CONF_SETITIMER */ +#if _FFR_SLEEP_USE_SELECT > 0 + if (intvl <= _FFR_SLEEP_USE_SELECT) + { + r = select(0, NULL, NULL, NULL, &sm_io_to); + if (r == 0) + break; + } + else +#endif /* _FFR_SLEEP_USE_SELECT > 0 */ (void) pause(); + } + + /* if out of the loop without the event being triggered remove it */ + if (!SmSleepDone) + sm_clrevent(ev); if (was_held > 0) (void) sm_blocksignal(SIGALRM); return (SLEEP_T) 0; +#endif /* HAVE_NANOSLEEP */ } +#if !HAVE_NANOSLEEP static void sm_endsleep() { @@ -525,4 +632,5 @@ sm_endsleep() SmSleepDone = true; } +#endif /* !HAVE_NANOSLEEP */ diff --git a/contrib/sendmail/libsm/errstring.c b/contrib/sendmail/libsm/errstring.c index 29aaade..74387a9 100644 --- a/contrib/sendmail/libsm/errstring.c +++ b/contrib/sendmail/libsm/errstring.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001 Sendmail, Inc. and its suppliers. + * Copyright (c) 2001, 2003 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -11,7 +11,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: errstring.c,v 1.12 2001/10/03 16:09:32 ca Exp $") +SM_RCSID("@(#)$Id: errstring.c,v 1.12.2.4 2003/06/24 17:16:09 ca Exp $") #include <errno.h> #include <stdio.h> /* sys_errlist, on some platforms */ @@ -42,6 +42,8 @@ SM_RCSID("@(#)$Id: errstring.c,v 1.12 2001/10/03 16:09:32 ca Exp $") ** ** Returns: ** A string description of errnum. +** +** Note: this may point to a local (static) buffer. */ const char * @@ -50,6 +52,7 @@ sm_errstring(errnum) { char *ret; + switch (errnum) { case EPERM: @@ -183,6 +186,9 @@ sm_errstring(errnum) case SMDBE_OLD_VERSION: return "Berkeley DB file is an old version, recreate it"; + + case SMDBE_VERSION_MISMATCH: + return "Berkeley DB version mismatch between include file and library"; } /* diff --git a/contrib/sendmail/libsm/flags.c b/contrib/sendmail/libsm/flags.c index b3877f1..7e2b0e2 100644 --- a/contrib/sendmail/libsm/flags.c +++ b/contrib/sendmail/libsm/flags.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. + * Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -13,7 +13,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: flags.c,v 1.20 2001/09/11 04:04:48 gshapiro Exp $") +SM_RCSID("@(#)$Id: flags.c,v 1.20.2.1 2003/09/03 18:51:56 ca Exp $") #include <sys/types.h> #include <sys/file.h> #include <errno.h> @@ -35,7 +35,7 @@ sm_flags(flags) { register int ret; - switch(flags) + switch(SM_IO_MODE(flags)) { case SM_IO_RDONLY: /* open for reading */ ret = SMRD; @@ -57,5 +57,7 @@ sm_flags(flags) ret = 0; break; } + if (SM_IS_BINARY(flags)) + ret |= SM_IO_BINARY; return ret; } diff --git a/contrib/sendmail/libsm/ldap.c b/contrib/sendmail/libsm/ldap.c index bc426a0..b022b39 100644 --- a/contrib/sendmail/libsm/ldap.c +++ b/contrib/sendmail/libsm/ldap.c @@ -8,7 +8,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: ldap.c,v 1.44.2.2 2002/08/09 22:23:12 gshapiro Exp $") +SM_RCSID("@(#)$Id: ldap.c,v 1.44.2.3 2003/07/07 20:16:16 gshapiro Exp $") #if LDAPMAP # include <sys/types.h> @@ -582,7 +582,7 @@ sm_ldap_results(lmap, msgid, flags, delim, rpool, result, save_errno += E_LDAPBASE; SM_LDAP_ERROR_CLEANUP(); errno = save_errno; - return EX_OSERR; + return EX_TEMPFAIL; } rl = sm_ldap_add_recurse(&recurse, dn, diff --git a/contrib/sendmail/libsm/shm.c b/contrib/sendmail/libsm/shm.c index 35ae028..2299aed 100644 --- a/contrib/sendmail/libsm/shm.c +++ b/contrib/sendmail/libsm/shm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. + * Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set @@ -8,7 +8,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: shm.c,v 1.10 2001/12/14 00:22:58 ca Exp $") +SM_RCSID("@(#)$Id: shm.c,v 1.10.2.6 2003/06/13 21:17:48 ca Exp $") #if SM_CONF_SHM # include <stdlib.h> @@ -16,6 +16,7 @@ SM_RCSID("@(#)$Id: shm.c,v 1.10 2001/12/14 00:22:58 ca Exp $") # include <errno.h> # include <sm/shm.h> + /* ** SM_SHMSTART -- initialize shared memory segment. ** @@ -69,6 +70,7 @@ sm_shmstart(key, size, shmflg, shmid, owner) return (void *) 0; } + /* ** SM_SHMSTOP -- stop using shared memory segment. ** @@ -85,6 +87,7 @@ sm_shmstart(key, size, shmflg, shmid, owner) ** detaches (and maybe removes) shared memory segment. */ + int sm_shmstop(shm, shmid, owner) void *shm; @@ -99,4 +102,6 @@ sm_shmstop(shm, shmid, owner) return r; return 0; } + + #endif /* SM_CONF_SHM */ diff --git a/contrib/sendmail/libsm/smstdio.c b/contrib/sendmail/libsm/smstdio.c index 879fcd2..d561e8d 100644 --- a/contrib/sendmail/libsm/smstdio.c +++ b/contrib/sendmail/libsm/smstdio.c @@ -8,7 +8,7 @@ */ #include <sm/gen.h> -SM_IDSTR(id, "@(#)$Id: smstdio.c,v 1.32 2002/02/23 20:18:36 gshapiro Exp $") +SM_IDSTR(id, "@(#)$Id: smstdio.c,v 1.32.2.2 2003/09/05 20:35:28 ca Exp $") #include <unistd.h> #include <stdio.h> #include <fcntl.h> @@ -68,6 +68,23 @@ sm_stdioopen(fp, info, flags, rpool) case SM_IO_APPENDRW: stdiomode = "a+"; break; +#if SM_IO_BINARY != 0 + case SM_IO_RDONLY_B: + stdiomode = "rb"; + break; + case SM_IO_WRONLY_B: + stdiomode = "wb"; + break; + case SM_IO_APPEND_B: + stdiomode = "ab"; + break; + case SM_IO_APPENDRW_B: + stdiomode = "a+b"; + break; + case SM_IO_RDWR_B: + stdiomode = "r+b"; + break; +#endif /* SM_IO_BINARY != 0 */ case SM_IO_RDWR: default: stdiomode = "r+"; diff --git a/contrib/sendmail/libsm/stdio.c b/contrib/sendmail/libsm/stdio.c index d45a774..23cc2af 100644 --- a/contrib/sendmail/libsm/stdio.c +++ b/contrib/sendmail/libsm/stdio.c @@ -13,7 +13,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: stdio.c,v 1.56.2.10 2003/01/10 23:07:17 ca Exp $") +SM_RCSID("@(#)$Id: stdio.c,v 1.56.2.13 2003/09/04 01:18:08 ca Exp $") #include <unistd.h> #include <errno.h> #include <fcntl.h> @@ -63,7 +63,7 @@ sm_stdopen(fp, info, flags, rpool) char *path = (char *) info; int oflags; - switch (flags) + switch (SM_IO_MODE(flags)) { case SM_IO_RDWR: oflags = O_RDWR; @@ -87,6 +87,10 @@ sm_stdopen(fp, info, flags, rpool) errno = EINVAL; return -1; } +#ifdef O_BINARY + if (SM_IS_BINARY(flags)) + oflags |= O_BINARY; +#endif /* O_BINARY */ fp->f_file = open(path, oflags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); if (fp->f_file < 0) @@ -221,7 +225,7 @@ sm_stdsetmode(fp, mode) { int flags = 0; - switch (*mode) + switch (SM_IO_MODE(*mode)) { case SM_IO_RDWR: flags |= SMRW; @@ -402,7 +406,7 @@ sm_stdfdopen(fp, info, flags, rpool) { int oflags, tmp, fdflags, fd = *((int *) info); - switch (flags) + switch (SM_IO_MODE(flags)) { case SM_IO_RDWR: oflags = O_RDWR | O_CREAT; @@ -423,6 +427,10 @@ sm_stdfdopen(fp, info, flags, rpool) errno = EINVAL; return -1; } +#ifdef O_BINARY + if (SM_IS_BINARY(flags)) + oflags |= O_BINARY; +#endif /* O_BINARY */ /* Make sure the mode the user wants is a subset of the actual mode. */ if ((fdflags = fcntl(fd, F_GETFL, 0)) < 0) diff --git a/contrib/sendmail/libsm/vasprintf.c b/contrib/sendmail/libsm/vasprintf.c index 9b3a12e..3441a3d 100644 --- a/contrib/sendmail/libsm/vasprintf.c +++ b/contrib/sendmail/libsm/vasprintf.c @@ -9,33 +9,22 @@ /* * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> - * All rights reserved. * - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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. + * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE + * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: vasprintf.c,v 1.26 2001/09/11 04:04:49 gshapiro Exp $") +SM_RCSID("@(#)$Id: vasprintf.c,v 1.26.2.1 2003/06/03 02:14:09 ca Exp $") #include <stdlib.h> #include <errno.h> #include <sm/io.h> |