]> git.sur5r.net Git - openldap/commitdiff
Added limits_unparse_one
authorHoward Chu <hyc@openldap.org>
Tue, 1 Mar 2005 21:25:32 +0000 (21:25 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 1 Mar 2005 21:25:32 +0000 (21:25 +0000)
servers/slapd/config.c
servers/slapd/limits.c
servers/slapd/proto-slap.h
servers/slapd/slap.h

index 7333f7ad582709c928c1a8ab5e0b24cf51e8194e..8417f3ab8bbf0fcd0c88a8c1db89322cacd75721 100644 (file)
@@ -84,6 +84,7 @@ static int replicationInterval;
 
 static char    *passwd_salt;
 static char    *logfileName;
+static BerVarray authz_rewrites;
 
 #ifdef LDAP_SLAPI
 int slapi_plugins_used = 0;
@@ -452,7 +453,7 @@ static ConfigTable SystemConfiguration[] = {
        { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
                &config_security, "( OLcfgAt:59 NAME 'olcSecurity' "
                        "SYNTAX OMsDirectoryString )", NULL, NULL },
-       { "sizelimit", "limit", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC|CFG_SIZE,
+       { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_SIZE,
                &config_sizelimit, "( OLcfgAt:60 NAME 'olcSizeLimit' "
                        "SYNTAX OMsInteger )", NULL, NULL },
        { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_LONG,
@@ -478,7 +479,7 @@ static ConfigTable SystemConfiguration[] = {
        { "threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_THREADS,
                &config_generic, "( OLcfgAt:66 NAME 'olcThreads' "
                        "SYNTAX OMsInteger )", NULL, NULL },
-       { "timelimit", "limit", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC|CFG_TIME,
+       { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_TIME,
                &config_timelimit, "( OLcfgAt:67 NAME 'olcTimeLimit' "
                        "SYNTAX OMsInteger )", NULL, NULL },
        { "TLSCACertificateFile", NULL, 0, 0, 0,
@@ -1107,14 +1108,29 @@ config_generic(ConfigArgs *c) {
                        break;
 #endif
 #ifdef LDAP_SLAPI
-               case CFG_PLUGIN:        /* FIXME */
+               case CFG_PLUGIN:
                        slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
                        if ( !c->rvalue_vals ) rc = 1;
                        break;
 #endif
 #ifdef SLAP_AUTH_REWRITE
-               case CFG_REWRITE:       /* FIXME */
-                       rc = 1;
+               case CFG_REWRITE:
+                       if ( authz_rewrites ) {
+                               struct berval bv, idx;
+                               char ibuf[32];
+                               int i;
+
+                               idx.bv_val = ibuf;
+                               for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
+                                       idx.bv_len = sprintf( idx.bv_val, "{%d}", i );
+                                       bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
+                                       bv.bv_val = ch_malloc( bv.bv_len + 1 );
+                                       strcpy( bv.bv_val, idx.bv_val );
+                                       strcpy( bv.bv_val+idx.bv_len, authz_rewrites[i].bv_val );
+                                       ber_bvarray_add( &c->rvalue_vals, &bv );
+                               }
+                       }
+                       if ( !c->rvalue_vals ) rc = 1;
                        break;
 #endif
                default:
@@ -1348,9 +1364,13 @@ config_generic(ConfigArgs *c) {
 #endif
 
 #ifdef SLAP_AUTH_REWRITE
-               case CFG_REWRITE:
+               case CFG_REWRITE: {
+                       struct berval bv;
                        if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
                                return(1);
+                       ber_str2bv( c->line, 0, 1, &bv );
+                       ber_bvarray_add( &authz_rewrites, &bv );
+                       }
                        break;
 #endif
 
@@ -1462,8 +1482,14 @@ config_sizelimit(ConfigArgs *c) {
        int i, rc = 0;
        char *next;
        struct slap_limits_set *lim = &c->be->be_def_limit;
-       if (c->emit) {  /* FIXME */
-               return 1;
+       if (c->emit) {
+               struct berval bv = BER_BVNULL;
+               limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv );
+               if ( !BER_BVISEMPTY( &bv ))
+                       ber_bvarray_add( &c->rvalue_vals, &bv );
+               else
+                       rc = 1;
+               return rc;
        }
        for(i = 1; i < c->argc; i++) {
                if(!strncasecmp(c->argv[i], "size", 4)) {
@@ -1502,7 +1528,13 @@ config_timelimit(ConfigArgs *c) {
        char *next;
        struct slap_limits_set *lim = &c->be->be_def_limit;
        if (c->emit) {
-               return 1;       /* FIXME */
+               struct berval bv = BER_BVNULL;
+               limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv );
+               if ( !BER_BVISEMPTY( &bv ))
+                       ber_bvarray_add( &c->rvalue_vals, &bv );
+               else
+                       rc = 1;
+               return rc;
        }
        for(i = 1; i < c->argc; i++) {
                if(!strncasecmp(c->argv[i], "time", 4)) {
index 49892a049ab8d727d286cc0c24a2c6c614ced13f..337129e142770672cf1787e21b103ff484d86def 100644 (file)
@@ -22,6 +22,7 @@
 #include <ac/string.h>
 
 #include "slap.h"
+#include "lutil.h"
 
 /* define to get an error if requesting limit higher than hard */
 #undef ABOVE_HARD_LIMIT_IS_ERROR
@@ -899,6 +900,84 @@ limits_parse_one(
        return 0;
 }
 
+void
+limits_unparse_one( struct slap_limits_set *lim, int which, struct berval *bv )
+{
+       char buf[8192], *ptr;
+
+       ptr = buf;
+       if ( which & SLAP_LIMIT_TIME ) {
+               if ( lim->lms_t_soft != SLAPD_DEFAULT_TIMELIMIT ) {
+                       ptr = lutil_strcopy( ptr, " time.soft=" );
+                       if ( lim->lms_t_soft == -1 )
+                               ptr = lutil_strcopy( ptr, "unlimited" );
+                       else
+                               ptr += sprintf( ptr, "%d", lim->lms_t_soft );
+                       *ptr++ = ' ';
+               }
+               if ( lim->lms_t_hard ) {
+                       ptr = lutil_strcopy( ptr, " time.hard=" );
+                       if ( lim->lms_t_hard == -1 )
+                               ptr = lutil_strcopy( ptr, "unlimited" );
+                       else
+                               ptr += sprintf( ptr, "%d", lim->lms_t_hard );
+                       *ptr++ = ' ';
+               }
+       }
+       if ( which & SLAP_LIMIT_SIZE ) {
+               if ( lim->lms_s_soft != SLAPD_DEFAULT_SIZELIMIT ) {
+                       ptr = lutil_strcopy( ptr, " size.soft=" );
+                       if ( lim->lms_s_soft == -1 )
+                               ptr = lutil_strcopy( ptr, "unlimited" );
+                       else
+                               ptr += sprintf( ptr, "%d", lim->lms_s_soft );
+                       *ptr++ = ' ';
+               }
+               if ( lim->lms_s_hard ) {
+                       ptr = lutil_strcopy( ptr, " size.hard=" );
+                       if ( lim->lms_s_soft == -1 )
+                               ptr = lutil_strcopy( ptr, "unlimited" );
+                       else
+                               ptr += sprintf( ptr, "%d", lim->lms_s_hard );
+                       *ptr++ = ' ';
+               }
+               if ( lim->lms_s_unchecked != -1 ) {
+                       ptr = lutil_strcopy( ptr, " size.unchecked=" );
+                       if ( lim->lms_s_unchecked == 0 )
+                               ptr = lutil_strcopy( ptr, "disabled" );
+                       else
+                               ptr += sprintf( ptr, "%d", lim->lms_s_unchecked );
+                       *ptr++ = ' ';
+               }
+               if ( lim->lms_s_pr_hide ) {
+                       ptr = lutil_strcopy( ptr, " size.pr=noEstimate " );
+               }
+               if ( lim->lms_s_pr ) {
+                       ptr = lutil_strcopy( ptr, " size.pr=" );
+                       if ( lim->lms_s_pr == -1 )
+                               ptr = lutil_strcopy( ptr, "unlimited" );
+                       else
+                               ptr += sprintf( ptr, "%d", lim->lms_s_pr );
+                       *ptr++ = ' ';
+               }
+               if ( lim->lms_s_pr_total ) {
+                       ptr = lutil_strcopy( ptr, " size.prtotal=" );
+                       if ( lim->lms_s_pr_total == -1 )
+                               ptr = lutil_strcopy( ptr, "unlimited" );
+                       else if ( lim->lms_s_pr_total == -2 )
+                               ptr = lutil_strcopy( ptr, "disabled" );
+                       else 
+                               ptr += sprintf( ptr, "%d", lim->lms_s_pr_total );
+                       *ptr++ = ' ';
+               }
+       }
+       if ( ptr != buf ) {
+               ptr--;
+               *ptr = '\0';
+               bv->bv_len = ptr - buf - 1;
+               ber_str2bv( buf+1, bv->bv_len, 1, bv );
+       }
+}
 
 int
 limits_check( Operation *op, SlapReply *rs )
index baa5b47ff0e5807a33ad920d99acd9eae35d24f1..7a257120ddc35494becb1dcf120d55a6bf95fc7e 100644 (file)
@@ -798,6 +798,8 @@ LDAP_SLAPD_F (int) limits_parse_one LDAP_P(( const char *arg,
        struct slap_limits_set *limit ));
 LDAP_SLAPD_F (int) limits_check LDAP_P((
        Operation *op, SlapReply *rs ));
+LDAP_SLAPD_F (void) limits_unparse_one LDAP_P(( 
+       struct slap_limits_set *limit, struct berval *bv ));
 
 /*
  * lock.c
index 7dc81b03f79ba78861e3aa7ad239cfc0ad21ddf6..4192e4423ecd6b90c22bed069507ad05d5b14e07 100644 (file)
@@ -1418,6 +1418,9 @@ struct slap_replica_info {
        slap_bindconf ri_bindconf;      /* for back-config */
 };
 
+#define SLAP_LIMIT_TIME        1
+#define SLAP_LIMIT_SIZE        2
+
 struct slap_limits_set {
        /* time limits */
        int     lms_t_soft;