mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-20 22:59:34 -05:00
Add a little SASL framework and remove old X-DIGEST-MD5 hardcode.
This code is not called (yet).
This commit is contained in:
parent
79fb44b129
commit
f90ed5aef8
8 changed files with 106 additions and 14 deletions
2
configure
vendored
2
configure
vendored
|
|
@ -10492,7 +10492,7 @@ fi
|
||||||
if test $have_cyrus_sasl != no ; then
|
if test $have_cyrus_sasl != no ; then
|
||||||
LUTIL_LIBS="$LUTIL_LIBS -lsasl"
|
LUTIL_LIBS="$LUTIL_LIBS -lsasl"
|
||||||
cat >> confdefs.h <<\EOF
|
cat >> confdefs.h <<\EOF
|
||||||
#define HAVE_CRYUS_SASL 1
|
#define HAVE_CYRUS_SASL 1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
ol_link_sasl=yes
|
ol_link_sasl=yes
|
||||||
|
|
|
||||||
|
|
@ -1653,7 +1653,7 @@ if test $ol_with_cyrus_sasl != no ; then
|
||||||
|
|
||||||
if test $have_cyrus_sasl != no ; then
|
if test $have_cyrus_sasl != no ; then
|
||||||
LUTIL_LIBS="$LUTIL_LIBS -lsasl"
|
LUTIL_LIBS="$LUTIL_LIBS -lsasl"
|
||||||
AC_DEFINE(HAVE_CRYUS_SASL,1,[define if you have Cyrus SASL])
|
AC_DEFINE(HAVE_CYRUS_SASL,1,[define if you have Cyrus SASL])
|
||||||
ol_link_sasl=yes
|
ol_link_sasl=yes
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -700,7 +700,7 @@
|
||||||
#undef NO_TERMCAP
|
#undef NO_TERMCAP
|
||||||
|
|
||||||
/* define if you have Cyrus SASL */
|
/* define if you have Cyrus SASL */
|
||||||
#undef HAVE_CRYUS_SASL
|
#undef HAVE_CYRUS_SASL
|
||||||
|
|
||||||
/* define if you actually have FreeBSD fetch(3) */
|
/* define if you actually have FreeBSD fetch(3) */
|
||||||
#undef HAVE_FETCH
|
#undef HAVE_FETCH
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ SRCS = main.c daemon.c connection.c search.c filter.c add.c charray.c \
|
||||||
phonetic.c acl.c str2filter.c aclparse.c init.c user.c \
|
phonetic.c acl.c str2filter.c aclparse.c init.c user.c \
|
||||||
repl.c lock.c controls.c extended.c \
|
repl.c lock.c controls.c extended.c \
|
||||||
schema.c schemaparse.c monitor.c configinfo.c \
|
schema.c schemaparse.c monitor.c configinfo.c \
|
||||||
root_dse.c module.c suffixalias.c
|
root_dse.c sasl.c module.c suffixalias.c
|
||||||
OBJS = main.o daemon.o connection.o search.o filter.o add.o charray.o \
|
OBJS = main.o daemon.o connection.o search.o filter.o add.o charray.o \
|
||||||
attr.o entry.o config.o backend.o result.o operation.o \
|
attr.o entry.o config.o backend.o result.o operation.o \
|
||||||
dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \
|
dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \
|
||||||
|
|
@ -19,7 +19,7 @@ OBJS = main.o daemon.o connection.o search.o filter.o add.o charray.o \
|
||||||
phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
|
phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
|
||||||
repl.o lock.o controls.o extended.o \
|
repl.o lock.o controls.o extended.o \
|
||||||
schema.o schemaparse.o monitor.o configinfo.o \
|
schema.o schemaparse.o monitor.o configinfo.o \
|
||||||
root_dse.o module.o suffixalias.o
|
root_dse.o sasl.o module.o suffixalias.o
|
||||||
|
|
||||||
LDAP_INCDIR= ../../include
|
LDAP_INCDIR= ../../include
|
||||||
LDAP_LIBDIR= ../../libraries
|
LDAP_LIBDIR= ../../libraries
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,7 @@
|
||||||
|
|
||||||
#include "slap.h"
|
#include "slap.h"
|
||||||
|
|
||||||
char *supportedSASLMechanisms[] = {
|
char **supportedSASLMechanisms = NULL;
|
||||||
"X-DIGEST-MD5",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
int
|
||||||
do_bind(
|
do_bind(
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ int load_module LDAP_P(( const char* file_name, int argc, char *argv[] ));
|
||||||
*/
|
*/
|
||||||
extern char *supportedExtensions[];
|
extern char *supportedExtensions[];
|
||||||
extern char *supportedControls[];
|
extern char *supportedControls[];
|
||||||
extern char *supportedSASLMechanisms[];
|
extern char **supportedSASLMechanisms;
|
||||||
|
|
||||||
void monitor_info LDAP_P((
|
void monitor_info LDAP_P((
|
||||||
Connection *conn,
|
Connection *conn,
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,12 @@ root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* supportedSASLMechanism */
|
/* supportedSASLMechanism */
|
||||||
for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
|
if( supportedSASLMechanisms != NULL ) {
|
||||||
val.bv_val = supportedSASLMechanisms[i];
|
for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
|
||||||
val.bv_len = strlen( val.bv_val );
|
val.bv_val = supportedSASLMechanisms[i];
|
||||||
attr_merge( e, "supportedSASLMechanisms", vals );
|
val.bv_len = strlen( val.bv_val );
|
||||||
|
attr_merge( e, "supportedSASLMechanisms", vals );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( default_referral != NULL ) {
|
if ( default_referral != NULL ) {
|
||||||
|
|
|
||||||
93
servers/slapd/sasl.c
Normal file
93
servers/slapd/sasl.c
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
#include "portable.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_CYRUS_SASL
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "slap.h"
|
||||||
|
#include "proto-slap.h"
|
||||||
|
|
||||||
|
#include <lber.h>
|
||||||
|
#include <ldap_log.h>
|
||||||
|
|
||||||
|
#ifdef MAIN
|
||||||
|
#undef Debug
|
||||||
|
#define Debug(x,s,a,b,c) fprintf(stderr, s, a, b, c)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sasl.h>
|
||||||
|
|
||||||
|
/* sasl server context */
|
||||||
|
static sasl_conn_t *server = NULL;
|
||||||
|
|
||||||
|
int sasl_init( void )
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
char *data;
|
||||||
|
unsigned len, count;
|
||||||
|
sasl_security_properties_t secprops;
|
||||||
|
|
||||||
|
rc = sasl_server_init( NULL, "slapd" );
|
||||||
|
|
||||||
|
if( rc != SASL_OK ) {
|
||||||
|
Debug( LDAP_DEBUG_ANY, "sasl_server_init failed\n",
|
||||||
|
0, 0, 0 );
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = sasl_server_new( "ldap", NULL, NULL, NULL,
|
||||||
|
SASL_SECURITY_LAYER,
|
||||||
|
&server );
|
||||||
|
|
||||||
|
if( rc != SASL_OK ) {
|
||||||
|
Debug( LDAP_DEBUG_ANY, "sasl_server_new failed\n",
|
||||||
|
0, 0, 0 );
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&secprops, 0, sizeof(secprops));
|
||||||
|
secprops.security_flags = SASL_SEC_NOPLAINTEXT | SASL_SEC_NOANONYMOUS;
|
||||||
|
secprops.property_names = NULL;
|
||||||
|
secprops.property_values = NULL;
|
||||||
|
|
||||||
|
rc = sasl_setprop( server, SASL_SEC_PROPS, &secprops );
|
||||||
|
|
||||||
|
if( rc != SASL_OK ) {
|
||||||
|
Debug( LDAP_DEBUG_ANY, "sasl_setprop failed\n",
|
||||||
|
0, 0, 0 );
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = sasl_listmech( server, NULL, NULL, ",", NULL,
|
||||||
|
&data, &len, &count);
|
||||||
|
|
||||||
|
if( rc != SASL_OK ) {
|
||||||
|
Debug( LDAP_DEBUG_ANY, "sasl_listmech failed: %d\n",
|
||||||
|
rc, 0, 0 );
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug( LDAP_DEBUG_TRACE, "SASL mechanisms: %s\n",
|
||||||
|
data, 0, 0 );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int sasl_destory( void )
|
||||||
|
{
|
||||||
|
if( server != NULL ) {
|
||||||
|
sasl_dispose( &server );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MAIN
|
||||||
|
int main( int argc, char* argv[] )
|
||||||
|
{
|
||||||
|
int rc = sasl_init();
|
||||||
|
|
||||||
|
sasl_destory();
|
||||||
|
|
||||||
|
exit(rc);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
Loading…
Reference in a new issue