From 53e1930fd075aa25f29b8e55ce34559c728e4a33 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 31 Oct 2002 09:57:24 +0000 Subject: [PATCH] use keyword "unlimited" instead of -1 for no limits --- doc/man/man5/slapd.conf.5 | 4 +- servers/slapd/config.c | 116 +++++++++++++++++++++++++++++--------- 2 files changed, 90 insertions(+), 30 deletions(-) diff --git a/doc/man/man5/slapd.conf.5 b/doc/man/man5/slapd.conf.5 index 8049673bd4..62998f7421 100644 --- a/doc/man/man5/slapd.conf.5 +++ b/doc/man/man5/slapd.conf.5 @@ -712,7 +712,7 @@ Note that the factor is measure of security provided by the underlying transport, e.g. ldapi:// (and eventually IPSEC). It is not normally used. .TP -.B sizelimit +.B sizelimit {|unlimited} .TP .B sizelimit size[.{soft|hard|unchecked}]= [...] Specify the maximum number of entries to return from a search operation. @@ -740,7 +740,7 @@ meaningful if you are using Kerberos authentication. Specify the maximum size of the primary thread pool. The default is 32. .TP -.B timelimit +.B timelimit {|unlimited} .TP .B timelimit time[.{soft|hard}]= [...] Specify the maximum number of seconds (in real time) diff --git a/servers/slapd/config.c b/servers/slapd/config.c index ec59972183..55d6191939 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -664,25 +664,55 @@ read_config( const char *fname, int depth ) for ( i = 1; i < cargc; i++ ) { if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) { rc = parse_limit( cargv[i], lim ); + if ( rc ) { +#ifdef NEW_LOGGING + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: unable " + "to parse value \"%s\" in \"sizelimit " + "\" line.\n", fname, lineno, cargv[i] ); +#else + Debug( LDAP_DEBUG_ANY, + "%s: line %d: unable " + "to parse value \"%s\" " + "in \"sizelimit " + "\" line\n", + fname, lineno, cargv[i] ); +#endif + return( 1 ); + } + } else { - lim->lms_s_soft = atoi( cargv[i] ); - lim->lms_s_hard = 0; - } + if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) { + lim->lms_s_soft = -1; + } else { + char *next; - if ( rc ) { + lim->lms_s_soft = strtol( cargv[i] , &next, 0 ); + if ( next == cargv[i] ) { #ifdef NEW_LOGGING - LDAP_LOG( CONFIG, CRIT, - "%s: line %d: unable " - "to parse value \"%s\" in \"sizelimit " - "\" line.\n", fname, lineno, cargv[i] ); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: unable to parse limit \"%s\" in \"sizelimit \" " + "line.\n", fname, lineno, cargv[i] ); #else - Debug( LDAP_DEBUG_ANY, - "%s: line %d: unable " - "to parse value \"%s\" " - "in \"sizelimit " - "\" line\n", - fname, lineno, cargv[i] ); + Debug( LDAP_DEBUG_ANY, + "%s: line %d: unable to parse limit \"%s\" in \"sizelimit \" line\n", + fname, lineno, cargv[i] ); +#endif + return( 1 ); + + } else if ( next[0] != '\0' ) { +#ifdef NEW_LOGGING + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: trailing chars \"%s\" in \"sizelimit \" " + "line ignored.\n", fname, lineno, next ); +#else + Debug( LDAP_DEBUG_ANY, + "%s: line %d: trailing chars \"%s\" in \"sizelimit \" line ignored\n", + fname, lineno, next ); #endif + } + } + lim->lms_s_hard = 0; } } @@ -714,25 +744,55 @@ read_config( const char *fname, int depth ) for ( i = 1; i < cargc; i++ ) { if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) { rc = parse_limit( cargv[i], lim ); + if ( rc ) { +#ifdef NEW_LOGGING + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: unable to parse value \"%s\" " + "in \"timelimit \" line.\n", + fname, lineno, cargv[i] ); +#else + Debug( LDAP_DEBUG_ANY, + "%s: line %d: unable " + "to parse value \"%s\" " + "in \"timelimit " + "\" line\n", + fname, lineno, cargv[i] ); +#endif + return( 1 ); + } + } else { - lim->lms_t_soft = atoi( cargv[i] ); - lim->lms_t_hard = 0; - } + if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) { + lim->lms_t_soft = -1; + } else { + char *next; - if ( rc ) { + lim->lms_t_soft = strtol( cargv[i] , &next, 0 ); + if ( next == cargv[i] ) { #ifdef NEW_LOGGING - LDAP_LOG( CONFIG, CRIT, - "%s: line %d: unable to parse value \"%s\" " - "in \"timelimit \" line.\n", - fname, lineno, cargv[i] ); + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: unable to parse limit \"%s\" in \"timelimit \" " + "line.\n", fname, lineno, cargv[i] ); #else - Debug( LDAP_DEBUG_ANY, - "%s: line %d: unable " - "to parse value \"%s\" " - "in \"timelimit " - "\" line\n", - fname, lineno, cargv[i] ); + Debug( LDAP_DEBUG_ANY, + "%s: line %d: unable to parse limit \"%s\" in \"timelimit \" line\n", + fname, lineno, cargv[i] ); +#endif + return( 1 ); + + } else if ( next[0] != '\0' ) { +#ifdef NEW_LOGGING + LDAP_LOG( CONFIG, CRIT, + "%s: line %d: trailing chars \"%s\" in \"timelimit \" " + "line ignored.\n", fname, lineno, next ); +#else + Debug( LDAP_DEBUG_ANY, + "%s: line %d: trailing chars \"%s\" in \"timelimit \" line ignored\n", + fname, lineno, next ); #endif + } + } + lim->lms_t_hard = 0; } } -- 2.39.5