- /* require these features */
- } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
- strcasecmp( cargv[0], "require" ) == 0 )
- {
- slap_mask_t requires;
-
- if ( cargc < 2 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: missing feature(s) in "
- "\"require <features>\" line.\n", fname, lineno ,0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: missing feature(s) in \"require <features>\" line\n",
- fname, lineno, 0 );
-#endif
-
- return( 1 );
- }
-
- requires = 0;
-
- for( i=1; i < cargc; i++ ) {
- if( strcasecmp( cargv[i], "bind" ) == 0 ) {
- requires |= SLAP_REQUIRE_BIND;
-
- } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
- requires |= SLAP_REQUIRE_LDAP_V3;
-
- } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
- requires |= SLAP_REQUIRE_AUTHC;
-
- } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
- requires |= SLAP_REQUIRE_SASL;
-
- } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
- requires |= SLAP_REQUIRE_STRONG;
-
- } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: unknown feature %s in "
- "\"require <features>\" line.\n",
- fname, lineno , cargv[i] );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: unknown feature %s in \"require <features>\" line\n",
- fname, lineno, cargv[i] );
-#endif
-
- return( 1 );
- }
- }
-
- if ( be == NULL ) {
- global_requires = requires;
- } else {
- be->be_requires = requires;
- }
-
- /* required security factors */
- } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
- slap_ssf_set_t *set;
-
- if ( cargc < 2 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: missing factor(s) in \"security <factors>\""
- " line.\n", fname, lineno ,0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
- fname, lineno, 0 );
-#endif
-
- return( 1 );
- }
-
- if ( be == NULL ) {
- set = &global_ssf_set;
- } else {
- set = &be->be_ssf_set;
- }
-
- for( i=1; i < cargc; i++ ) {
- if( strncasecmp( cargv[i], "ssf=",
- sizeof("ssf") ) == 0 )
- {
- set->sss_ssf =
- atoi( &cargv[i][sizeof("ssf")] );
-
- } else if( strncasecmp( cargv[i], "transport=",
- sizeof("transport") ) == 0 )
- {
- set->sss_transport =
- atoi( &cargv[i][sizeof("transport")] );
-
- } else if( strncasecmp( cargv[i], "tls=",
- sizeof("tls") ) == 0 )
- {
- set->sss_tls =
- atoi( &cargv[i][sizeof("tls")] );
-
- } else if( strncasecmp( cargv[i], "sasl=",
- sizeof("sasl") ) == 0 )
- {
- set->sss_sasl =
- atoi( &cargv[i][sizeof("sasl")] );
-
- } else if( strncasecmp( cargv[i], "update_ssf=",
- sizeof("update_ssf") ) == 0 )
- {
- set->sss_update_ssf =
- atoi( &cargv[i][sizeof("update_ssf")] );
-
- } else if( strncasecmp( cargv[i], "update_transport=",
- sizeof("update_transport") ) == 0 )
- {
- set->sss_update_transport =
- atoi( &cargv[i][sizeof("update_transport")] );
-
- } else if( strncasecmp( cargv[i], "update_tls=",
- sizeof("update_tls") ) == 0 )
- {
- set->sss_update_tls =
- atoi( &cargv[i][sizeof("update_tls")] );
-
- } else if( strncasecmp( cargv[i], "update_sasl=",
- sizeof("update_sasl") ) == 0 )
- {
- set->sss_update_sasl =
- atoi( &cargv[i][sizeof("update_sasl")] );
-
- } else if( strncasecmp( cargv[i], "simple_bind=",
- sizeof("simple_bind") ) == 0 )
- {
- set->sss_simple_bind =
- atoi( &cargv[i][sizeof("simple_bind")] );
-
- } else {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: unknown factor %S in "
- "\"security <factors>\" line.\n",
- fname, lineno, cargv[1] );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
- fname, lineno, cargv[i] );
-#endif
-
- return( 1 );
- }
- }
- /* where to send clients when we don't hold it */
- } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
- if ( cargc < 2 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: missing URL in \"referral <URL>\""
- " line.\n", fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: missing URL in \"referral <URL>\" line\n",
- fname, lineno, 0 );
-#endif
-
- return( 1 );
- }
-
- if( validate_global_referral( cargv[1] ) ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
- fname, lineno, cargv[1] );
-#else
- Debug( LDAP_DEBUG_ANY, "%s: line %d: "
- "invalid URL (%s) in \"referral\" line.\n",
- fname, lineno, cargv[1] );
-#endif
- return 1;
- }
-
- vals[0].bv_val = cargv[1];
- vals[0].bv_len = strlen( vals[0].bv_val );
- if( value_add( &default_referral, vals ) )
- return LDAP_OTHER;
-
-#ifdef NEW_LOGGING
- } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
- FILE *logfile;
- if ( cargc < 2 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: Error in logfile directive, "
- "\"logfile <filename>\"\n", fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
- fname, lineno, 0 );
-#endif
-
- return( 1 );
- }
- logfile = fopen( cargv[1], "w" );
- if ( logfile != NULL ) lutil_debug_file( logfile );
-
-#endif
- /* start of a new database definition */
- } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
- int level;
- if ( cargc < 3 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: Error in debug directive, "
- "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
- fname, lineno, 0 );
-#endif
-
- return( 1 );
- }
- level = atoi( cargv[2] );
- if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
- lutil_set_debug_level( cargv[1], level );
- /* specify an Object Identifier macro */
- } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
- rc = parse_oidm( fname, lineno, cargc, cargv );
- if( rc ) return rc;
-
- /* specify an objectclass */
- } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
- if ( cargc < 2 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: illegal objectclass format.\n",
- fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: illegal objectclass format.\n",
- fname, lineno, 0 );
-#endif
- return( 1 );
-
- } else if ( *cargv[1] == '(' /*')'*/) {
- char * p;
- p = strchr(saveline,'(' /*')'*/);
- rc = parse_oc( fname, lineno, p, cargv );
- if( rc ) return rc;
-
- } else {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: old objectclass format not supported\n",
- fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: old objectclass format not supported.\n",
- fname, lineno, 0 );
-#endif
- }
-
- } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
- char * p;
- p = strchr(saveline,'(' /*')'*/);
- rc = parse_cr( fname, lineno, p, cargv );
- if( rc ) return rc;
-
- /* specify an attribute type */
- } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
- || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
- {
- if ( cargc < 2 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO, "%s: line %d: "
- "illegal attribute type format.\n",
- fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY, "%s: line %d: "
- "illegal attribute type format.\n",
- fname, lineno, 0 );
-#endif
- return( 1 );
-
- } else if ( *cargv[1] == '(' /*')'*/) {
- char * p;
- p = strchr(saveline,'(' /*')'*/);
- rc = parse_at( fname, lineno, p, cargv );
- if( rc ) return rc;
-
- } else {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: old attribute type format not supported.\n",
- fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: old attribute type format not supported.\n",
- fname, lineno, 0 );
-#endif
-
- }
-
- /* define attribute option(s) */
- } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
- ad_define_option( NULL, NULL, 0 );
- for ( i = 1; i < cargc; i++ )
- if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
- return 1;
-
- /* turn on/off schema checking */
- } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
- if ( cargc < 2 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: missing on|off in \"schemacheck <on|off>\""
- " line.\n", fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
- fname, lineno, 0 );
-#endif
-
- return( 1 );
- }
- if ( strcasecmp( cargv[1], "off" ) == 0 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: schema checking disabled! your mileage may "
- "vary!\n", fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: schema checking disabled! your mileage may vary!\n",
- fname, lineno, 0 );
-#endif
- global_schemacheck = 0;
- } else {
- global_schemacheck = 1;
- }
-
- /* specify access control info */
- } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
- parse_acl( be, fname, lineno, cargc, cargv );
-
- /* debug level to log things to syslog */
- } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
- if ( cargc < 2 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: missing level in \"loglevel <level>\""
- " line.\n", fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: missing level in \"loglevel <level>\" line\n",
- fname, lineno, 0 );
-#endif
-
- return( 1 );
- }
-
- ldap_syslog = 0;
-
- for( i=1; i < cargc; i++ ) {
- ldap_syslog += atoi( cargv[1] );
- }
-
- /* list of sync replication information in this backend (slave only) */
- } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
-
- if ( be == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: syncrepl line must appear inside "
- "a database definition.\n", fname, lineno, 0);
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: syncrepl line must appear inside "
- "a database definition.\n", fname, lineno, 0);
-#endif
- return 1;
- } else {
- if ( add_syncrepl( be, cargv, cargc )) {
- return 1;
- }
- }
-
- /* list of replicas of the data in this backend (master only) */
- } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
- if ( cargc < 2 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: missing host or uri in \"replica "
- " <host[:port]\" line\n", fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
- fname, lineno, 0 );
-#endif
-
- return( 1 );
- }
- if ( be == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: replica line must appear inside "
- "a database definition.\n", fname, lineno, 0);
-#else
- Debug( LDAP_DEBUG_ANY,
-"%s: line %d: replica line must appear inside a database definition\n",
- fname, lineno, 0 );
-#endif
- return 1;
-
- } else {
- int nr = -1;
-
- for ( i = 1; i < cargc; i++ ) {
- if ( strncasecmp( cargv[i], "host=", 5 )
- == 0 ) {
- nr = add_replica_info( be,
- cargv[i] + 5 );
- break;
- } else if (strncasecmp( cargv[i], "uri=", 4 )
- == 0 ) {
- if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
- != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: replica line contains invalid "
- "uri definition.\n", fname, lineno, 0);
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: replica line contains invalid "
- "uri definition.\n", fname, lineno, 0);
-#endif
- return 1;
- }
- if (ludp->lud_host == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: replica line contains invalid "
- "uri definition - missing hostname.\n",
- fname, lineno, 0);
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: replica line contains invalid "
- "uri definition - missing hostname.\n", fname, lineno, 0);
-#endif
- return 1;
- }
- replicahost = ch_malloc( strlen( cargv[ i ] ) );
- if ( replicahost == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, ERR,
- "out of memory in read_config\n", 0, 0,0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "out of memory in read_config\n", 0, 0, 0 );
-#endif
- ldap_free_urldesc( ludp );
- exit( EXIT_FAILURE );
- }
- sprintf(replicahost, "%s:%d",
- ludp->lud_host, ludp->lud_port);
- nr = add_replica_info( be, replicahost );
- ldap_free_urldesc( ludp );
- ch_free(replicahost);
- break;
- }
- }
- if ( i == cargc ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: missing host or uri in \"replica\" line\n",
- fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: missing host or uri in \"replica\" line\n",
- fname, lineno, 0 );
-#endif
- return 1;
-
- } else if ( nr == -1 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: unable to add"
- " replica \"%s\"\n",
- fname, lineno,
- cargv[i] + 5 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: unable to add replica \"%s\"\n",
- fname, lineno, cargv[i] + 5 );
-#endif
- return 1;
- } else {
- for ( i = 1; i < cargc; i++ ) {
- if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
-
- switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
- case 1:
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: suffix \"%s\" in \"replica\""
- " line is not valid for backend(ignored)\n",
- fname, lineno, cargv[i] + 7 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
- fname, lineno, cargv[i] + 7 );
-#endif
- break;
-
- case 2:
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: unable to normalize suffix"
- " in \"replica\" line (ignored)\n",
- fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
- fname, lineno, 0 );
-#endif
- break;
- }
-
- } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
- int exclude = 0;
- char *arg = cargv[i] + 4;
-
- if ( arg[0] == '!' ) {
- arg++;
- exclude = 1;
- }
-
- if ( arg[0] != '=' ) {
- continue;
- }
-
- if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: attribute \"%s\" in "
- "\"replica\" line is unknown\n",
- fname, lineno, arg + 1 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
- fname, lineno, arg + 1 );
-#endif
- return( 1 );
- }
- }
- }
- }
- }
-
- /* dn of slave entity allowed to write to replica */
- } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
- if ( cargc < 2 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: missing dn in \"updatedn <dn>\""
- " line.\n", fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
- fname, lineno, 0 );
-#endif
-
- return( 1 );
- }
- if ( be == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO,
- "%s: line %d: updatedn line must appear inside "
- "a database definition\n",
- fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
-"%s: line %d: updatedn line must appear inside a database definition\n",
- fname, lineno, 0 );
-#endif
- return 1;
-
- } else {
- struct berval dn;
-
- if ( load_ucdata( NULL ) < 0 ) return 1;
-
- dn.bv_val = cargv[1];
- dn.bv_len = strlen( cargv[1] );
-
- rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
- if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT,
- "%s: line %d: updatedn DN is invalid.\n",
- fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: updatedn DN is invalid\n",
- fname, lineno, 0 );
-#endif
- return 1;
- }
- }
-
- } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
- if ( cargc < 2 ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
- "missing url in \"updateref <ldapurl>\" line.\n",
- fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY, "%s: line %d: "
- "missing url in \"updateref <ldapurl>\" line\n",
- fname, lineno, 0 );
-#endif
-
- return( 1 );
- }
- if ( be == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
- " line must appear inside a database definition\n",
- fname, lineno , 0 );
-#else
- Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
- " line must appear inside a database definition\n",
- fname, lineno, 0 );
-#endif
- return 1;