X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fmain.c;h=994f9fcfa933c663d6f7dace9eeb927d7df48a6b;hb=3cdba151ad18dba10786fde4464442ddaf67b5fe;hp=8b1ee9c9c6300cd01aef7a657f6ef554e21be8e5;hpb=c3f9d6802712140407ec44723d976e6baad75c1e;p=openldap diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 8b1ee9c9c6..994f9fcfa9 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2006 The OpenLDAP Foundation. + * Copyright 1998-2007 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -98,8 +98,9 @@ const char Versionstr[] = OPENLDAP_PACKAGE " " OPENLDAP_VERSION " Standalone LDAP Server (slapd)"; #endif -#define CHECK_NONE 0x00 -#define CHECK_CONFIG 0x01 +#define CHECK_NONE 0x00 +#define CHECK_CONFIG 0x01 +#define CHECK_LOGLEVEL 0x02 static int check = CHECK_NONE; static int version = 0; @@ -369,6 +370,7 @@ int main( int argc, char **argv ) size_t l; int slapd_pid_file_unlink = 0, slapd_args_file_unlink = 0; + int firstopt = 1; #ifdef CSRIMALLOC FILE *leakfile; @@ -502,8 +504,8 @@ int main( int argc, char **argv ) int level = 0; if ( strcmp( optarg, "?" ) == 0 ) { - rc = loglevel_print( stdout ); - goto destroy; + check |= CHECK_LOGLEVEL; + break; } no_detach = 1; @@ -563,8 +565,8 @@ int main( int argc, char **argv ) case 's': /* set syslog level */ if ( strcmp( optarg, "?" ) == 0 ) { - rc = loglevel_print( stdout ); - goto destroy; + check |= CHECK_LOGLEVEL; + break; } if ( parse_debug_level( optarg, &ldap_syslog, &syslog_unknowns ) ) { @@ -623,6 +625,12 @@ int main( int argc, char **argv ) break; case 'T': + if ( firstopt == 0 ) { + fprintf( stderr, "warning: \"-T %s\" " + "should be the first option.\n", + optarg ); + } + /* try full option string first */ for ( i = 0; tools[i].name; i++ ) { if ( strcmp( optarg, &tools[i].name[4] ) == 0 ) { @@ -653,6 +661,10 @@ unhandled_option:; SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 15 ); goto stop; } + + if ( firstopt ) { + firstopt = 0; + } } ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &slap_debug); @@ -754,6 +766,11 @@ unhandled_option:; syslog_unknowns = NULL; if ( rc ) goto destroy; + } + + if ( check & CHECK_LOGLEVEL ) { + rc = 0; + goto destroy; } if ( check & CHECK_CONFIG ) { @@ -924,6 +941,9 @@ shutdown: rc |= slap_shutdown( NULL ); destroy: + if ( check & CHECK_LOGLEVEL ) { + (void)loglevel_print( stdout ); + } /* remember an error during destroy */ rc |= slap_destroy();