X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslurpd%2Fconfig.c;h=ad78eda888aad82ef5b6c829c12e6ea08cf11969;hb=71dfd57e75a98d02c26ec823554035e5feae1675;hp=bd47c26a61348ca92c9301008c6648510f4afd9e;hpb=2ca323d2b52d259feab620e984ad1150cca796f3;p=openldap diff --git a/servers/slurpd/config.c b/servers/slurpd/config.c index bd47c26a61..ad78eda888 100644 --- a/servers/slurpd/config.c +++ b/servers/slurpd/config.c @@ -1,10 +1,20 @@ /* $OpenLDAP$ */ -/* - * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2003 The OpenLDAP Foundation. + * Portions Copyright 2003 Mark Benson. + * Portions Copyright 2002 John Morrissey. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . */ -/* - * Copyright (c) 1996 Regents of the University of Michigan. +/* Portions Copyright (c) 1996 Regents of the University of Michigan. * All rights reserved. * * Redistribution and use in source and binary forms are permitted @@ -14,6 +24,13 @@ * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. */ +/* ACKNOWLEDGEMENTS: + * This work was originally developed by the University of Michigan + * (as part of U-MICH LDAP). Additional signficant contributors + * include: + * John Morrissey + * Mark Benson + */ /* @@ -48,7 +65,8 @@ char **cargv; /* current config file line # */ static int lineno; - +char *slurpd_pid_file = NULL; +char *slurpd_args_file = NULL; /* * Read the slapd config file, looking only for config options we're @@ -63,12 +81,15 @@ slurpd_read_config( FILE *fp; char *line; + if ( cargv == NULL ) { cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) ); cargv_size = ARGS_STEP + 1; + } #ifdef NEW_LOGGING - LDAP_LOG (( "config", LDAP_LEVEL_ARGS, - "slurpd_read_config: Config: opening config file \"%s\"\n", fname )); + LDAP_LOG ( CONFIG, ARGS, + "slurpd_read_config: Config: opening config file \"%s\"\n", + fname, 0, 0 ); #else Debug( LDAP_DEBUG_CONFIG, "Config: opening config file \"%s\"\n", fname, 0, 0 ); @@ -87,8 +108,8 @@ slurpd_read_config( } #ifdef NEW_LOGGING - LDAP_LOG (( "config", LDAP_LEVEL_DETAIL1, - "slurpd_read_config: Config: (%s)\n", line )); + LDAP_LOG ( CONFIG, DETAIL1, + "slurpd_read_config: Config: (%s)\n", line, 0, 0 ); #else Debug( LDAP_DEBUG_CONFIG, "Config: (%s)\n", line, 0, 0 ); #endif @@ -132,9 +153,9 @@ slurpd_read_config( if ( cargc < 2 ) { #ifdef NEW_LOGGING - LDAP_LOG(( "config", LDAP_LEVEL_CRIT, + LDAP_LOG( CONFIG, CRIT, "%s: line %d: missing filename in \"include " - "\" line.\n", fname, lineno )); + "\" line.\n", fname, lineno , 0 ); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: missing filename in \"include \" line\n", @@ -152,13 +173,48 @@ slurpd_read_config( free( savefname ); lineno = savelineno - 1; + + } else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) { + if ( cargc < 2 ) { +#ifdef NEW_LOGGING + LDAP_LOG( CONFIG, CRIT, + "%s: line %d missing file name in \"replica-pidfile \" " + "line.\n", fname, lineno, 0 ); +#else + Debug( LDAP_DEBUG_ANY, + "%s: line %d: missing file name in \"replica-pidfile \" line\n", + fname, lineno, 0 ); +#endif + + return( 1 ); + } + + slurpd_pid_file = ch_strdup( cargv[1] ); + + } else if ( strcasecmp( cargv[0], "replica-argsfile" ) == 0 ) { + if ( cargc < 2 ) { +#ifdef NEW_LOGGING + LDAP_LOG( CONFIG, CRIT, + "%s: %d: missing file name in " + "\"argsfile \" line.\n", + fname, lineno, 0 ); +#else + Debug( LDAP_DEBUG_ANY, + "%s: line %d: missing file name in \"argsfile \" line\n", + fname, lineno, 0 ); +#endif + + return( 1 ); + } + + slurpd_args_file = ch_strdup( cargv[1] ); } } fclose( fp ); #ifdef NEW_LOGGING - LDAP_LOG (( "config", LDAP_LEVEL_RESULTS, + LDAP_LOG ( CONFIG, RESULTS, "slurpd_read_config: Config: " - "** configuration file successfully read and parsed\n" )); + "** configuration file successfully read and parsed\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_CONFIG, "Config: ** configuration file successfully read and parsed\n", @@ -344,11 +400,11 @@ add_replica( sglob->num_replicas--; } else { #ifdef NEW_LOGGING - LDAP_LOG (( "config", LDAP_LEVEL_RESULTS, + LDAP_LOG ( CONFIG, RESULTS, "add_replica: Config: ** successfully added replica \"%s%d\"\n", sglob->replicas[ nr - 1 ]->ri_hostname == NULL ? "(null)" : sglob->replicas[ nr - 1 ]->ri_hostname, - sglob->replicas[ nr - 1 ]->ri_port, 0 )); + sglob->replicas[ nr - 1 ]->ri_port, 0 ); #else Debug( LDAP_DEBUG_CONFIG, "Config: ** successfully added replica \"%s:%d\"\n", @@ -405,9 +461,16 @@ parse_replica_line( int gots = 0; int i; char *hp, *val; + LDAPURLDesc *ludp; for ( i = 1; i < cargc; i++ ) { if ( !strncasecmp( cargv[ i ], HOSTSTR, sizeof( HOSTSTR ) - 1 ) ) { + if ( gots & GOT_HOST ) { + fprintf( stderr, "Error: Malformed \"replica\" line in slapd config " ); + fprintf( stderr, "file, too many host or uri names specified, line %d\n", + lineno ); + return -1; + } val = cargv[ i ] + sizeof( HOSTSTR ); /* '\0' string terminator accounts for '=' */ if (( hp = strchr( val, ':' )) != NULL ) { *hp = '\0'; @@ -419,15 +482,46 @@ parse_replica_line( } ri->ri_hostname = strdup( val ); gots |= GOT_HOST; + } else if ( !strncasecmp( cargv[ i ], URISTR, sizeof( URISTR ) - 1 ) ) { + if ( gots & GOT_HOST ) { + fprintf( stderr, "Error: Malformed \"replica\" line in slapd config " ); + fprintf( stderr, "file, too many host or uri names specified, line %d\n", + lineno ); + return -1; + } + if ( ldap_url_parse( cargv[ i ] + sizeof( URISTR ), &ludp ) != LDAP_SUCCESS ) { + fprintf( stderr, "Error: Malformed \"replica\" line in slapd config " ); + fprintf( stderr, "file, bad uri format specified, line %d\n", + lineno ); + return -1; + } + if (ludp->lud_host == NULL) { + fprintf( stderr, "Error: Malformed \"replica\" line in slapd config " ); + fprintf( stderr, "file, missing uri hostname, line %d\n", + lineno ); + return -1; + } + ri->ri_hostname = strdup ( ludp->lud_host ); + ri->ri_port = ludp->lud_port; + ri->ri_uri = strdup ( cargv[ i ] + sizeof( URISTR ) ); + ldap_free_urldesc( ludp ); + gots |= GOT_HOST; } else if ( !strncasecmp( cargv[ i ], ATTRSTR, sizeof( ATTRSTR ) - 1 ) ) { /* ignore it */ ; } else if ( !strncasecmp( cargv[ i ], SUFFIXSTR, sizeof( SUFFIXSTR ) - 1 ) ) { /* ignore it */ ; + } else if ( !strncasecmp( cargv[i], STARTTLSSTR, sizeof(STARTTLSSTR)-1 )) { + val = cargv[ i ] + sizeof( STARTTLSSTR ); + if( !strcasecmp( val, CRITICALSTR ) ) { + ri->ri_tls = TLS_CRITICAL; + } else { + ri->ri_tls = TLS_ON; + } } else if ( !strncasecmp( cargv[ i ], TLSSTR, sizeof( TLSSTR ) - 1 ) ) { val = cargv[ i ] + sizeof( TLSSTR ); - if( !strcasecmp( val, TLSCRITICALSTR ) ) { + if( !strcasecmp( val, CRITICALSTR ) ) { ri->ri_tls = TLS_CRITICAL; } else { ri->ri_tls = TLS_ON; @@ -446,10 +540,10 @@ parse_replica_line( fprintf( stderr, "slurpd no longer supports Kerberos.\n" ); exit( EXIT_FAILURE ); } else if ( !strcasecmp( val, SIMPLESTR )) { - ri->ri_bind_method = AUTH_SIMPLE; + ri->ri_bind_method = LDAP_AUTH_SIMPLE; gots |= GOT_METHOD; } else if ( !strcasecmp( val, SASLSTR )) { - ri->ri_bind_method = AUTH_SASL; + ri->ri_bind_method = LDAP_AUTH_SASL; gots |= GOT_METHOD; } else { ri->ri_bind_method = -1; @@ -498,14 +592,13 @@ parse_replica_line( } } - if ( ri->ri_bind_method == AUTH_SASL) { + if ( ri->ri_bind_method == LDAP_AUTH_SASL) { if ((gots & GOT_MECH) == 0) { fprintf( stderr, "Error: \"replica\" line needs SASLmech flag in " ); fprintf( stderr, "slapd config file, line %d\n", lineno ); return -1; } - } - else if ( gots != GOT_ALL ) { + } else if ( gots != GOT_ALL ) { fprintf( stderr, "Error: Malformed \"replica\" line in slapd " ); fprintf( stderr, "config file, line %d\n", lineno ); return -1;