]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/bconfig.c
Add note about contrib/slapd-modules
[openldap] / servers / slapd / bconfig.c
index c500b9971f2248ed316158c951da0b4e1c391d82..3d3771b838df86ebf92e2d0e77fb966ebf888561 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2005 The OpenLDAP Foundation.
+ * Copyright 2005-2006 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -211,6 +211,7 @@ static OidRec OidMacros[] = {
  * OLcfgOv{Oc|At}:6                    -> smbk5pwd
  * OLcfgOv{Oc|At}:7                    -> distproc
  * OLcfgOv{Oc|At}:8                    -> dynlist
+ * OLcfgOv{Oc|At}:9                    -> dds
  */
 
 /* alphabetical ordering */
@@ -246,7 +247,7 @@ static ConfigTable config_back_cf_table[] = {
                &config_generic, "( OLcfgGlAt:5 NAME 'olcAttributeOptions' "
                        "EQUALITY caseIgnoreMatch "
                        "SYNTAX OMsDirectoryString )", NULL, NULL },
-       { "attribute",  "attribute", 2, 0, 9,
+       { "attribute",  "attribute", 2, 0, STRLENOF( "attribute" ),
                ARG_PAREN|ARG_MAGIC|CFG_ATTR|ARG_NO_DELETE|ARG_NO_INSERT,
                &config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
                        "DESC 'OpenLDAP attributeTypes' "
@@ -741,7 +742,8 @@ config_generic(ConfigArgs *c) {
                                                break;
                                        }
                                        bv.bv_val = buf + bv.bv_len;
-                                       limits_unparse( c->be->be_limits[i], &bv );
+                                       limits_unparse( c->be->be_limits[i], &bv,
+                                                       sizeof( buf ) - ( bv.bv_val - buf ) );
                                        bv.bv_len += bv.bv_val - buf;
                                        bv.bv_val = buf;
                                        value_add_one( &c->rvalue_vals, &bv );
@@ -786,6 +788,9 @@ config_generic(ConfigArgs *c) {
                                rc = 1;
                        }
                        break;
+               case CFG_ATOPT:
+                       ad_unparse_options( &c->rvalue_vals );
+                       break;
                case CFG_OC: {
                        ConfigFile *cf = c->private;
                        if ( !cf )
@@ -1445,13 +1450,10 @@ config_generic(ConfigArgs *c) {
 
 
                default:
-                       Debug( SLAPD_DEBUG_CONFIG_ERROR,
-                               "%s: unknown CFG_TYPE %d"
-                               SLAPD_CONF_UNKNOWN_IGNORED ".\n",
+                       Debug( LDAP_DEBUG_ANY,
+                               "%s: unknown CFG_TYPE %d.\n",
                                c->log, c->type, 0 );
-#ifdef SLAPD_CONF_UNKNOWN_BAILOUT
                        return 1;
-#endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
 
        }
        return(0);
@@ -1597,7 +1599,7 @@ config_sizelimit(ConfigArgs *c) {
                struct berval bv;
                bv.bv_val = buf;
                bv.bv_len = 0;
-               limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv );
+               limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv, sizeof( buf ) );
                if ( !BER_BVISEMPTY( &bv ))
                        value_add_one( &c->rvalue_vals, &bv );
                else
@@ -1648,7 +1650,7 @@ config_timelimit(ConfigArgs *c) {
                struct berval bv;
                bv.bv_val = buf;
                bv.bv_len = 0;
-               limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv );
+               limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv, sizeof( buf ) );
                if ( !BER_BVISEMPTY( &bv ))
                        value_add_one( &c->rvalue_vals, &bv );
                else
@@ -1696,12 +1698,10 @@ config_overlay(ConfigArgs *c) {
        }
        if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1])) {
                /* log error */
-               Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: (optional) %s overlay \"%s\" configuration failed"
-                       SLAPD_CONF_UNKNOWN_IGNORED ".\n",
+               Debug( LDAP_DEBUG_ANY,
+                       "%s: (optional) %s overlay \"%s\" configuration failed.\n",
                        c->log, c->be == frontendDB ? "global " : "", &c->argv[1][1]);
-#ifdef SLAPD_CONF_UNKNOWN_BAILOUT
                return 1;
-#endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
        } else if(overlay_config(c->be, c->argv[1])) {
                return(1);
        }
