/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2006 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 2003 IBM Corporation.
* All rights reserved.
static LDIFFP dummy;
-#ifdef LDAP_SYSLOG
+#if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
int start_syslog;
static char **syslog_unknowns;
#ifdef LOG_LOCAL4
static int syslogUser = SLAP_DEFAULT_SYSLOG_USER;
#endif /* LOG_LOCAL4 */
-#endif /* LDAP_SYSLOG */
+#endif /* LDAP_DEBUG && LDAP_SYSLOG */
static void
usage( int tool, const char *progname )
case SLAPADD:
options = " [-c]\n\t[-g] [-n databasenumber | -b suffix]\n"
- "\t[-l ldiffile] [-q] [-u] [-s] [-w]\n";
+ "\t[-l ldiffile] [-j linenumber] [-q] [-u] [-s] [-w]\n";
break;
case SLAPAUTH:
break;
case SLAPINDEX:
- options = " [-c]\n\t[-g] [-n databasenumber | -b suffix] [-q]\n";
+ options = " [-c]\n\t[-g] [-n databasenumber | -b suffix] [attr ...] [-q]\n";
break;
case SLAPTEST:
} else if ( strncasecmp( optarg, "authzDN", len ) == 0 ) {
ber_str2bv( p, 0, 1, &authzDN );
-#ifdef LDAP_SYSLOG
+#if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
} else if ( strncasecmp( optarg, "syslog", len ) == 0 ) {
if ( parse_debug_level( p, &ldap_syslog, &syslog_unknowns ) ) {
return -1;
}
start_syslog = 1;
#endif /* LOG_LOCAL4 */
-#endif /* LDAP_SYSLOG */
+#endif /* LDAP_DEBUG && LDAP_SYSLOG */
} else {
return -1;
switch( tool ) {
case SLAPADD:
- options = "b:cd:f:F:gl:n:o:qstuvw";
+ options = "b:cd:f:F:gj:l:n:o:qsS:tuvw";
break;
case SLAPCAT:
break;
case SLAPTEST:
- options = "d:f:F:o:uv";
+ options = "d:f:F:o:Quv";
mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
break;
while ( (i = getopt( argc, argv, options )) != EOF ) {
switch ( i ) {
case 'a':
- filterstr = strdup( optarg );
+ filterstr = ch_strdup( optarg );
break;
case 'b':
break;
case 'f': /* specify a conf file */
- conffile = strdup( optarg );
+ conffile = ch_strdup( optarg );
break;
case 'F': /* specify a conf dir */
- confdir = strdup( optarg );
+ confdir = ch_strdup( optarg );
break;
case 'g': /* disable subordinate glue */
use_glue = 0;
break;
+ case 'j': /* jump to linenumber */
+ if ( lutil_atoi( &jumpline, optarg ) ) {
+ usage( tool, progname );
+ }
+ break;
+
case 'l': /* LDIF file */
- ldiffile = strdup( optarg );
+ ldiffile = ch_strdup( optarg );
break;
case 'M':
dn_mode = SLAP_TOOL_LDAPDN_PRETTY;
break;
+ case 'Q':
+ quiet++;
+ slap_debug = 0;
+ break;
+
case 'q': /* turn on quick */
mode |= SLAP_TOOL_QUICK;
break;
realm = optarg;
break;
+ case 'S':
+ if ( lutil_atoul( &csnsid, optarg )
+ || csnsid > SLAP_SYNC_SID_MAX )
+ {
+ usage( tool, progname );
+ }
+ break;
+
case 's': /* dump subtree */
if ( tool == SLAPADD )
mode |= SLAP_TOOL_NO_SCHEMA_CHECK;
else if ( tool == SLAPCAT )
- subtree = strdup( optarg );
+ subtree = ch_strdup( optarg );
break;
case 't': /* turn on truncate */
}
}
-#ifdef LDAP_SYSLOG
+#if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
if ( start_syslog ) {
char *logName;
#ifdef HAVE_EBCDIC
#ifdef LOG_LOCAL4
openlog( logName, OPENLOG_OPTIONS, syslogUser );
-#elif LOG_DEBUG
+#elif defined LOG_DEBUG
openlog( logName, OPENLOG_OPTIONS );
#endif
#ifdef HAVE_EBCDIC
free( logName );
#endif
}
-#endif /* LDAP_SYSLOG */
+#endif /* LDAP_DEBUG && LDAP_SYSLOG */
switch ( tool ) {
case SLAPADD:
case SLAPCAT:
- case SLAPINDEX:
if ( ( argc != optind ) || (dbnum >= 0 && base.bv_val != NULL ) ) {
usage( tool, progname );
}
break;
+ case SLAPINDEX:
+ if ( dbnum >= 0 && base.bv_val != NULL ) {
+ usage( tool, progname );
+ }
+
+ break;
+
case SLAPDN:
if ( argc == optind ) {
usage( tool, progname );
exit( EXIT_FAILURE );
}
+#if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
if ( syslog_unknowns ) {
rc = parse_debug_unknowns( syslog_unknowns, &ldap_syslog );
ldap_charray_free( syslog_unknowns );
if ( rc )
exit( EXIT_FAILURE );
}
+#endif
at_oc_cache = 1;
exit( EXIT_FAILURE );
}
- be = select_backend( &nbase, 0, 0 );
+ be = select_backend( &nbase, 0 );
ber_memfree( nbase.bv_val );
switch ( tool ) {
if ( !BER_BVISNULL( &authcDN ) ) {
ch_free( authcDN.bv_val );
}
+
+ if ( ldiffp && ldiffp != &dummy ) {
+ ldif_close( ldiffp );
+ }
}