Build system and LDAP XPCOM SDK changes to switch to LDAP C SDK version 5; required for SSL-LDAP (bug 124244). r=sspitzer@netscape.com, seawood@netscape.com (build changes); sr=bienvenu@netscape.com; a=asa@mozilla.org

This commit is contained in:
dmose%netscape.com 2002-03-27 06:31:38 +00:00
Родитель 4455f0fd87
Коммит 5e565e67aa
16 изменённых файлов: 103 добавлений и 312 удалений

Просмотреть файл

@ -268,7 +268,7 @@ endif
endif # BUILD_MODULES == all
STATIC_MAKEFILES := nsprpub directory/c-sdk/ldap
STATIC_MAKEFILES := nsprpub directory/c-sdk
ifdef MOZ_PSM
STATIC_MAKEFILES += security/nss
@ -301,7 +301,7 @@ ifndef MOZ_NATIVE_NSPR
$(MAKE) -C nsprpub $@
endif
ifdef MOZ_LDAP_XPCOM
$(MAKE) -C directory/c-sdk/ldap $@
$(MAKE) -C directory/c-sdk $@
endif
endif
@ -330,8 +330,8 @@ endif
ldap:
ifdef MOZ_LDAP_XPCOM
$(MAKE) -C directory/c-sdk/ldap export
$(MAKE) -C directory/c-sdk/ldap install
$(MAKE) -C directory/c-sdk export
$(MAKE) -C directory/c-sdk install
endif
freetype:

Просмотреть файл

@ -160,7 +160,7 @@ LDAPCSDK_CO_FLAGS=$(MOZ_CO_FLAGS)
!if "$(LDAPCSDK_CO_TAG)" != ""
LDAPCSDK_CO_FLAGS=$(LDAPCSDK_CO_FLAGS) -r $(LDAPCSDK_CO_TAG)
!else
LDAPCSDK_CO_FLAGS=$(LDAPCSDK_CO_FLAGS) -r LDAPCSDK_40_BRANCH
LDAPCSDK_CO_FLAGS=$(LDAPCSDK_CO_FLAGS) -r ldapcsdk_50_client_branch
!endif
CVSCO_LDAPCSDK = cvs $(CVS_FLAGS) co $(LDAPCSDK_CO_FLAGS)
@ -334,19 +334,26 @@ pull_clientmak:
# nmake has to be hardcoded, or we have to depend on mozilla/config
# being pulled already to figure out what $(NMAKE) should be.
clobber_all: clobber_nspr clobber_psm clobber_seamonkey
clobber_all: clobber_nspr clobber_ldapcsdk clobber_psm clobber_seamonkey
build_all: build_nspr build_seamonkey
build_all: build_nspr build_ldapcsdk build_seamonkey
build_all_dep: depend libs
distclean:
@cd $(MOZ_SRC)\$(MOZ_TOP)\directory\c-sdk
gmake -f gmakefile.win distclean MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
gmake -f gmakefile.win distclean MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
@cd $(MOZ_SRC)\$(MOZ_TOP)
nmake /f client.mak clobber_psm
nmake /f client.mak clobber_seamonkey
clobber_ldapcsdk:
@cd $(MOZ_SRC)\$(MOZ_TOP)\directory\c-sdk
gmake -f gmakefile.win clobber_all MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED) \
SHELL=sh
clobber_nspr:
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
gmake -f gmakefile.win clobber_all MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
@ -400,6 +407,10 @@ build_nspr:
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
gmake -f gmakefile.win MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
build_ldapcsdk:
@cd $(MOZ_SRC)\$(MOZ_TOP)\directory\c-sdk
gmake -f gmakefile.win MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED) SHELL=sh
build_psm:
@cd $(MOZ_SRC)\$(MOZ_TOP)\security
nmake -f makefile.win
@ -440,7 +451,7 @@ libs:
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
nmake -f makefile.win libs
export: build_nspr
export: build_nspr build_ldapcsdk
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
nmake -f makefile.win export

Просмотреть файл

@ -56,7 +56,7 @@
NSPR_CO_TAG = NSPRPUB_PRE_4_2_CLIENT_BRANCH
PSM_CO_TAG = #We will now build PSM from the tip instead of a branch.
NSS_CO_TAG = NSS_CLIENT_TAG
LDAPCSDK_CO_TAG = LDAPCSDK_40_BRANCH
LDAPCSDK_CO_TAG = ldapcsdk_50_client_branch
ACCESSIBLE_CO_TAG =
GFX2_CO_TAG =
IMGLIB2_CO_TAG =