@@ -1843,13 +1843,9 @@ config_suffix(ConfigArgs *c)
        ndn = c->value_ndn;
        tbe = select_backend(&ndn, 0, 0);
        if(tbe == c->be) {
-               Debug( SLAPD_DEBUG_CONFIG_ERROR,
-                       "%s: suffix already served by this backend!"
-                       SLAPD_CONF_UNKNOWN_IGNORED ".\n",
+               Debug( LDAP_DEBUG_ANY, "%s: suffix already served by this backend!.\n",
                        c->log, 0, 0);
-#ifdef SLAPD_CONF_UNKNOWN_BAILOUT
                return 1;
-#endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
                free(pdn.bv_val);
                free(ndn.bv_val);
        } else if(tbe) {
@@ -1994,6 +1990,7 @@ config_allows(ConfigArgs *c) {
                { BER_BVC("bind_anon_cred"),    SLAP_ALLOW_BIND_ANON_CRED },
                { BER_BVC("bind_anon_dn"),      SLAP_ALLOW_BIND_ANON_DN },
                { BER_BVC("update_anon"),       SLAP_ALLOW_UPDATE_ANON },
+               { BER_BVC("proxy_authz_anon"),  SLAP_ALLOW_PROXY_AUTHZ_ANON },
                { BER_BVNULL,   0 }
        };
        if (c->op == SLAP_CONFIG_EMIT) {
@@ -2105,8 +2102,10 @@ loglevel_init( void )
                { BER_BVC("Stats2"),    LDAP_DEBUG_STATS2 },
                { BER_BVC("Shell"),     LDAP_DEBUG_SHELL },
                { BER_BVC("Parse"),     LDAP_DEBUG_PARSE },
+#if 0  /* no longer used (nor supported) */
                { BER_BVC("Cache"),     LDAP_DEBUG_CACHE },
                { BER_BVC("Index"),     LDAP_DEBUG_INDEX },
+#endif
                { BER_BVC("Sync"),      LDAP_DEBUG_SYNC },
                { BER_BVC("None"),      LDAP_DEBUG_NONE },
                { BER_BVNULL,           0 }
@@ -2401,10 +2400,14 @@ config_security(ConfigArgs *c) {
 }
 
 char *
-anlist_unparse( AttributeName *an, char *ptr ) {
+anlist_unparse( AttributeName *an, char *ptr, ber_len_t buflen ) {
        int comma = 0;
+       char *start = ptr;
 
        for (; !BER_BVISNULL( &an->an_name ); an++) {
+               /* if buflen == 0, assume the buffer size has been 
+                * already checked otherwise */
+               if ( buflen > 0 && buflen - ( ptr - start ) < comma + an->an_name.bv_len ) return NULL;
                if ( comma ) *ptr++ = ',';
                ptr = lutil_strcopy( ptr, an->an_name.bv_val );
                comma = 1;
@@ -2468,7 +2471,7 @@ replica_unparse( struct slap_replica_info *ri, int i, struct berval *bv )
                ptr = lutil_strcopy( ptr, " attrs" );
                if ( ri->ri_exclude ) *ptr++ = '!';
                *ptr++ = '=';
-               ptr = anlist_unparse( ri->ri_attrs, ptr );
+               ptr = anlist_unparse( ri->ri_attrs, ptr, 0 );
        }
 }
 
@@ -2564,22 +2567,16 @@ config_replica(ConfigArgs *c) {
                        } else if(!strncasecmp(c->argv[i], "suffix=", STRLENOF( "suffix="))) {
                                switch(add_replica_suffix(c->be, nr, c->argv[i] + STRLENOF("suffix="))) {
                                        case 1:
-                                               Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: "
-                                               "suffix \"%s\" in \"replica\" line is not valid for backend"
-                                               SLAPD_CONF_UNKNOWN_IGNORED ".\n",
-                                               c->log, c->argv[i] + STRLENOF("suffix="), 0);
-#ifdef SLAPD_CONF_UNKNOWN_BAILOUT
+                                               Debug( LDAP_DEBUG_ANY, "%s: "
+                                                       "suffix \"%s\" in \"replica\" line is not valid for backend.\n",
+                                                       c->log, c->argv[i] + STRLENOF("suffix="), 0);
                                                return 1;
-#endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
                                                break;
                                        case 2:
-                                               Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: "
-                                               "unable to normalize suffix in \"replica\" line"
-                                               SLAPD_CONF_UNKNOWN_IGNORED ".\n",
-                                               c->log, 0, 0);
-#ifdef SLAPD_CONF_UNKNOWN_BAILOUT
+                                               Debug( LDAP_DEBUG_ANY, "%s: "
+                                                       "unable to normalize suffix in \"replica\" line.\n",
+                                                       c->log, 0, 0);
                                                return 1;
-#endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
                                                break;
                                }
 
@@ -3614,9 +3611,19 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs, i
         * These entries can have auto-assigned indexes (appended to the end)
         * but only the other types support auto-renumbering of siblings.
         */
-       rc = check_name_index( last, colst[0]->co_type, e, rs, renum );
-       if ( rc )
-               goto done;
+       {
+               int renumber = renum ? *renum : 0;
+               rc = check_name_index( last, colst[0]->co_type, e, rs, renum );
+               if ( rc ) {
+                       goto done;
+               }
+               if ( renum && *renum && renumber == -1 ) {
+                       snprintf( ca->msg, sizeof( ca->msg ),
+                               "operation requires sibling renumbering" );
+                       rc = LDAP_UNWILLING_TO_PERFORM;
+                       goto done;
+               }
+       }
 
        init_config_argv( ca );
 
@@ -3734,10 +3741,15 @@ config_back_add( Operation *op, SlapReply *rs )
         * 4) store entry in underlying database
         * 5) perform any necessary renumbering
         */
+       /* NOTE: by now we do not accept adds that require renumbering */
+       renumber = -1;
        rs->sr_err = config_add_internal( cfb, op->ora_e, &ca, rs, &renumber );
        if ( rs->sr_err != LDAP_SUCCESS ) {
                rs->sr_text = ca.msg;
-       } else if ( cfb->cb_use_ldif ) {
+               goto out2;
+       }
+
+       if ( cfb->cb_use_ldif ) {
                BackendDB *be = op->o_bd;
                slap_callback sc = { NULL, slap_null_cb, NULL, NULL };
                struct berval dn, ndn;
@@ -3758,12 +3770,15 @@ config_back_add( Operation *op, SlapReply *rs )
                op->o_dn = dn;
                op->o_ndn = ndn;
        }
+
        if ( renumber ) {
+               /* TODO */
        }
 
+out2:;
        ldap_pvt_thread_pool_resume( &connection_pool );
 
-out:
+out:;
        send_ldap_result( op, rs );
        return rs->sr_err;
 }
