]> git.sur5r.net Git - openldap/commitdiff
Rework root dse and other info entry codes to produce entry
authorKurt Zeilenga <kurt@openldap.org>
Tue, 16 May 2000 16:22:52 +0000 (16:22 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 16 May 2000 16:22:52 +0000 (16:22 +0000)
to caller (do_search) such that info can be used by other
operations (ie: do_compare).
SLAPD_SCHEMA_NOT_COMPAT: Add additional code to support filters (needs work)

servers/slapd/filter.c
servers/slapd/proto-slap.h
servers/slapd/root_dse.c
servers/slapd/sasl.c
servers/slapd/schema.c
servers/slapd/schema_init.c
servers/slapd/search.c

index f821304e855ec902c7db33d187daf61899e3123c..9d7e7187c01a4b3671144ed02fe40587d94c073d 100644 (file)
@@ -361,21 +361,32 @@ get_substring_filter(
        ber_tag_t       rc;
        struct berval *val;
        char            *last;
-       char            *type;
+       struct berval type;
+#ifndef SLAPD_SCHEMA_NOT_COMPAT
        int             syntax;
-
+#endif
        *text = "error decoding filter";
 
        Debug( LDAP_DEBUG_FILTER, "begin get_substring_filter\n", 0, 0, 0 );
 
-       if ( ber_scanf( ber, "{a" /*}*/, &type ) == LBER_ERROR ) {
+       if ( ber_scanf( ber, "{o" /*}*/, &type ) == LBER_ERROR ) {
                return SLAPD_DISCONNECT;
        }
 
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
-       /* not yet implemented */
+       rc = slap_bv2ad( &type, &f->f_sub_desc, text );
+
+       ch_free( type.bv_val );
+
+       if( rc != LDAP_SUCCESS ) {
+               text = NULL;
+               f->f_choice = SLAPD_FILTER_COMPUTED;
+               f->f_result = SLAPD_COMPARE_UNDEFINED;
+               *fstr = ch_strdup( "(undefined)" );
+               return LDAP_SUCCESS;
+       }
 #else
-       f->f_sub_type = type;
+       f->f_sub_type = type.bv_val;
        attr_normalize( f->f_sub_type );
 
        /* should get real syntax and see if we have a substring matching rule */
@@ -387,7 +398,11 @@ get_substring_filter(
        f->f_sub_final = NULL;
 
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
-       /* not yet implemented */
+       if( fstr ) {
+               *fstr = ch_malloc( sizeof("(=" /*)*/) +
+                       f->f_sub_desc->ad_cname->bv_len );
+               sprintf( *fstr, "(%s=" /*)*/, f->f_sub_desc->ad_cname->bv_val );
+       }
 #else
        if( fstr ) {
                *fstr = ch_malloc( strlen( f->f_sub_type ) + 3 );
@@ -412,9 +427,7 @@ get_substring_filter(
 
                rc = LDAP_PROTOCOL_ERROR;
 
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
-               /* not yet implemented */
-#else
+#ifndef SLAPD_SCHEMA_NOT_COMPAT
                /* we should call a substring syntax normalization routine */
                value_normalize( val->bv_val, syntax );
                /* this is bogus, value_normalize should take a berval */
@@ -485,7 +498,7 @@ return_error:
                        }
 
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
-                       /* not yet implemented */
+                       ad_free( f->f_sub_desc, 1 );
 #else
                        ch_free( f->f_sub_type );
 #endif
index 3c8452e097121825b40d702c5ec808b3c422d2fc..90a269c6ae7667bfd7bd318f9715b875ef71267d 100644 (file)
@@ -440,11 +440,8 @@ LIBSLAPD_F (void) *module_resolve LDAP_P((
  */
 LIBSLAPD_F (char *) supportedControls[];
 
-LIBSLAPD_F (void) monitor_info LDAP_P((
-       Connection *conn,
-       Operation *op,
-       char ** attrs,
-       int attrsonly ));
+LIBSLAPD_F (int) monitor_info LDAP_P((
+       Entry **entry, char **text ));
 
 /*
  * operation.c
@@ -596,8 +593,7 @@ LIBSLAPD_F (int) register_matching_rule LDAP_P((char * desc,
        slap_mr_indexer_func *indexer,
        slap_mr_filter_func *filter     ));
 
-LIBSLAPD_F (void) schema_info LDAP_P((Connection *conn, Operation *op,
-       char **attrs, int attrsonly));
+LIBSLAPD_F (int) schema_info LDAP_P(( Entry **entry, char **text ));
 
 LIBSLAPD_F (int) is_entry_objectclass LDAP_P((
        Entry *, const char* objectclass ));
@@ -788,17 +784,11 @@ LIBSLAPD_F (void) slapd_remove LDAP_P((ber_socket_t s, int wake));
 LIBSLAPD_F (RETSIGTYPE) slap_sig_shutdown LDAP_P((int sig));
 LIBSLAPD_F (RETSIGTYPE) slap_sig_wake LDAP_P((int sig));
 
-LIBSLAPD_F (void) config_info LDAP_P((
-       Connection *conn,
-       Operation *op,
-       char ** attrs,
-       int attrsonly ));
+LIBSLAPD_F (int) config_info LDAP_P((
+       Entry **e, char **text ));
 
-LIBSLAPD_F (void) root_dse_info LDAP_P((
-       Connection *conn,
-       Operation *op,
-       char ** attrs,
-       int attrsonly ));
+LIBSLAPD_F (int) root_dse_info LDAP_P((
+       Entry **e, char **text ));
 
 LIBSLAPD_F (int) do_abandon LDAP_P((Connection *conn, Operation *op));
 LIBSLAPD_F (int) do_add LDAP_P((Connection *conn, Operation *op));
index 0a89fa13f89630e112a4d9b2d968937d8cd3ee11..c5fd1f91f2c2d287a5d0b7606b63f23bdfade866 100644 (file)
@@ -17,8 +17,8 @@
 
 #include "slap.h"
 
-void
-root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
+int
+root_dse_info( Entry **entry, char **text )
 {
        char buf[BUFSIZ];
        Entry           *e;
@@ -121,12 +121,7 @@ root_dse_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
                attr_merge( e, ad_ref, default_referral );
        }
 
-       send_search_entry( &backends[0], conn, op,
-               e, attrs, attrsonly, NULL );
-
-       send_search_result( conn, op, LDAP_SUCCESS,
-               NULL, NULL, NULL, NULL, 1 );
-
-       entry_free( e );
+       *entry = e;
+       return LDAP_SUCCESS;
 }
 
index 23d6d9960801f3ca7cbfc8e1558e6ddb3b327eab..e94e3c63044ce32b1393089cfd351d2a6403e741 100644 (file)
@@ -197,7 +197,8 @@ int sasl_bind(
        int sc;
        int rc = 1;
 
-       Debug(LDAP_DEBUG_ARGS, "==> sasl_bind: dn=%s, mech=%s, cred->bv_len=%d\n",
+       Debug(LDAP_DEBUG_ARGS,
+               "==> sasl_bind: dn=\"%s\" mech=%s cred->bv_len=%d\n",
                dn, mech, cred ? cred->bv_len : 0 );
 
        if ( conn->c_sasl_bind_context == NULL ) {
index 4dc42d6617840260c9b4440212fd25fa7cb9e810..55ee96c92b0b840665ff2d7d9c5bc82c6e6e1831 100644 (file)
@@ -19,8 +19,8 @@
 
 #if defined( SLAPD_SCHEMA_DN )
 
-void
-schema_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
+int
+schema_info( Entry **entry, char **text )
 {
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
        AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
@@ -60,9 +60,8 @@ schema_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
        attr_merge( e, ad_objectClass, vals );
 
        {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
                int rc;
-               char *text;
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
                AttributeDescription *desc = NULL;
 #else
                char *desc;
@@ -71,11 +70,9 @@ schema_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
                val.bv_val = strchr( rdn, '=' );
 
                if( val.bv_val == NULL ) {
-                       send_ldap_result( conn, op, LDAP_OTHER,
-                               NULL, "improperly configured subschema subentry",
-                               NULL, NULL );
                        free( rdn );
-                       return;
+                       *text = "improperly configured subschema subentry";
+                       return LDAP_OTHER;
                }
 
                *val.bv_val = '\0';
@@ -85,11 +82,10 @@ schema_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
                rc = slap_str2ad( rdn, &desc, &text );
 
                if( rc != LDAP_SUCCESS ) {
-                       send_ldap_result( conn, op, LDAP_OTHER,
-                               NULL, "improperly configured subschema subentry",
-                               NULL, NULL );
                        free( rdn );
-                       return;
+                       entry_free( e );
+                       *text = "improperly configured subschema subentry";
+                       return LDAP_OTHER;
                }
 #else
                desc = rdn;
@@ -106,17 +102,12 @@ schema_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
        {
                /* Out of memory, do something about it */
                entry_free( e );
-               send_ldap_result( conn, op, LDAP_OTHER,
-                       NULL, "out of memory", NULL, NULL );
-               return;
+               text = "out of memory";
+               return LDAP_OTHER;
        }
        
-       send_search_entry( &backends[0], conn, op,
-               e, attrs, attrsonly, NULL );
-       send_search_result( conn, op, LDAP_SUCCESS,
-               NULL, NULL, NULL, NULL, 1 );
-
-       entry_free( e );
+       *entry = e;
+       return LDAP_SUCCESS;
 }
 #endif
 
index 54fb340e57d824f31a28b4a39322532e2e9372c5..70d17ba0673fd1819e27187a96f3bbc5e1dd573b 100644 (file)
@@ -666,7 +666,7 @@ struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_entry) },
        { "children",
                offsetof(struct slap_internal_schema, si_ad_children) },
-       { NULL, NULL }
+       { NULL, 0 }
 };
 
 #endif
index 22082200fc97430fab52865be46be7524ba86ed9..ad5975c51bbe5aab82ee858cde37667b64eecd17 100644 (file)
@@ -160,29 +160,41 @@ do_search(
            op->o_connid, op->o_opid, base, scope, fstr );
 
        if ( scope == LDAP_SCOPE_BASE ) {
+               Entry *entry = NULL;
+
+               if ( strcasecmp( nbase, LDAP_ROOT_DSE ) == 0 ) {
+                       rc = root_dse_info( &entry, &text );
+               }
+
 #if defined( SLAPD_MONITOR_DN )
-               if ( strcasecmp( nbase, SLAPD_MONITOR_DN ) == 0 ) {
-                       monitor_info( conn, op, attrs, attrsonly );
-                       goto return_results;
+               else if ( strcasecmp( nbase, SLAPD_MONITOR_DN ) == 0 ) {
+                       rc = monitor_info( &entry, &text );
                }
 #endif
 
 #if defined( SLAPD_CONFIG_DN )
-               if ( strcasecmp( nbase, SLAPD_CONFIG_DN ) == 0 ) {
-                       config_info( conn, op, attrs, attrsonly );
-                       goto return_results;
+               else if ( strcasecmp( nbase, SLAPD_CONFIG_DN ) == 0 ) {
+                       rc = config_info( &entry, &text );
                }
 #endif
 
 #if defined( SLAPD_SCHEMA_DN )
-               if ( strcasecmp( nbase, SLAPD_SCHEMA_DN ) == 0 ) {
-                       schema_info( conn, op, attrs, attrsonly );
-                       goto return_results;
+               else if ( strcasecmp( nbase, SLAPD_SCHEMA_DN ) == 0 ) {
+                       rc= schema_info( &entry, &text );
                }
 #endif
 
-               if ( strcasecmp( nbase, LDAP_ROOT_DSE ) == 0 ) {
-                       root_dse_info( conn, op, attrs, attrsonly );
+               if( rc != LDAP_SUCCESS ) {
+                       send_ldap_result( conn, op, rc,
+                               NULL, text, NULL, NULL );
+                       goto return_results;
+
+               } else if ( entry != NULL ) {
+                       send_search_entry( &backends[0], conn, op,
+                               entry, attrs, attrsonly, NULL );
+                       send_ldap_result( conn, op, LDAP_SUCCESS,
+                               NULL, NULL, NULL, NULL );
+                       entry_free( entry );
                        goto return_results;
                }
        }