From: Howard Chu Date: Tue, 1 Mar 2005 21:25:32 +0000 (+0000) Subject: Added limits_unparse_one X-Git-Tag: OPENLDAP_REL_ENG_2_3_BP~112 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=58939adc360e03a1585c753626991bffbad42228;p=openldap Added limits_unparse_one --- diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 7333f7ad58..8417f3ab8b 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -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)) { diff --git a/servers/slapd/limits.c b/servers/slapd/limits.c index 49892a049a..337129e142 100644 --- a/servers/slapd/limits.c +++ b/servers/slapd/limits.c @@ -22,6 +22,7 @@ #include #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 ) diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index baa5b47ff0..7a257120dd 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -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 diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 7dc81b03f7..4192e4423e 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -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;