@@ -3800,6 +3815,7 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
        ca->bi = ce->ce_bi;
        ca->private = ce->ce_private;
        ca->ca_entry = e;
+       ca->fname = "slapd";
        strcpy( ca->log, "back-config" );
 
        for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
@@ -4140,6 +4156,9 @@ config_back_modrdn( Operation *op, SlapReply *rs )
        }
        ldap_pvt_thread_pool_pause( &connection_pool );
 
+       rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+       rs->sr_text = "renaming not implemented yet within naming context";
+
        ldap_pvt_thread_pool_resume( &connection_pool );
 out:
        send_ldap_result( op, rs );
@@ -4198,7 +4217,9 @@ config_build_attrs( Entry *e, AttributeType **at, AttributeDescription *ad,
                for (i=0;ct[i].name;i++) {
                        if (ct[i].ad == (*at)->sat_ad) {
                                rc = config_get_vals(&ct[i], c);
-                               if (rc == LDAP_SUCCESS) {
+                               /* NOTE: tolerate that config_get_vals()
+                                * returns success with no values */
+                               if (rc == LDAP_SUCCESS && c->rvalue_vals != NULL ) {
                                        if ( c->rvalue_nvals )
                                                attr_merge(e, ct[i].ad, c->rvalue_vals,
                                                        c->rvalue_nvals);
@@ -4798,6 +4819,9 @@ config_back_initialize( BackendInfo *bi )
                NULL
        };
 
+       /* Make sure we don't exceed the bits reserved for userland */
+       config_check_userland( CFG_LAST );
+
        bi->bi_controls = controls;
 
        bi->bi_open = 0;
@@ -4839,9 +4863,6 @@ config_back_initialize( BackendInfo *bi )
        bi->bi_tool_entry_get = config_tool_entry_get;
        bi->bi_tool_entry_put = config_tool_entry_put;
 
-       /* Make sure we don't exceed the bits reserved for userland */
-       assert( ( ( CFG_LAST - 1 ) & ARGS_USERLAND ) == ( CFG_LAST - 1 ) );
-
        argv[3] = NULL;
        for (i=0; OidMacros[i].name; i++ ) {
                argv[1] = OidMacros[i].name;