1 /* config.c - configuration file handling routines */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
14 #include <ac/socket.h>
22 * defaults for various global variables
24 int defsize = SLAPD_DEFAULT_SIZELIMIT;
25 int deftime = SLAPD_DEFAULT_TIMELIMIT;
26 AccessControl *global_acl = NULL;
27 slap_access_t global_default_access = ACL_READ;
28 slap_mask_t global_restrictops = 0;
29 slap_mask_t global_allows = 0;
30 slap_mask_t global_disallows = 0;
31 slap_mask_t global_requires = 0;
32 slap_ssf_set_t global_ssf_set;
34 int global_lastmod = ON;
35 int global_idletimeout = 0;
36 char *global_host = NULL;
37 char *global_realm = NULL;
38 char *global_ucdata_path = NULL;
39 char *ldap_srvtab = "";
40 char *default_passwd_hash;
41 char *default_search_base = NULL;
42 char *default_search_nbase = NULL;
44 char *slapd_pid_file = NULL;
45 char *slapd_args_file = NULL;
48 SaslRegexp_t *SaslRegexp = NULL;
50 static char *fp_getline(FILE *fp, int *lineno);
51 static void fp_getline_init(int *lineno);
52 static int fp_parse_line(char *line, int *argcp, char **argv);
54 static char *strtok_quote(char *line, char *sep);
57 read_config( const char *fname )
60 char *line, *savefname, *saveline;
61 int cargc, savelineno;
62 char *cargv[MAXARGS+1];
67 struct berval *vals[2];
70 static BackendInfo *bi = NULL;
71 static BackendDB *be = NULL;
76 if ( (fp = fopen( fname, "r" )) == NULL ) {
78 Debug( LDAP_DEBUG_ANY,
79 "could not open config file \"%s\" - absolute path?\n",
85 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
87 fp_getline_init( &lineno );
89 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
90 /* skip comments and blank lines */
91 if ( line[0] == '#' || line[0] == '\0' ) {
95 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
97 /* fp_parse_line is destructive, we save a copy */
98 saveline = ch_strdup( line );
100 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
105 Debug( LDAP_DEBUG_ANY,
106 "%s: line %d: bad config line (ignored)\n",
111 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
113 Debug( LDAP_DEBUG_ANY,
114 "%s: line %d: missing type in \"backend <type>\" line\n",
120 Debug( LDAP_DEBUG_ANY,
121 "%s: line %d: backend line must appear before any database definition\n",
126 bi = backend_info( cargv[1] );
129 Debug( LDAP_DEBUG_ANY,
130 "backend %s initialization failed.\n",
135 /* start of a new database definition */
136 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
138 Debug( LDAP_DEBUG_ANY,
139 "%s: line %d: missing type in \"database <type>\" line\n",
145 be = backend_db_init( cargv[1] );
148 Debug( LDAP_DEBUG_ANY,
149 "database %s initialization failed.\n",
154 /* set thread concurrency */
155 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
158 Debug( LDAP_DEBUG_ANY,
159 "%s: line %d: missing level in \"concurrency <level>\" line\n",
164 c = atoi( cargv[1] );
167 Debug( LDAP_DEBUG_ANY,
168 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
173 ldap_pvt_thread_set_concurrency( c );
175 /* default search base */
176 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
178 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
179 "missing dn in \"defaultSearchBase <dn>\" line\n",
183 } else if ( cargc > 2 ) {
184 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
185 "extra cruft after <dn> in \"defaultSearchBase %s\", "
187 fname, lineno, cargv[1] );
190 if ( bi != NULL || be != NULL ) {
191 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
192 "defaultSearchBaase line must appear prior to "
193 "any backend or database definition\n",
198 if ( default_search_nbase != NULL ) {
199 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
200 "default search base \"%s\" already defined "
201 "(discarding old)\n",
202 fname, lineno, default_search_base );
203 free( default_search_base );
204 free( default_search_nbase );
207 default_search_base = ch_strdup( cargv[1] );
208 default_search_nbase = ch_strdup( cargv[1] );
210 if( dn_normalize( default_search_nbase ) == NULL ) {
211 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
212 "invalid default search base \"%s\"\n",
213 fname, lineno, default_search_base );
217 /* set maximum threads in thread pool */
218 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
221 Debug( LDAP_DEBUG_ANY,
222 "%s: line %d: missing count in \"threads <count>\" line\n",
227 c = atoi( cargv[1] );
230 Debug( LDAP_DEBUG_ANY,
231 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
236 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
238 /* get pid file name */
239 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
241 Debug( LDAP_DEBUG_ANY,
242 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
247 slapd_pid_file = ch_strdup( cargv[1] );
249 /* get args file name */
250 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
252 Debug( LDAP_DEBUG_ANY,
253 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
258 slapd_args_file = ch_strdup( cargv[1] );
260 /* default password hash */
261 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
263 Debug( LDAP_DEBUG_ANY,
264 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
268 if ( default_passwd_hash != NULL ) {
269 Debug( LDAP_DEBUG_ANY,
270 "%s: line %d: already set default password_hash!\n",
275 default_passwd_hash = ch_strdup( cargv[1] );
279 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
281 Debug( LDAP_DEBUG_ANY,
282 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
287 if ( global_host != NULL ) {
288 Debug( LDAP_DEBUG_ANY,
289 "%s: line %d: already set sasl-host!\n",
294 global_host = ch_strdup( cargv[1] );
298 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
300 Debug( LDAP_DEBUG_ANY,
301 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
306 if ( global_realm != NULL ) {
307 Debug( LDAP_DEBUG_ANY,
308 "%s: line %d: already set sasl-realm!\n",
313 global_realm = ch_strdup( cargv[1] );
316 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
317 || !strcasecmp( cargv[0], "saslregexp" ) )
321 Debug( LDAP_DEBUG_ANY,
322 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
326 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
331 /* SASL security properties */
332 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
336 Debug( LDAP_DEBUG_ANY,
337 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
342 txt = slap_sasl_secprops( cargv[1] );
344 Debug( LDAP_DEBUG_ANY,
345 "%s: line %d: sasl-secprops: %s\n",
346 fname, lineno, txt );
350 /* set UCDATA path */
351 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
353 Debug( LDAP_DEBUG_ANY,
354 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
359 if ( global_ucdata_path != NULL ) {
360 Debug( LDAP_DEBUG_ANY,
361 "%s: line %d: already set ucdata-path!\n",
366 global_ucdata_path = ch_strdup( cargv[1] );
370 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
372 Debug( LDAP_DEBUG_ANY,
373 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
378 defsize = atoi( cargv[1] );
380 be->be_sizelimit = atoi( cargv[1] );
384 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
386 Debug( LDAP_DEBUG_ANY,
387 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
392 deftime = atoi( cargv[1] );
394 be->be_timelimit = atoi( cargv[1] );
397 /* set database suffix */
398 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
401 Debug( LDAP_DEBUG_ANY,
402 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
405 } else if ( cargc > 2 ) {
406 Debug( LDAP_DEBUG_ANY,
407 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
408 fname, lineno, cargv[1] );
411 Debug( LDAP_DEBUG_ANY,
412 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
414 } else if ( ( tmp_be = select_backend( cargv[1] ) ) == be ) {
415 Debug( LDAP_DEBUG_ANY,
416 "%s: line %d: suffix already served by this backend (ignored)\n",
418 } else if ( tmp_be != NULL ) {
419 Debug( LDAP_DEBUG_ANY,
420 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
421 fname, lineno, tmp_be->be_suffix[0] );
423 char *dn = ch_strdup( cargv[1] );
424 if( dn_validate( dn ) == NULL ) {
425 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
426 "suffix DN invalid \"%s\"\n",
427 fname, lineno, cargv[1] );
430 } else if( *dn == '\0' && default_search_nbase != NULL ) {
431 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
432 "suffix DN empty and default "
433 "search base provided \"%s\" (assuming okay)\n",
434 fname, lineno, default_search_base );
436 charray_add( &be->be_suffix, dn );
437 (void) ldap_pvt_str2upper( dn );
438 charray_add( &be->be_nsuffix, dn );
442 /* set database suffixAlias */
443 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
446 Debug( LDAP_DEBUG_ANY,
447 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
450 } else if ( cargc < 3 ) {
451 Debug( LDAP_DEBUG_ANY,
452 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
455 } else if ( cargc > 3 ) {
456 Debug( LDAP_DEBUG_ANY,
457 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
462 Debug( LDAP_DEBUG_ANY,
463 "%s: line %d: suffixAlias line"
464 " must appear inside a database definition (ignored)\n",
466 } else if ( (tmp_be = select_backend( cargv[1] )) != NULL ) {
467 Debug( LDAP_DEBUG_ANY,
468 "%s: line %d: suffixAlias served by"
469 " a preceeding backend \"%s\" (ignored)\n",
470 fname, lineno, tmp_be->be_suffix[0] );
472 } else if ( (tmp_be = select_backend( cargv[2] )) != NULL ) {
473 Debug( LDAP_DEBUG_ANY,
474 "%s: line %d: suffixAlias derefs to differnet backend"
475 " a preceeding backend \"%s\" (ignored)\n",
476 fname, lineno, tmp_be->be_suffix[0] );
479 char *alias, *aliased_dn;
481 alias = ch_strdup( cargv[1] );
482 (void) dn_normalize( alias );
484 aliased_dn = ch_strdup( cargv[2] );
485 (void) dn_normalize( aliased_dn );
487 charray_add( &be->be_suffixAlias, alias );
488 charray_add( &be->be_suffixAlias, aliased_dn );
494 /* set max deref depth */
495 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
498 Debug( LDAP_DEBUG_ANY,
499 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
504 Debug( LDAP_DEBUG_ANY,
505 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
507 } else if ((i = atoi(cargv[1])) < 0) {
508 Debug( LDAP_DEBUG_ANY,
509 "%s: line %d: depth must be positive (ignored)\n",
513 be->be_max_deref_depth = i;
517 /* set magic "root" dn for this database */
518 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
520 Debug( LDAP_DEBUG_ANY,
521 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
526 Debug( LDAP_DEBUG_ANY,
527 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
530 be->be_root_dn = ch_strdup( cargv[1] );
531 be->be_root_ndn = ch_strdup( cargv[1] );
533 if( dn_normalize( be->be_root_ndn ) == NULL ) {
534 free( be->be_root_dn );
535 free( be->be_root_ndn );
536 Debug( LDAP_DEBUG_ANY,
537 "%s: line %d: rootdn DN is invalid\n",
543 /* set super-secret magic database password */
544 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
546 Debug( LDAP_DEBUG_ANY,
547 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
552 Debug( LDAP_DEBUG_ANY,
553 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
556 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
557 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
560 /* make this database read-only */
561 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
563 Debug( LDAP_DEBUG_ANY,
564 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
569 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
570 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
572 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
575 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
576 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
578 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
583 /* allow these features */
584 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
585 strcasecmp( cargv[0], "allow" ) == 0 )
590 Debug( LDAP_DEBUG_ANY,
591 "%s: line %d: allow line must appear prior to database definitions\n",
596 Debug( LDAP_DEBUG_ANY,
597 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
604 for( i=1; i < cargc; i++ ) {
605 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
606 allows |= SLAP_ALLOW_TLS_2_ANON;
608 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
609 Debug( LDAP_DEBUG_ANY,
610 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
611 fname, lineno, cargv[i] );
616 global_allows = allows;
618 /* disallow these features */
619 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
620 strcasecmp( cargv[0], "disallow" ) == 0 )
622 slap_mask_t disallows;
625 Debug( LDAP_DEBUG_ANY,
626 "%s: line %d: disallow line must appear prior to database definitions\n",
631 Debug( LDAP_DEBUG_ANY,
632 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
639 for( i=1; i < cargc; i++ ) {
640 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
641 disallows |= SLAP_DISALLOW_BIND_V2;
643 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
644 disallows |= SLAP_DISALLOW_BIND_ANON;
646 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
647 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
649 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
650 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
652 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
653 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
655 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
656 disallows |= SLAP_DISALLOW_BIND_KRBV4;
658 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
659 disallows |= SLAP_DISALLOW_TLS_AUTHC;
661 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
662 Debug( LDAP_DEBUG_ANY,
663 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
664 fname, lineno, cargv[i] );
669 global_disallows = disallows;
671 /* require these features */
672 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
673 strcasecmp( cargv[0], "require" ) == 0 )
675 slap_mask_t requires;
678 Debug( LDAP_DEBUG_ANY,
679 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
686 for( i=1; i < cargc; i++ ) {
687 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
688 requires |= SLAP_REQUIRE_BIND;
690 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
691 requires |= SLAP_REQUIRE_LDAP_V3;
693 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
694 requires |= SLAP_REQUIRE_AUTHC;
696 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
697 requires |= SLAP_REQUIRE_SASL;
699 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
700 requires |= SLAP_REQUIRE_STRONG;
702 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
703 Debug( LDAP_DEBUG_ANY,
704 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
705 fname, lineno, cargv[i] );
711 global_requires = requires;
713 be->be_requires = requires;
716 /* required security factors */
717 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
721 Debug( LDAP_DEBUG_ANY,
722 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
728 set = &global_ssf_set;
730 set = &be->be_ssf_set;
733 for( i=1; i < cargc; i++ ) {
734 if( strncasecmp( cargv[i], "ssf=",
735 sizeof("ssf") ) == 0 )
738 atoi( &cargv[i][sizeof("ssf")] );
740 } else if( strncasecmp( cargv[i], "transport=",
741 sizeof("transport") ) == 0 )
744 atoi( &cargv[i][sizeof("transport")] );
746 } else if( strncasecmp( cargv[i], "tls=",
747 sizeof("tls") ) == 0 )
750 atoi( &cargv[i][sizeof("tls")] );
752 } else if( strncasecmp( cargv[i], "sasl=",
753 sizeof("sasl") ) == 0 )
756 atoi( &cargv[i][sizeof("sasl")] );
758 } else if( strncasecmp( cargv[i], "update_ssf=",
759 sizeof("update_ssf") ) == 0 )
761 set->sss_update_ssf =
762 atoi( &cargv[i][sizeof("update_ssf")] );
764 } else if( strncasecmp( cargv[i], "update_transport=",
765 sizeof("update_transport") ) == 0 )
767 set->sss_update_transport =
768 atoi( &cargv[i][sizeof("update_transport")] );
770 } else if( strncasecmp( cargv[i], "update_tls=",
771 sizeof("update_tls") ) == 0 )
773 set->sss_update_tls =
774 atoi( &cargv[i][sizeof("update_tls")] );
776 } else if( strncasecmp( cargv[i], "update_sasl=",
777 sizeof("update_sasl") ) == 0 )
779 set->sss_update_sasl =
780 atoi( &cargv[i][sizeof("update_sasl")] );
783 Debug( LDAP_DEBUG_ANY,
784 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
785 fname, lineno, cargv[i] );
791 /* where to send clients when we don't hold it */
792 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
794 Debug( LDAP_DEBUG_ANY,
795 "%s: line %d: missing URL in \"referral <URL>\" line\n",
800 vals[0]->bv_val = cargv[1];
801 vals[0]->bv_len = strlen( vals[0]->bv_val );
802 value_add( &default_referral, vals );
804 /* specify an Object Identifier macro */
805 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
806 parse_oidm( fname, lineno, cargc, cargv );
808 /* specify an objectclass */
809 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
810 if ( *cargv[1] == '(' ) {
812 p = strchr(saveline,'(');
813 parse_oc( fname, lineno, p, cargv );
815 Debug( LDAP_DEBUG_ANY,
816 "%s: line %d: old objectclass format not supported.\n",
820 /* specify an attribute type */
821 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
822 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
824 if ( *cargv[1] == '(' ) {
826 p = strchr(saveline,'(');
827 parse_at( fname, lineno, p, cargv );
829 Debug( LDAP_DEBUG_ANY,
830 "%s: line %d: old attribute type format not supported.\n",
834 /* turn on/off schema checking */
835 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
837 Debug( LDAP_DEBUG_ANY,
838 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
842 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
843 global_schemacheck = 0;
845 global_schemacheck = 1;
848 /* specify access control info */
849 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
850 parse_acl( be, fname, lineno, cargc, cargv );
852 /* specify default access control info */
853 } else if ( strcasecmp( cargv[0], "defaultaccess" ) == 0 ) {
854 slap_access_t access;
857 Debug( LDAP_DEBUG_ANY,
858 "%s: line %d: missing limit in \"defaultaccess <access>\" line\n",
863 access = str2access( cargv[1] );
865 if ( access == ACL_INVALID_ACCESS ) {
866 Debug( LDAP_DEBUG_ANY,
867 "%s: line %d: bad access level \"%s\", "
868 "expecting none|auth|compare|search|read|write\n",
869 fname, lineno, cargv[1] );
874 global_default_access = access;
876 be->be_dfltaccess = access;
879 /* debug level to log things to syslog */
880 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
882 Debug( LDAP_DEBUG_ANY,
883 "%s: line %d: missing level in \"loglevel <level>\" line\n",
890 for( i=1; i < cargc; i++ ) {
891 ldap_syslog += atoi( cargv[1] );
894 /* list of replicas of the data in this backend (master only) */
895 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
897 Debug( LDAP_DEBUG_ANY,
898 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
903 Debug( LDAP_DEBUG_ANY,
904 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
907 for ( i = 1; i < cargc; i++ ) {
908 if ( strncasecmp( cargv[i], "host=", 5 )
910 charray_add( &be->be_replica,
916 Debug( LDAP_DEBUG_ANY,
917 "%s: line %d: missing host in \"replica\" line (ignored)\n",
922 /* dn of master entity allowed to write to replica */
923 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
925 Debug( LDAP_DEBUG_ANY,
926 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
931 Debug( LDAP_DEBUG_ANY,
932 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
935 be->be_update_ndn = ch_strdup( cargv[1] );
936 if( dn_normalize( be->be_update_ndn ) == NULL ) {
937 Debug( LDAP_DEBUG_ANY,
938 "%s: line %d: updatedn DN is invalid\n",
944 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
946 Debug( LDAP_DEBUG_ANY,
947 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
952 Debug( LDAP_DEBUG_ANY,
953 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
955 } else if ( be->be_update_ndn == NULL ) {
956 Debug( LDAP_DEBUG_ANY,
957 "%s: line %d: updateref line must after updatedn (ignored)\n",
960 vals[0]->bv_val = cargv[1];
961 vals[0]->bv_len = strlen( vals[0]->bv_val );
962 value_add( &be->be_update_refs, vals );
965 /* replication log file to which changes are appended */
966 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
968 Debug( LDAP_DEBUG_ANY,
969 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
974 be->be_replogfile = ch_strdup( cargv[1] );
976 replogfile = ch_strdup( cargv[1] );
979 /* maintain lastmodified{by,time} attributes */
980 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
982 Debug( LDAP_DEBUG_ANY,
983 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
987 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
994 be->be_lastmod = OFF;
996 global_lastmod = OFF;
999 /* set idle timeout value */
1000 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1003 Debug( LDAP_DEBUG_ANY,
1004 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1009 i = atoi( cargv[1] );
1012 Debug( LDAP_DEBUG_ANY,
1013 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1018 global_idletimeout = i;
1020 /* include another config file */
1021 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1023 Debug( LDAP_DEBUG_ANY,
1024 "%s: line %d: missing filename in \"include <filename>\" line\n",
1028 savefname = ch_strdup( cargv[1] );
1029 savelineno = lineno;
1031 if ( read_config( savefname ) != 0 ) {
1036 lineno = savelineno - 1;
1038 /* location of kerberos srvtab file */
1039 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1041 Debug( LDAP_DEBUG_ANY,
1042 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1046 ldap_srvtab = ch_strdup( cargv[1] );
1048 #ifdef SLAPD_MODULES
1049 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1051 Debug( LDAP_DEBUG_ANY,
1052 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1054 exit( EXIT_FAILURE );
1056 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1057 Debug( LDAP_DEBUG_ANY,
1058 "%s: line %d: failed to load or initialize module %s\n",
1059 fname, lineno, cargv[1]);
1060 exit( EXIT_FAILURE );
1062 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1064 Debug( LDAP_DEBUG_ANY,
1065 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1067 exit( EXIT_FAILURE );
1069 if (module_path( cargv[1] )) {
1070 Debug( LDAP_DEBUG_ANY,
1071 "%s: line %d: failed to set module search path to %s\n",
1072 fname, lineno, cargv[1]);
1073 exit( EXIT_FAILURE );
1076 #endif /*SLAPD_MODULES*/
1079 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1080 rc = ldap_pvt_tls_set_option( NULL,
1081 LDAP_OPT_X_TLS_PROTOCOL,
1086 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1087 rc = ldap_pvt_tls_set_option( NULL,
1088 LDAP_OPT_X_TLS_CIPHER_SUITE,
1093 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1094 rc = ldap_pvt_tls_set_option( NULL,
1095 LDAP_OPT_X_TLS_CERTFILE,
1100 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1101 rc = ldap_pvt_tls_set_option( NULL,
1102 LDAP_OPT_X_TLS_KEYFILE,
1107 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1108 rc = ldap_pvt_tls_set_option( NULL,
1109 LDAP_OPT_X_TLS_CACERTDIR,
1114 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1115 rc = ldap_pvt_tls_set_option( NULL,
1116 LDAP_OPT_X_TLS_CACERTFILE,
1120 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1121 rc = ldap_pvt_tls_set_option( NULL,
1122 LDAP_OPT_X_TLS_REQUIRE_CERT,
1129 /* pass anything else to the current backend info/db config routine */
1132 if ( bi->bi_config == 0 ) {
1133 Debug( LDAP_DEBUG_ANY,
1134 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1135 fname, lineno, cargv[0] );
1137 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1143 } else if ( be != NULL ) {
1144 if ( be->be_config == 0 ) {
1145 Debug( LDAP_DEBUG_ANY,
1146 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1147 fname, lineno, cargv[0] );
1149 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1156 Debug( LDAP_DEBUG_ANY,
1157 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1158 fname, lineno, cargv[0] );
1177 for ( token = strtok_quote( line, " \t" ); token != NULL;
1178 token = strtok_quote( NULL, " \t" ) ) {
1179 if ( *argcp == MAXARGS ) {
1180 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1184 argv[(*argcp)++] = token;
1186 argv[*argcp] = NULL;
1191 strtok_quote( char *line, char *sep )
1197 if ( line != NULL ) {
1200 while ( *next && strchr( sep, *next ) ) {
1204 if ( *next == '\0' ) {
1210 for ( inquote = 0; *next; ) {
1218 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1224 next + 1, strlen( next + 1 ) + 1 );
1225 next++; /* dont parse the escaped character */
1230 if ( strchr( sep, *next ) != NULL ) {
1243 static char buf[BUFSIZ];
1245 static int lmax, lcur;
1247 #define CATLINE( buf ) { \
1249 len = strlen( buf ); \
1250 while ( lcur + len + 1 > lmax ) { \
1252 line = (char *) ch_realloc( line, lmax ); \
1254 strcpy( line + lcur, buf ); \
1259 fp_getline( FILE *fp, int *lineno )
1267 /* hack attack - keeps us from having to keep a stack of bufs... */
1268 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1273 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1274 if ( (p = strchr( buf, '\n' )) != NULL ) {
1277 if ( ! isspace( (unsigned char) buf[0] ) ) {
1286 return( line[0] ? line : NULL );
1290 fp_getline_init( int *lineno )