Bug: 339298
Description: Merge sun libprldap changes on to trunk Fix Description: Pretty much the same as the fixes made for bugs 352519 352673 on the sun_merge_branch_20060523, this just merges those changes on to the trunk. One additional change is the removal of an unused variable.
This commit is contained in:
Родитель
b8ce737879
Коммит
f4a6bf3d6b
|
@ -6779,6 +6779,8 @@ esac
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -560,6 +560,12 @@ LDAP_API(void) LDAP_CALL ldap_memcache_update( LDAPMemCache *cache );
|
|||
#define LDAP_X_OPT_CONNECT_TIMEOUT (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F01)
|
||||
/* 0x4000 + 0x0F01 = 0x4F01 = 20225 - API extension */
|
||||
|
||||
/*
|
||||
* Socket buffer structure associated to the LDAP connection
|
||||
*/
|
||||
#define LDAP_X_OPT_SOCKBUF (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F03)
|
||||
/* 0x4000 + 0x0F03 = 0x4F03 = 20227 - API extension */
|
||||
|
||||
/*
|
||||
* Memory allocation callback functions (an API extension --
|
||||
* LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS). These are global and can
|
||||
|
|
|
@ -116,12 +116,15 @@ typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETHOSTBYNAME)(
|
|||
typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETHOSTBYADDR)(
|
||||
const char *addr, int length, int type, LDAPHostEnt *result,
|
||||
char *buffer, int buflen, int *statusp, void *extradata );
|
||||
typedef int (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETPEERNAME)(
|
||||
LDAP *ld, struct sockaddr *netaddr, char *buffer, int buflen);
|
||||
|
||||
struct ldap_dns_fns {
|
||||
void *lddnsfn_extradata;
|
||||
int lddnsfn_bufsize;
|
||||
LDAP_DNSFN_GETHOSTBYNAME *lddnsfn_gethostbyname;
|
||||
LDAP_DNSFN_GETHOSTBYADDR *lddnsfn_gethostbyaddr;
|
||||
LDAP_DNSFN_GETPEERNAME *lddnsfn_getpeername;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -65,6 +65,13 @@ extern "C" {
|
|||
LDAP * LDAP_CALL ldapssl_init( const char *defhost, int defport,
|
||||
int defsecure );
|
||||
|
||||
/*
|
||||
* Shutdown LDAP library for SSL :
|
||||
* Perform necessary cleanup and attempt to shutdown NSS. All existing
|
||||
* ld session handles should be ldap_unbind(ld) prior to calling this.
|
||||
*/
|
||||
int LDAP_CALL ldapssl_shutdown();
|
||||
|
||||
/* Initialize LDAP library for TLS(SSL) and sends StartTLS extended
|
||||
* operation to the Directory Server.
|
||||
* Returns LDAP_SUCCESS if all goes well.
|
||||
|
|
|
@ -232,6 +232,28 @@ int LDAP_CALL prldap_set_socket_info( int fd, void *socketarg,
|
|||
int LDAP_CALL prldap_get_socket_info( int fd, void *socketarg,
|
||||
PRLDAPSocketInfo *soip );
|
||||
|
||||
/*
|
||||
* Function: prldap_get_default_socket_info().
|
||||
*
|
||||
* Given an LDAP session handle, retrieve socket specific information.
|
||||
* If ld is NULL, LDAP_PARAM_ERROR is returned.
|
||||
*
|
||||
* Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in
|
||||
* which case the fields in the structure that soip points to are filled in).
|
||||
*/
|
||||
int LDAP_CALL prldap_get_default_socket_info( LDAP *ld, PRLDAPSocketInfo *soip );
|
||||
|
||||
/*
|
||||
* Function: prldap_set_default_socket_info().
|
||||
*
|
||||
* Given an LDAP session handle, set socket specific information.
|
||||
* If ld is NULL, LDAP_PARAM_ERROR is returned.
|
||||
*
|
||||
* Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in
|
||||
* which case the fields in the structure that soip points to are filled in).
|
||||
*/
|
||||
int LDAP_CALL prldap_set_default_socket_info( LDAP *ld, PRLDAPSocketInfo *soip );
|
||||
|
||||
/* Function: prldap_is_installed()
|
||||
* Check if NSPR routine is installed
|
||||
*/
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
MOD_DEPTH = ../../..
|
||||
srcdir = @srcdir@
|
||||
topsrcdir = @top_srcdir@
|
||||
HAVE_SASL = @HAVE_SASL@
|
||||
SASL_CFLAGS = @SASL_CFLAGS@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/build.mk
|
||||
|
|
|
@ -141,6 +141,11 @@ ldap_get_option( LDAP *ld, int option, void *optdata )
|
|||
break;
|
||||
#endif /* LDAP_ASYNC_IO */
|
||||
|
||||
/* stuff in the sockbuf */
|
||||
case LDAP_X_OPT_SOCKBUF:
|
||||
*((Sockbuf **) optdata) = ld->ld_sbp;
|
||||
break;
|
||||
|
||||
case LDAP_OPT_DESC:
|
||||
if ( ber_sockbuf_get_option( ld->ld_sbp,
|
||||
LBER_SOCKBUF_OPT_DESC, optdata ) != 0 ) {
|
||||
|
|
|
@ -343,6 +343,7 @@ struct ldap {
|
|||
#define ld_dns_bufsize ld_dnsfn.lddnsfn_bufsize
|
||||
#define ld_dns_gethostbyname_fn ld_dnsfn.lddnsfn_gethostbyname
|
||||
#define ld_dns_gethostbyaddr_fn ld_dnsfn.lddnsfn_gethostbyaddr
|
||||
#define ld_dns_getpeername_fn ld_dnsfn.lddnsfn_getpeername
|
||||
|
||||
/* function pointers, etc. for threading */
|
||||
struct ldap_thread_fns ld_thread;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
461 ldapssl_set_option
|
||||
462 ldapssl_get_option
|
||||
463 ldap_start_tls_s
|
||||
464 ldapssl_shutdown
|
||||
# the last Windows ordinal number that has been reserved for SSL is 469.
|
||||
|
||||
# Windows ordinals 1100-1150 are reserved for privately/non-published
|
||||
|
|
|
@ -49,6 +49,8 @@ static LDAPHostEnt *prldap_gethostbyname( const char *name,
|
|||
static LDAPHostEnt *prldap_gethostbyaddr( const char *addr, int length,
|
||||
int type, LDAPHostEnt *result, char *buffer, int buflen,
|
||||
int *statusp, void *extradata );
|
||||
static int prldap_getpeername( LDAP *ld, struct sockaddr *addr,
|
||||
char *buffer, int buflen );
|
||||
static LDAPHostEnt *prldap_convert_hostent( LDAPHostEnt *ldhp,
|
||||
PRHostEnt *prhp );
|
||||
|
||||
|
@ -68,6 +70,7 @@ prldap_install_dns_functions( LDAP *ld )
|
|||
dnsfns.lddnsfn_bufsize = PR_NETDB_BUF_SIZE;
|
||||
dnsfns.lddnsfn_gethostbyname = prldap_gethostbyname;
|
||||
dnsfns.lddnsfn_gethostbyaddr = prldap_gethostbyaddr;
|
||||
dnsfns.lddnsfn_getpeername = prldap_getpeername;
|
||||
if ( ldap_set_option( ld, LDAP_OPT_DNS_FN_PTRS, (void *)&dnsfns ) != 0 ) {
|
||||
return( -1 );
|
||||
}
|
||||
|
@ -119,6 +122,33 @@ prldap_gethostbyaddr( const char *addr, int length, int type,
|
|||
}
|
||||
|
||||
|
||||
static int
|
||||
prldap_getpeername( LDAP *ld, struct sockaddr *addr, char *buffer, int buflen)
|
||||
{
|
||||
PRLDAPIOSocketArg *sa;
|
||||
PRNetAddr iaddr;
|
||||
int ret;
|
||||
|
||||
if (NULL != ld) {
|
||||
ret = prldap_socket_arg_from_ld( ld, &sa );
|
||||
if (ret != LDAP_SUCCESS) {
|
||||
return (-1);
|
||||
}
|
||||
ret = PR_GetPeerName(sa->prsock_prfd, &iaddr);
|
||||
if( ret == PR_FAILURE ) {
|
||||
return( -1 );
|
||||
}
|
||||
*addr = *((struct sockaddr *)&iaddr.raw);
|
||||
ret = PR_NetAddrToString(&iaddr, buffer, buflen);
|
||||
if( ret == PR_FAILURE ) {
|
||||
return( -1 );
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function: prldap_convert_hostent()
|
||||
* Description: copy the fields of a PRHostEnt struct to an LDAPHostEnt
|
||||
|
|
|
@ -113,6 +113,7 @@ int prldap_set_io_max_timeout( PRLDAPIOSessionArg *prsessp,
|
|||
int io_max_timeout );
|
||||
int prldap_get_io_max_timeout( PRLDAPIOSessionArg *prsessp,
|
||||
int *io_max_timeoutp );
|
||||
int prldap_socket_arg_from_ld( LDAP *ld, PRLDAPIOSocketArg **sockargpp );
|
||||
PRLDAPIOSocketArg *prldap_socket_arg_alloc( PRLDAPIOSessionArg *sessionarg );
|
||||
|
||||
|
||||
|
|
|
@ -447,6 +447,9 @@ prldap_connect( const char *hostlist, int defport, int timeout,
|
|||
ldap_memfree( host );
|
||||
}
|
||||
|
||||
if ( host ) {
|
||||
ldap_memfree( host );
|
||||
}
|
||||
ldap_x_hostlist_statusfree( status );
|
||||
|
||||
if ( rc < 0 ) {
|
||||
|
@ -604,6 +607,43 @@ prldap_session_arg_from_ld( LDAP *ld, PRLDAPIOSessionArg **sessargpp )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Given an LDAP session handle, retrieve a socket argument.
|
||||
* Returns an LDAP error code.
|
||||
*/
|
||||
int
|
||||
prldap_socket_arg_from_ld( LDAP *ld, PRLDAPIOSocketArg **sockargpp )
|
||||
{
|
||||
Sockbuf *sbp;
|
||||
struct lber_x_ext_io_fns extiofns;
|
||||
|
||||
if ( NULL == ld || NULL == sockargpp ) {
|
||||
/* XXXmcs: NULL ld's are not supported */
|
||||
ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL );
|
||||
return( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
if ( ldap_get_option( ld, LDAP_X_OPT_SOCKBUF, (void *)&sbp ) < 0 ) {
|
||||
return( ldap_get_lderrno( ld, NULL, NULL ));
|
||||
}
|
||||
|
||||
memset( &extiofns, 0, sizeof(extiofns));
|
||||
extiofns.lbextiofn_size = LBER_X_EXTIO_FNS_SIZE;
|
||||
if ( ber_sockbuf_get_option( sbp, LBER_SOCKBUF_OPT_EXT_IO_FNS,
|
||||
(void *)&extiofns ) < 0 ) {
|
||||
return( ldap_get_lderrno( ld, NULL, NULL ));
|
||||
}
|
||||
|
||||
if ( NULL == extiofns.lbextiofn_socket_arg ) {
|
||||
ldap_set_lderrno( ld, LDAP_LOCAL_ERROR, NULL, NULL );
|
||||
return( LDAP_LOCAL_ERROR );
|
||||
}
|
||||
|
||||
*sockargpp = extiofns.lbextiofn_socket_arg;
|
||||
return( LDAP_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Allocate a socket argument.
|
||||
*/
|
||||
|
|
|
@ -311,6 +311,83 @@ prldap_get_socket_info( int fd, void *socketarg, PRLDAPSocketInfo *soip )
|
|||
return( LDAP_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function: prldap_get_default_socket_info().
|
||||
*
|
||||
* Given an LDAP session handle, retrieve socket specific information.
|
||||
* If ld is NULL, LDAP_PARAM_ERROR is returned.
|
||||
*
|
||||
* Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in
|
||||
* which case the fields in the structure that soip points to are filled in).
|
||||
*/
|
||||
int LDAP_CALL
|
||||
prldap_get_default_socket_info( LDAP *ld, PRLDAPSocketInfo *soip )
|
||||
{
|
||||
int rc;
|
||||
PRLDAPIOSocketArg *prsockp;
|
||||
|
||||
|
||||
if ( NULL == soip || PRLDAP_SOCKETINFO_SIZE != soip->soinfo_size ) {
|
||||
ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL );
|
||||
return( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
if ( NULL != ld ) {
|
||||
if ( LDAP_SUCCESS !=
|
||||
( rc = prldap_socket_arg_from_ld( ld, &prsockp ))) {
|
||||
return( rc );
|
||||
}
|
||||
} else {
|
||||
ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL );
|
||||
return( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
soip->soinfo_prfd = prsockp->prsock_prfd;
|
||||
soip->soinfo_appdata = prsockp->prsock_appdata;
|
||||
|
||||
return( LDAP_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function: prldap_set_default_socket_info().
|
||||
*
|
||||
* Given an LDAP session handle, set socket specific information.
|
||||
* If ld is NULL, LDAP_PARAM_ERROR is returned.
|
||||
*
|
||||
* Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in
|
||||
* which case the fields in the structure that soip points to are filled in).
|
||||
*/
|
||||
int LDAP_CALL
|
||||
prldap_set_default_socket_info( LDAP *ld, PRLDAPSocketInfo *soip )
|
||||
{
|
||||
int rc;
|
||||
PRLDAPIOSocketArg *prsockp;
|
||||
|
||||
|
||||
if ( NULL == soip || PRLDAP_SOCKETINFO_SIZE != soip->soinfo_size ) {
|
||||
ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL );
|
||||
return( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
if ( NULL != ld ) {
|
||||
if ( LDAP_SUCCESS !=
|
||||
( rc = prldap_socket_arg_from_ld( ld, &prsockp ))) {
|
||||
return( rc );
|
||||
}
|
||||
} else {
|
||||
ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL );
|
||||
return( LDAP_PARAM_ERROR );
|
||||
}
|
||||
|
||||
prsockp->prsock_prfd = soip->soinfo_prfd;
|
||||
prsockp->prsock_appdata = soip->soinfo_appdata;
|
||||
|
||||
return( LDAP_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function: prldap_import_connection().
|
||||
*
|
||||
|
@ -324,7 +401,7 @@ prldap_import_connection (LDAP *ld)
|
|||
{
|
||||
int rc = LDAP_SUCCESS; /* optimistic */
|
||||
int shared = 1; /* Assume shared init */
|
||||
int orig_socket = -1;
|
||||
LBER_SOCKET orig_socket = -1;
|
||||
PRLDAPIOSessionArg *prsessp = NULL;
|
||||
PRLDAPIOSocketArg *prsockp = NULL;
|
||||
PRFileDesc *pr_socket = NULL;
|
||||
|
|
|
@ -44,3 +44,5 @@
|
|||
2017 prldap_get_session_option
|
||||
2018 prldap_is_installed
|
||||
2019 prldap_import_connection
|
||||
2020 prldap_set_default_socket_info
|
||||
2021 prldap_get_default_socket_info
|
||||
|
|
|
@ -171,6 +171,40 @@ static PRStatus local_SSLPLCY_Install(void)
|
|||
}
|
||||
|
||||
|
||||
static SECStatus
|
||||
ldapssl_shutdown_handler(void *appData, void *nssData)
|
||||
{
|
||||
SSL_ClearSessionCache();
|
||||
if ( NSS_UnregisterShutdown(ldapssl_shutdown_handler,
|
||||
(void *)NULL) != SECSuccess ) {
|
||||
return SECFailure;
|
||||
}
|
||||
inited = 0;
|
||||
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Perform necessary cleanup and attempt to shutdown NSS. All existing
|
||||
* ld session handles should be ldap_unbind(ld) prior to calling this.
|
||||
*/
|
||||
int
|
||||
LDAP_CALL
|
||||
ldapssl_shutdown()
|
||||
{
|
||||
if ( ldapssl_shutdown_handler( (void *)NULL,
|
||||
(void *)NULL ) != SECSuccess ) {
|
||||
return( -1 );
|
||||
}
|
||||
if ( NSS_Shutdown() != SECSuccess ) {
|
||||
inited = 1;
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
return( LDAP_SUCCESS );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Note: by design, the keydbpath can actually be a certdbpath. Some
|
||||
|
@ -233,6 +267,11 @@ ldapssl_basic_init( const char *certdbpath, const char *keydbpath,
|
|||
if ( NSS_Initialize(confDir,certdbPrefix,keydbPrefix,
|
||||
secmoddbpath, NSS_INIT_READONLY) != SECSuccess) {
|
||||
retcode = -1;
|
||||
} else {
|
||||
if ( NSS_RegisterShutdown(ldapssl_shutdown_handler,
|
||||
(void *)NULL) != SECSuccess ) {
|
||||
retcode = -1;
|
||||
}
|
||||
}
|
||||
|
||||
ldapssl_free((void **)&certdbPrefix);
|
||||
|
@ -243,7 +282,6 @@ ldapssl_basic_init( const char *certdbpath, const char *keydbpath,
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Cover functions for malloc(), calloc(), strdup() and free() that are
|
||||
* compatible with the NSS libraries (they seem to use the C runtime
|
||||
|
|
Загрузка…
Ссылка в новой задаче