]> git.sur5r.net Git - openldap/commitdiff
Import latest changes from devel
authorKurt Zeilenga <kurt@openldap.org>
Wed, 16 Aug 2000 21:28:58 +0000 (21:28 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 16 Aug 2000 21:28:58 +0000 (21:28 +0000)
30 files changed:
build/openldap.m4
clients/finger/main.c
doc/man/man5/slapd.conf.5
doc/man/man8/in.xfingerd.8
doc/man/man8/slapadd.8
doc/man/man8/slapcat.8
doc/man/man8/slapd.8
doc/man/man8/slapindex.8
doc/man/man8/slappasswd.8
doc/man/man8/slurpd.8
include/ldap_pvt.h
libraries/liblber/memory.c
libraries/libldap/cyrus.c
libraries/libldap/init.c
libraries/libldap/os-ip.c
libraries/libldap/sasl.c
libraries/libldap/util-int.c
libraries/libldbm/ldbm.c
libraries/liblutil/authpasswd.c
libraries/liblutil/passwd.c
servers/slapd/back-ldbm/filterindex.c
servers/slapd/back-ldbm/idl.c
servers/slapd/back-ldbm/modify.c
servers/slapd/back-sql/rdbms_depend/mssql/testdb_metadata.sql [new file with mode: 0644]
servers/slapd/back-sql/rdbms_depend/mysql/testdb_metadata.sql [new file with mode: 0644]
servers/slapd/back-sql/rdbms_depend/oracle/testdb_metadata.sql [new file with mode: 0644]
servers/slapd/sasl.c
servers/slapd/schema_init.c
servers/slurpd/Makefile.in
servers/slurpd/slurp.h

index a12b0a2577d9dff5a6aa7e0435c95afbf2ebab2c..2db4042fb098a5a0d04b58a88f2a266a5c748844 100644 (file)
@@ -317,14 +317,17 @@ main()
        int rc;
        u_int32_t flags = DB_CREATE | DB_THREAD;
 
-
 #if DB_VERSION_MAJOR > 2
        DB_ENV *env = NULL;
 
        rc = db_env_create( &env, 0 );
 
        if( rc == 0 ) {
+#if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
+               rc = env->open( env, NULL, flags, 0 );
+#else
                rc = env->open( env, NULL, NULL, flags, 0 );
+#endif
        }
 
 #else
@@ -336,6 +339,13 @@ main()
        if( rc == 0 ) {
                db_appexit( &env );
        }
+#endif
+#if DB_VERSION_MAJOR > 2
+#if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
+       env->remove( env, NULL, DB_FORCE);
+#else
+       env->remove( env, NULL, NULL, DB_FORCE);
+#endif
 #endif
 
        return rc;
index 5e8111633e0ee2037f8eb110dcf04dedcceba412..bc02da053abddc9ecd08795ab5108b1eb6406fa7 100644 (file)
@@ -52,7 +52,7 @@ static void do_read(LDAP *ld, LDAPMessage *e);
 static void
 usage( char *name )
 {
-       fprintf( stderr, "usage: %s [-l] [-x ldaphost] [-p ldapport] [-f filterfile] [-t templatefile] [-c rdncount]\r\n", name );
+       fprintf( stderr, "usage: %s [-l] [-x ldaphost] [-p ldapport] [-b searchbase] [-f filterfile] [-t templatefile] [-c rdncount]\r\n", name );
        exit( EXIT_FAILURE );
 }
 
@@ -67,7 +67,7 @@ main( int argc, char **argv )
        int                     interactive = 0;
 
        deref = FINGER_DEREF;
-       while ( (i = getopt( argc, argv, "f:ilp:t:x:p:c:" )) != EOF ) {
+       while ( (i = getopt( argc, argv, "f:ilp:t:x:p:b:c:" )) != EOF ) {
                switch( i ) {
                case 'f':       /* ldap filter file */
                        filterfile = strdup( optarg );
@@ -93,6 +93,10 @@ main( int argc, char **argv )
                        ldapport = atoi( optarg );
                        break;
 
+               case 'b':       /* specify search base */
+                       base = strdup( optarg );
+                       break; 
+
                case 'c':       /* specify number of DN components to show */
                        rdncount = atoi( optarg );
                        break;
index 5b101652f282e2bf5360173b4fe74a63440d1bc3..a86c8aa22d48a6e7e32f7b6425ca68c95a2e397e 100644 (file)
@@ -1,4 +1,4 @@
-.TH SLAPD.CONF 5 "5 August 1999" "OpenLDAP LDVERSION"
+.TH SLAPD.CONF 5 "13 August 2000" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
 .\" Copyright 1998-2000 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
@@ -66,18 +66,19 @@ Options described in this section apply to all backends, unless specifically
 overridden in a backend definition. Arguments that should be replaced by 
 actual text are shown in brackets <>.
 .TP
-.B
-access to <what> [ by <who> <access> <control> ]+
+.B access to <what> [ by <who> <access> <control> ]+
 Grant access (specified by <access>) to a set of entries and/or
 attributes (specified by <what>) by one or more requestors (specified
 by <who>).
 See Developer's FAQ (http://www.openldap.org/faq/) for details.
-.TP
-.B
-attributetype ( <oid> [NAME <name>] [DESC <description>] \
-[OBSOLETE] [SUP <oid>] [EQUALITY <oid>] [ORDERING <oid>] \
-[SUBSTR <oid>] [SYNTAX <oidlen>] [SINGLE\-VALUE] [COLLECTIVE] \
-[NO\-USER\-MODIFICATION] [USAGE <attributeUsage>] )
+.HP
+.hy 0
+.B attributetype (\ <oid> [NAME\ <name>] [OBSOLETE]\
+ [DESC\ <description>]\
+ [SUP\ <oid>] [EQUALITY\ <oid>] [ORDERING\ <oid>]\
+ [SUBSTR\ <oid>] [SYNTAX\ <oidlen>] [SINGLE\-VALUE] [COLLECTIVE]\
+ [NO\-USER\-MODIFICATION] [USAGE\ <attributeUsage>]\ )
+.RS
 Specify an attribute type using the LDAPv3 syntax defined in RFC 2252.
 The slapd parser extends the RFC 2252 definition by allowing string
 forms as well as numeric OIDs to be used for the attribute OID and
@@ -102,19 +103,21 @@ SubstringAssertion NISnetgrouptriple Bootparameter
 .PD
 .RE
 .RE
+.RE
 .TP
 .B concurrency <integer>
 Specify a desired level of concurrency.  Provided to the underlying
 thread system as a hint.  The default is not to provdide any hint.
-.TP
-.B
-defaultaccess { none | auth | compare | search | read | write }
+.HP
+.B defaultaccess { none | auth | compare | search | read | write }
+.RS
 Specify the default access level to grant requestors when
 no access directives were provided for the database.
 The default behavior is to grant 'read' access.  It is
 recommended that
 .B access
 directives be used instead.
+.RE
 .TP
 .B idletimeout <integer>
 Specify the number of seconds to wait before forcibly closing
@@ -186,11 +189,11 @@ entry parsing
 .PD
 .RE
 .RE
-.TP
-.B
-objectclass ( <oid> [NAME <name>] [DESC <description] [OBSOLETE] \
-[SUP <oids>] [{ ABSTRACT | STRUCTURAL | AUXILIARY }] [MUST <oids>] \
-[MAY <oids>] )
+.HP
+.B objectclass ( <oid> [NAME <name>] [DESC <description] [OBSOLETE]\
+ [SUP <oids>] [{ ABSTRACT | STRUCTURAL | AUXILIARY }] [MUST <oids>]\
+ [MAY <oids>] )
+.RS
 Specify an objectclass using the LDAPv3 syntax defined in RFC 2252.
 The slapd parser extends the RFC 2252 definition by allowing string
 forms as well as numeric OIDs to be used for the object class OID.
@@ -198,6 +201,7 @@ forms as well as numeric OIDs to be used for the object class OID.
 .B
 objectidentifier
 description.)  Object classes are "STRUCTURAL" by default.
+.RE
 .TP
 .B objectidentifier <name> { <oid> | <name>[:<suffix>] }
 Define a string name that equates to the given OID. The string can be used
@@ -280,17 +284,16 @@ createTimestamp attributes for entries.  By default, lastmod is on.
 This option puts the database into "read-only" mode.  Any attempts to 
 modify the database will return an "unwilling to perform" error.  By
 default, readonly is off.
-.TP
-.B
-replica host=<hostname>[:port] "binddn=<DN>" bindmethod=simple |
-.B
-kerberos [credentials=<password>] [srvtab=<filename>]
-.br
+.HP
+.B replica host=<hostname>[:port] "binddn=<DN>" bindmethod=simple |\
+ kerberos [credentials=<password>] [srvtab=<filename> ]
+.RS
 Specify a replication site for this database.  Refer to "The SLAPD and
 SLURPD Administrator's Guide" for detailed information on setting up
 a replicated
 .B slapd
 directory service.
+.RE
 .TP
 .B replogfile <filename>
 Specify the name of the replication log file to log changes to.  
@@ -417,7 +420,7 @@ file.
 Specifies an alternate passwd file to use.  The default is
 .B /etc/passwd.
 .SH EXAMPLE
-"The SLAPD and SLURPD Administrator's Guide" contains an annotated
+"OpenLDAP Administrator's Guide" contains an annotated
 example of a configuration file.
 .SH FILES
 ETCDIR/slapd.conf
@@ -433,7 +436,7 @@ ETCDIR/slapd.conf
 .BR slappassword (8),
 .BR slurpd (8),
 .LP
-"The SLAPD and SLURPD Administrator's Guide"
+"OpenLDAP Administrator's Guide"
 .SH ACKNOWLEDGEMENTS
 .B     OpenLDAP
 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
index 5f65271896e2004ad9d6b1c5ded18a56bf574342..0baa476b9471104533d3e01616299ddbb877a721 100644 (file)
@@ -1,4 +1,4 @@
-.TH IN.XFINGERD 8C "22 September 1998" "OpenLDAP LDVERSION"
+.TH IN.XFINGERD 8C "16 August 200" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
 .\" Copyright 1998-2000 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
@@ -7,7 +7,7 @@ in.xfingerd \- Finger to LDAP/X.500 gateway daemon
 .SH SYNOPSIS
 .B LIBEXECDIR/in.xfingerd [\-f filterfile] [\-i]
 .B [\-l] [\-t templatefile] [\-c rdncount] [\-x hostname]
-.B [\-p port]
+.B [\-b searchbase] [\-p port]
 .SH DESCRIPTION
 .B in.xfingerd
 is the LDAP/X.500 finger daemon.  It runs from
@@ -66,6 +66,9 @@ Specify an alternate host on which the ldap server is running.
 .TP
 .BI \-p " port"
 Specify an alternate port on which the ldap server is listening.
+.TP
+.BI \-b " searchbase"
+Specify an alternate search base for queries.
 .SH NOTES
 The default values for most of the things you can specify with
 options are configured at compile time in the
index 3c066c2cf737a896998f8006ddb4bc619c50e590..9359ab0d9f892ecb023034393fc7967db1e57daf 100644 (file)
@@ -1,4 +1,4 @@
-.TH SLAPADD 8C "17 August 1999" "OpenLDAP LDVERSION"
+.TH SLAPADD 8C "13 August 2000" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
 .\" Copyright 1998-2000 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
@@ -96,6 +96,8 @@ database give the command:
 .BR slapcat (8),
 .BR ldapadd (1),
 .BR slapd (8)
+.LP
+"OpenLDAP Administrator's Guide"
 .SH ACKNOWLEDGEMENTS
 .B     OpenLDAP
 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
index 3b0faea380d476cbad95f0e282844884e89dd8ad..49499a68acb11e4d2efc831c1bb142e6cc8abeb0 100644 (file)
@@ -1,4 +1,4 @@
-.TH SLAPCAT 8C "17 August 1999" "OpenLDAP LDVERSION"
+.TH SLAPCAT 8C "13 August 2000" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
 .\" Copyright 1998-2000 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
@@ -85,6 +85,8 @@ give the command:
 .BR slapadd (8),
 .BR ldapadd (1),
 .BR slapd (8)
+.LP
+"OpenLDAP Administrator's Guide"
 .SH ACKNOWLEDGEMENTS
 .B     OpenLDAP
 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
index 1e353dd3b59aee48c0b25103aaa6e147dd610605..e84476f4da2ae9cd46e393770ea98d37f6b08346 100644 (file)
@@ -1,4 +1,4 @@
-.TH SLAPD 8C "19 September 1999" "OpenLDAP LDVERSION"
+.TH SLAPD 8C "13 August 2000" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
 .\" Copyright 1998-2000 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
@@ -10,6 +10,7 @@ slapd \- Stand-alone LDAP Daemon
 .B [\-h URLs]
 .B [\-d debug\-level]
 .B [\-n service\-name] [\-s syslog\-level] [\-l syslog\-local\-user]
+.B [\-r directory]
 .B [\-u user] [\-g group]
 .B 
 .SH DESCRIPTION
@@ -100,19 +101,28 @@ Specifies the slapd configuration file. The default is
 .B slapd
 will serve
 .B ldap:///
-(LDAP over TCP on all interfaces on default LDAP port).  As such,
-it will bind to INADDR_ANY, port 389.
+(LDAP over TCP on all interfaces on default LDAP port).  That is, 
+it will bind to using INADDR_ANY and port 389.
 The
 .B \-h
 option may be used to specify LDAP (and LDAPS) URLs to serve.
 For example, if slapd is given
-.B \-h " ldap://127.0.0.1:9009/ ldaps:///", 
-It will bind 127.0.0.1:9009 for LDAP and INADDR_ANY:636 for LDAP over TLS.
+.B \-h " ldap://127.0.0.1:9009/ ldaps:/// ldapi:///", 
+It will bind 127.0.0.1:9009 for LDAP, INADDR_ANY:636 for LDAP over TLS,
+and LDAP over IPC (Unix domain sockets).
 A space separated list of URLs is expected.  The URLS should be of
-LDAP (ldap://) or, if supported, LDAP over TLS (ldaps://) type without
-a DN or other optional parameters.  Hosts may be specified in either
-Internet '.' format (preferred) or by name.  Ports, if specfied,
-must be numeric.
+LDAP (ldap://) or LDAP over TLS (ldaps://) or LDAP over IPC (ldapi://)
+scheme without a DN or other optional parameters.  Support for the
+latter two schemes depends on selected configuration options.  Hosts
+may be specified by name or IPv4 and IPv6 address formats.
+Ports, if specfied, must be numeric.  The default ldap:// port is 389
+and the default ldaps:// port is 636.
+.TP
+.BI \-r " directory"
+Specifies a run-time directory.  slapd will
+.BR chroot (2)
+to this directory after opening listeners but before any reading
+any configuration file or initializing any backend.
 .TP
 .BI \-u " user"
 .B slapd
@@ -156,7 +166,7 @@ on voluminous debugging which will be printed on standard error, type:
 .BR slapd.conf (5),
 .BR slurpd (8)
 .LP
-"The SLAPD and SLURPD Administrator's Guide"
+"OpenLDAP Administrator's Guide"
 .SH BUGS
 See http://www.openldap.org/its/
 .SH ACKNOWLEDGEMENTS
index b94fc7dbeeac6152d4ac8c69d0e759a60271b6c3..32334bf845c49a0da8d4282db0e3fcf7e367e3d3 100644 (file)
@@ -1,4 +1,4 @@
-.TH SLAPINDEX 8C "17 July 1999" "OpenLDAP LDVERSION"
+.TH SLAPINDEX 8C "13 August 2000" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
 .\" Copyright 1998-2000 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
@@ -76,6 +76,8 @@ To reindex your SLAPD database, give the command:
 .BR slapadd (8),
 .BR ldapadd (1),
 .BR slapd (8)
+.LP
+"OpenLDAP Administrator's Guide"
 .SH ACKNOWLEDGEMENTS
 .B     OpenLDAP
 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
index 706125a18a877003d046df181f70cd627b04c62a..bfe842d683da48e7acfb275d99283dcdce55f4b8 100644 (file)
@@ -1,4 +1,4 @@
-.TH SLAPPASSWD 8C "15 June 2000" "OpenLDAP LDVERSION"
+.TH SLAPPASSWD 8C "13 August 2000" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
 .\" Copyright 1998-2000 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
@@ -62,6 +62,8 @@ were clear text passwords.
 .BR ldappasswd (1),
 .BR ldapmodify (1),
 .BR slapd (8)
+.LP
+"OpenLDAP Administrator's Guide"
 .SH ACKNOWLEDGEMENTS
 .B     OpenLDAP
 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
index 2b8fea8b5d6e867526d7e4af2f59bfe8ce6ebc79..b4fd42a153e3fb3684e06f6eacd4737c56a56534 100644 (file)
@@ -1,4 +1,4 @@
-.TH SLURPD 8C "22 September 1998" "OpenLDAP LDVERSION"
+.TH SLURPD 8C "13 August 2000" "OpenLDAP LDVERSION"
 .\" $OpenLDAP$
 .\" Copyright 1998-2000 The OpenLDAP Foundation All Rights Reserved.
 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
@@ -109,7 +109,7 @@ processes a replication log and exits.
 copies the replication log to a working directory before processing it.
 This option allows you to specify the location of these temporary files. 
 The default is
-.BR /usr/tmp .
+.BR LOCALSTATEDIR/openldap-slurp .
 .TP
 .BI \-k " srvtab\-file"
 Specify the location of the kerberos srvtab file which contains keys
@@ -151,7 +151,7 @@ on voluminous debugging which will be printed on standard error, type:
 .BR slapd.replog (5),
 .BR slapd (8)
 .LP
-"The SLAPD and SLURPD Administrator's Guide"
+"OpenLDAP Administrator's Guide"
 .SH ACKNOWLEDGEMENTS
 .B     OpenLDAP
 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
index 92e287cdfd5f1b5c8322b2dea1da45007116915e..5a2fa336cd35a963bffc8213715592c7c7dc4536 100644 (file)
@@ -45,6 +45,8 @@ ldap_pvt_ctime LDAP_P((
        const time_t *tp,
        char *buf ));
 
+LDAP_F( char *) ldap_pvt_get_fqdn LDAP_P(( char * ));
+
 LDAP_F( int )
 ldap_pvt_gethostbyname_a LDAP_P((
        const char *name, 
index 861dd3a23a127990c2806fb6fdf63ebf1e8e49e3..b908c40b7d10e36794797b0e8ce0da7faa8ae2a6 100644 (file)
@@ -498,12 +498,6 @@ ber_bvstr(
                return NULL;
        }
 
-       if ( *s == '\0' ) {
-               new->bv_val = NULL;
-               new->bv_len = 0;
-               return new;
-       }
-
        new->bv_val = (char *) s;
        new->bv_len = strlen( s );
 
index 0320f7bbc8ed308afd6e1448f39a76e41837e525..c63bc37da76f049480611d1ff6b3c7516aadf07b 100644 (file)
@@ -555,6 +555,13 @@ ldap_int_sasl_bind(
                }
 
                if ( rc != LDAP_SUCCESS && rc != LDAP_SASL_BIND_IN_PROGRESS ) {
+                       if( scred ) {
+                               /* and server provided us with data? */
+                               Debug( LDAP_DEBUG_TRACE,
+                                       "ldap_int_sasl_bind: rc=%d sasl=%d len=%ld\n",
+                                       rc, saslrc, scred->bv_len );
+                               ber_bvfree( scred );
+                       }
                        return ld->ld_errno;
                }
 
@@ -609,8 +616,6 @@ ldap_int_sasl_bind(
                return ld->ld_errno = sasl_err2ldap( saslrc );
        }
 
-       /* likely should add a quiet option */
-
        if( flags != LDAP_SASL_QUIET ) {
                saslrc = sasl_getprop( ctx, SASL_USERNAME, (void **) &data );
                if( saslrc == SASL_OK && data && *data ) {
index 164761b6edfa4254a540a7cc4ecc5bb863b8da05..1941a8b980ecb4c8f9b1a1106ea6a74a6afea222 100644 (file)
@@ -427,7 +427,7 @@ void ldap_int_initialize_global_options( struct ldapoptions *gopts, int *dbglvl
 
 #if defined(LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND) \
        || defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
-char * ldap_int_hostname = "localhost";
+char * ldap_int_hostname = NULL;
 #endif
 
 void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
@@ -438,13 +438,7 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
 
 #if defined(LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND) \
        || defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
-       {
-               char hostbuf[MAXHOSTNAMELEN+1];
-               if( gethostname( hostbuf, MAXHOSTNAMELEN ) == 0 ) {
-                       hostbuf[MAXHOSTNAMELEN] = '\0';
-                       ldap_int_hostname = hostbuf;
-               }
-       }
+       ldap_int_hostname = ldap_pvt_get_fqdn( ldap_int_hostname );
 #endif
 
        ldap_int_utils_init();
index c2143561a10a7e2841b931901ecd5dddccb9a50e..cf7f322e76b83a5418ffe5a21b8115ed6328fcc0 100644 (file)
@@ -473,6 +473,17 @@ ldap_host_connected_to( Sockbuf *sb )
                        {
                                return LDAP_STRDUP( ldap_int_hostname );
                        }
+
+#ifdef INADDR_LOOPBACK
+                       localhost.sin_addr.s_addr = htonl( INADDR_LOOPBACK );
+
+                       if( memcmp ( &localhost.sin_addr,
+                               &((struct sockaddr_in *)&sa)->sin_addr,
+                               sizeof(localhost.sin_addr) ) == 0 )
+                       {
+                               return LDAP_STRDUP( ldap_int_hostname );
+                       }
+#endif
                }
                break;
 
index a98f41e205d23f2dc5ca8d137760947c061c18ef..1c74713da6e2358938fea87a9ee34d18ec05cb83 100644 (file)
@@ -357,7 +357,7 @@ ldap_pvt_sasl_getmechs ( LDAP *ld, char **pmechlist )
 
        Debug( LDAP_DEBUG_TRACE, "ldap_pvt_sasl_getmech\n", 0, 0, 0 );
 
-       rc = ldap_search_s( ld, NULL, LDAP_SCOPE_BASE,
+       rc = ldap_search_s( ld, "", LDAP_SCOPE_BASE,
                NULL, attrs, 0, &res );
 
        if ( rc != LDAP_SUCCESS ) {
index 126b573cb20f322d764a5be4c3d10b76c99afaa5..0cc70589d6bf6334085d86afed1fff952416b96a 100644 (file)
@@ -142,6 +142,7 @@ int ldap_pvt_gethostbyname_a(
 # define NEED_COPY_HOSTENT   
        struct hostent *he;
        int     retval;
+       *buf = NULL;
        
        ldap_pvt_thread_mutex_lock( &ldap_int_gethostby_mutex );
        
@@ -162,6 +163,7 @@ int ldap_pvt_gethostbyname_a(
        
        return retval;
 #else  
+       *buf = NULL;
        *result = gethostbyname( name );
 
        if (*result!=NULL) {
@@ -221,6 +223,7 @@ int ldap_pvt_gethostbyaddr_a(
 # define NEED_COPY_HOSTENT   
        struct hostent *he;
        int     retval;
+       *buf = NULL;   
        
        ldap_pvt_thread_mutex_lock( &ldap_int_gethostby_mutex );
        
@@ -241,6 +244,7 @@ int ldap_pvt_gethostbyaddr_a(
        
        return retval;   
 #else /* gethostbyaddr() */
+       *buf = NULL;   
        *result = gethostbyaddr( addr, len, type );
 
        if (*result!=NULL) {
@@ -377,4 +381,31 @@ static char *safe_realloc( char **buf, int len )
 }
 #endif
 
+char * ldap_pvt_get_fqdn( char *name )
+{
+       char *fqdn, *ha_buf;
+       char hostbuf[MAXHOSTNAMELEN+1];
+       struct hostent *hp, he_buf;
+       int rc, local_h_errno;
+
+       if( name == NULL ) {
+               if( gethostname( hostbuf, MAXHOSTNAMELEN ) == 0 ) {
+                       hostbuf[MAXHOSTNAMELEN] = '\0';
+                       name = hostbuf;
+               } else {
+                       name = "localhost";
+               }
+       }
+
+       rc = ldap_pvt_gethostbyname_a( name,
+               &he_buf, &ha_buf, &hp, &local_h_errno );
+
+       if( rc < 0 || hp == NULL || hp->h_name == NULL ) {
+               fqdn = LDAP_STRDUP( name );
+       } else {
+               fqdn = LDAP_STRDUP( hp->h_name );
+       }
 
+       LDAP_FREE( ha_buf );
+       return fqdn;
+}
index 8b857f630db3297a8768d083504f72661c983bf6..951e06b2767c6efdc5bab4c379b8d69c09628854 100644 (file)
@@ -145,12 +145,17 @@ int ldbm_initialize( void )
                return( 1 );
        }
 
-#if DB_VERSION_MAJOR >= 3
+#if DB_VERSION_MAJOR > 2
        ldbm_Env->set_errcall( ldbm_Env, ldbm_db_errcall );
        ldbm_Env->set_errpfx( ldbm_Env, "==>" );
 
         envFlags |= DB_INIT_MPOOL;
+
+#if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
+        err = ldbm_Env->open( ldbm_Env, NULL, envFlags, 0 );
+#else
         err = ldbm_Env->open( ldbm_Env, NULL, NULL, envFlags, 0 );
+#endif
         if ( err != 0 )
         {
             char error[BUFSIZ];
@@ -175,7 +180,7 @@ int ldbm_shutdown( void )
        if( !ldbm_initialized ) return 1;
 
 #if DB_VERSION_MAJOR >= 3
-        ldbm_Env->close( ldbm_Env, 0 );
+       ldbm_Env->close( ldbm_Env, 0 );
 #else
        db_appexit( ldbm_Env );
 #endif
@@ -253,8 +258,7 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize )
 
        memset( &dbinfo, '\0', sizeof( dbinfo ));
 
-#if defined( DB_VERSION_MAJOR ) && defined( DB_VERSION_MINOR ) && \
-    DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 4
+#if    DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 4
        /*
         * BerkeleyDB 2.4 do not allow db_cachesize
         * to be specified if an DB_ENV is.
index e179f32dbcd661ac233ad78ce62c7043123abae2..b7dab5a25d543499aaf25d6a62233c3f341db380 100644 (file)
@@ -609,18 +609,18 @@ static int chk_kerberos(
                }
 
                {
-                       char host[MAXHOSTNAMELEN+1];
+                       char *host = ldap_pvt_get_fqdn( NULL );
 
-                       if( gethostname( host, MAXHOSTNAMELEN ) != 0 ) {
+                       if( host == NULL ) {
                                krb5_free_principal( context, client );
                                krb5_free_context( context );
                                return 1;
                        }
 
-                       host[MAXHOSTNAMELEN] = '\0';
-
                        ret = krb5_sname_to_principal( context,
                                host, "ldap", KRB5_NT_SRV_HST, &server );
+
+                       ber_memfree( host );
                }
 
                if (ret) {
index 68c2709ab6053a4d96843e1bb5005a70982e6938..eca2ff12b16908981f81a2597e7b009301ade42b 100644 (file)
@@ -726,18 +726,18 @@ static int chk_kerberos(
                }
 
                {
-                       char host[MAXHOSTNAMELEN+1];
+                       char *host = ldap_pvt_get_fqdn( NULL );
 
-                       if( gethostname( host, MAXHOSTNAMELEN ) != 0 ) {
+                       if( host == NULL ) {
                                krb5_free_principal( context, client );
                                krb5_free_context( context );
                                return 1;
                        }
 
-                       host[MAXHOSTNAMELEN] = '\0';
-
                        ret = krb5_sname_to_principal( context,
                                host, "ldap", KRB5_NT_SRV_HST, &server );
+
+                       ber_memfree( host );
                }
 
                if (ret) {
index 59acdb94a1394762d89ed429c11e0a7b422d8498..674910ddb8f0ea36a78fe55460e66fb94b51d7e4 100644 (file)
@@ -133,6 +133,7 @@ presence_candidates(
 
        if( dbname == NULL ) {
                /* not indexed */
+               ber_bvfree( prefix );
                return idl;
        }
 
@@ -142,6 +143,7 @@ presence_candidates(
                Debug( LDAP_DEBUG_ANY,
                    "<= presense_candidates db open failed (%s%s)\n",
                        dbname, LDBM_SUFFIX, 0 );
+               ber_bvfree( prefix );
                return idl;
        }
 
@@ -152,17 +154,19 @@ presence_candidates(
                rc = key_read( be, db, prefix, &idl );
 
                if( rc != LDAP_SUCCESS ) {
-                       Debug( LDAP_DEBUG_TRACE, "<= presense_candidates key read failed (%d)\n",
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<= presense_candidates key read failed (%d)\n",
                            rc, 0, 0 );
 
                } else if( idl == NULL ) {
-                       Debug( LDAP_DEBUG_TRACE, "<= presense_candidates NULL\n",
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<= presense_candidates NULL\n",
                            0, 0, 0 );
                }
        }
 
        ldbm_cache_close( be, db );
-
+       ber_bvfree( prefix );
 
        Debug( LDAP_DEBUG_TRACE, "<= presence_candidates %ld\n",
            idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
@@ -198,16 +202,19 @@ equality_candidates(
 
        if( dbname == NULL ) {
                /* not indexed */
+               ber_bvfree( prefix );
                return idl;
        }
 
        mr = ava->aa_desc->ad_type->sat_equality;
        if( !mr ) {
+               ber_bvfree( prefix );
                /* return LDAP_INAPPROPRIATE_MATCHING; */
                return idl;
        }
 
        if( !mr->smr_filter ) {
+               ber_bvfree( prefix );
                return idl;
        }
 
@@ -219,6 +226,8 @@ equality_candidates(
                ava->aa_value,
                &keys );
 
+       ber_bvfree( prefix );
+
        if( rc != LDAP_SUCCESS ) {
                return idl;
        }
@@ -241,7 +250,8 @@ equality_candidates(
                if( rc != LDAP_SUCCESS ) {
                        idl_free( idl );
                        idl = NULL;
-                       Debug( LDAP_DEBUG_TRACE, "<= equality_candidates key read failed (%d)\n",
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<= equality_candidates key read failed (%d)\n",
                            rc, 0, 0 );
                        break;
                }
@@ -249,7 +259,8 @@ equality_candidates(
                if( tmp == NULL ) {
                        idl_free( idl );
                        idl = NULL;
-                       Debug( LDAP_DEBUG_TRACE, "<= equality_candidates NULL\n",
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<= equality_candidates NULL\n",
                            0, 0, 0 );
                        break;
                }
@@ -257,6 +268,7 @@ equality_candidates(
                save = idl;
                idl = idl_intersection( be, idl, tmp );
                idl_free( save );
+               idl_free( tmp );
 
                if( idl == NULL ) break;
        }
@@ -300,6 +312,7 @@ approx_candidates(
 
        if( dbname == NULL ) {
                /* not indexed */
+               ber_bvfree( prefix );
                return idl;
        }
 
@@ -310,11 +323,13 @@ approx_candidates(
        }
 
        if( !mr ) {
+               ber_bvfree( prefix );
                /* return LDAP_INAPPROPRIATE_MATCHING; */
                return idl;
        }
 
        if( !mr->smr_filter ) {
+               ber_bvfree( prefix );
                return idl;
        }
 
@@ -326,6 +341,8 @@ approx_candidates(
                ava->aa_value,
                &keys );
 
+       ber_bvfree( prefix );
+
        if( rc != LDAP_SUCCESS ) {
                return idl;
        }
index 13ac4235b05752fa8a49c4bdfcf4dd0a33cd4305..e189a5bd6bbc1f6f1dbddcae976524a2d626bdde 100644 (file)
@@ -551,7 +551,6 @@ idl_insert_key(
                                            id, 0, 0 );
                                }
 
-                               assert( 0 ); /* not yet implemented */
                                idl_free( tmp );
                                idl_free( tmp2 );
                                idl_free( idl );
index 6d3974cef49817218e81ee9a759c2fdba3b0a9ae..114dbb0c626f849137d27100f2097a70b19e60ef 100644 (file)
@@ -379,26 +379,17 @@ delete_values(
                        if( rc == LDAP_SUCCESS && match != 0 ) {
                                continue;
                        }
+
+                       /* found a matching value */
                        found = 1;
 
-                       /* found a matching value - delete it */
+                       /* delete it */
                        ber_bvfree( a->a_vals[j] );
                        for ( k = j + 1; a->a_vals[k] != NULL; k++ ) {
                                a->a_vals[k - 1] = a->a_vals[k];
                        }
                        a->a_vals[k - 1] = NULL;
 
-                       /* delete the entire attribute, if no values remain */
-                       if ( a->a_vals[0] == NULL) {
-                               Debug( LDAP_DEBUG_ARGS,
-                                       "removing entire attribute %s\n",
-                                       desc, 0, 0 );
-                               if ( attr_delete( &e->e_attrs, mod->sm_desc ) ) {
-                                       ber_bvfree( asserted );
-                                       return LDAP_NO_SUCH_ATTRIBUTE;
-                               }
-                       }
-
                        break;
                }
 
@@ -413,6 +404,16 @@ delete_values(
                }
        }
 
+       /* if no values remain, delete the entire attribute */
+       if ( a->a_vals[0] == NULL ) {
+               Debug( LDAP_DEBUG_ARGS,
+                       "removing entire attribute %s\n",
+                       desc, 0, 0 );
+               if ( attr_delete( &e->e_attrs, mod->sm_desc ) ) {
+                       return LDAP_NO_SUCH_ATTRIBUTE;
+               }
+       }
+
        return LDAP_SUCCESS;
 }
 
diff --git a/servers/slapd/back-sql/rdbms_depend/mssql/testdb_metadata.sql b/servers/slapd/back-sql/rdbms_depend/mssql/testdb_metadata.sql
new file mode 100644 (file)
index 0000000..f360815
--- /dev/null
@@ -0,0 +1,180 @@
+-- mappings
+
+
+SET IDENTITY_INSERT ldap_oc_mappings ON
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return)
+values (1,'inetorgperson','persons','id','{call create_person(?)}','{call delete_person(?)}',0)
+
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return)
+values (2,'document','documents','id','{call create_document(?)}','{call delete_document(?)}',0)
+
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return)
+values (3,'organization','institutes','id','{call create_org(?)}','{call delete_org(?)}',0)
+SET IDENTITY_INSERT ldap_oc_mappings OFF
+
+
+SET IDENTITY_INSERT ldap_attr_mappings ON
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,modify_proc,delete_proc,param_order,expect_return)
+values (1,1,'cn','persons.name','persons',NULL,'{call set_person_name(?,?)}',
+        NULL,NULL,0,0)
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,modify_proc,delete_proc,param_order,expect_return)
+values (2,1,'telephoneNumber','phones.phone','persons,phones',
+        'phones.pers_id=persons.id','{call add_phone(?,?)}',
+        NULL,'{call delete_phone(?,?)}',0,0)
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,modify_proc,delete_proc,param_order,expect_return)
+values (3,1,'sn','persons.name','persons',NULL,'{call set_person_name(?,?)}',
+        NULL,NULL,0,0)
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,modify_proc,delete_proc,param_order,expect_return)
+values (4,2,'description','documents.abstract','documents',NULL,'{call set_doc_abstract(?,?)}',
+        NULL,NULL,0,0)
+                     
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,modify_proc,delete_proc,param_order,expect_return)
+values (5,2,'documentTitle','documents.title','documents',NULL,'{call set_doc_title(?,?)}',
+        NULL,NULL,0,0)
+
+-- insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,modify_proc,delete_proc,param_order,expect_return)
+-- values (6,2,'documentAuthor','persons.name','persons,documents,authors_docs',
+--         'persons.id=authors_docs.pers_id AND documents.id=authors_docs.doc_id',
+--     NULL,NULL,NULL,0,0)
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,modify_proc,delete_proc,param_order,expect_return)
+values (7,3,'o','institutes.name','institutes',NULL,'{call set_org_name(?,?)}',
+        NULL,NULL,0,0)
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,modify_proc,delete_proc,param_order,expect_return)
+values (8,1,'documentDN','ldap_entries.dn','ldap_entries,documents,authors_docs,persons',
+        'ldap_entries.keyval=documents.id AND ldap_entries.oc_map_id=2 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id',
+       '{call make_doc_link(?,?)}',NULL,'{call del_doc_link(?,?)}',0,0)
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,modify_proc,delete_proc,param_order,expect_return)
+values (9,2,'documentAuthor','ldap_entries.dn','ldap_entries,documents,authors_docs,persons',
+        'ldap_entries.keyval=persons.id AND ldap_entries.oc_map_id=1 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id',
+       '{call make_author_link(?,?)}',NULL,'{call del_author_link(?,?)}',0,0)
+
+SET IDENTITY_INSERT ldap_attr_mappings OFF
+
+-- entries
+
+SET IDENTITY_INSERT ldap_entries ON
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (1,'o=sql,c=RU',3,0,1)
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (2,'cn=Mitya Kovalev,o=sql,c=RU',1,1,1)
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (3,'cn=Torvlobnor Puzdoy,o=sql,c=RU',1,1,2)
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (4,'cn=Akakiy Zinberstein,o=sql,c=RU',1,1,3)
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (5,'documentTitle=book1,o=sql,c=RU',2,1,1)
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (6,'documentTitle=book2,o=sql,c=RU',2,1,2)
+
+SET IDENTITY_INSERT ldap_entries OFF
+
+-- referrals
+
+insert into ldap_entry_objclasses (entry_id,oc_name)
+values (4,'referral');
+
+insert into ldap_referrals (entry_id,url)
+values (4,'http://localhost');
+
+-- support procedures
+
+SET QUOTED_IDENTIFIER  OFF    SET ANSI_NULLS  ON 
+GO
+
+
+CREATE PROCEDURE add_phone @pers_id int, @phone varchar(255) AS
+INSERT INTO ldap.phones (pers_id,phone) VALUES (@pers_id,@phone)
+GO
+
+CREATE PROCEDURE create_person @@keyval int OUTPUT AS
+INSERT INTO ldap.persons (name) VALUES ('');
+set @@keyval=(SELECT MAX(id) FROM ldap.persons)
+GO
+
+CREATE PROCEDURE delete_person @keyval int AS
+DELETE FROM ldap.phones WHERE pers_id=@keyval;
+DELETE FROM ldap.authors_docs WHERE pers_id=@keyval;
+DELETE FROM ldap.persons WHERE id=@keyval;
+GO
+
+CREATE PROCEDURE create_org @@keyval int OUTPUT AS
+INSERT INTO ldap.institutes (name) VALUES ('');
+set @@keyval=(SELECT MAX(id) FROM ldap.institutes)
+GO
+
+CREATE PROCEDURE create_document @@keyval int OUTPUT AS
+INSERT INTO ldap.documents (title) VALUES ('');
+set @@keyval=(SELECT MAX(id) FROM ldap.documents)
+GO
+
+CREATE PROCEDURE delete_org @keyval int AS
+DELETE FROM ldap.institutes WHERE id=@keyval;
+GO
+
+CREATE PROCEDURE delete_document @keyval int AS
+DELETE FROM ldap.authors_docs WHERE doc_id=@keyval;
+DELETE FROM ldap.documents WHERE id=@keyval;
+GO
+
+CREATE PROCEDURE delete_phone @keyval int,@phone varchar(64) AS
+DELETE FROM ldap.phones WHERE pers_id=@keyval AND phone=@phone;
+GO
+
+CREATE PROCEDURE set_person_name @keyval int, @new_name varchar(255)  AS
+UPDATE ldap.persons SET name=@new_name WHERE id=@keyval;
+GO
+
+CREATE PROCEDURE set_org_name @keyval int, @new_name varchar(255)  AS
+UPDATE ldap.institutes SET name=@new_name WHERE id=@keyval;
+GO
+
+CREATE PROCEDURE set_doc_title @keyval int, @new_title varchar(255)  AS
+UPDATE ldap.documents SET title=@new_title WHERE id=@keyval;
+GO
+
+CREATE PROCEDURE set_doc_abstract @keyval int, @new_abstract varchar(255)  AS
+UPDATE ldap.documents SET abstract=@new_abstract WHERE id=@keyval;
+GO
+
+CREATE PROCEDURE make_author_link @keyval int, @author_dn varchar(255)  AS
+DECLARE @per_id int;
+SET @per_id=(SELECT keyval FROM ldap.ldap_entries 
+          WHERE oc_map_id=1 AND dn=@author_dn);
+IF NOT (@per_id IS NULL)
+ INSERT INTO ldap.authors_docs (doc_id,pers_id) VALUES (@keyval,@per_id);
+GO
+
+CREATE PROCEDURE make_doc_link @keyval int, @doc_dn varchar(255)  AS
+DECLARE @doc_id int;
+SET @doc_id=(SELECT keyval FROM ldap.ldap_entries 
+          WHERE oc_map_id=2 AND dn=@doc_dn);
+IF NOT (@doc_id IS NULL)
+ INSERT INTO ldap.authors_docs (pers_id,doc_id) VALUES (@keyval,@doc_id);
+GO
+
+CREATE PROCEDURE del_doc_link @keyval int, @doc_dn varchar(255)  AS
+DECLARE @doc_id int;
+SET @doc_id=(SELECT keyval FROM ldap.ldap_entries 
+          WHERE oc_map_id=2 AND dn=@doc_dn);
+IF NOT (@doc_id IS NULL)
+DELETE FROM ldap.authors_docs WHERE pers_id=@keyval AND doc_id=@doc_id;
+GO
+
+CREATE PROCEDURE del_author_link @keyval int, @author_dn varchar(255)  AS
+DECLARE @per_id int;
+SET @per_id=(SELECT keyval FROM ldap.ldap_entries 
+          WHERE oc_map_id=1 AND dn=@author_dn);
+IF NOT (@per_id IS NULL)
+ DELETE FROM ldap.authors_docs WHERE doc_id=@keyval AND pers_id=@per_id;
+GO
diff --git a/servers/slapd/back-sql/rdbms_depend/mysql/testdb_metadata.sql b/servers/slapd/back-sql/rdbms_depend/mysql/testdb_metadata.sql
new file mode 100644 (file)
index 0000000..13aef25
--- /dev/null
@@ -0,0 +1,74 @@
+--mappings 
+
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return)
+values (1,'inetOrgPerson','persons','id',"insert into persons (name) values ('');\n select last_insert_id();",NULL,0);
+
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return)
+values (2,'document','documents','id',NULL,NULL,0);
+
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return)
+values (3,'organization','institutes','id',NULL,NULL,0);
+
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (1,1,'cn','persons.name','persons',NULL,NULL,NULL,3,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (2,1,'telephoneNumber','phones.phone','persons,phones',
+        'phones.pers_id=persons.id',NULL,NULL,3,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (3,1,'sn','persons.name','persons',NULL,NULL,NULL,3,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (4,2,'description','documents.abstract','documents',NULL,NULL,NULL,3,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (5,2,'documentTitle','documents.title','documents',NULL,NULL,NULL,3,0);
+
+-- insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+-- values (6,2,'documentAuthor','persons.name','persons,documents,authors_docs',
+--         'persons.id=authors_docs.pers_id AND documents.id=authors_docs.doc_id',
+--     NULL,NULL,3,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (7,3,'o','institutes.name','institutes',NULL,NULL,NULL,3,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (8,1,'documentDN','ldap_entries.dn','ldap_entries,documents,authors_docs,persons',
+        'ldap_entries.keyval=documents.id AND ldap_entries.oc_map_id=2 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id',
+       NULL,NULL,3,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (9,2,'documentAuthor','ldap_entries.dn','ldap_entries,documents,authors_docs,persons',
+        'ldap_entries.keyval=persons.id AND ldap_entries.oc_map_id=1 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id',
+       NULL,NULL,3,0);
+       
+-- entries
+       
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (1,'o=sql,c=RU',3,0,1);
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (2,'cn=Mitya Kovalev,o=sql,c=RU',1,1,1);
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (3,'cn=Torvlobnor Puzdoy,o=sql,c=RU',1,1,2);
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (4,'cn=Akakiy Zinberstein,o=sql,c=RU',1,1,3);
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (5,'documentTitle=book1,o=sql,c=RU',2,1,1);
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (6,'documentTitle=book2,o=sql,c=RU',2,1,2);
+       
+       
+-- referrals
+
+insert into ldap_entry_objclasses (entry_id,oc_name)
+values (4,'referral');
+
+insert into ldap_referrals (entry_id,url)
+values (4,'http://localhost');
diff --git a/servers/slapd/back-sql/rdbms_depend/oracle/testdb_metadata.sql b/servers/slapd/back-sql/rdbms_depend/oracle/testdb_metadata.sql
new file mode 100644 (file)
index 0000000..7571527
--- /dev/null
@@ -0,0 +1,214 @@
+-- mappings
+
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return)
+values (1,'person','persons','id','{call create_person(?)}','{call delete_person(?)}',0);
+
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return)
+values (2,'document','documents','id','{call create_document(?)}','{call delete_document(?)}',0);
+
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return)
+values (3,'organization','institutes','id','{call create_org(?)}','{call delete_org(?)}',0);
+
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (1,1,'cn','persons.name','persons',NULL,'{call set_person_name(?,?)}',
+        NULL,0,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (2,1,'telephoneNumber','phones.phone','persons,phones',
+        'phones.pers_id=persons.id','{call add_phone(?,?)}',
+        '{call delete_phone(?,?)}',0,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (3,1,'sn','persons.name','persons',NULL,'{call set_person_name(?,?)}',
+        NULL,0,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (4,2,'abstract','documents.abstract','documents',NULL,'{call set_doc_abstract(?,?)}',
+        NULL,0,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (5,2,'documentTitle','documents.title','documents',NULL,'{call set_doc_title(?,?)}',
+        NULL,0,0);
+
+-- insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)                         
+-- values (6,2,'documentAuthor','persons.name','persons,documents,authors_docs',
+--         'persons.id=authors_docs.pers_id AND documents.id=authors_docs.doc_id',
+--     NULL,NULL,0,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (7,3,'o','institutes.name','institutes',NULL,'{call set_org_name(?,?)}',
+        NULL,0,0);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (8,1,'documentDN','ldap_entries.dn','ldap_entries,documents,authors_docs,persons',
+        'ldap_entries.keyval=documents.id AND ldap_entries.oc_map_id=2 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id',
+       '{?=call make_doc_link(?,?)}','{?=call del_doc_link(?,?)}',0,3);
+
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
+values (9,2,'documentAuthor','ldap_entries.dn','ldap_entries,documents,authors_docs,persons',
+        'ldap_entries.keyval=persons.id AND ldap_entries.oc_map_id=1 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id',
+       '{?=call make_author_link(?,?)}','{?=call del_author_link(?,?)}',0,3);
+
+
+-- entries
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (ldap_entry_ids.nextval,'o=sql,c=RU',3,0,1);
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (ldap_entry_ids.nextval,'cn=Mitya Kovalev,o=sql,c=RU',1,1,1);
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (ldap_entry_ids.nextval,'cn=Torvlobnor Puzdoy,o=sql,c=RU',1,1,2);
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (ldap_entry_ids.nextval,'cn=Akakiy Zinberstein,o=sql,c=RU',1,1,3);
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (ldap_entry_ids.nextval,'documentTitle=book1,o=sql,c=RU',2,1,1);
+
+insert into ldap_entries (id,dn,oc_map_id,parent,keyval)
+values (ldap_entry_ids.nextval,'documentTitle=book2,o=sql,c=RU',2,1,2);
+
+-- referrals
+
+insert into ldap_entry_objclasses (entry_id,oc_name)
+values (4,'referral');
+
+insert into ldap_referrals (entry_id,url)
+values (4,'http://localhost');
+
+
+-- procedures
+
+CREATE OR REPLACE PROCEDURE create_person(keyval OUT NUMBER) AS
+BEGIN
+INSERT INTO persons (id,name) VALUES (person_ids.nextval,' ');
+SELECT person_ids.currval INTO keyval FROM DUAL;
+END;
+/
+
+CREATE OR REPLACE PROCEDURE delete_person(keyval IN NUMBER) AS
+BEGIN
+DELETE FROM phones WHERE pers_id=keyval;
+DELETE FROM authors_docs WHERE pers_id=keyval;
+DELETE FROM persons WHERE id=keyval;
+END;
+/
+
+CREATE OR REPLACE PROCEDURE create_org(keyval OUT NUMBER) AS
+BEGIN
+INSERT INTO institutes (id,name) VALUES (institute_ids.nextval,' ');
+SELECT institute_ids.currval INTO keyval FROM DUAL;
+END;
+/
+
+CREATE OR REPLACE PROCEDURE delete_org(keyval IN NUMBER) AS
+BEGIN
+DELETE FROM institutes WHERE id=keyval;
+END;
+/
+
+CREATE OR REPLACE PROCEDURE create_document(keyval OUT NUMBER) AS
+BEGIN
+INSERT INTO documents (id,title) VALUES (document_ids.nextval,' ');
+SELECT document_ids.currval INTO keyval FROM DUAL;
+END;
+/
+
+CREATE OR REPLACE PROCEDURE delete_document (keyval IN NUMBER) AS
+BEGIN
+DELETE FROM authors_docs WHERE doc_id=keyval;
+DELETE FROM documents WHERE id=keyval;
+END;
+/
+
+CREATE OR REPLACE PROCEDURE add_phone(pers_id IN NUMBER, phone IN varchar2) AS
+BEGIN
+INSERT INTO phones (id,pers_id,phone) VALUES (phone_ids.nextval,pers_id,phone);
+END;
+/
+
+CREATE OR REPLACE PROCEDURE delete_phone(keyval IN NUMBER, phone IN varchar2) AS
+BEGIN
+DELETE FROM phones WHERE pers_id=keyval AND phone=phone;
+END;
+/
+
+CREATE OR REPLACE PROCEDURE set_person_name(keyval IN NUMBER, new_name IN varchar2) AS
+BEGIN
+UPDATE persons SET name=new_name WHERE id=keyval;
+END;
+/
+
+CREATE OR REPLACE PROCEDURE set_org_name(keyval IN NUMBER, new_name IN varchar2) AS
+BEGIN
+UPDATE institutes SET name=new_name WHERE id=keyval;
+END;
+/
+
+CREATE OR REPLACE PROCEDURE set_doc_title (keyval IN NUMBER, new_title IN varchar2)  AS
+BEGIN
+UPDATE documents SET title=new_title WHERE id=keyval;
+END;
+/
+
+CREATE OR REPLACE PROCEDURE set_doc_abstract (keyval IN NUMBER, new_abstract IN varchar2)  AS
+BEGIN
+UPDATE documents SET abstract=new_abstract WHERE id=keyval;
+END;
+/
+
+CREATE OR REPLACE FUNCTION make_author_link (keyval IN NUMBER, author_dn IN varchar2) RETURN NUMBER AS
+per_id NUMBER;
+BEGIN
+SELECT keyval INTO per_id FROM ldap_entries 
+                                       WHERE oc_map_id=1 AND dn=author_dn;
+IF NOT (per_id IS NULL) THEN
+ INSERT INTO authors_docs (doc_id,pers_id) VALUES (keyval,per_id);
+ RETURN 1;
+END IF;
+RETURN 0;
+END;
+/
+
+CREATE OR REPLACE FUNCTION make_doc_link (keyval IN NUMBER, doc_dn IN varchar2) RETURN NUMBER AS
+docid NUMBER;
+BEGIN
+SELECT keyval INTO docid FROM ldap_entries 
+                  WHERE oc_map_id=2 AND dn=doc_dn;
+IF NOT (docid IS NULL) THEN
+ INSERT INTO authors_docs (pers_id,doc_id) VALUES (keyval,docid);
+ RETURN 1;
+END IF;
+RETURN 0;
+END;
+/
+
+CREATE OR REPLACE FUNCTION del_doc_link (keyval IN NUMBER, doc_dn IN varchar2) RETURN NUMBER AS
+docid NUMBER;
+BEGIN
+SELECT keyval INTO docid FROM ldap_entries 
+               WHERE oc_map_id=2 AND dn=doc_dn;
+IF NOT (docid IS NULL) THEN
+ DELETE FROM authors_docs WHERE pers_id=keyval AND doc_id=docid;
+ RETURN 1;
+END IF;
+RETURN 0;
+END;
+/
+
+CREATE OR REPLACE FUNCTION del_author_link (keyval IN NUMBER, author_dn IN varchar2) RETURN NUMBER AS
+per_id NUMBER;
+BEGIN
+SELECT keyval INTO per_id FROM ldap_entries
+     WHERE oc_map_id=1 AND dn=author_dn;
+
+IF NOT (per_id IS NULL) THEN
+ DELETE FROM authors_docs WHERE doc_id=keyval AND pers_id=per_id;
+ RETURN 1;
+END IF;
+ RETURN 0;
+END;
+/
index 6e46d65fe3572308064423f935ce550b87409485..dcc83f5c74b6a4247fef2582264aa96bfa968509 100644 (file)
@@ -196,12 +196,7 @@ int slap_sasl_init( void )
        }
 
        if( sasl_host == NULL ) {
-               static char hostname[MAXHOSTNAMELEN+1];
-
-               if( gethostname( hostname, MAXHOSTNAMELEN ) == 0 ) {
-                       hostname[MAXHOSTNAMELEN] = '\0';
-                       sasl_host = hostname;
-               }
+               sasl_host = ldap_pvt_get_fqdn( NULL );
        }
 
        Debug( LDAP_DEBUG_TRACE,
@@ -468,16 +463,16 @@ int slap_sasl_bind(
                        rc = LDAP_SUCCESS;
 
                        if( username == NULL || (
-                               !strncasecmp( username, "anonymous", sizeof("anonyous")-1 ) &&
-                               ( ( username[sizeof("anonymous")] == '\0' ) ||
-                                 ( username[sizeof("anonymous")] == '@' ) ) ) )
+                               !strncasecmp( username, "anonymous", sizeof("anonymous")-1 ) &&
+                               ( username[sizeof("anonymous")-1] == '\0' ||
+                                 username[sizeof("anonymous")-1] == '@' ) ) )
                        {
                                Debug(LDAP_DEBUG_TRACE, "<== slap_sasl_bind: anonymous\n",
                                        0, 0, 0);
 
                        } else if ( username[0] == 'u' && username[1] == ':'
                                && username[2] != '\0'
-                               && strpbrk( &username[2], "=,;\"\\") == NULL )
+                               && strpbrk( &username[2], "+=,;\"\\ \t") == NULL )
                        {
                                *edn = ch_malloc( sizeof( "uid= + realm=" )
                                        + strlen( &username[2] )
index 51db9b7247db6d8b3296195b32e3f8ddbbb802b1..814004e67c362dd008bb35860a132ea54d5f9bc6 100644 (file)
@@ -541,7 +541,8 @@ IA5StringConvert(
        struct berval *bv = ch_malloc( sizeof(struct berval) );
 
        bv->bv_len = len * sizeof( ldap_unicode_t );
-       bv->bv_val = (char *) u = ch_malloc( bv->bv_len + sizeof(ldap_unicode_t) );
+       u = (ldap_unicode_t *) ch_malloc( bv->bv_len + sizeof(ldap_unicode_t) );
+       bv->bv_val = (char *) u;
 
        for(i=0; i < len; i++ ) {
                /*
@@ -1611,7 +1612,7 @@ numericStringNormalize(
 
        assert( *newval->bv_val );
        assert( newval->bv_val < p );
-       assert( p <= q );
+       assert( q <= p );
 
        /* cannot start with a space */
        assert( !ASCII_SPACE(*newval->bv_val) );
index 6a1137eb161685499d4f128b2d58cc80b47a2a5b..613ba59da716d51e4f5e32960fbeaff0a094e192 100644 (file)
@@ -45,6 +45,7 @@ version.c: $(OBJS) $(LDAP_LIBDEPEND) $(LDAP_LIBTHREAD_DEPEND)
 
 install-local-srv: FORCE
        -$(MKDIR) $(DESTDIR)$(libexecdir)
+       -$(MKDIR) $(DESTDIR)$(localstatedir)/openldap-slurp
        @(                                                              \
            for prg in $(PROGRAMS); do                                  \
                $(LTINSTALL) $(INSTALLFLAGS) -s -m 755 $$prg$(EXEEXT)   \
index 4983641a60547ee2a8ba6357b207737e70bff49c..f1f54b35c04623e67f1cc19f2f1dc3fcfa8eaace 100644 (file)
@@ -40,7 +40,7 @@
 
 
 /* Default directory for slurpd's private copy of replication logs */
-#define        DEFAULT_SLURPD_REPLICA_DIR      "/usr/tmp"
+#define        DEFAULT_SLURPD_REPLICA_DIR      LDAP_RUNDIR LDAP_DIRSEP "openldap-slurp"
 
 /* Default name for slurpd's private copy of the replication log */
 #define        DEFAULT_SLURPD_REPLOGFILE       "slurpd.replog"
@@ -49,7 +49,7 @@
 #define        DEFAULT_SLURPD_STATUS_FILE      "slurpd.status"
 
 /* slurpd dump file - contents of rq struct are written here (debugging) */
-#define        SLURPD_DUMPFILE                 "/tmp/slurpd.dump"
+#define        SLURPD_DUMPFILE                 LDAP_TMPDIR LDAP_DIRSEP "slurpd.dump"
 
 /* default srvtab file.  Can be overridden */
 #define        SRVTAB                          "/etc/srvtab"