]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/config.c
Do not return pointers into BerElement we do not own
[openldap] / servers / slapd / config.c
index a9677b60389c2ab8dbdaceb55ffaf94477c890cd..8951f40664229f103fa8e1c54acede67ce3d63bc 100644 (file)
@@ -6,7 +6,6 @@
  */
 
 #include "portable.h"
-#include "slapi_common.h"
 
 #include <stdio.h>
 
 #include <ac/socket.h>
 #include <ac/errno.h>
 
-#include "lutil.h"
 #include "ldap_pvt.h"
 #include "slap.h"
+#ifdef LDAP_SLAPI
 #include "slapi.h"
+#endif
+#include "lutil.h"
 
 #define ARGS_STEP      512
 
@@ -62,16 +63,15 @@ struct berval global_schemandn = { 0, NULL };
 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
 
+int    slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
+int    slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
+
 char   *slapd_pid_file  = NULL;
 char   *slapd_args_file = NULL;
 
 char   *strtok_quote_ptr;
 
-#ifdef SLAPD_RLOOKUPS
-int use_reverse_lookup = 1;
-#else /* !SLAPD_RLOOKUPS */
 int use_reverse_lookup = 0;
-#endif /* !SLAPD_RLOOKUPS */
 
 static char    *fp_getline(FILE *fp, int *lineno);
 static void    fp_getline_init(int *lineno);
@@ -335,6 +335,80 @@ read_config( const char *fname, int depth )
 
                        sockbuf_max_incoming_auth = max;
 
+               /* set conn pending max */
+               } else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) {
+                       long max;
+                       if ( cargc < 2 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG( CONFIG, CRIT, 
+                                  "%s: line %d: missing max in \"conn_max_pending "
+                                  "<requests>\" line\n", fname, lineno, 0 );
+#else
+                               Debug( LDAP_DEBUG_ANY,
+                                          "%s: line %d: missing max in \"conn_max_pending <requests>\" line\n",
+                                   fname, lineno, 0 );
+#endif
+
+                               return( 1 );
+                       }
+
+                       max = atol( cargv[1] );
+
+                       if( max < 0 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG( CONFIG, CRIT, 
+                                          "%s: line %d: invalid max value (%ld) in "
+                                          "\"conn_max_pending <requests>\" line.\n",
+                                          fname, lineno, max );
+#else
+                               Debug( LDAP_DEBUG_ANY,
+                                       "%s: line %d: invalid max value (%ld) in "
+                                       "\"conn_max_pending <requests>\" line.\n",
+                                   fname, lineno, max );
+#endif
+
+                               return( 1 );
+                       }
+
+                       slap_conn_max_pending = max;
+
+               /* set conn pending max authenticated */
+               } else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) {
+                       long max;
+                       if ( cargc < 2 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG( CONFIG, CRIT, 
+                                  "%s: line %d: missing max in \"conn_max_pending_auth "
+                                  "<requests>\" line\n", fname, lineno, 0 );
+#else
+                               Debug( LDAP_DEBUG_ANY,
+                                          "%s: line %d: missing max in \"conn_max_pending_auth <requests>\" line\n",
+                                   fname, lineno, 0 );
+#endif
+
+                               return( 1 );
+                       }
+
+                       max = atol( cargv[1] );
+
+                       if( max < 0 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG( CONFIG, CRIT, 
+                                          "%s: line %d: invalid max value (%ld) in "
+                                          "\"conn_max_pending_auth <requests>\" line.\n",
+                                          fname, lineno, max );
+#else
+                               Debug( LDAP_DEBUG_ANY,
+                                       "%s: line %d: invalid max value (%ld) in "
+                                       "\"conn_max_pending_auth <requests>\" line.\n",
+                                   fname, lineno, max );
+#endif
+
+                               return( 1 );
+                       }
+
+                       slap_conn_max_pending_auth = max;
+
                /* default search base */
                } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
                        if ( cargc < 2 ) {
@@ -959,141 +1033,6 @@ read_config( const char *fname, int depth )
                        ber_bvarray_add( &be->be_suffix, &pdn );
                        ber_bvarray_add( &be->be_nsuffix, &ndn );
 
-               /* set database suffixAlias */
-               } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
-                       Backend *tmp_be;
-                       struct berval alias, palias, nalias;
-                       struct berval aliased, paliased, naliased;
-
-                       if ( cargc < 2 ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG( CONFIG, CRIT, 
-                                       "%s: line %d: missing alias and aliased_dn in "
-                                       "\"suffixAlias <alias> <aliased_dn>\" line.\n",
-                                       fname, lineno, 0 );
-#else
-                               Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d: missing alias and aliased_dn in "
-                                       "\"suffixAlias <alias> <aliased_dn>\" line.\n",
-                                       fname, lineno, 0 );
-#endif
-
-                               return( 1 );
-                       } else if ( cargc < 3 ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG( CONFIG, CRIT, 
-                                       "%s: line %d: missing aliased_dn in "
-                                       "\"suffixAlias <alias> <aliased_dn>\" line\n",
-                                       fname, lineno, 0 );
-#else
-                               Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d: missing aliased_dn in "
-                                       "\"suffixAlias <alias> <aliased_dn>\" line\n",
-                                       fname, lineno, 0 );
-#endif
-                               return( 1 );
-
-                       } else if ( cargc > 3 ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG( CONFIG, CRIT, 
-                                       "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
-                                       fname, lineno, 0 );
-#else
-                               Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
-                                       fname, lineno, 0 );
-#endif
-                       }
-
-                       if ( be == NULL ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG( CONFIG, INFO, 
-                                       "%s: line %d: suffix line must appear inside a database "
-                                       "definition.\n", fname, lineno, 0 );
-#else
-                               Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d: suffixAlias line"
-                                       " must appear inside a database definition.\n",
-                                       fname, lineno, 0 );
-#endif
-                               return 1;
-                       }
-
-                       if ( load_ucdata( NULL ) < 0 ) return 1;
-                       
-                       alias.bv_val = cargv[1];
-                       alias.bv_len = strlen( cargv[1] );
-
-                       rc = dnPrettyNormal( NULL, &alias, &palias, &nalias );
-                       if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG( CONFIG, CRIT, 
-                                       "%s: line %d: alias DN is invalid.\n", fname, lineno, 0 );
-#else
-                               Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d: alias DN is invalid\n",
-                                  fname, lineno, 0 );
-#endif
-                               return( 1 );
-                       }
-
-                       tmp_be = select_backend( &nalias, 0, 0 );
-                       free( nalias.bv_val );
-                       if ( tmp_be && tmp_be != be ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG( CONFIG, INFO, 
-                                       "%s: line %d: suffixAlias served by a preceeding "
-                                       "backend \"%s\"\n", fname, lineno, 
-                                       tmp_be->be_suffix[0].bv_val );
-#else
-                               Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d: suffixAlias served by"
-                                       "  a preceeding backend \"%s\"\n",
-                                       fname, lineno, tmp_be->be_suffix[0].bv_val );
-#endif
-                               free( palias.bv_val );
-                               return -1;
-                       }
-
-                       aliased.bv_val = cargv[2];
-                       aliased.bv_len = strlen( cargv[2] );
-
-                       rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased );
-                       if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG( CONFIG, CRIT, 
-                                       "%s: line %d: aliased DN is invalid.\n", fname, lineno,0 );
-#else
-                               Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d: aliased DN is invalid\n",
-                                  fname, lineno, 0 );
-#endif
-                               free( palias.bv_val );
-                               return( 1 );
-                       }
-
-                       tmp_be = select_backend( &naliased, 0, 0 );
-                       free( naliased.bv_val );
-                       if ( tmp_be && tmp_be != be ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG( CONFIG, INFO, 
-                                       "%s: line %d: suffixAlias derefs to a different backend "
-                                       "a preceeding backend \"%s\"\n",
-                                       fname, lineno, tmp_be->be_suffix[0].bv_val );
-#else
-                               Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d: suffixAlias derefs to differnet backend"
-                                       "  a preceeding backend \"%s\"\n",
-                                       fname, lineno, tmp_be->be_suffix[0].bv_val );
-#endif
-                               free( palias.bv_val );
-                               free( paliased.bv_val );
-                               return -1;
-                       }
-
-                       ber_bvarray_add( &be->be_suffixAlias, &palias ); 
-                       ber_bvarray_add( &be->be_suffixAlias, &paliased );
-
                /* set max deref depth */
                } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
                                        int i;