Просмотреть файл

@ -129,7 +129,7 @@ NGLAYOUT_DIST=$(XPDIST)\NGL$(MOZ_BITS)_D.OBJ
#//-----------------------------------------------------------------------
!ifndef DISABLE_LDAP
LDAP_CFLAGS=-I$(XPDIST)\include\ldap
LDAP_CFLAGS=-I$(XPDIST)\public\ldap
!endif
CFGFILE=$(OBJDIR)\cmd.cfg

Просмотреть файл

@ -4185,11 +4185,11 @@ if test "$MOZ_DEBUG" || test "$NS_TRACE_MALLOC"; then
fi
if test "$MOZ_LDAP_XPCOM"; then
LDAP_CFLAGS='-I${DIST}/include/ldap'
LDAP_CFLAGS='-I${DIST}/public/ldap'
if test "$_WIN32_MSVC"; then
LDAP_LIBS='$(DIST)/lib/$(LIB_PREFIX)nsldap32v40.${LIB_SUFFIX}'
LDAP_LIBS='$(DIST)/lib/$(LIB_PREFIX)nsldap32v50.${LIB_SUFFIX} $(DIST)/lib/$(LIB_PREFIX)/nsldappr32v50.${LIB_SUFFIX}'
else
LDAP_LIBS='-L${DIST}/bin -L${DIST}/lib -lldap40 -llber40'
LDAP_LIBS='-L${DIST}/bin -L${DIST}/lib -lldap50 -llber50 -lprldap50'
fi
fi
@ -4614,24 +4614,24 @@ rm -f build/unix/mozilla-config.bak
#
if test "$MOZ_LDAP_XPCOM"; then
# these subdirs may not yet have been created in the build tree.
# don't use the "-p" switch to mkdir, since not all platforms have it
#
if test ! -d "directory"; then
mkdir "directory"
fi
if test ! -d "directory/c-sdk"; then
mkdir "directory/c-sdk"
fi
if test ! -d "directory/c-sdk/ldap"; then
mkdir "directory/c-sdk/ldap"
fi
# these subdirs may not yet have been created in the build tree.
# don't use the "-p" switch to mkdir, since not all platforms have it
#
if test ! -d "directory"; then
mkdir "directory"
fi
if test ! -d "directory/c-sdk"; then
mkdir "directory/c-sdk"
fi
if test ! -d "directory/c-sdk/ldap"; then
mkdir "directory/c-sdk/ldap"
fi
ac_configure_args="$_SUBDIR_CONFIG_ARGS --prefix=$MOZ_BUILD_ROOT/dist"
ac_configure_args="$_SUBDIR_CONFIG_ARGS --prefix=$MOZ_BUILD_ROOT/dist --with-dist-prefix=$MOZ_BUILD_ROOT/dist --without-nss"
if test -n "$HAVE_64BIT_OS"; then
ac_configure_args="$ac_configure_args --enable-64bit"
fi
AC_OUTPUT_SUBDIRS(directory/c-sdk/ldap)
AC_OUTPUT_SUBDIRS(directory/c-sdk)
ac_configure_args="$_SUBDIR_CONFIG_ARGS"
fi

Просмотреть файл

@ -71,11 +71,6 @@ CPPSRCS += \
REQUIRES += mimetype
endif
CSRCS = \
nsLDAPConnectionCallbacks.c \
$(NULL)
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) $(LDAP_LIBS)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -30,7 +30,8 @@ MODULE_NAME=nsLDAPProtocolModule
LLIBS = $(LIBNSPR) \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\nsldap32v40.lib \
$(DIST)\lib\nsldap32v50.lib \
$(DIST)\lib\nsldappr32v50.lib \
$(NULL)
CPP_OBJS = .\$(OBJDIR)\nsLDAPURL.obj \

Просмотреть файл

