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], "saslregexp" ) ) {
319 Debug( LDAP_DEBUG_ANY,
320 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
324 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
329 /* SASL security properties */
330 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
334 Debug( LDAP_DEBUG_ANY,
335 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
340 txt = slap_sasl_secprops( cargv[1] );
342 Debug( LDAP_DEBUG_ANY,
343 "%s: line %d: sasl-secprops: %s\n",
344 fname, lineno, txt );
348 /* set UCDATA path */
349 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
351 Debug( LDAP_DEBUG_ANY,
352 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
357 if ( global_ucdata_path != NULL ) {
358 Debug( LDAP_DEBUG_ANY,
359 "%s: line %d: already set ucdata-path!\n",
364 global_ucdata_path = ch_strdup( cargv[1] );
368 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
370 Debug( LDAP_DEBUG_ANY,
371 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
376 defsize = atoi( cargv[1] );
378 be->be_sizelimit = atoi( cargv[1] );
382 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
384 Debug( LDAP_DEBUG_ANY,
385 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
390 deftime = atoi( cargv[1] );
392 be->be_timelimit = atoi( cargv[1] );
395 /* set database suffix */
396 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
399 Debug( LDAP_DEBUG_ANY,
400 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
403 } else if ( cargc > 2 ) {
404 Debug( LDAP_DEBUG_ANY,
405 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
406 fname, lineno, cargv[1] );
409 Debug( LDAP_DEBUG_ANY,
410 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
412 } else if ( ( tmp_be = select_backend( cargv[1] ) ) == be ) {
413 Debug( LDAP_DEBUG_ANY,
414 "%s: line %d: suffix already served by this backend (ignored)\n",
416 } else if ( tmp_be != NULL ) {
417 Debug( LDAP_DEBUG_ANY,
418 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
419 fname, lineno, tmp_be->be_suffix[0] );
421 char *dn = ch_strdup( cargv[1] );
422 if( dn_validate( dn ) == NULL ) {
423 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
424 "suffix DN invalid \"%s\"\n",
425 fname, lineno, cargv[1] );
428 } else if( *dn == '\0' && default_search_nbase != NULL ) {
429 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
430 "suffix DN empty and default "
431 "search base provided \"%s\" (assuming okay)\n",
432 fname, lineno, default_search_base );
434 charray_add( &be->be_suffix, dn );
435 (void) ldap_pvt_str2upper( dn );
436 charray_add( &be->be_nsuffix, dn );
440 /* set database suffixAlias */
441 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
444 Debug( LDAP_DEBUG_ANY,
445 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
448 } else if ( cargc < 3 ) {
449 Debug( LDAP_DEBUG_ANY,
450 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
453 } else if ( cargc > 3 ) {
454 Debug( LDAP_DEBUG_ANY,
455 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
460 Debug( LDAP_DEBUG_ANY,
461 "%s: line %d: suffixAlias line"
462 " must appear inside a database definition (ignored)\n",
464 } else if ( (tmp_be = select_backend( cargv[1] )) != NULL ) {
465 Debug( LDAP_DEBUG_ANY,
466 "%s: line %d: suffixAlias served by"
467 " a preceeding backend \"%s\" (ignored)\n",
468 fname, lineno, tmp_be->be_suffix[0] );
470 } else if ( (tmp_be = select_backend( cargv[2] )) != NULL ) {
471 Debug( LDAP_DEBUG_ANY,
472 "%s: line %d: suffixAlias derefs to differnet backend"
473 " a preceeding backend \"%s\" (ignored)\n",
474 fname, lineno, tmp_be->be_suffix[0] );
477 char *alias, *aliased_dn;
479 alias = ch_strdup( cargv[1] );
480 (void) dn_normalize( alias );
482 aliased_dn = ch_strdup( cargv[2] );
483 (void) dn_normalize( aliased_dn );
485 charray_add( &be->be_suffixAlias, alias );
486 charray_add( &be->be_suffixAlias, aliased_dn );
492 /* set max deref depth */
493 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
496 Debug( LDAP_DEBUG_ANY,
497 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
502 Debug( LDAP_DEBUG_ANY,
503 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
505 } else if ((i = atoi(cargv[1])) < 0) {
506 Debug( LDAP_DEBUG_ANY,
507 "%s: line %d: depth must be positive (ignored)\n",
511 be->be_max_deref_depth = i;
515 /* set magic "root" dn for this database */
516 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
518 Debug( LDAP_DEBUG_ANY,
519 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
524 Debug( LDAP_DEBUG_ANY,
525 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
528 be->be_root_dn = ch_strdup( cargv[1] );
529 be->be_root_ndn = ch_strdup( cargv[1] );
531 if( dn_normalize( be->be_root_ndn ) == NULL ) {
532 free( be->be_root_dn );
533 free( be->be_root_ndn );
534 Debug( LDAP_DEBUG_ANY,
535 "%s: line %d: rootdn DN is invalid\n",
541 /* set super-secret magic database password */
542 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
544 Debug( LDAP_DEBUG_ANY,
545 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
550 Debug( LDAP_DEBUG_ANY,
551 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
554 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
555 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
558 /* make this database read-only */
559 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
561 Debug( LDAP_DEBUG_ANY,
562 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
567 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
568 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
570 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
573 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
574 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
576 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
581 /* allow these features */
582 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
583 strcasecmp( cargv[0], "allow" ) == 0 )
588 Debug( LDAP_DEBUG_ANY,
589 "%s: line %d: allow line must appear prior to database definitions\n",
594 Debug( LDAP_DEBUG_ANY,
595 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
602 for( i=1; i < cargc; i++ ) {
603 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
604 allows |= SLAP_ALLOW_TLS_2_ANON;
606 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
607 Debug( LDAP_DEBUG_ANY,
608 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
609 fname, lineno, cargv[i] );
614 global_allows = allows;
616 /* disallow these features */
617 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
618 strcasecmp( cargv[0], "disallow" ) == 0 )
620 slap_mask_t disallows;
623 Debug( LDAP_DEBUG_ANY,
624 "%s: line %d: disallow line must appear prior to database definitions\n",
629 Debug( LDAP_DEBUG_ANY,
630 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
637 for( i=1; i < cargc; i++ ) {
638 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
639 disallows |= SLAP_DISALLOW_BIND_V2;
641 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
642 disallows |= SLAP_DISALLOW_BIND_ANON;
644 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
645 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
647 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
648 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
650 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
651 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
653 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
654 disallows |= SLAP_DISALLOW_BIND_KRBV4;
656 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
657 disallows |= SLAP_DISALLOW_TLS_AUTHC;
659 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
660 Debug( LDAP_DEBUG_ANY,
661 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
662 fname, lineno, cargv[i] );
667 global_disallows = disallows;
669 /* require these features */
670 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
671 strcasecmp( cargv[0], "require" ) == 0 )
673 slap_mask_t requires;
676 Debug( LDAP_DEBUG_ANY,
677 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
684 for( i=1; i < cargc; i++ ) {
685 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
686 requires |= SLAP_REQUIRE_BIND;
688 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
689 requires |= SLAP_REQUIRE_LDAP_V3;
691 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
692 requires |= SLAP_REQUIRE_AUTHC;
694 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
695 requires |= SLAP_REQUIRE_SASL;
697 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
698 requires |= SLAP_REQUIRE_STRONG;
700 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
701 Debug( LDAP_DEBUG_ANY,
702 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
703 fname, lineno, cargv[i] );
709 global_requires = requires;
711 be->be_requires = requires;
714 /* required security factors */
715 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
719 Debug( LDAP_DEBUG_ANY,
720 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
726 set = &global_ssf_set;
728 set = &be->be_ssf_set;
731 for( i=1; i < cargc; i++ ) {
732 if( strncasecmp( cargv[i], "ssf=",
733 sizeof("ssf") ) == 0 )
736 atoi( &cargv[i][sizeof("ssf")] );
738 } else if( strncasecmp( cargv[i], "transport=",
739 sizeof("transport") ) == 0 )
742 atoi( &cargv[i][sizeof("transport")] );
744 } else if( strncasecmp( cargv[i], "tls=",
745 sizeof("tls") ) == 0 )
748 atoi( &cargv[i][sizeof("tls")] );
750 } else if( strncasecmp( cargv[i], "sasl=",
751 sizeof("sasl") ) == 0 )
754 atoi( &cargv[i][sizeof("sasl")] );
756 } else if( strncasecmp( cargv[i], "update_ssf=",
757 sizeof("update_ssf") ) == 0 )
759 set->sss_update_ssf =
760 atoi( &cargv[i][sizeof("update_ssf")] );
762 } else if( strncasecmp( cargv[i], "update_transport=",
763 sizeof("update_transport") ) == 0 )
765 set->sss_update_transport =
766 atoi( &cargv[i][sizeof("update_transport")] );
768 } else if( strncasecmp( cargv[i], "update_tls=",
769 sizeof("update_tls") ) == 0 )
771 set->sss_update_tls =
772 atoi( &cargv[i][sizeof("update_tls")] );
774 } else if( strncasecmp( cargv[i], "update_sasl=",
775 sizeof("update_sasl") ) == 0 )
777 set->sss_update_sasl =
778 atoi( &cargv[i][sizeof("update_sasl")] );
781 Debug( LDAP_DEBUG_ANY,
782 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
783 fname, lineno, cargv[i] );
789 /* where to send clients when we don't hold it */
790 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
792 Debug( LDAP_DEBUG_ANY,
793 "%s: line %d: missing URL in \"referral <URL>\" line\n",
798 vals[0]->bv_val = cargv[1];
799 vals[0]->bv_len = strlen( vals[0]->bv_val );
800 value_add( &default_referral, vals );
802 /* specify an Object Identifier macro */
803 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
804 parse_oidm( fname, lineno, cargc, cargv );
806 /* specify an objectclass */
807 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
808 if ( *cargv[1] == '(' ) {
810 p = strchr(saveline,'(');
811 parse_oc( fname, lineno, p, cargv );
813 Debug( LDAP_DEBUG_ANY,
814 "%s: line %d: old objectclass format not supported.\n",
818 /* specify an attribute type */
819 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
820 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
822 if ( *cargv[1] == '(' ) {
824 p = strchr(saveline,'(');
825 parse_at( fname, lineno, p, cargv );
827 Debug( LDAP_DEBUG_ANY,
828 "%s: line %d: old attribute type format not supported.\n",
832 /* turn on/off schema checking */
833 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
835 Debug( LDAP_DEBUG_ANY,
836 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
840 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
841 global_schemacheck = 0;
843 global_schemacheck = 1;
846 /* specify access control info */
847 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
848 parse_acl( be, fname, lineno, cargc, cargv );
850 /* specify default access control info */
851 } else if ( strcasecmp( cargv[0], "defaultaccess" ) == 0 ) {
852 slap_access_t access;
855 Debug( LDAP_DEBUG_ANY,
856 "%s: line %d: missing limit in \"defaultaccess <access>\" line\n",
861 access = str2access( cargv[1] );
863 if ( access == ACL_INVALID_ACCESS ) {
864 Debug( LDAP_DEBUG_ANY,
865 "%s: line %d: bad access level \"%s\", "
866 "expecting none|auth|compare|search|read|write\n",
867 fname, lineno, cargv[1] );
872 global_default_access = access;
874 be->be_dfltaccess = access;
877 /* debug level to log things to syslog */
878 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
880 Debug( LDAP_DEBUG_ANY,
881 "%s: line %d: missing level in \"loglevel <level>\" line\n",
888 for( i=1; i < cargc; i++ ) {
889 ldap_syslog += atoi( cargv[1] );
892 /* list of replicas of the data in this backend (master only) */
893 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
895 Debug( LDAP_DEBUG_ANY,
896 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
901 Debug( LDAP_DEBUG_ANY,
902 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
905 for ( i = 1; i < cargc; i++ ) {
906 if ( strncasecmp( cargv[i], "host=", 5 )
908 charray_add( &be->be_replica,
914 Debug( LDAP_DEBUG_ANY,
915 "%s: line %d: missing host in \"replica\" line (ignored)\n",
920 /* dn of master entity allowed to write to replica */
921 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
923 Debug( LDAP_DEBUG_ANY,
924 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
929 Debug( LDAP_DEBUG_ANY,
930 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
933 be->be_update_ndn = ch_strdup( cargv[1] );
934 if( dn_normalize( be->be_update_ndn ) == NULL ) {
935 Debug( LDAP_DEBUG_ANY,
936 "%s: line %d: updatedn DN is invalid\n",
942 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
944 Debug( LDAP_DEBUG_ANY,
945 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
950 Debug( LDAP_DEBUG_ANY,
951 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
953 } else if ( be->be_update_ndn == NULL ) {
954 Debug( LDAP_DEBUG_ANY,
955 "%s: line %d: updateref line must after updatedn (ignored)\n",
958 vals[0]->bv_val = cargv[1];
959 vals[0]->bv_len = strlen( vals[0]->bv_val );
960 value_add( &be->be_update_refs, vals );
963 /* replication log file to which changes are appended */
964 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
966 Debug( LDAP_DEBUG_ANY,
967 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
972 be->be_replogfile = ch_strdup( cargv[1] );
974 replogfile = ch_strdup( cargv[1] );
977 /* maintain lastmodified{by,time} attributes */
978 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
980 Debug( LDAP_DEBUG_ANY,
981 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
985 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
992 be->be_lastmod = OFF;
994 global_lastmod = OFF;
997 /* set idle timeout value */
998 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1001 Debug( LDAP_DEBUG_ANY,
1002 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1007 i = atoi( cargv[1] );
1010 Debug( LDAP_DEBUG_ANY,
1011 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1016 global_idletimeout = i;
1018 /* include another config file */
1019 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1021 Debug( LDAP_DEBUG_ANY,
1022 "%s: line %d: missing filename in \"include <filename>\" line\n",
1026 savefname = ch_strdup( cargv[1] );
1027 savelineno = lineno;
1029 if ( read_config( savefname ) != 0 ) {
1034 lineno = savelineno - 1;
1036 /* location of kerberos srvtab file */
1037 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1039 Debug( LDAP_DEBUG_ANY,
1040 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1044 ldap_srvtab = ch_strdup( cargv[1] );
1046 #ifdef SLAPD_MODULES
1047 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1049 Debug( LDAP_DEBUG_ANY,
1050 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1052 exit( EXIT_FAILURE );
1054 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1055 Debug( LDAP_DEBUG_ANY,
1056 "%s: line %d: failed to load or initialize module %s\n",
1057 fname, lineno, cargv[1]);
1058 exit( EXIT_FAILURE );
1060 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1062 Debug( LDAP_DEBUG_ANY,
1063 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1065 exit( EXIT_FAILURE );
1067 if (module_path( cargv[1] )) {
1068 Debug( LDAP_DEBUG_ANY,
1069 "%s: line %d: failed to set module search path to %s\n",
1070 fname, lineno, cargv[1]);
1071 exit( EXIT_FAILURE );
1074 #endif /*SLAPD_MODULES*/
1077 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1078 rc = ldap_pvt_tls_set_option( NULL,
1079 LDAP_OPT_X_TLS_PROTOCOL,
1084 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1085 rc = ldap_pvt_tls_set_option( NULL,
1086 LDAP_OPT_X_TLS_CIPHER_SUITE,
1091 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1092 rc = ldap_pvt_tls_set_option( NULL,
1093 LDAP_OPT_X_TLS_CERTFILE,
1098 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1099 rc = ldap_pvt_tls_set_option( NULL,
1100 LDAP_OPT_X_TLS_KEYFILE,
1105 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1106 rc = ldap_pvt_tls_set_option( NULL,
1107 LDAP_OPT_X_TLS_CACERTDIR,
1112 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1113 rc = ldap_pvt_tls_set_option( NULL,
1114 LDAP_OPT_X_TLS_CACERTFILE,
1118 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1119 rc = ldap_pvt_tls_set_option( NULL,
1120 LDAP_OPT_X_TLS_REQUIRE_CERT,
1127 /* pass anything else to the current backend info/db config routine */
1130 if ( bi->bi_config == 0 ) {
1131 Debug( LDAP_DEBUG_ANY,
1132 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1133 fname, lineno, cargv[0] );
1135 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1141 } else if ( be != NULL ) {
1142 if ( be->be_config == 0 ) {
1143 Debug( LDAP_DEBUG_ANY,
1144 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1145 fname, lineno, cargv[0] );
1147 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1154 Debug( LDAP_DEBUG_ANY,
1155 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1156 fname, lineno, cargv[0] );
1175 for ( token = strtok_quote( line, " \t" ); token != NULL;
1176 token = strtok_quote( NULL, " \t" ) ) {
1177 if ( *argcp == MAXARGS ) {
1178 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1182 argv[(*argcp)++] = token;
1184 argv[*argcp] = NULL;
1189 strtok_quote( char *line, char *sep )
1195 if ( line != NULL ) {
1198 while ( *next && strchr( sep, *next ) ) {
1202 if ( *next == '\0' ) {
1208 for ( inquote = 0; *next; ) {
1216 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1222 next + 1, strlen( next + 1 ) + 1 );
1223 next++; /* dont parse the escaped character */
1228 if ( strchr( sep, *next ) != NULL ) {
1241 static char buf[BUFSIZ];
1243 static int lmax, lcur;
1245 #define CATLINE( buf ) { \
1247 len = strlen( buf ); \
1248 while ( lcur + len + 1 > lmax ) { \
1250 line = (char *) ch_realloc( line, lmax ); \
1252 strcpy( line + lcur, buf ); \
1257 fp_getline( FILE *fp, int *lineno )
1265 /* hack attack - keeps us from having to keep a stack of bufs... */
1266 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1271 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1272 if ( (p = strchr( buf, '\n' )) != NULL ) {
1275 if ( ! isspace( (unsigned char) buf[0] ) ) {
1284 return( line[0] ? line : NULL );
1288 fp_getline_init( int *lineno )