@@ -1642,7 +1581,19 @@ read_config( const char *fname, int depth )
 
                /* specify an objectclass */
                } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
-                       if ( *cargv[1] == '('  /*')'*/) {
+                       if ( cargc < 2 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG( CONFIG, INFO, 
+                                       "%s: line %d: illegal objectclass format.\n",
+                                       fname, lineno , 0 );
+#else
+                               Debug( LDAP_DEBUG_ANY,
+                                      "%s: line %d: illegal objectclass format.\n",
+                                      fname, lineno, 0 );
+#endif
+                               return( 1 );
+
+                       } else if ( *cargv[1] == '('  /*')'*/) {
                                char * p;
                                p = strchr(saveline,'(' /*')'*/);
                                rc = parse_oc( fname, lineno, p, cargv );
@@ -1672,7 +1623,19 @@ read_config( const char *fname, int depth )
                } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
                        || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
                {
-                       if ( *cargv[1] == '(' /*')'*/) {
+                       if ( cargc < 2 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG( CONFIG, INFO, "%s: line %d: "
+                                       "illegal attribute type format.\n",
+                                       fname, lineno , 0 );
+#else
+                               Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+                                       "illegal attribute type format.\n",
+                                       fname, lineno, 0 );
+#endif
+                               return( 1 );
+
+                       } else if ( *cargv[1] == '(' /*')'*/) {
                                char * p;
                                p = strchr(saveline,'(' /*')'*/);
                                rc = parse_at( fname, lineno, p, cargv );
@@ -2343,12 +2306,12 @@ read_config( const char *fname, int depth )
 #endif
                                return( 1 );
                        }
+#endif /* notdef */
 
                        if ( netscape_plugin( be, fname, lineno, cargc, cargv ) 
                                        != LDAP_SUCCESS ) {
                                return( 1 );
                        }
-#endif /* notdef */
 
 #else /* !defined( LDAP_SLAPI ) */
 #ifdef NEW_LOGGING
@@ -2682,5 +2645,7 @@ config_destroy( )
                free ( slapd_args_file );
        if ( slapd_pid_file )
                free ( slapd_pid_file );
+       if ( default_passwd_hash )
+               free( default_passwd_hash );
        acl_destroy( global_acl, NULL );
 }