SLP extension derived from patch provided by Caldera Systems.

Copyright 2000, Caldera Systems, Inc All rights reserved.
This software is not subject to any license of Caldera Systems, Inc

This is free software; you can redistribute and use it
under the same terms as OpenLDAP itself
This commit is contained in:
Kurt Zeilenga 2001-01-16 22:18:33 +00:00
parent cacb73c3db
commit 8a22a0e0d0
5 changed files with 986 additions and 738 deletions

View file

@ -145,7 +145,7 @@ SLAPD_SQL_LDFLAGS = @SLAPD_SQL_LDFLAGS@
SLAPD_SQL_INCLUDES = @SLAPD_SQL_INCLUDES@ SLAPD_SQL_INCLUDES = @SLAPD_SQL_INCLUDES@
SLAPD_SQL_LIBS = @SLAPD_SQL_LIBS@ SLAPD_SQL_LIBS = @SLAPD_SQL_LIBS@
SLAPD_LIBS = @SLAPD_LIBS@ @SLAPD_PERL_LDFLAGS@ @SLAPD_SQL_LDFLAGS@ @SLAPD_SQL_LIBS@ SLAPD_LIBS = @SLAPD_LIBS@ @SLAPD_PERL_LDFLAGS@ @SLAPD_SQL_LDFLAGS@ @SLAPD_SQL_LIBS@ @SLAPD_SLP_LIBS@
SLURPD_LIBS = @SLURPD_LIBS@ SLURPD_LIBS = @SLURPD_LIBS@
# Our Defaults # Our Defaults

