]> git.sur5r.net Git - openldap/commitdiff
plug one-time leaks; misc cleanup
authorPierangelo Masarati <ando@openldap.org>
Fri, 16 Dec 2005 01:58:36 +0000 (01:58 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 16 Dec 2005 01:58:36 +0000 (01:58 +0000)
servers/slapd/add.c
servers/slapd/backend.c
servers/slapd/backover.c
servers/slapd/bconfig.c
servers/slapd/config.c
servers/slapd/delete.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/referral.c
servers/slapd/repl.c
servers/slapd/slap.h

index c35cafc96f2924021c8eaf3398c1b88965e1e9fc..6bfebbd7c878db5642cdf3a30b89425ab248aa0c 100644 (file)
@@ -214,10 +214,9 @@ int
 fe_op_add( Operation *op, SlapReply *rs )
 {
        int             manageDSAit;
-       Modifications   *modlist = op->ora_modlist;
-       Modifications   **modtail = &modlist;
+       Modifications   **modtail = &op->ora_modlist;
        int             rc = 0;
-       BackendDB *op_be;
+       BackendDB       *op_be;
        char            textbuf[ SLAP_TEXT_BUFLEN ];
        size_t          textlen = sizeof( textbuf );
 
@@ -268,7 +267,7 @@ fe_op_add( Operation *op, SlapReply *rs )
                goto done;
        }
 
-       rs->sr_err = slap_mods_obsolete_check( op, modlist,
+       rs->sr_err = slap_mods_obsolete_check( op, op->ora_modlist,
                &rs->sr_text, textbuf, textlen );
 
        if ( rs->sr_err != LDAP_SUCCESS ) {
@@ -287,7 +286,7 @@ fe_op_add( Operation *op, SlapReply *rs )
                int repl_user = be_isupdate( op );
 #ifndef SLAPD_MULTIMASTER
                if ( !SLAP_SHADOW(op->o_bd) || repl_user )
-#endif
+#endif /* ! SLAPD_MULTIMASTER */
                {
                        int             update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
                        slap_callback   cb = { NULL, slap_replog_cb, NULL, NULL };
@@ -295,7 +294,7 @@ fe_op_add( Operation *op, SlapReply *rs )
                        op->o_bd = op_be;
 
                        if ( !update ) {
-                               rs->sr_err = slap_mods_no_user_mod_check( op, modlist,
+                               rs->sr_err = slap_mods_no_user_mod_check( op, op->ora_modlist,
                                        &rs->sr_text, textbuf, textlen );
 
                                if ( rs->sr_err != LDAP_SUCCESS ) {
@@ -306,7 +305,7 @@ fe_op_add( Operation *op, SlapReply *rs )
 
                        if ( !repl_user ) {
                                /* go to the last mod */
-                               for ( modtail = &modlist;
+                               for ( modtail = &op->ora_modlist;
                                                *modtail != NULL;
                                                modtail = &(*modtail)->sml_next )
                                {
@@ -317,7 +316,7 @@ fe_op_add( Operation *op, SlapReply *rs )
 
                                /* check for duplicate values */
                                rs->sr_err = slap_mods_no_repl_user_mod_check( op,
-                                       modlist, &rs->sr_text, textbuf, textlen );
+                                       op->ora_modlist, &rs->sr_text, textbuf, textlen );
                                if ( rs->sr_err != LDAP_SUCCESS ) {
                                        send_ldap_result( op, rs );
                                        goto done;
@@ -333,7 +332,7 @@ fe_op_add( Operation *op, SlapReply *rs )
 
 #ifdef SLAPD_MULTIMASTER
                        if ( !repl_user )
-#endif
+#endif /* SLAPD_MULTIMASTER */
                        {
                                cb.sc_next = op->o_callback;
                                op->o_callback = &cb;
index 1bb7e618b7b8b1fae5cf13af4c32f3cb370a5ec8..708233cfba795e40d1a5d1c4ebd1ecb5b1a80709 100644 (file)
@@ -425,6 +425,12 @@ void backend_destroy_one( BackendDB *bd, int dynamic )
        if ( bd->be_replogfile ) {
                ch_free( bd->be_replogfile );
        }
+       if ( bd->be_replica_argsfile ) {
+               ch_free( bd->be_replica_argsfile );
+       }
+       if ( bd->be_replica_pidfile ) {
+               ch_free( bd->be_replica_pidfile );
+       }
        destroy_replica_info( bd );
        if ( !BER_BVISNULL( &bd->be_update_ndn ) ) {
                ch_free( bd->be_update_ndn.bv_val );
@@ -480,6 +486,12 @@ int backend_destroy(void)
                if ( bd->be_replogfile != NULL ) {
                        free( bd->be_replogfile );
                }
+               if ( bd->be_replica_argsfile ) {
+                       ch_free( bd->be_replica_argsfile );
+               }
+               if ( bd->be_replica_pidfile ) {
+                       ch_free( bd->be_replica_pidfile );
+               }
                assert( bd->be_replica == NULL );
        }
 
index 0aa4a72be93ca3e193060cc214b0a7282ac5d2fa..68415383c378d86f05bb1e231497b6030615d8f2 100644 (file)
@@ -890,7 +890,7 @@ overlay_register_control( BackendDB *be, const char *oid )
                return -1;
        }
 
-       if ( SLAP_DBFLAGS( be ) & SLAP_DBFLAG_GLOBAL_OVERLAY ) {
+       if ( SLAP_ISGLOBALOVERLAY( be ) ) {
                BackendDB *bd;
                
                /* add to all backends... */
index a080eb992b66c52fccd6812a7ec0d0d68b040622..c500b9971f2248ed316158c951da0b4e1c391d82 100644 (file)
@@ -1820,10 +1820,11 @@ config_suffix(ConfigArgs *c)
                        int i = c->valx;
                        ch_free( c->be->be_suffix[i].bv_val );
                        ch_free( c->be->be_nsuffix[i].bv_val );
-                       for (; c->be->be_suffix[i].bv_val; i++) {
+                       do {
                                c->be->be_suffix[i] = c->be->be_suffix[i+1];
                                c->be->be_nsuffix[i] = c->be->be_nsuffix[i+1];
-                       }
+                               i++;
+                       } while ( !BER_BVISNULL( &c->be->be_suffix[i] ) );
                }
                return 0;
        }
index 2f8cd60f4c7b86240245f0e59b8ad26c7ba49bf4..8f169ce478b554484b54417903433db77db74416 100644 (file)
@@ -237,20 +237,20 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) {
                                {
                                        iarg = 0;
                                } else {
-                                       snprintf( c->msg, sizeof( c->msg ), "<%s> invalid value, ignored",
+                                       snprintf( c->msg, sizeof( c->msg ), "<%s> invalid value",
                                                c->argv[0] );
-                                       Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
+                                       Debug(LDAP_DEBUG_ANY, "%s: %s\n",
                                                c->log, c->msg, 0 );
-                                       return(0);
+                                       return(ARG_BAD_CONF);
                                }
                                break;
                }
                j = (arg_type & ARG_NONZERO) ? 1 : 0;
                if(iarg < j && larg < j && barg < j ) {
                        larg = larg ? larg : (barg ? barg : iarg);
-                       snprintf( c->msg, sizeof( c->msg ), "<%s> invalid value, ignored",
+                       snprintf( c->msg, sizeof( c->msg ), "<%s> invalid value",
                                c->argv[0] );
-                       Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
+                       Debug(LDAP_DEBUG_ANY, "%s: %s\n",
                                c->log, c->msg, 0 );
                        return(ARG_BAD_CONF);
                }
@@ -805,20 +805,29 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft)
                                rc = (*c->be->be_config)(c->be, c->fname, c->lineno,
                                        c->argc, c->argv);
                        }
-                       if ( rc ) {
-                               switch(rc) {
-                               case SLAP_CONF_UNKNOWN:
-                                       Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: "
-                                               "unknown directive <%s> inside backend database "
-                                               "definition" SLAPD_CONF_UNKNOWN_IGNORED ".\n",
-                                               c->log, *c->argv, 0);
+                       if ( rc == SLAP_CONF_UNKNOWN && SLAP_ISGLOBALOVERLAY( frontendDB ) ) {
+                               /* global overlays may need 
+                                * definitions inside other databases...
+                                */
+                               rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv);
+                       }
+
+                       switch ( rc ) {
+                       case 0:
+                               break;
+
+                       case SLAP_CONF_UNKNOWN:
+                               Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: "
+                                       "unknown directive <%s> inside backend database "
+                                       "definition" SLAPD_CONF_UNKNOWN_IGNORED ".\n",
+                                       c->log, *c->argv, 0);
 #ifndef SLAPD_CONF_UNKNOWN_BAILOUT
-                                       continue;
+                               break;
 #endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
-                               default:
-                                       rc = 1;
-                                       goto done;
-                               }
+                               
+                       default:
+                               rc = 1;
+                               goto done;
                        }
 
                } else if ( frontendDB->be_config ) {
@@ -831,8 +840,9 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft)
                                                SLAPD_CONF_UNKNOWN_IGNORED ".\n",
                                                c->log, *c->argv, 0);
 #ifndef SLAPD_CONF_UNKNOWN_BAILOUT
-                                       continue;
+                                       break;
 #endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
+
                                default:
                                        rc = 1;
                                        goto done;
index 078505cd221eaf2affd0cff80b67fd9a364f7e62..2eb56d42abe64fe92a45d15b9a32885be569c797 100644 (file)
@@ -161,7 +161,7 @@ fe_op_delete( Operation *op, SlapReply *rs )
                int repl_user = be_isupdate( op );
 #ifndef SLAPD_MULTIMASTER
                if ( !SLAP_SHADOW(op->o_bd) || repl_user )
-#endif
+#endif /* ! SLAPD_MULTIMASTER */
                {
                        struct berval   org_req_dn = BER_BVNULL;
                        struct berval   org_req_ndn = BER_BVNULL;
@@ -174,7 +174,7 @@ fe_op_delete( Operation *op, SlapReply *rs )
 
 #ifdef SLAPD_MULTIMASTER
                        if ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
-#endif
+#endif /* SLAPD_MULTIMASTER */
                        {
                                cb.sc_next = op->o_callback;
                                op->o_callback = &cb;
@@ -234,7 +234,7 @@ fe_op_delete( Operation *op, SlapReply *rs )
                                        LDAP_UNWILLING_TO_PERFORM,
                                        "shadow context; no update referral" );
                        }
-#endif
+#endif /* ! SLAPD_MULTIMASTER */
                }
 
        } else {
index 116dc3cb17ca68280cbb01fcff74d6bc3fd278ae..ff7669dca86fd5f7ba49b6ad84aff79160b69dd1 100644 (file)
@@ -214,13 +214,11 @@ fe_op_modify( Operation *op, SlapReply *rs )
        Modifications   *tmp;
 #endif
        int             manageDSAit;
-       Modifications   *modlist = op->orm_modlist;
-       int             increment = op->orm_increment;
-       BackendDB *op_be;
+       BackendDB       *op_be;
        char            textbuf[ SLAP_TEXT_BUFLEN ];
        size_t          textlen = sizeof( textbuf );
        
-       if( BER_BVISEMPTY( &op->o_req_ndn ) ) {
+       if ( BER_BVISEMPTY( &op->o_req_ndn ) ) {
                Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
 
                send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
@@ -238,7 +236,7 @@ fe_op_modify( Operation *op, SlapReply *rs )
 #ifdef LDAP_DEBUG
        Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
 
-       for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
+       for ( tmp = op->orm_modlist; tmp != NULL; tmp = tmp->sml_next ) {
                Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
                        tmp->sml_op == LDAP_MOD_ADD ? "add" :
                                (tmp->sml_op == LDAP_MOD_INCREMENT ? "increment" :
@@ -267,7 +265,7 @@ fe_op_modify( Operation *op, SlapReply *rs )
                Statslog( LDAP_DEBUG_STATS, "%s MOD dn=\"%s\"\n",
                        op->o_log_prefix, op->o_req_dn.bv_val, 0, 0, 0 );
 
-               for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
+               for ( tmp = op->orm_modlist; tmp != NULL; tmp = tmp->sml_next ) {
                        if (len + 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
                                Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n",
                                    op->o_log_prefix, abuf, 0, 0, 0 );
@@ -306,15 +304,20 @@ fe_op_modify( Operation *op, SlapReply *rs )
        if ( op->o_bd == NULL ) {
                rs->sr_ref = referral_rewrite( default_referral,
                        NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
-               if (!rs->sr_ref) rs->sr_ref = default_referral;
+               if ( !rs->sr_ref ) {
+                       rs->sr_ref = default_referral;
+               }
 
-               if (rs->sr_ref != NULL ) {
+               if ( rs->sr_ref != NULL ) {
                        rs->sr_err = LDAP_REFERRAL;
                        op->o_bd = frontendDB;
                        send_ldap_result( op, rs );
                        op->o_bd = NULL;
 
-                       if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
+                       if ( rs->sr_ref != default_referral ) {
+                               ber_bvarray_free( rs->sr_ref );
+                       }
+
                } else {
                        op->o_bd = frontendDB;
                        send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
@@ -331,17 +334,17 @@ fe_op_modify( Operation *op, SlapReply *rs )
        }
 
        /* check restrictions */
-       if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
+       if ( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
                send_ldap_result( op, rs );
                goto cleanup;
        }
 
        /* check for referrals */
-       if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
+       if ( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
                goto cleanup;
        }
 
-       rs->sr_err = slap_mods_obsolete_check( op, modlist,
+       rs->sr_err = slap_mods_obsolete_check( op, op->orm_modlist,
                &rs->sr_text, textbuf, textlen );
        if ( rs->sr_err != LDAP_SUCCESS ) {
                send_ldap_result( op, rs );
@@ -349,7 +352,7 @@ fe_op_modify( Operation *op, SlapReply *rs )
        }
 
        /* check for modify/increment support */
-       ifincrement && !SLAP_INCREMENT( op->o_bd ) ) {
+       if ( op->orm_increment && !SLAP_INCREMENT( op->o_bd ) ) {
                send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
                        "modify/increment not supported in context" );
        }
@@ -369,7 +372,7 @@ fe_op_modify( Operation *op, SlapReply *rs )
                 */
 #ifndef SLAPD_MULTIMASTER
                if ( !SLAP_SHADOW(op->o_bd) || repl_user )
-#endif
+#endif /* ! SLAPD_MULTIMASTER */
                {
                        int             update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
                        slap_callback   cb = { NULL, slap_replog_cb, NULL, NULL };
@@ -377,7 +380,7 @@ fe_op_modify( Operation *op, SlapReply *rs )
                        op->o_bd = op_be;
 
                        if ( !update ) {
-                               rs->sr_err = slap_mods_no_user_mod_check( op, modlist,
+                               rs->sr_err = slap_mods_no_user_mod_check( op, op->orm_modlist,
                                        &rs->sr_text, textbuf, textlen );
                                if ( rs->sr_err != LDAP_SUCCESS ) {
                                        send_ldap_result( op, rs );
@@ -385,10 +388,9 @@ fe_op_modify( Operation *op, SlapReply *rs )
                                }
                        }
 
-                       op->orm_modlist = modlist;
 #ifdef SLAPD_MULTIMASTER
                        if ( !repl_user )
-#endif
+#endif /* SLAPD_MULTIMASTER */
                        {
                                /* but multimaster slapd logs only the ones 
                                 * not from a replicator user */
@@ -421,7 +423,7 @@ fe_op_modify( Operation *op, SlapReply *rs )
                                send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
                                        "shadow context; no update referral" );
                        }
-#endif
+#endif /* ! SLAPD_MULTIMASTER */
                }
        } else {
                send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
@@ -478,7 +480,9 @@ slap_mods_no_user_mod_check(
        size_t textlen )
 {
        for ( ; ml != NULL; ml = ml->sml_next ) {
-               if ( !is_at_no_user_mod( ml->sml_desc->ad_type ) ) continue;
+               if ( !is_at_no_user_mod( ml->sml_desc->ad_type ) ) {
+                       continue;
+               }
 
                if ( get_manageDIT( op ) ) {
                        if ( ml->sml_desc->ad_type->sat_flags & SLAP_AT_MANAGEABLE ) {
index 97f499782660db6ac4706cf01e23a46badb21571..39165a37b03c9d4fe3f1c24150918cecd750e3b8 100644 (file)
@@ -291,7 +291,7 @@ fe_op_modrdn( Operation *op, SlapReply *rs )
                int repl_user = be_isupdate( op );
 #ifndef SLAPD_MULTIMASTER
                if ( !SLAP_SHADOW(op->o_bd) || repl_user )
-#endif
+#endif /* ! SLAPD_MULTIMASTER */
                {
                        slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
 
@@ -299,7 +299,7 @@ fe_op_modrdn( Operation *op, SlapReply *rs )
 
 #ifdef SLAPD_MULTIMASTER
                        if ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
-#endif
+#endif /* SLAPD_MULTIMASTER */
                        {
                                cb.sc_next = op->o_callback;
                                op->o_callback = &cb;
@@ -363,7 +363,7 @@ fe_op_modrdn( Operation *op, SlapReply *rs )
                                send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
                                        "shadow context; no update referral" );
                        }
-#endif
+#endif /* ! SLAPD_MULTIMASTER */
                }
        } else {
                send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
index ce3e4529f216c8a5e5b43e64c8cfad39e1da21c6..34038528595d7a1135ec7a022dcc4389273f1cac 100644 (file)
@@ -153,6 +153,7 @@ int validate_global_referral( const char *url )
 
        case LDAP_URL_ERR_BADSCHEME:
                /* not LDAP hence valid */
+               Debug( LDAP_DEBUG_CONFIG, "referral \"%s\": not LDAP.\n", url, 0, 0 );
                return 0;
 
        default:
index 73b3c8ca96c03f60ced1da115e4c2c8efef14d1c..96a982e38f8534c2358df9ddff5c8e38dfc829dc 100644 (file)
@@ -166,7 +166,7 @@ replog( Operation *op )
 /* undef NO_LOG_WHEN_NO_REPLICAS */
 #ifdef NO_LOG_WHEN_NO_REPLICAS
        int     count = 0;
-#endif
+#endif /* NO_LOG_WHEN_NO_REPLICAS */
        int     subsets = 0;
        long    now = slap_get_time();
        char    *replogfile;
@@ -212,7 +212,7 @@ replog( Operation *op )
                fprintf( fp, "replica: %s\n", op->o_bd->be_replica[i]->ri_host );
 #ifdef NO_LOG_WHEN_NO_REPLICAS
                ++count;
-#endif
+#endif /* NO_LOG_WHEN_NO_REPLICAS */
        }
 
 #ifdef NO_LOG_WHEN_NO_REPLICAS
@@ -224,7 +224,7 @@ replog( Operation *op )
 
                return;
        }
-#endif
+#endif /* NO_LOG_WHEN_NO_REPLICAS */
 
        replog1( NULL, op, fp, now );
 
index 330cd93cdd93f02de9f26ac36071a582484a16f3..34105c657ddbd8f09f88e1be47ba0a3555492f6f 100644 (file)
@@ -1741,6 +1741,7 @@ struct slap_backend_db {
 #define SLAP_NOLASTMOD(be)                     (SLAP_DBFLAGS(be) & SLAP_DBFLAG_NOLASTMOD)
 #define SLAP_LASTMOD(be)                       (!SLAP_NOLASTMOD(be))
 #define SLAP_ISOVERLAY(be)                     (SLAP_DBFLAGS(be) & SLAP_DBFLAG_OVERLAY)
+#define SLAP_ISGLOBALOVERLAY(be)               (SLAP_DBFLAGS(be) & SLAP_DBFLAG_GLOBAL_OVERLAY)
 #define SLAP_NO_SCHEMA_CHECK(be)       \
        (SLAP_DBFLAGS(be) & SLAP_DBFLAG_NO_SCHEMA_CHECK)
 #define        SLAP_GLUE_INSTANCE(be)          \