diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2004-08-01 01:04:57 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2004-08-01 01:04:57 +0000 |
commit | 1fc446a819a244515d9461fa50d34ee191414d6f (patch) | |
tree | f6477ae85b00ee6d58b086b0d1d597dd9a403391 /contrib/sendmail/libsm | |
parent | 238623a0204c90e8d61dbde7b3b499a5036f2e5d (diff) | |
download | FreeBSD-src-1fc446a819a244515d9461fa50d34ee191414d6f.zip FreeBSD-src-1fc446a819a244515d9461fa50d34ee191414d6f.tar.gz |
Import sendmail 8.13.1
Diffstat (limited to 'contrib/sendmail/libsm')
-rw-r--r-- | contrib/sendmail/libsm/Makefile.m4 | 4 | ||||
-rw-r--r-- | contrib/sendmail/libsm/README | 5 | ||||
-rw-r--r-- | contrib/sendmail/libsm/assert.c | 2 | ||||
-rw-r--r-- | contrib/sendmail/libsm/clock.c | 11 | ||||
-rw-r--r-- | contrib/sendmail/libsm/config.c | 8 | ||||
-rw-r--r-- | contrib/sendmail/libsm/debug.c | 27 | ||||
-rw-r--r-- | contrib/sendmail/libsm/errstring.c | 75 | ||||
-rw-r--r-- | contrib/sendmail/libsm/exc.c | 2 | ||||
-rw-r--r-- | contrib/sendmail/libsm/flags.c | 4 | ||||
-rw-r--r-- | contrib/sendmail/libsm/ldap.c | 191 | ||||
-rw-r--r-- | contrib/sendmail/libsm/local.h | 2 | ||||
-rw-r--r-- | contrib/sendmail/libsm/mbdb.c | 8 | ||||
-rw-r--r-- | contrib/sendmail/libsm/refill.c | 2 | ||||
-rw-r--r-- | contrib/sendmail/libsm/rpool.c | 32 | ||||
-rw-r--r-- | contrib/sendmail/libsm/shm.c | 2 | ||||
-rw-r--r-- | contrib/sendmail/libsm/smstdio.c | 4 | ||||
-rw-r--r-- | contrib/sendmail/libsm/stdio.c | 4 | ||||
-rw-r--r-- | contrib/sendmail/libsm/strdup.c | 98 | ||||
-rw-r--r-- | contrib/sendmail/libsm/t-shm.c | 5 | ||||
-rw-r--r-- | contrib/sendmail/libsm/vasprintf.c | 2 |
20 files changed, 414 insertions, 74 deletions
diff --git a/contrib/sendmail/libsm/Makefile.m4 b/contrib/sendmail/libsm/Makefile.m4 index 563cf10..f028c24 100644 --- a/contrib/sendmail/libsm/Makefile.m4 +++ b/contrib/sendmail/libsm/Makefile.m4 @@ -1,11 +1,11 @@ -dnl $Id: Makefile.m4,v 1.64.2.1 2002/06/21 21:58:29 ca Exp $ +dnl $Id: Makefile.m4,v 1.66 2003/11/03 18:28:26 ca Exp $ define(`confREQUIRE_LIBUNIX') include(confBUILDTOOLSDIR`/M4/switch.m4') define(`confREQUIRE_LIBSM', `true') PREPENDDEF(`confENVDEF', `confMAPDEF') bldPRODUCT_START(`library', `libsm') -define(`bldSOURCES', ` assert.c debug.c errstring.c exc.c heap.c match.c rpool.c strdup.c strerror.c strl.c clrerr.c fclose.c feof.c ferror.c fflush.c fget.c fpos.c findfp.c flags.c fopen.c fprintf.c fpurge.c fput.c fread.c fscanf.c fseek.c fvwrite.c fwalk.c fwrite.c get.c makebuf.c put.c refill.c rewind.c setvbuf.c smstdio.c snprintf.c sscanf.c stdio.c strio.c ungetc.c vasprintf.c vfprintf.c vfscanf.c vprintf.c vsnprintf.c vsprintf.c vsscanf.c wbuf.c wsetup.c string.c stringf.c xtrap.c strto.c test.c path.c strcasecmp.c strrevcmp.c signal.c clock.c config.c shm.c mbdb.c strexit.c cf.c ldap.c niprop.c mpeix.c ') +define(`bldSOURCES', ` assert.c debug.c errstring.c exc.c heap.c match.c rpool.c strdup.c strerror.c strl.c clrerr.c fclose.c feof.c ferror.c fflush.c fget.c fpos.c findfp.c flags.c fopen.c fprintf.c fpurge.c fput.c fread.c fscanf.c fseek.c fvwrite.c fwalk.c fwrite.c get.c makebuf.c put.c refill.c rewind.c setvbuf.c smstdio.c snprintf.c sscanf.c stdio.c strio.c ungetc.c vasprintf.c vfprintf.c vfscanf.c vprintf.c vsnprintf.c vsscanf.c wbuf.c wsetup.c string.c stringf.c xtrap.c strto.c test.c path.c strcasecmp.c strrevcmp.c signal.c clock.c config.c shm.c mbdb.c strexit.c cf.c ldap.c niprop.c mpeix.c ') bldPRODUCT_END dnl sem.c msg.c dnl syslogio.c diff --git a/contrib/sendmail/libsm/README b/contrib/sendmail/libsm/README index d75d55f..aff25a1 100644 --- a/contrib/sendmail/libsm/README +++ b/contrib/sendmail/libsm/README @@ -5,7 +5,7 @@ # forth in the LICENSE file which can be found at the top level of # the sendmail distribution. # -# $Id: README,v 1.21 2002/01/23 17:30:48 gshapiro Exp $ +# $Id: README,v 1.24 2003/12/20 09:23:48 gshapiro Exp $ # Libsm is a library of generally useful C abstractions. @@ -109,6 +109,9 @@ SM_CONF_BROKEN_STRTOD SM_CONF_GETOPT Set to 1 if your operating system does not include getopt(3). +SM_CONF_LDAP_INITIALIZE + Set to 1 if your LDAP client libraries include ldap_initialize(3). + SM_CONF_LDAP_MEMFREE Set to 1 if your LDAP client libraries include ldap_memfree(3). diff --git a/contrib/sendmail/libsm/assert.c b/contrib/sendmail/libsm/assert.c index 7ba5c1a..7200a0f 100644 --- a/contrib/sendmail/libsm/assert.c +++ b/contrib/sendmail/libsm/assert.c @@ -9,7 +9,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: assert.c,v 1.25.2.1 2003/12/05 22:44:17 ca Exp $") +SM_RCSID("@(#)$Id: assert.c,v 1.26 2003/12/05 22:45:24 ca Exp $") /* ** Abnormal program termination and assertion checking. diff --git a/contrib/sendmail/libsm/clock.c b/contrib/sendmail/libsm/clock.c index 4d70cb8..5805554 100644 --- a/contrib/sendmail/libsm/clock.c +++ b/contrib/sendmail/libsm/clock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2003 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -12,7 +12,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: clock.c,v 1.35.2.10 2003/06/26 16:36:49 ca Exp $") +SM_RCSID("@(#)$Id: clock.c,v 1.45 2004/01/19 19:32:08 ca Exp $") #include <unistd.h> #include <time.h> #include <errno.h> @@ -523,11 +523,14 @@ sleep(intvl) SM_EVENT *ev; #if _FFR_SLEEP_USE_SELECT > 0 int r; +# if _FFR_SLEEP_USE_SELECT > 0 + struct timeval sm_io_to; +# endif /* _FFR_SLEEP_USE_SELECT > 0 */ #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; + struct timeval slpv; # endif /* _FFR_SLEEP_USE_SELECT > 0 */ #else /* SM_CONF_SETITIMER */ time_t begin, now; @@ -596,7 +599,7 @@ sleep(intvl) 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; + sm_io_to.tv_usec = 0; # endif /* _FFR_SLEEP_USE_SELECT > 0 */ #endif /* SM_CONF_SETITIMER */ #if _FFR_SLEEP_USE_SELECT > 0 diff --git a/contrib/sendmail/libsm/config.c b/contrib/sendmail/libsm/config.c index ea6aeb9..a5e1327 100644 --- a/contrib/sendmail/libsm/config.c +++ b/contrib/sendmail/libsm/config.c @@ -9,7 +9,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: config.c,v 1.27.2.1 2003/03/06 02:16:24 ca Exp $") +SM_RCSID("@(#)$Id: config.c,v 1.30 2003/12/10 03:19:07 gshapiro Exp $") #include <stdlib.h> #include <sm/heap.h> @@ -176,6 +176,9 @@ char *SmCompileOptions[] = #if SM_CONF_GETOPT "SM_CONF_GETOPT", #endif /* SM_CONF_GETOPT */ +#if SM_CONF_LDAP_INITIALIZE + "SM_CONF_LDAP_INITIALIZE", +#endif /* SM_CONF_LDAP_INITIALIZE */ #if SM_CONF_LDAP_MEMFREE "SM_CONF_LDAP_MEMFREE", #endif /* SM_CONF_LDAP_MEMFREE */ @@ -232,6 +235,9 @@ char *SmCompileOptions[] = #if SM_CONF_UID_GID "SM_CONF_UID_GID", #endif /* SM_CONF_UID_GID */ +#if DO_NOT_USE_STRCPY + "DO_NOT_USE_STRCPY", +#endif /* DO_NOT_USE_STRCPY */ #if SM_HEAP_CHECK "SM_HEAP_CHECK", #endif /* SM_HEAP_CHECK */ diff --git a/contrib/sendmail/libsm/debug.c b/contrib/sendmail/libsm/debug.c index 37e5e82..a6582ae 100644 --- a/contrib/sendmail/libsm/debug.c +++ b/contrib/sendmail/libsm/debug.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: debug.c,v 1.28 2001/09/25 19:57:05 gshapiro Exp $") +SM_RCSID("@(#)$Id: debug.c,v 1.29 2003/01/10 00:26:06 ca Exp $") /* ** libsm debugging and tracing @@ -77,6 +77,29 @@ sm_debug_setfile(fp) } /* +** SM_DEBUG_CLOSE -- Close debug file pointer. +** +** Parameters: +** none. +** +** Returns: +** none. +** +** Side Effects: +** Closes SmDebugOutput. +*/ + +void +sm_debug_close() +{ + if (SmDebugOutput != NULL && SmDebugOutput != smioout) + { + sm_io_close(SmDebugOutput, SM_TIME_DEFAULT); + SmDebugOutput = NULL; + } +} + +/* ** SM_DPRINTF -- printf() for debug output. ** ** Parameters: diff --git a/contrib/sendmail/libsm/errstring.c b/contrib/sendmail/libsm/errstring.c index 74387a9..b2999bd 100644 --- a/contrib/sendmail/libsm/errstring.c +++ b/contrib/sendmail/libsm/errstring.c @@ -11,7 +11,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: errstring.c,v 1.12.2.4 2003/06/24 17:16:09 ca Exp $") +SM_RCSID("@(#)$Id: errstring.c,v 1.19 2003/12/10 03:53:05 gshapiro Exp $") #include <errno.h> #include <stdio.h> /* sys_errlist, on some platforms */ @@ -189,13 +189,84 @@ sm_errstring(errnum) case SMDBE_VERSION_MISMATCH: return "Berkeley DB version mismatch between include file and library"; + +#if LDAPMAP + + /* + ** LDAP URL error messages. + */ + + /* OpenLDAP errors */ +# ifdef LDAP_URL_ERR_MEM + case E_LDAPURLBASE + LDAP_URL_ERR_MEM: + return "LDAP URL can't allocate memory space"; +# endif /* LDAP_URL_ERR_MEM */ + +# ifdef LDAP_URL_ERR_PARAM + case E_LDAPURLBASE + LDAP_URL_ERR_PARAM: + return "LDAP URL parameter is bad"; +# endif /* LDAP_URL_ERR_PARAM */ + +# ifdef LDAP_URL_ERR_BADSCHEME + case E_LDAPURLBASE + LDAP_URL_ERR_BADSCHEME: + return "LDAP URL doesn't begin with \"ldap[si]://\""; +# endif /* LDAP_URL_ERR_BADSCHEME */ + +# ifdef LDAP_URL_ERR_BADENCLOSURE + case E_LDAPURLBASE + LDAP_URL_ERR_BADENCLOSURE: + return "LDAP URL is missing trailing \">\""; +# endif /* LDAP_URL_ERR_BADENCLOSURE */ + +# ifdef LDAP_URL_ERR_BADURL + case E_LDAPURLBASE + LDAP_URL_ERR_BADURL: + return "LDAP URL is bad"; +# endif /* LDAP_URL_ERR_BADURL */ + +# ifdef LDAP_URL_ERR_BADHOST + case E_LDAPURLBASE + LDAP_URL_ERR_BADHOST: + return "LDAP URL host port is bad"; +# endif /* LDAP_URL_ERR_BADHOST */ + +# ifdef LDAP_URL_ERR_BADATTRS + case E_LDAPURLBASE + LDAP_URL_ERR_BADATTRS: + return "LDAP URL bad (or missing) attributes"; +# endif /* LDAP_URL_ERR_BADATTRS */ + +# ifdef LDAP_URL_ERR_BADSCOPE + case E_LDAPURLBASE + LDAP_URL_ERR_BADSCOPE: + return "LDAP URL scope string is invalid (or missing)"; +# endif /* LDAP_URL_ERR_BADSCOPE */ + +# ifdef LDAP_URL_ERR_BADFILTER + case E_LDAPURLBASE + LDAP_URL_ERR_BADFILTER: + return "LDAP URL bad or missing filter"; +# endif /* LDAP_URL_ERR_BADFILTER */ + +# ifdef LDAP_URL_ERR_BADEXTS + case E_LDAPURLBASE + LDAP_URL_ERR_BADEXTS: + return "LDAP URL bad or missing extensions"; +# endif /* LDAP_URL_ERR_BADEXTS */ + + /* Sun LDAP errors */ +# ifdef LDAP_URL_ERR_NOTLDAP + case E_LDAPURLBASE + LDAP_URL_ERR_NOTLDAP: + return "LDAP URL doesn't begin with \"ldap://\""; +# endif /* LDAP_URL_ERR_NOTLDAP */ + +# ifdef LDAP_URL_ERR_NODN + case E_LDAPURLBASE + LDAP_URL_ERR_NODN: + return "LDAP URL has no DN (required)"; +# endif /* LDAP_URL_ERR_NODN */ + +#endif /* LDAPMAP */ } +#if LDAPMAP + /* ** LDAP error messages. */ -#if LDAPMAP if (errnum >= E_LDAPBASE) return ldap_err2string(errnum - E_LDAPBASE); #endif /* LDAPMAP */ diff --git a/contrib/sendmail/libsm/exc.c b/contrib/sendmail/libsm/exc.c index e2360c6..26ad020 100644 --- a/contrib/sendmail/libsm/exc.c +++ b/contrib/sendmail/libsm/exc.c @@ -9,7 +9,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: exc.c,v 1.47.2.1 2003/12/05 22:44:17 ca Exp $") +SM_RCSID("@(#)$Id: exc.c,v 1.48 2003/12/05 22:45:24 ca Exp $") /* ** exception handling diff --git a/contrib/sendmail/libsm/flags.c b/contrib/sendmail/libsm/flags.c index 7e2b0e2..94ecd5c 100644 --- a/contrib/sendmail/libsm/flags.c +++ b/contrib/sendmail/libsm/flags.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers. + * Copyright (c) 2000-2001, 2004 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.2.1 2003/09/03 18:51:56 ca Exp $") +SM_RCSID("@(#)$Id: flags.c,v 1.22 2004/03/03 19:20:29 ca Exp $") #include <sys/types.h> #include <sys/file.h> #include <errno.h> diff --git a/contrib/sendmail/libsm/ldap.c b/contrib/sendmail/libsm/ldap.c index 0e1c718..570c3cdb 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.5 2003/12/23 21:21:56 gshapiro Exp $") +SM_RCSID("@(#)$Id: ldap.c,v 1.59 2003/12/23 21:20:15 gshapiro Exp $") #if LDAPMAP # include <sys/types.h> @@ -52,14 +52,10 @@ sm_ldap_clear(lmap) if (lmap == NULL) return; - lmap->ldap_target = NULL; + lmap->ldap_host = NULL; lmap->ldap_port = LDAP_PORT; -#if _FFR_LDAP_URI - lmap->ldap_uri = false; -#endif /* _FFR_LDAP_URI */ -# if _FFR_LDAP_SETVERSION + lmap->ldap_uri = NULL; lmap->ldap_version = 0; -# endif /* _FFR_LDAP_SETVERSION */ lmap->ldap_deref = LDAP_DEREF_NEVER; lmap->ldap_timelimit = LDAP_NO_LIMIT; lmap->ldap_sizelimit = LDAP_NO_LIMIT; @@ -80,10 +76,8 @@ sm_ldap_clear(lmap) lmap->ldap_ld = NULL; lmap->ldap_filter = NULL; lmap->ldap_attr[0] = NULL; -#if _FFR_LDAP_RECURSION lmap->ldap_attr_type[0] = SM_LDAP_ATTR_NONE; lmap->ldap_attr_needobjclass[0] = NULL; -#endif /* _FFR_LDAP_RECURSION */ lmap->ldap_res = NULL; lmap->ldap_next = NULL; lmap->ldap_pid = 0; @@ -133,39 +127,79 @@ sm_ldap_start(name, lmap) { int bind_result; int save_errno; + char *id; SM_EVENT *ev = NULL; - LDAP *ld; + LDAP *ld = NULL; if (sm_debug_active(&SmLDAPTrace, 2)) sm_dprintf("ldapmap_start(%s)\n", name == NULL ? "" : name); + if (lmap->ldap_host != NULL) + id = lmap->ldap_host; + else if (lmap->ldap_uri != NULL) + id = lmap->ldap_uri; + else + id = "localhost"; + if (sm_debug_active(&SmLDAPTrace, 9)) - sm_dprintf("ldapmap_start(%s, %d)\n", - lmap->ldap_target == NULL ? "localhost" : lmap->ldap_target, - lmap->ldap_port); + { + /* Don't print a port number for LDAP URIs */ + if (lmap->ldap_uri != NULL) + sm_dprintf("ldapmap_start(%s)\n", id); + else + sm_dprintf("ldapmap_start(%s, %d)\n", id, + lmap->ldap_port); + } + + if (lmap->ldap_uri != NULL) + { +#if SM_CONF_LDAP_INITIALIZE + /* LDAP server supports URIs so use them directly */ + save_errno = ldap_initialize(&ld, lmap->ldap_uri); +#else /* SM_CONF_LDAP_INITIALIZE */ + int err; + LDAPURLDesc *ludp = NULL; + + /* Blast apart URL and use the ldap_init/ldap_open below */ + err = ldap_url_parse(lmap->ldap_uri, &ludp); + if (err != 0) + { + errno = err + E_LDAPURLBASE; + return false; + } + lmap->ldap_host = sm_strdup_x(ludp->lud_host); + if (lmap->ldap_host == NULL) + { + save_errno = errno; + ldap_free_urldesc(ludp); + errno = save_errno; + return false; + } + lmap->ldap_port = ludp->lud_port; + ldap_free_urldesc(ludp); +#endif /* SM_CONF_LDAP_INITIALIZE */ + } + if (ld == NULL) + { # if USE_LDAP_INIT -# if _FFR_LDAP_URI - if (lmap->ldap_uri) - errno = ldap_initialize(&ld, lmap->ldap_target); - else -# endif /* _FFR_LDAP_URI */ - ld = ldap_init(lmap->ldap_target, lmap->ldap_port); - save_errno = errno; + ld = ldap_init(lmap->ldap_host, lmap->ldap_port); + save_errno = errno; # else /* USE_LDAP_INIT */ - /* - ** If using ldap_open(), the actual connection to the server - ** happens now so we need the timeout here. For ldap_init(), - ** the connection happens at bind time. - */ + /* + ** If using ldap_open(), the actual connection to the server + ** happens now so we need the timeout here. For ldap_init(), + ** the connection happens at bind time. + */ - SM_LDAP_SETTIMEOUT(lmap->ldap_timeout.tv_sec); - ld = ldap_open(lmap->ldap_target, lmap->ldap_port); - save_errno = errno; + SM_LDAP_SETTIMEOUT(lmap->ldap_timeout.tv_sec); + ld = ldap_open(lmap->ldap_host, lmap->ldap_port); + save_errno = errno; - /* clear the event if it has not sprung */ - SM_LDAP_CLEARTIMEOUT(); + /* clear the event if it has not sprung */ + SM_LDAP_CLEARTIMEOUT(); # endif /* USE_LDAP_INIT */ + } errno = save_errno; if (ld == NULL) @@ -232,7 +266,7 @@ ldaptimeout(unused) } /* -** SM_LDAP_SEARCH -- iniate LDAP search +** SM_LDAP_SEARCH -- initiate LDAP search ** ** Initiate an LDAP search, return the msgid. ** The calling function must collect the results. @@ -319,7 +353,6 @@ sm_ldap_search(lmap, key) return msgid; } -# if _FFR_LDAP_RECURSION /* ** SM_LDAP_HAS_OBJECTCLASS -- determine if an LDAP entry is part of a ** particular objectClass @@ -509,6 +542,8 @@ sm_ldap_add_recurse(top, item, type, rpool) newe->lr_search = sm_rpool_strdup_x(rpool, item); newe->lr_type = type; + newe->lr_ludp = NULL; + newe->lr_attrs = NULL; newe->lr_done = false; ((*top)->lr_data)[insertat] = newe; @@ -941,6 +976,16 @@ sm_ldap_results(lmap, msgid, flags, delim, rpool, result, /* mark this DN as done */ rl->lr_done = true; + if (rl->lr_ludp != NULL) + { + ldap_free_urldesc(rl->lr_ludp); + rl->lr_ludp = NULL; + } + if (rl->lr_attrs != NULL) + { + free(rl->lr_attrs); + rl->lr_attrs = NULL; + } /* We don't want multiple values and we have one */ if ((char) delim == '\0' && *result != NULL) @@ -1050,10 +1095,71 @@ sm_ldap_results(lmap, msgid, flags, delim, rpool, result, } else if (rl->lr_type == SM_LDAP_ATTR_URL) { - /* do new URL search */ - sid = ldap_url_search(lmap->ldap_ld, - rl->lr_search, - lmap->ldap_attrsonly); + /* Parse URL */ + sid = ldap_url_parse(rl->lr_search, + &rl->lr_ludp); + + if (sid != 0) + { + errno = sid + E_LDAPURLBASE; + return EX_TEMPFAIL; + } + + /* We need to add objectClass */ + if (rl->lr_ludp->lud_attrs != NULL) + { + int attrnum = 0; + + while (rl->lr_ludp->lud_attrs[attrnum] != NULL) + { + if (strcasecmp(rl->lr_ludp->lud_attrs[attrnum], + "objectClass") == 0) + { + /* already requested */ + attrnum = -1; + break; + } + attrnum++; + } + + if (attrnum >= 0) + { + int i; + + rl->lr_attrs = (char **)malloc(sizeof(char *) * (attrnum + 2)); + if (rl->lr_attrs == NULL) + { + save_errno = errno; + ldap_free_urldesc(rl->lr_ludp); + errno = save_errno; + return EX_TEMPFAIL; + } + for (i = 0 ; i < attrnum; i++) + { + rl->lr_attrs[i] = rl->lr_ludp->lud_attrs[i]; + } + rl->lr_attrs[i++] = "objectClass"; + rl->lr_attrs[i++] = NULL; + } + } + + /* + ** Use the existing connection + ** for this search. It really + ** should use lud_scheme://lud_host:lud_port/ + ** instead but that would require + ** opening a new connection. + ** This should be fixed ASAP. + */ + + sid = ldap_search(lmap->ldap_ld, + rl->lr_ludp->lud_dn, + rl->lr_ludp->lud_scope, + rl->lr_ludp->lud_filter, + rl->lr_attrs, + lmap->ldap_attrsonly); + + /* Use the attributes specified by URL */ newflags |= SM_LDAP_USE_ALLATTR; } else @@ -1100,6 +1206,16 @@ sm_ldap_results(lmap, msgid, flags, delim, rpool, result, /* Mark as done */ rl->lr_done = true; + if (rl->lr_ludp != NULL) + { + ldap_free_urldesc(rl->lr_ludp); + rl->lr_ludp = NULL; + } + if (rl->lr_attrs != NULL) + { + free(rl->lr_attrs); + rl->lr_attrs = NULL; + } /* Reset rlidx as new items may have been added */ rlidx = -1; @@ -1107,7 +1223,6 @@ sm_ldap_results(lmap, msgid, flags, delim, rpool, result, } return statp; } -#endif /* _FFR_LDAP_RECURSION */ /* ** SM_LDAP_CLOSE -- close LDAP connection @@ -1151,13 +1266,11 @@ sm_ldap_setopts(ld, lmap) SM_LDAP_STRUCT *lmap; { # if USE_LDAP_SET_OPTION -# if _FFR_LDAP_SETVERSION if (lmap->ldap_version != 0) { ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &lmap->ldap_version); } -# endif /* _FFR_LDAP_SETVERSION */ ldap_set_option(ld, LDAP_OPT_DEREF, &lmap->ldap_deref); if (bitset(LDAP_OPT_REFERRALS, lmap->ldap_options)) ldap_set_option(ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON); diff --git a/contrib/sendmail/libsm/local.h b/contrib/sendmail/libsm/local.h index 610663d..6d64195 100644 --- a/contrib/sendmail/libsm/local.h +++ b/contrib/sendmail/libsm/local.h @@ -11,7 +11,7 @@ * forth in the LICENSE file which can be found at the top level of * the sendmail distribution. * - * $Id: local.h,v 1.51.2.2 2004/01/09 18:32:44 ca Exp $ + * $Id: local.h,v 1.53 2004/01/09 18:34:22 ca Exp $ */ /* diff --git a/contrib/sendmail/libsm/mbdb.c b/contrib/sendmail/libsm/mbdb.c index 0c338fe..ad0e7cc 100644 --- a/contrib/sendmail/libsm/mbdb.c +++ b/contrib/sendmail/libsm/mbdb.c @@ -8,7 +8,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: mbdb.c,v 1.38.2.1 2002/11/20 22:59:06 gshapiro Exp $") +SM_RCSID("@(#)$Id: mbdb.c,v 1.40 2003/12/10 03:19:07 gshapiro Exp $") #include <sys/param.h> @@ -441,13 +441,13 @@ mbdb_ldap_initialize(arg) { sm_ldap_clear(&LDAPLMAP); LDAPLMAP.ldap_base = MBDB_DEFAULT_LDAP_BASEDN; - LDAPLMAP.ldap_target = MBDB_DEFAULT_LDAP_SERVER; + LDAPLMAP.ldap_host = MBDB_DEFAULT_LDAP_SERVER; LDAPLMAP.ldap_filter = MBDB_LDAP_FILTER; /* Only want one match */ LDAPLMAP.ldap_sizelimit = 1; - /* interpolate new ldap_base and ldap_target from arg if given */ + /* interpolate new ldap_base and ldap_host from arg if given */ if (arg != NULL && *arg != '\0') { char *new; @@ -463,7 +463,7 @@ mbdb_ldap_initialize(arg) if (sep != NULL) { *sep++ = '\0'; - LDAPLMAP.ldap_target = sep; + LDAPLMAP.ldap_host = sep; } LDAPLMAP.ldap_base = new; } diff --git a/contrib/sendmail/libsm/refill.c b/contrib/sendmail/libsm/refill.c index 6e06783..c3db172 100644 --- a/contrib/sendmail/libsm/refill.c +++ b/contrib/sendmail/libsm/refill.c @@ -13,7 +13,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: refill.c,v 1.49.2.1 2002/09/09 21:38:08 gshapiro Exp $") +SM_RCSID("@(#)$Id: refill.c,v 1.50 2002/09/09 21:50:10 gshapiro Exp $") #include <stdlib.h> #include <unistd.h> #include <errno.h> diff --git a/contrib/sendmail/libsm/rpool.c b/contrib/sendmail/libsm/rpool.c index 8632166..57c0393 100644 --- a/contrib/sendmail/libsm/rpool.c +++ b/contrib/sendmail/libsm/rpool.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers. + * Copyright (c) 2000-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: rpool.c,v 1.24 2002/01/11 21:54:43 ca Exp $") +SM_RCSID("@(#)$Id: rpool.c,v 1.27 2003/10/09 17:49:47 ca Exp $") /* ** resource pools @@ -491,3 +491,31 @@ sm_rpool_attach_x(rpool, rfree, rcontext) --rpool->sm_ravail; return a; } + +#if DO_NOT_USE_STRCPY +/* +** SM_RPOOL_STRDUP_X -- Create a copy of a C string +** +** Parameters: +** rpool -- rpool to use. +** s -- the string to copy. +** +** Returns: +** pointer to newly allocated string. +*/ + +char * +sm_rpool_strdup_x(rpool, s) + SM_RPOOL_T *rpool; + const char *s; +{ + size_t l; + char *n; + + l = strlen(s); + SM_ASSERT(l + 1 > l); + n = sm_rpool_malloc_x(rpool, l + 1); + sm_strlcpy(n, s, l + 1); + return n; +} +#endif /* DO_NOT_USE_STRCPY */ diff --git a/contrib/sendmail/libsm/shm.c b/contrib/sendmail/libsm/shm.c index 2299aed..4cef892 100644 --- a/contrib/sendmail/libsm/shm.c +++ b/contrib/sendmail/libsm/shm.c @@ -8,7 +8,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: shm.c,v 1.10.2.6 2003/06/13 21:17:48 ca Exp $") +SM_RCSID("@(#)$Id: shm.c,v 1.16 2003/06/13 21:18:08 ca Exp $") #if SM_CONF_SHM # include <stdlib.h> diff --git a/contrib/sendmail/libsm/smstdio.c b/contrib/sendmail/libsm/smstdio.c index d561e8d..e8637c1 100644 --- a/contrib/sendmail/libsm/smstdio.c +++ b/contrib/sendmail/libsm/smstdio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers. + * Copyright (c) 2000-2002, 2004 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_IDSTR(id, "@(#)$Id: smstdio.c,v 1.32.2.2 2003/09/05 20:35:28 ca Exp $") +SM_IDSTR(id, "@(#)$Id: smstdio.c,v 1.33 2004/03/03 19:14:51 ca Exp $") #include <unistd.h> #include <stdio.h> #include <fcntl.h> diff --git a/contrib/sendmail/libsm/stdio.c b/contrib/sendmail/libsm/stdio.c index 23cc2af..0df98ab 100644 --- a/contrib/sendmail/libsm/stdio.c +++ b/contrib/sendmail/libsm/stdio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2003 Sendmail, Inc. and its suppliers. + * Copyright (c) 2000-2004 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: stdio.c,v 1.56.2.13 2003/09/04 01:18:08 ca Exp $") +SM_RCSID("@(#)$Id: stdio.c,v 1.68 2004/03/03 19:20:29 ca Exp $") #include <unistd.h> #include <errno.h> #include <fcntl.h> diff --git a/contrib/sendmail/libsm/strdup.c b/contrib/sendmail/libsm/strdup.c index 64fe5c2..7094275 100644 --- a/contrib/sendmail/libsm/strdup.c +++ b/contrib/sendmail/libsm/strdup.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 @@ -9,7 +9,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: strdup.c,v 1.13 2001/09/11 04:04:49 gshapiro Exp $") +SM_RCSID("@(#)$Id: strdup.c,v 1.15 2003/10/10 17:56:57 ca Exp $") #include <sm/heap.h> #include <sm/string.h> @@ -70,3 +70,97 @@ sm_strdup(s) (void) sm_strlcpy(d, s, l); return d; } + +#if DO_NOT_USE_STRCPY + +/* +** SM_STRDUP_X -- Duplicate a string +** +** Allocates memory and copies source string into it. +** +** Parameters: +** s -- string to copy. +** +** Returns: +** copy of string, exception if out of memory. +** +** Side Effects: +** allocate memory for new string. +*/ + +char * +sm_strdup_x(s) + const char *s; +{ + size_t l; + char *d; + + l = strlen(s) + 1; + d = sm_malloc_tagged_x(l, "sm_strdup_x", 0, sm_heap_group()); + (void) sm_strlcpy(d, s, l); + return d; +} + +/* +** SM_PSTRDUP_X -- Duplicate a string (using "permanent" memory) +** +** Allocates memory and copies source string into it. +** +** Parameters: +** s -- string to copy. +** +** Returns: +** copy of string, exception if out of memory. +** +** Side Effects: +** allocate memory for new string. +*/ + +char * +sm_pstrdup_x(s) + const char *s; +{ + size_t l; + char *d; + + l = strlen(s) + 1; + d = sm_pmalloc_x(l); + (void) sm_strlcpy(d, s, l); + return d; +} + +/* +** SM_STRDUP_X -- Duplicate a string +** +** Allocates memory and copies source string into it. +** +** Parameters: +** s -- string to copy. +** file -- name of source file +** line -- line in source file +** group -- heap group +** +** Returns: +** copy of string, exception if out of memory. +** +** Side Effects: +** allocate memory for new string. +*/ + +char * +sm_strdup_tagged_x(s, file, line, group) + const char *s; + char *file; + int line, group; +{ + size_t l; + char *d; + + l = strlen(s) + 1; + d = sm_malloc_tagged_x(l, file, line, group); + (void) sm_strlcpy(d, s, l); + return d; +} + +#endif /* DO_NOT_USE_STRCPY */ + diff --git a/contrib/sendmail/libsm/t-shm.c b/contrib/sendmail/libsm/t-shm.c index 5da07c1..b20040a 100644 --- a/contrib/sendmail/libsm/t-shm.c +++ b/contrib/sendmail/libsm/t-shm.c @@ -8,7 +8,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: t-shm.c,v 1.18 2002/01/31 04:11:41 ca Exp $") +SM_RCSID("@(#)$Id: t-shm.c,v 1.19 2004/04/20 23:14:21 ca Exp $") #include <stdio.h> @@ -45,7 +45,7 @@ shminter(owner) bool owner; { int *shm, shmid; - int i, j, t; + int i, t; shm = (int *) sm_shmstart(T_SHMKEY, SHMSIZE, 0, &shmid, owner); if (shm == (int *) 0) @@ -74,7 +74,6 @@ shminter(owner) t = *shm; for (i = 0; i < SHM_MAX; i++) { - j += i; ++*shm; } if (*shm != SHM_MAX + t) diff --git a/contrib/sendmail/libsm/vasprintf.c b/contrib/sendmail/libsm/vasprintf.c index 3441a3d..69d8576 100644 --- a/contrib/sendmail/libsm/vasprintf.c +++ b/contrib/sendmail/libsm/vasprintf.c @@ -24,7 +24,7 @@ */ #include <sm/gen.h> -SM_RCSID("@(#)$Id: vasprintf.c,v 1.26.2.1 2003/06/03 02:14:09 ca Exp $") +SM_RCSID("@(#)$Id: vasprintf.c,v 1.27 2003/06/03 02:14:24 ca Exp $") #include <stdlib.h> #include <errno.h> #include <sm/io.h> |