X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fslapcommon.c;h=a1d8c0d9d819d92a9324a15dd299b9a0287eabc6;hb=f3c2c7ba48e67468e4052cea4699ffabad59a741;hp=bbdb5bb3e3556b8c5aa6f35df750c4682ef5177d;hpb=4a1eabf257473d8eadf0c14d72d77a83e73ff09d;p=openldap diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index bbdb5bb3e3..a1d8c0d9d8 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2005 The OpenLDAP Foundation. + * Copyright 1998-2006 The OpenLDAP Foundation. * Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 2003 IBM Corporation. * All rights reserved. @@ -62,8 +62,8 @@ usage( int tool, const char *progname ) break; case SLAPADD: - options = " [-c]\n\t[-n databasenumber | -b suffix]\n" - "\t[-l ldiffile] [-q] [-u] [-w]\n"; + options = " [-c]\n\t[-g] [-n databasenumber | -b suffix]\n" + "\t[-l ldiffile] [-q] [-u] [-s] [-w]\n"; break; case SLAPAUTH: @@ -71,7 +71,7 @@ usage( int tool, const char *progname ) break; case SLAPCAT: - options = " [-c]\n\t[-n databasenumber | -b suffix]" + options = " [-c]\n\t[-g] [-n databasenumber | -b suffix]" " [-l ldiffile] [-a filter]\n"; break; @@ -80,7 +80,7 @@ usage( int tool, const char *progname ) break; case SLAPINDEX: - options = " [-c]\n\t[-n databasenumber | -b suffix] [-q]\n"; + options = " [-c]\n\t[-g] [-n databasenumber | -b suffix] [-q]\n"; break; case SLAPTEST: @@ -133,16 +133,28 @@ parse_slapacl( void ) ber_str2bv( p, 0, 1, &sock_name ); } else if ( strncasecmp( optarg, "ssf", len ) == 0 ) { - ssf = atoi( p ); + if ( lutil_atou( &ssf, p ) ) { + Debug( LDAP_DEBUG_ANY, "unable to parse ssf=\"%s\".\n", p, 0, 0 ); + return -1; + } } else if ( strncasecmp( optarg, "transport_ssf", len ) == 0 ) { - transport_ssf = atoi( p ); + if ( lutil_atou( &transport_ssf, p ) ) { + Debug( LDAP_DEBUG_ANY, "unable to parse transport_ssf=\"%s\".\n", p, 0, 0 ); + return -1; + } } else if ( strncasecmp( optarg, "tls_ssf", len ) == 0 ) { - tls_ssf = atoi( p ); + if ( lutil_atou( &tls_ssf, p ) ) { + Debug( LDAP_DEBUG_ANY, "unable to parse tls_ssf=\"%s\".\n", p, 0, 0 ); + return -1; + } } else if ( strncasecmp( optarg, "sasl_ssf", len ) == 0 ) { - sasl_ssf = atoi( p ); + if ( lutil_atou( &sasl_ssf, p ) ) { + Debug( LDAP_DEBUG_ANY, "unable to parse sasl_ssf=\"%s\".\n", p, 0, 0 ); + return -1; + } } else if ( strncasecmp( optarg, "authzDN", len ) == 0 ) { ber_str2bv( p, 0, 1, &authzDN ); @@ -162,6 +174,8 @@ parse_slapacl( void ) * argc, argv command line arguments */ +static int need_shutdown; + void slap_tool_init( const char* progname, @@ -178,6 +192,13 @@ slap_tool_init( int rc, i, dbnum; int mode = SLAP_TOOL_MODE; int truncatemode = 0; + int use_glue = 1; + +#ifdef LDAP_DEBUG + /* tools default to "none", so that at least LDAP_DEBUG_ANY + * messages show up; use -d 0 to reset */ + slap_debug = LDAP_DEBUG_NONE; +#endif #ifdef CSRIMALLOC leakfilename = malloc( strlen( progname ) + STRLENOF( ".leak" ) + 1 ); @@ -190,11 +211,11 @@ slap_tool_init( switch( tool ) { case SLAPADD: - options = "b:cd:f:F:l:n:qtuvw"; + options = "b:cd:f:F:gl:n:qstuvw"; break; case SLAPCAT: - options = "a:b:cd:f:F:l:n:s:v"; + options = "a:b:cd:f:F:gl:n:s:v"; mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY; break; @@ -214,7 +235,7 @@ slap_tool_init( break; case SLAPINDEX: - options = "b:cd:f:F:n:qv"; + options = "b:cd:f:F:gn:qv"; mode |= SLAP_TOOL_READMAIN; break; @@ -243,9 +264,26 @@ slap_tool_init( continuemode++; break; - case 'd': /* turn on debugging */ - ldap_debug += atoi( optarg ); - break; + case 'd': { /* turn on debugging */ + int level = 0; + + if ( parse_debug_level( optarg, &level ) ) { + usage( tool, progname ); + } +#ifdef LDAP_DEBUG + if ( level == 0 ) { + /* allow to reset log level */ + slap_debug = 0; + + } else { + slap_debug |= level; + } +#else + if ( level != 0 ) + fputs( "must compile with LDAP_DEBUG for debugging\n", + stderr ); +#endif + } break; case 'D': ber_str2bv( optarg, 0, 1, &authcDN ); @@ -259,6 +297,10 @@ slap_tool_init( confdir = strdup( optarg ); break; + case 'g': /* disable subordinate glue */ + use_glue = 0; + break; + case 'l': /* LDIF file */ ldiffile = strdup( optarg ); break; @@ -275,7 +317,9 @@ slap_tool_init( break; case 'n': /* which config file db to index */ - dbnum = atoi( optarg ); + if ( lutil_atoi( &dbnum, optarg ) ) { + usage( tool, progname ); + } break; case 'o': @@ -300,7 +344,10 @@ slap_tool_init( break; case 's': /* dump subtree */ - subtree = strdup( optarg ); + if ( tool == SLAPADD ) + mode |= SLAP_TOOL_NO_SCHEMA_CHECK; + else if ( tool == SLAPCAT ) + subtree = strdup( optarg ); break; case 't': /* turn on truncate */ @@ -424,11 +471,14 @@ slap_tool_init( break; } - rc = glue_sub_init(); + if ( use_glue ) { + rc = glue_sub_attach(); - if ( rc != 0 ) { - fprintf( stderr, "%s: subordinate configuration error\n", progname ); - exit( EXIT_FAILURE ); + if ( rc != 0 ) { + fprintf( stderr, + "%s: subordinate configuration error\n", progname ); + exit( EXIT_FAILURE ); + } } rc = slap_schema_check(); @@ -578,6 +628,8 @@ startup:; /* slapdn doesn't specify a backend to startup */ if ( !dryrun && tool != SLAPDN && slap_startup( be ) ) { + need_shutdown = 1; + switch ( tool ) { case SLAPTEST: fprintf( stderr, "slap_startup failed " @@ -597,7 +649,9 @@ startup:; void slap_tool_destroy( void ) { if ( !dryrun ) { - slap_shutdown( be ); + if ( need_shutdown ) { + slap_shutdown( be ); + } slap_destroy(); } #ifdef SLAPD_MODULES