1548
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -146,8 +146,10 @@ dnl ----------------------------------------------------------------
dnl SLAPD OPTIONS dnl SLAPD OPTIONS
AC_ARG_WITH(xxslapdoptions,[SLAPD (Standalone LDAP Daemon) Options:]) AC_ARG_WITH(xxslapdoptions,[SLAPD (Standalone LDAP Daemon) Options:])
OL_ARG_ENABLE(slapd,[ --enable-slapd enable building slapd], yes)dnl OL_ARG_ENABLE(slapd,[ --enable-slapd enable building slapd], yes)dnl
OL_ARG_ENABLE(aci,[ --enable-aci enable per-object ACIs], no)dnl
OL_ARG_ENABLE(cleartext,[ --enable-cleartext enable cleartext passwords], yes)dnl OL_ARG_ENABLE(cleartext,[ --enable-cleartext enable cleartext passwords], yes)dnl
OL_ARG_ENABLE(crypt,[ --enable-crypt enable crypt(3) passwords], auto)dnl OL_ARG_ENABLE(crypt,[ --enable-crypt enable crypt(3) passwords], auto)dnl
OL_ARG_ENABLE(dynamic,[ --enable-dynamic enable linking built binaries with dynamic libs], no)dnl
OL_ARG_ENABLE(kpasswd,[ --enable-kpasswd enable Kerberos password verification], no)dnl OL_ARG_ENABLE(kpasswd,[ --enable-kpasswd enable Kerberos password verification], no)dnl
OL_ARG_ENABLE(lmpasswd,[ --enable-lmpasswd enable LAN Manager passwords], auto)dnl OL_ARG_ENABLE(lmpasswd,[ --enable-lmpasswd enable LAN Manager passwords], auto)dnl
OL_ARG_ENABLE(spasswd,[ --enable-spasswd enable (Cyrus) SASL password verification], no)dnl OL_ARG_ENABLE(spasswd,[ --enable-spasswd enable (Cyrus) SASL password verification], no)dnl
@ -155,9 +157,8 @@ OL_ARG_ENABLE(modules,[ --enable-modules enable dynamic module support], no
dnl OL_ARG_ENABLE(multimaster,[ --enable-multimaster enable multimaster replication], no)dnl dnl OL_ARG_ENABLE(multimaster,[ --enable-multimaster enable multimaster replication], no)dnl
OL_ARG_ENABLE(phonetic,[ --enable-phonetic enable phonetic/soundex], no)dnl OL_ARG_ENABLE(phonetic,[ --enable-phonetic enable phonetic/soundex], no)dnl
OL_ARG_ENABLE(rlookups,[ --enable-rlookups enable reverse lookups], no)dnl OL_ARG_ENABLE(rlookups,[ --enable-rlookups enable reverse lookups], no)dnl
OL_ARG_ENABLE(aci,[ --enable-aci enable per-object ACIs], no)dnl OL_ARG_ENABLE(slp, [ --enable-slp enable SLPv2 support], no)dnl
OL_ARG_ENABLE(wrappers,[ --enable-wrappers enable tcp wrapper support], no)dnl OL_ARG_ENABLE(wrappers,[ --enable-wrappers enable tcp wrapper support], no)dnl
OL_ARG_ENABLE(dynamic,[ --enable-dynamic enable linking built binaries with dynamic libs], no)dnl
dnl SLAPD Backend options dnl SLAPD Backend options
OL_ARG_ENABLE(bdb,[ --enable-bdb enable Berkeley DB backend], no)dnl OL_ARG_ENABLE(bdb,[ --enable-bdb enable Berkeley DB backend], no)dnl
@ -464,6 +465,8 @@ TLS_LIBS=
MODULES_LIBS= MODULES_LIBS=
AUTH_LIBS= AUTH_LIBS=
SLAPD_SLP_LIBS=
dnl ================================================================ dnl ================================================================
dnl Checks for programs dnl Checks for programs
@ -2061,6 +2064,23 @@ if test $ol_enable_proctitle != no ; then
fi fi
fi fi
dnl ----------------------------------------------------------------
dnl Check for SLPv2 Compliant API Library
if test $ol_enable_slp != no ; then
AC_CHECK_HEADERS( slp.h )
if test ac_cv_header_slp_h = yes ; then
AC_CHECK_LIB(slp, SLPOpen, [have_slp=yes], [have_slp=no])
if test $have_slp = yes ; then
AC_DEFINE(HAVE_SLP, 1, [define if you have -lslp])
SLAPD_SLP_LIBS=-lslp
fi
elif test $ol_enable_slp = yes ; then
AC_MSG_ERROR([SLP not found])
fi
fi
dnl ---------------------------------------------------------------- dnl ----------------------------------------------------------------
dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_MODE_T AC_TYPE_MODE_T
@ -2463,6 +2483,8 @@ AC_SUBST(TLS_LIBS)
AC_SUBST(MODULES_LIBS) AC_SUBST(MODULES_LIBS)
AC_SUBST(AUTH_LIBS) AC_SUBST(AUTH_LIBS)
AC_SUBST(SLAPD_SLP_LIBS)
AC_SUBST(SLAPD_SQL_LDFLAGS) AC_SUBST(SLAPD_SQL_LDFLAGS)
AC_SUBST(SLAPD_SQL_LIBS) AC_SUBST(SLAPD_SQL_LIBS)
AC_SUBST(SLAPD_SQL_INCLUDES) AC_SUBST(SLAPD_SQL_INCLUDES)

View file

@ -480,6 +480,9 @@
/* Define if you have the <shadow.h> header file. */ /* Define if you have the <shadow.h> header file. */
#undef HAVE_SHADOW_H #undef HAVE_SHADOW_H
/* Define if you have the <slp.h> header file. */
#undef HAVE_SLP_H
/* Define if you have the <ssl.h> header file. */ /* Define if you have the <ssl.h> header file. */
#undef HAVE_SSL_H #undef HAVE_SSL_H
@ -669,6 +672,9 @@
/* define if you have TLS */ /* define if you have TLS */
#undef HAVE_TLS #undef HAVE_TLS
/* define to support LAN Manager passwords */
#undef SLAPD_LMHASH
/* set to the number of arguments ctime_r() expects */ /* set to the number of arguments ctime_r() expects */
#undef CTIME_R_NARGS #undef CTIME_R_NARGS
@ -777,6 +783,9 @@
/* define if setproctitle(3) is available */ /* define if setproctitle(3) is available */
#undef HAVE_SETPROCTITLE #undef HAVE_SETPROCTITLE
/* define if you have -lslp */
#undef HAVE_SLP
/* Define to `int' if <sys/types.h> does not define. */ /* Define to `int' if <sys/types.h> does not define. */
#undef mode_t #undef mode_t
@ -876,9 +885,6 @@
/* define to support SASL passwords */ /* define to support SASL passwords */
#undef SLAPD_SPASSWD #undef SLAPD_SPASSWD
/* define to support multimaster replication */
#undef SLAPD_MULTIMASTER
/* define to support phonetic */ /* define to support phonetic */
#undef SLAPD_PHONETIC #undef SLAPD_PHONETIC

View file

@ -79,7 +79,7 @@ extern int is_NT_Service;
#endif #endif
#ifndef HAVE_WINSOCK #ifndef HAVE_WINSOCK
static static
#endif #endif
volatile sig_atomic_t slapd_shutdown = 0; volatile sig_atomic_t slapd_shutdown = 0;
@ -97,7 +97,91 @@ static struct slap_daemon {
fd_set sd_actives; fd_set sd_actives;
fd_set sd_readers; fd_set sd_readers;
fd_set sd_writers; fd_set sd_writers;
} slap_daemon; } slap_daemon;
#ifdef HAVE_SLP
/*
* SLP related functions
*/
#include <slp.h>
#define MAX_HOSTNAME_LEN 256
#define LDAP_SRVTYPE_PREFIX "service:ldap://"
static char** slapd_srvurls = 0;
static SLPHandle slapd_hslp = 0;
void slapd_slp_init( const char* urls ) {
int i;
struct hostent* he;
char hn[MAX_HOSTNAME_LEN];
slapd_srvurls = str2charray( urls, " " );
for( i=0; slapd_srvurls[i]!=NULL; i++ ) {
if( strcmp( slapd_srvurls[i], "ldap:///" ) == 0) {
/* INADDR_ANY urls should be marked up with host.domainname */
if ( gethostname( hn, MAX_HOSTNAME_LEN ) == 0) {
he = gethostbyname( hn );
if( he ) {
slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i],
strlen( he->h_name ) +
strlen( LDAP_SRVTYPE_PREFIX ) + 1);
strcpy( slapd_srvurls[i], LDAP_SRVTYPE_PREFIX );
strcat( slapd_srvurls[i], he->h_name );
}
}
}
}
/* open the SLP handle */
SLPOpen("en", 0, &slapd_hslp);
}
void slapd_slp_deinit() {
if ( slapd_srvurls ) {
charray_free( slapd_srvurls );
}
/* close the SLP handle */
SLPClose( slapd_hslp );
}
void slapd_slp_regreport(
SLPHandle hslp,
SLPError errcode,
void* cookie )
{
/* empty report */
}
void slapd_slp_reg() {
int i;
for( i=0; slapd_srvurls[i] != NULL; i++ ) {
SLPReg( slapd_hslp,
slapd_srvurls[i],
SLP_LIFETIME_MAXIMUM,
"ldap",
"",
1,
slapd_slp_regreport,
NULL );
}
}
void slapd_slp_dereg() {
int i;
for( i=0; slapd_srvurls[i] != NULL; i++ ) {
SLPDereg( slapd_hslp,
slapd_srvurls[i],
slapd_slp_regreport,
NULL );
}
}
#endif /* HAVE_SLP */
/* /*
* Add a descriptor to daemon control * Add a descriptor to daemon control
@ -237,7 +321,7 @@ static int slap_get_listener_addresses(
#ifdef HAVE_GETADDRINFO #ifdef HAVE_GETADDRINFO
struct addrinfo hints, *res, *sai; struct addrinfo hints, *res, *sai;
int n, err; int n, err;
memset( &hints, '\0', sizeof(hints) ); memset( &hints, '\0', sizeof(hints) );
hints.ai_flags = AI_PASSIVE; hints.ai_flags = AI_PASSIVE;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
@ -258,9 +342,9 @@ static int slap_get_listener_addresses(
} }
} else } else
# endif # endif
{ {
char serv[7]; char serv[7];
snprintf(serv, sizeof serv, "%d", port); snprintf(serv, sizeof serv, "%d", port);
hints.ai_family = AF_UNSPEC; hints.ai_family = AF_UNSPEC;
if (err = getaddrinfo(host, serv, &hints, &res)) { if (err = getaddrinfo(host, serv, &hints, &res)) {
@ -300,7 +384,7 @@ static int slap_get_listener_addresses(
*((struct sockaddr_un *)sai->ai_addr); *((struct sockaddr_un *)sai->ai_addr);
} break; } break;
# endif # endif
# ifdef LDAP_PF_INET6 # ifdef LDAP_PF_INET6
case AF_INET6: { case AF_INET6: {
*sap = ch_malloc(sizeof(struct sockaddr_in6)); *sap = ch_malloc(sizeof(struct sockaddr_in6));
if (*sap == NULL) { if (*sap == NULL) {
@ -320,7 +404,7 @@ static int slap_get_listener_addresses(
*(struct sockaddr_in *)*sap = *(struct sockaddr_in *)*sap =
*((struct sockaddr_in *)sai->ai_addr); *((struct sockaddr_in *)sai->ai_addr);
} break; } break;
default: default:
*sap = NULL; *sap = NULL;
break; break;
} }
@ -360,7 +444,7 @@ static int slap_get_listener_addresses(
} }
strcpy( ((struct sockaddr_un *)*sap)->sun_path, host ); strcpy( ((struct sockaddr_un *)*sap)->sun_path, host );
} else } else
# endif # endif
{ {
struct in_addr in; struct in_addr in;
@ -464,7 +548,7 @@ static Listener * slap_open_listener(
#endif #endif
port = (unsigned short) lud->lud_port; port = (unsigned short) lud->lud_port;
if ( ldap_pvt_url_scheme2proto(lud->lud_scheme) == LDAP_PROTO_IPC ) { if ( ldap_pvt_url_scheme2proto(lud->lud_scheme) == LDAP_PROTO_IPC ) {
#ifdef LDAP_PF_LOCAL #ifdef LDAP_PF_LOCAL
if ( lud->lud_host == NULL || lud->lud_host[0] == '\0' ) { if ( lud->lud_host == NULL || lud->lud_host[0] == '\0' ) {
@ -571,7 +655,7 @@ static Listener * slap_open_listener(
} }
#endif #endif
} }
switch( (*sal)->sa_family ) { switch( (*sal)->sa_family ) {
case AF_INET: case AF_INET:
addrlen = sizeof(struct sockaddr_in); addrlen = sizeof(struct sockaddr_in);
@ -587,7 +671,7 @@ static Listener * slap_open_listener(
break; break;
#endif #endif
} }
if (!bind(l.sl_sd, *sal, addrlen)) if (!bind(l.sl_sd, *sal, addrlen))
break; break;
err = sock_errno(); err = sock_errno();
@ -640,14 +724,14 @@ static Listener * slap_open_listener(
case AF_INET: { case AF_INET: {
char *s; char *s;
#ifdef HAVE_GETADDRINFO #ifdef HAVE_GETADDRINFO
char addr[INET_ADDRSTRLEN]; char addr[INET_ADDRSTRLEN];
inet_ntop( AF_INET, &((struct sockaddr_in *)*sal)->sin_addr, inet_ntop( AF_INET, &((struct sockaddr_in *)*sal)->sin_addr,
addr, sizeof(addr) ); addr, sizeof(addr) );
s = addr; s = addr;
#else #else
s = inet_ntoa( l.sl_addr.sin_addr ); s = inet_ntoa( l.sl_addr.sin_addr );
#endif #endif
l.sl_name = ch_malloc( sizeof("IP=255.255.255.255:65535") ); l.sl_name = ch_malloc( sizeof("IP=255.255.255.255:65535") );
sprintf( l.sl_name, "IP=%s:%d", sprintf( l.sl_name, "IP=%s:%d",
s != NULL ? s : "unknown" , port ); s != NULL ? s : "unknown" , port );
@ -809,6 +893,12 @@ int slapd_daemon_init( const char *urls )
Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners opened\n", Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners opened\n",
i, 0, 0 ); i, 0, 0 );
#endif #endif
#ifdef HAVE_SLP
slapd_slp_init( urls );
slapd_slp_reg();
#endif
charray_free( u ); charray_free( u );
ldap_pvt_thread_mutex_init( &slap_daemon.sd_mutex ); ldap_pvt_thread_mutex_init( &slap_daemon.sd_mutex );
return !i; return !i;
@ -822,6 +912,12 @@ slapd_daemon_destroy(void)
tcp_close( wake_sds[1] ); tcp_close( wake_sds[1] );
tcp_close( wake_sds[0] ); tcp_close( wake_sds[0] );
sockdestroy(); sockdestroy();
#ifdef HAVE_SLP
slapd_slp_dereg();
slapd_slp_deinit();
#endif
return 0; return 0;
} }
@ -968,7 +1064,7 @@ slapd_daemon_task(
case -1: { /* failure - try again */ case -1: { /* failure - try again */
int err = sock_errno(); int err = sock_errno();
if( err == EBADF if( err == EBADF
#ifdef WSAENOTSOCK #ifdef WSAENOTSOCK
/* you'd think this would be EBADF */ /* you'd think this would be EBADF */
|| err == WSAENOTSOCK || err == WSAENOTSOCK
@ -1191,7 +1287,7 @@ slapd_daemon_task(
continue; continue;
} }
if ( ( from.sa_addr.sa_family == AF_INET ) if ( ( from.sa_addr.sa_family == AF_INET )
#ifdef LDAP_PF_INET6 #ifdef LDAP_PF_INET6
|| ( from.sa_addr.sa_family == AF_INET6 ) || ( from.sa_addr.sa_family == AF_INET6 )
#endif #endif
@ -1548,29 +1644,29 @@ int sockinit(void)
WORD wVersionRequested; WORD wVersionRequested;
WSADATA wsaData; WSADATA wsaData;
int err; int err;
wVersionRequested = MAKEWORD( 2, 0 ); wVersionRequested = MAKEWORD( 2, 0 );
err = WSAStartup( wVersionRequested, &wsaData ); err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) { if ( err != 0 ) {
/* Tell the user that we couldn't find a usable */ /* Tell the user that we couldn't find a usable */
/* WinSock DLL. */ /* WinSock DLL. */
return -1; return -1;
} }
/* Confirm that the WinSock DLL supports 2.0.*/ /* Confirm that the WinSock DLL supports 2.0.*/
/* Note that if the DLL supports versions greater */ /* Note that if the DLL supports versions greater */
/* than 2.0 in addition to 2.0, it will still return */ /* than 2.0 in addition to 2.0, it will still return */
/* 2.0 in wVersion since that is the version we */ /* 2.0 in wVersion since that is the version we */
/* requested. */ /* requested. */
if ( LOBYTE( wsaData.wVersion ) != 2 || if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 0 ) HIBYTE( wsaData.wVersion ) != 0 )
{ {
/* Tell the user that we couldn't find a usable */ /* Tell the user that we couldn't find a usable */
/* WinSock DLL. */ /* WinSock DLL. */
WSACleanup(); WSACleanup();
return -1; return -1;
} }
/* The WinSock DLL is acceptable. Proceed. */ /* The WinSock DLL is acceptable. Proceed. */