]> git.sur5r.net Git - openldap/commitdiff
revert previous commit(s); clarify usage of "-s" in slapd(8).
authorPierangelo Masarati <ando@openldap.org>
Tue, 20 Dec 2005 08:20:16 +0000 (08:20 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 20 Dec 2005 08:20:16 +0000 (08:20 +0000)
doc/man/man8/slapd.8
servers/slapd/main.c
servers/slapd/proto-slap.h
servers/slapd/slapcommon.c
tests/scripts/defines.sh

index bb55fe7174e4ab86a9743ddc85907f52e877d3a9..ea8cd6e5e228e25b1ce6993f528cdb011afb77b5 100644 (file)
@@ -86,6 +86,10 @@ will not fork or disassociate from the invoking terminal.  Some general
 operation and status messages are printed for any value of \fIdebug\-level\fP.
 \fIdebug\-level\fP is taken as a bit string, with each bit corresponding to a
 different kind of debugging information.  See <ldap.h> for details.
+Comma-separated arrays of friendly names can be specified to select
+debugging output of the corresponding debugging information.
+All the names recognized by the \fIloglevel\fP directive 
+described in \fBslapd.conf\fP(5) are supported.
 Remember that if you turn on packet logging, packets containing bind passwords
 will be output, so if you redirect the log to a logfile, that file should
 be read-protected.
@@ -96,16 +100,11 @@ This option tells
 at what level debugging statements should be logged to the
 .BR syslog (8)
 facility.
-The value can be any of
-"EMERG",
-"ALERT",
-"CRIT",
-"ERR",
-"WARNING",
-"NOTICE",
-"INFO" or
-"DEBUG",
-defaulting to "DEBUG".
+The value "syslog\-level" can be set to any value or combination
+allowed by the "-d" switch.
+Slapd logs all messages selected by "syslog\-level" 
+at the syslog(3) severity level "DEBUG",
+on the unit specified with "-l".
 .TP
 .BI \-n " service\-name"
 Specifies the service name for logging and other purposes.  Defaults
@@ -128,6 +127,7 @@ However, this option is only permitted on systems that support
 local users with the 
 .BR syslog (8)
 facility.
+Logging to syslog(8) occurs at the "DEBUG" severity level.
 .TP
 .BI \-f " slapd\-config\-file"
 Specifies the slapd configuration file. The default is
index bd58a36edc733577bc2d78c27bd7a1fd0497f899..4d48c2bed092c61567e353e32e6f4b77406431b0 100644 (file)
@@ -185,6 +185,91 @@ struct option_helper {
        { BER_BVNULL, 0, NULL, NULL }
 };
 
+/* (yet) unused */
+#if 0
+static int
+parse_syslog_level( const char *arg )
+{
+       if ( !isdigit( arg[ 0 ] ) ) {
+               slap_verbmasks  str2syslog_level[] = {
+                       { BER_BVC( "EMERG" ),   LOG_EMERG },
+                       { BER_BVC( "ALERT" ),   LOG_ALERT },
+                       { BER_BVC( "CRIT" ),    LOG_CRIT },
+                       { BER_BVC( "ERR" ),     LOG_ERR },
+                       { BER_BVC( "WARNING" ), LOG_WARNING },
+                       { BER_BVC( "NOTICE" ),  LOG_NOTICE },
+                       { BER_BVC( "INFO" ),    LOG_INFO },
+                       { BER_BVC( "DEBUG" ),   LOG_DEBUG },
+                       { BER_BVNULL, 0 }
+               };
+               int i = verb_to_mask( arg, str2syslog_level );
+               if ( BER_BVISNULL( &str2syslog_level[ i ].word ) ) {
+                       Debug( LDAP_DEBUG_ANY,
+                               "unknown syslog level \"%s\".\n",
+                               arg, 0, 0 );
+                       return 1;
+               }
+               
+               ldap_syslog_level = str2syslog_level[ i ].mask;
+
+       } else if ( lutil_atoi( &ldap_syslog_level, arg ) != 0 ) {
+               Debug( LDAP_DEBUG_ANY,
+                       "unable to parse syslog level \"%s\".\n",
+                       arg, 0, 0 );
+               return 1;
+       }
+
+       return 0;
+}
+#endif
+
+int
+parse_debug_level( const char *arg, int *levelp )
+{
+       int     level;
+
+       if ( arg != NULL && arg[ 0 ] != '-' && !isdigit( arg[ 0 ] ) )
+       {
+               int     i, goterr = 0;
+               char    **levels;
+
+               levels = ldap_str2charray( arg, "," );
+
+               for ( i = 0; levels[ i ] != NULL; i++ ) {
+                       level = 0;
+
+                       if ( str2loglevel( levels[ i ], &level ) ) {
+                               fprintf( stderr,
+                                       "unrecognized log level "
+                                       "\"%s\"\n", levels[ i ] );
+                               goterr = 1;
+                               /* but keep parsing... */
+
+                       } else {
+                               *levelp |= level;
+                       }
+               }
+
+               ldap_charray_free( levels );
+
+               if ( goterr ) {
+                       return 1;
+               }
+
+       } else {
+               if ( lutil_atoix( &level, arg, 0 ) != 0 ) {
+                       fprintf( stderr,
+                               "unrecognized log level "
+                               "\"%s\"\n", arg );
+                       return 1;
+               }
+
+               *levelp |= level;
+       }
+
+       return 0;
+}
+
 static void
 usage( char *name )
 {
@@ -395,46 +480,13 @@ int main( int argc, char **argv )
                        int     level = 0;
 
                        no_detach = 1;
-#ifdef LDAP_DEBUG
-                       if ( optarg != NULL && optarg[ 0 ] != '-' && !isdigit( optarg[ 0 ] ) )
-                       {
-                               int     i, goterr = 0;
-                               char    **levels;
-
-                               levels = ldap_str2charray( optarg, "," );
-
-                               for ( i = 0; levels[ i ] != NULL; i++ ) {
-                                       level = 0;
-
-                                       if ( str2loglevel( levels[ i ], &level ) ) {
-                                               fprintf( stderr,
-                                                       "unrecognized log level "
-                                                       "\"%s\"\n", levels[ i ] );
-                                               goterr = 1;
-                                               /* but keep parsing... */
-
-                                       } else {
-                                               slap_debug |= level;
-                                       }
-                               }
-
-                               ldap_charray_free( levels );
-
-                               if ( goterr ) {
-                                       goto destroy;
-                               }
-
-                       } else {
-                               if ( lutil_atoix( &level, optarg, 0 ) != 0 ) {
-                                       fprintf( stderr,
-                                               "unrecognized log level "
-                                               "\"%s\"\n", optarg );
-                                       goto destroy;
-                               }
-                               slap_debug |= level;
+                       if ( parse_debug_level( optarg, &level ) ) {
+                               goto destroy;
                        }
+#ifdef LDAP_DEBUG
+                       slap_debug |= level;
 #else
-                       if ( lutil_atoi( &level, optarg ) != 0 || level != 0 )
+                       if ( level != 0 )
                                fputs( "must compile with LDAP_DEBUG for debugging\n",
                                       stderr );
 #endif
@@ -483,32 +535,7 @@ int main( int argc, char **argv )
                }
 
                case 's':       /* set syslog level */
-                       if ( !isdigit( optarg[ 0 ] ) ) {
-                               slap_verbmasks  str2syslog_level[] = {
-                                       { BER_BVC( "EMERG" ),   LOG_EMERG },
-                                       { BER_BVC( "ALERT" ),   LOG_ALERT },
-                                       { BER_BVC( "CRIT" ),    LOG_CRIT },
-                                       { BER_BVC( "ERR" ),     LOG_ERR },
-                                       { BER_BVC( "WARNING" ), LOG_WARNING },
-                                       { BER_BVC( "NOTICE" ),  LOG_NOTICE },
-                                       { BER_BVC( "INFO" ),    LOG_INFO },
-                                       { BER_BVC( "DEBUG" ),   LOG_DEBUG },
-                                       { BER_BVNULL, 0 }
-                               };
-                               int i = verb_to_mask( optarg, str2syslog_level );
-                               if ( BER_BVISNULL( &str2syslog_level[ i ].word ) ) {
-                                       Debug( LDAP_DEBUG_ANY,
-                                               "unknown syslog level \"%s\".\n",
-                                               optarg, 0, 0 );
-                                       goto destroy;
-                               }
-               
-                               ldap_syslog_level = str2syslog_level[ i ].mask;
-
-                       } else if ( lutil_atoi( &ldap_syslog_level, optarg ) != 0 ) {
-                               Debug( LDAP_DEBUG_ANY,
-                                       "unable to parse syslog level \"%s\".\n",
-                                       optarg, 0, 0 );
+                       if ( parse_debug_level( optarg, &ldap_syslog ) ) {
                                goto destroy;
                        }
                        break;
index 0b0fd90cf0083a9f6b722cec7e3e0beae65feda4..ab6fda8196a9434d0e854c66ccd7d0ea9630fd06 100644 (file)
@@ -1005,6 +1005,12 @@ LDAP_SLAPD_F (FILE *) lock_fopen LDAP_P(( const char *fname,
        const char *type, FILE **lfp ));
 LDAP_SLAPD_F (int) lock_fclose LDAP_P(( FILE *fp, FILE *lfp ));
 
+/*
+ * main.c
+ */
+LDAP_SLAPD_F (int)
+parse_debug_level LDAP_P(( const char *arg, int *levelp ));
+
 /*
  * matchedValues.c
  */
index 6fc5afed39d6588a8f31b246ecd91a49e93fa2fe..96aad01bce318573c71de824d6ef75b59e71d49c 100644 (file)
@@ -267,59 +267,19 @@ slap_tool_init(
                case 'd': {     /* turn on debugging */
                        int     level = 0;
 
+                       if ( parse_debug_level( optarg, &level ) ) {
+                               usage( tool, progname );
+                       }
 #ifdef LDAP_DEBUG
-                       if ( optarg != NULL && optarg[ 0 ] != '-' && !isdigit( optarg[ 0 ] ) )
-                       {
-                               int     i, goterr = 0;
-                               char    **levels;
-
-                               levels = ldap_str2charray( optarg, "," );
-
-                               for ( i = 0; levels[ i ] != NULL; i++ ) {
-                                       level = 0;
-
-                                       if ( str2loglevel( levels[ i ], &level ) ) {
-                                               fprintf( stderr,
-                                                       "unrecognized log level "
-                                                       "\"%s\"\n", levels[ i ] );
-                                               goterr = 1;
-                                               /* but keep parsing... */
-
-                                       } else {
-                                               if ( level != 0 ) {
-                                                       slap_debug |= level;
-
-                                               } else {
-                                                       /* allow to reset log level */
-                                                       slap_debug = 0;
-                                               }
-                                       }
-                               }
-
-                               ldap_charray_free( levels );
-
-                               if ( goterr ) {
-                                       usage( tool, progname );
-                               }
+                       if ( level == 0 ) {
+                               /* allow to reset log level */
+                               slap_debug = 0;
 
                        } else {
-                               if ( lutil_atoix( &level, optarg, 0 ) != 0 ) {
-                                       fprintf( stderr,
-                                               "unrecognized log level "
-                                               "\"%s\"\n", optarg );
-                                       usage( tool, progname );
-                               }
-
-                               if ( level != 0 ) {
-                                       slap_debug |= level;
-
-                               } else {
-                                       /* allow to reset log level */
-                                       slap_debug = 0;
-                               }
+                               slap_debug |= level;
                        }
 #else
-                       if ( lutil_atoi( &level, optarg ) != 0 || level != 0 )
+                       if ( level != 0 )
                                fputs( "must compile with LDAP_DEBUG for debugging\n",
                                       stderr );
 #endif
index 58a33bc1e665643e2e367b387ffe867411275812..170b23a720d8bbfa0896335a11660f5bf4d9a65a 100755 (executable)
@@ -137,7 +137,7 @@ DIFF="diff -i"
 CMP="diff -i"
 BCMP="diff -iB"
 CMPOUT=/dev/null
-SLAPD="../servers/slapd/slapd -sDEBUG"
+SLAPD="../servers/slapd/slapd -s0"
 SLURPD=../servers/slurpd/slurpd
 LDAPPASSWD="$CLIENTDIR/ldappasswd $TOOLARGS"
 LDAPSASLSEARCH="$CLIENTDIR/ldapsearch $TOOLPROTO $LDAP_TOOLARGS -LLL"