]> git.sur5r.net Git - openldap/commitdiff
allow to delete olcLimits values (ITS#6159)
authorPierangelo Masarati <ando@openldap.org>
Tue, 2 Jun 2009 23:17:58 +0000 (23:17 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 2 Jun 2009 23:17:58 +0000 (23:17 +0000)
servers/slapd/bconfig.c
servers/slapd/limits.c
servers/slapd/proto-slap.h

index de7665cd30cb08b5433d1ddd0393da5ae4638b12..b259178efeb73ff2c1219169a17364f8e275d59e 100644 (file)
@@ -1388,6 +1388,36 @@ config_generic(ConfigArgs *c) {
 
                case CFG_LIMITS:
                        /* FIXME: there is no limits_free function */
+                       if ( c->valx < 0 ) {
+                               limits_destroy( c->be->be_limits );
+                               c->be->be_limits = NULL;
+
+                       } else {
+                               int cnt, num = -1;
+
+                               if ( c->be->be_limits ) {
+                                       for ( num = 0; c->be->be_limits[ num ]; num++ )
+                                               /* just count */ ;
+                               }
+
+                               if ( c->valx >= num ) {
+                                       return 1;
+                               }
+
+                               if ( num == 1 ) {
+                                       limits_destroy( c->be->be_limits );
+                                       c->be->be_limits = NULL;
+
+                               } else {
+                                       limits_free_one( c->be->be_limits[ c->valx ] );
+
+                                       for ( cnt = c->valx; cnt < num; cnt++ ) {
+                                               c->be->be_limits[ cnt ] = c->be->be_limits[ cnt + 1 ];
+                                       }
+                               }
+                       }
+                       break;
+
                case CFG_ATOPT:
                        /* FIXME: there is no ad_option_free function */
                case CFG_ROOTDSE:
index 796149c4b3c508cb8ad70804916d2dcc29909bdf..cf22aed463252dbad93f1bf41a5822f42c053b8f 100644 (file)
@@ -1324,6 +1324,19 @@ limits_check( Operation *op, SlapReply *rs )
        return 0;
 }
 
+void
+limits_free_one( 
+       struct slap_limits      *lm )
+{
+       if ( ( lm->lm_flags & SLAP_LIMITS_MASK ) == SLAP_LIMITS_REGEX )
+               regfree( &lm->lm_regex );
+
+       if ( !BER_BVISNULL( &lm->lm_pat ) )
+               ch_free( lm->lm_pat.bv_val );
+
+       ch_free( lm );
+}
+
 void
 limits_destroy( 
        struct slap_limits      **lm )
@@ -1335,13 +1348,7 @@ limits_destroy(
        }
 
        for ( i = 0; lm[ i ]; i++ ) {
-               if ( (lm[ i ]->lm_flags & SLAP_LIMITS_MASK) == SLAP_LIMITS_REGEX )
-                       regfree( &lm[ i ]->lm_regex );
-
-               if ( !BER_BVISNULL( &lm[ i ]->lm_pat ) )
-                       ch_free( lm[ i ]->lm_pat.bv_val );
-
-               ch_free( lm[ i ] );
+               limits_free_one( lm[ i ] );
        }
 
        ch_free( lm );
index 8c0115febd2a21a431a0c811c82134e13a184b8b..6e962d2ebb3cd6cebe388cfd48ab9948ffa71dc2 100644 (file)
@@ -1151,6 +1151,8 @@ LDAP_SLAPD_F (int) limits_unparse_one LDAP_P((
        struct slap_limits_set *limit, int which, struct berval *bv, ber_len_t buflen ));
 LDAP_SLAPD_F (int) limits_unparse LDAP_P(( 
        struct slap_limits *limit, struct berval *bv, ber_len_t buflen ));
+LDAP_SLAPD_F (void) limits_free_one LDAP_P(( 
+       struct slap_limits      *lm ));
 LDAP_SLAPD_F (void) limits_destroy LDAP_P(( struct slap_limits **lm ));
 
 /*