@ -54,9 +54,6 @@
const char kConsoleServiceContractId[] = "@mozilla.org/consoleservice;1";
const char kDNSServiceContractId[] = "@mozilla.org/network/dns-service;1";
extern "C" int nsLDAPThreadDataInit(void);
extern "C" int nsLDAPThreadFuncsInit(LDAP *aLDAP);
// constructor
//
nsLDAPConnection::nsLDAPConnection()
@ -79,23 +76,21 @@ nsLDAPConnection::~nsLDAPConnection()
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("unbinding\n"));
if (mConnectionHandle) {
rc = ldap_unbind_s(mConnectionHandle);
// note that the ldap_unbind() call in the 5.0 version of the LDAP C SDK
// appears to be exactly identical to ldap_unbind_s(), so it may in fact
// still be synchronous
//
rc = ldap_unbind(mConnectionHandle);
#ifdef PR_LOGGING
if (rc != LDAP_SUCCESS) {
if (gLDAPLogModule) {
PR_LOG(gLDAPLogModule, PR_LOG_WARNING,
("nsLDAPConnection::~nsLDAPConnection: %s\n",
ldap_err2string(rc)));
}
PR_LOG(gLDAPLogModule, PR_LOG_WARNING,
("nsLDAPConnection::~nsLDAPConnection: %s\n",
ldap_err2string(rc)));
}
#endif
}
#ifdef PR_LOGGING
if (gLDAPLogModule) {
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("unbound\n"));
}
#endif
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("unbound\n"));
if (mBindName) {
delete mBindName;
@ -185,17 +180,6 @@ nsLDAPConnection::Init(const char *aHost, PRInt16 aPort,
return NS_ERROR_ILLEGAL_VALUE;
}
#ifdef PR_LOGGING
// initialize logging, if it hasn't been already
//
if (!gLDAPLogModule) {
gLDAPLogModule = PR_NewLogModule("ldap");
NS_ABORT_IF_FALSE(gLDAPLogModule,
"failed to initialize LDAP log module");
}
#endif
// Make sure we haven't called Init earlier, i.e. there's a DNS
// request pending.
//
@ -225,12 +209,6 @@ nsLDAPConnection::Init(const char *aHost, PRInt16 aPort,
//
mInitListener = aMessageListener;
// initialize the thread-specific data for the calling thread as necessary
//
if (!nsLDAPThreadDataInit()) {
return NS_ERROR_FAILURE;
}
// allocate a hashtable to keep track of pending operations.
// 10 buckets seems like a reasonable size, and we do want it to
// be threadsafe
@ -779,14 +757,6 @@ nsLDAPConnectionLoop::Run(void)
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
("nsLDAPConnection::Run() entered\n"));
// initialize the thread-specific data for the child thread (as necessary)
//
if (!nsLDAPThreadDataInit()) {
NS_ERROR("nsLDAPConnection::Run() couldn't initialize "
"thread-specific data");
return NS_ERROR_FAILURE;
}
// wait for results
//
while(1) {
@ -981,14 +951,10 @@ nsLDAPConnection::OnStopLookup(nsISupports *aContext,
//
if ( !mConnectionHandle ) {
rv = NS_ERROR_FAILURE; // LDAP C SDK API gives no useful error
} else if (!nsLDAPThreadFuncsInit(mConnectionHandle)) {
rv = NS_ERROR_UNEXPECTED;
} else {
#ifdef DEBUG_dmose
const int lDebug = 0;
ldap_set_option(mConnectionHandle, LDAP_OPT_DEBUG_LEVEL, &lDebug);
ldap_set_option(mConnectionHandle, LDAP_OPT_ASYNC_CONNECT,
NS_REINTERPRET_CAST(void *, 0));
#endif
}

Просмотреть файл

@ -1,227 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the mozilla.org LDAP XPCOM SDK.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Dan Mosedale <dmose@mozilla.org>
* Leif Hedstrom <leif@netscape.com>
* Mark C. Smith <mcs@netscape.com>
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#include "nspr.h"
#include "ldap.h"
/* XXXdmose errno.h should go away, probably after ldap C SDK 4.1 lands */
#include "errno.h"
/* one of these exists per thread */
struct nsLDAPLderrno {
/* must be native (ie non-NSPR) types, because of the callback decls */
int mErrno;
char *mMatched;
char *mErrMsg;
};
static PRUintn kLDAPErrnoData = 0;
struct ldap_thread_fns kLDAPThreadFuncs;
struct ldap_extra_thread_fns kLDAPExtraThreadFuncs;
/**
* initialize the thread-specific data for this thread (if necessary)
*
* @return 1 on success; 0 on failure
*/
int
nsLDAPThreadDataInit(void)
{
void *errnoData;
/* if we don't have an index for this data, get one */
if (kLDAPErrnoData == 0) {
if (PR_NewThreadPrivateIndex(&kLDAPErrnoData, &PR_Free)
!= PR_SUCCESS) {
#ifdef DEBUG
PR_fprintf(PR_STDERR, "nsLDAPThreadDataInit(): error "
"allocating kLDAPErrorData thread-private index.\n");
#endif
return 0;
}
}
/* if the data for this thread has already been allocated, we're done */
errnoData = PR_GetThreadPrivate(kLDAPErrnoData);
if ( errnoData != NULL ) {
return 1;
}
/* get some memory for the data for this thread */
errnoData = PR_Calloc( 1, sizeof(struct nsLDAPLderrno));
if (!errnoData) {
#ifdef DEBUG
PR_fprintf(PR_STDERR, "nsLDAPThreadDataInit(): PR_calloc failed\n");
#endif
return 0;
}
if ( PR_SetThreadPrivate(kLDAPErrnoData, errnoData) != PR_SUCCESS ) {
#ifdef DEBUG
PR_fprintf(PR_STDERR, "nsLDAPThreadDataInit(): PR_SetThreadPrivate "
"failed\n");
#endif
return 0;
}
return 1;
}
/**
* Function for setting the (thread-specific) LDAP error.
*/
static void
nsLDAPSetLderrno(int aErrno, char *aMatched, char *aErrMsg, void *aDummy)
{
struct nsLDAPLderrno *nle;
nle = PR_GetThreadPrivate(kLDAPErrnoData);
if (!nle) {
#ifdef DEBUG
PR_fprintf(PR_STDERR, "nsLDAPSetLDAPErrno(): PR_GetThreadPrivate "
"failed\n");
#endif
return;
}
nle->mErrno = aErrno;
/* free any previous setting and replace it with the new one */
if ( nle->mMatched != NULL ) {
ldap_memfree( nle->mMatched );
}
nle->mMatched = aMatched;
/* free any previous setting and replace it with the new one */
if ( nle->mErrMsg != NULL ) {
ldap_memfree( nle->mErrMsg );
}
nle->mErrMsg = aErrMsg;
}
/* Function for getting an LDAP error. */
static int
nsLDAPGetLderrno( char **aMatched, char **aErrMsg, void *aDummy )
{
struct nsLDAPLderrno *nle;
nle = PR_GetThreadPrivate(kLDAPErrnoData);
if (!nle) {
#ifdef DEBUG
PR_fprintf(PR_STDERR, "nsLDAPSetLDAPErrno(): PR_GetThreadPrivate "
"failed\n");
#endif
return LDAP_OTHER;
}
if ( aMatched != NULL ) {
*aMatched = nle->mMatched;
}
if ( aErrMsg != NULL ) {
*aErrMsg = nle->mErrMsg;
}
return( nle->mErrno );
}
/*
* these two functions work with pthreads. they might work with other
* threads too. but maybe not. ultimately, when LDAP C SDK 4.1
* lands, we'll have NSPR functions used by the SDK, so that we can
* use NSPR's errno, not the system one. (and that should be
* cross-platform).
*/
static void
nsLDAPSetErrno( int aErr )
{
errno = aErr;
}
static int
nsLDAPGetErrno( void )
{
return errno;
}
/*
* This function will be used by the C-SDK to get the thread ID. We
* need this to avoid calling into the locking function multiple
* times on the same lock.
*/
static void *
nsLDAPGetThreadID( void )
{
return( (void *)PR_GetCurrentThread());
}
int
nsLDAPThreadFuncsInit(LDAP *aLDAP)
{
kLDAPThreadFuncs.ltf_mutex_alloc = (void *(*)(void))PR_NewLock;
kLDAPThreadFuncs.ltf_mutex_free = (void (*)(void *))PR_DestroyLock;
kLDAPThreadFuncs.ltf_mutex_lock = (int (*)(void *))PR_Lock;
kLDAPThreadFuncs.ltf_mutex_unlock = (int (*)(void *))PR_Unlock;
kLDAPThreadFuncs.ltf_get_errno = nsLDAPGetErrno;
kLDAPThreadFuncs.ltf_set_errno = nsLDAPSetErrno;
kLDAPThreadFuncs.ltf_get_lderrno = nsLDAPGetLderrno;
kLDAPThreadFuncs.ltf_set_lderrno = nsLDAPSetLderrno;
/* Don't pass any extra parameter to the functions for
getting and setting libldap function call errors */
kLDAPThreadFuncs.ltf_lderrno_arg = NULL;
if (ldap_set_option(aLDAP, LDAP_OPT_THREAD_FN_PTRS,
(void *)&kLDAPThreadFuncs) != 0) {
return 0;
}
/* set extended thread function pointers */
kLDAPExtraThreadFuncs.ltf_threadid_fn = nsLDAPGetThreadID;
if ( ldap_set_option(aLDAP, LDAP_OPT_EXTRA_THREAD_FN_PTRS,
(void *)&kLDAPExtraThreadFuncs ) != 0 ) {
return 0;
}
return 1;
}

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsLDAPMessage.h"
#include "nsLDAPServer.h"
#include "nsLDAPService.h"
#include "ldappr.h"
#ifdef MOZ_LDAP_XPCOM_EXPERIMENTAL
#include "nsLDAPProtocolHandler.h"
@ -85,9 +86,49 @@ static const nsModuleComponentInfo components[] =
"@mozilla.org/network/ldap-url;1", nsLDAPURLConstructor }
};
PR_STATIC_CALLBACK(nsresult)
nsLDAPInitialize(nsIModule *aSelf)
{
#ifdef PR_LOGGING
gLDAPLogModule = PR_NewLogModule("ldap");
if (!gLDAPLogModule) {
PR_fprintf(PR_STDERR, "LDAP_Initialize(): PR_NewLogModule() failed\n");
return NS_ERROR_NOT_AVAILABLE;
}
#endif
// use NSPR under the hood for all networking
//
int rv = prldap_install_routines( NULL, 1 /* shared */ );
if (rv != LDAP_SUCCESS) {
PR_LOG(gLDAPLogModule, PR_LOG_ERROR,
("LDAPInitialize(): pr_ldap_install_routines() failed: %s\n",
ldap_err2string(rv)));
return NS_ERROR_FAILURE;
}
#if 0
// XXXdmose - for some reason, turning on this code causes connects to
// fail
//
rv = prldap_set_session_option(0, 0, PRLDAP_OPT_IO_MAX_TIMEOUT,
LDAP_X_IO_TIMEOUT_NO_WAIT);
if (rv != LDAP_SUCCESS) {
PR_LOG(gLDAPLogModule, PR_LOG_ERROR,
("LDAPInitialize(): error setting LDAP_X_IO_TIMEOUT_NO_WAIT:"
" %s\n",ldap_err2string(rv)));
return NS_ERROR_FAILURE;
}
#endif
return NS_OK;
}
// implement the NSGetModule() exported function
//
NS_IMPL_NSGETMODULE(nsLDAPProtocolModule, components);
NS_IMPL_NSGETMODULE_WITH_CTOR(nsLDAPProtocolModule, components,
nsLDAPInitialize)
#ifdef PR_LOGGING
PRLogModuleInfo *gLDAPLogModule = 0;

Просмотреть файл

@ -108,7 +108,6 @@ DIRS = \
extensions \
themes \
!if !defined(DISABLE_LDAP)
directory\c-sdk \
directory\xpcom \
!endif
l10n \

Просмотреть файл

@ -116,7 +116,8 @@ LLFLAGS=$(LLFLAGS) /HEAP:0x40000
LLIBS= \
$(DIST)\lib\xpcom.lib \
!ifndef DISABLE_LDAP
$(DIST)\lib\nsldap32v40.lib \
$(DIST)\lib\nsldap32v50.lib \
$(DIST)\lib\nsldappr32v50.lib \
!endif
$(DIST)\lib\js3250.lib \
$(DIST)\lib\util.lib \

Просмотреть файл

@ -233,8 +233,9 @@ bin/res/builtin/platformHTMLBindings.xml
[mail]
bin/components/libmeta_mail.so
bin/libldap40.so
bin/liblber40.so
bin/libldap50.so
bin/liblber50.so
bin/libprldap50.so
bin/components/addrbook.xpt
bin/components/mailnews.xpt
bin/components/mime.xpt

Просмотреть файл

@ -253,7 +253,8 @@ bin\res\builtin\platformHTMLBindings.xml
[mail]
bin\components\mail.dll
bin\nsldap32v40.dll
bin\nsldap32v50.dll
bin\nsldappr32v50.dll
bin\components\addrbook.xpt
bin\components\mailnewspublic.xpt
bin\components\mime.xpt

Просмотреть файл

@ -315,8 +315,9 @@ bin/res/builtin/platformHTMLBindings.xml
[mail]
bin/libldap40.so
bin/liblber40.so
bin/libldap50.so
bin/liblber50.so
bin/libprldap50.so
bin/libmsgbaseutil.so
bin/components/addrbook.xpt
bin/components/libaddrbook.so

Просмотреть файл

@ -366,7 +366,8 @@ bin\components\absync.xpt
bin\components\nsLDAPPrefsService.js
bin\components\mozldap.dll
bin\components\mozldap.xpt
bin\nsldap32v40.dll
bin\nsldap32v50.dll
bin\nsldappr32v50.dll
bin\chrome\messenger.jar
bin\chrome\messenger\*
bin\components\msgsmime.dll