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" ) ) {
318 Debug( LDAP_DEBUG_ANY,
319 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
323 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
327 /* SASL security properties */
328 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
332 Debug( LDAP_DEBUG_ANY,
333 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
338 txt = slap_sasl_secprops( cargv[1] );
340 Debug( LDAP_DEBUG_ANY,
341 "%s: line %d: sasl-secprops: %s\n",
342 fname, lineno, txt );
346 /* set UCDATA path */
347 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
349 Debug( LDAP_DEBUG_ANY,
350 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
355 if ( global_ucdata_path != NULL ) {
356 Debug( LDAP_DEBUG_ANY,
357 "%s: line %d: already set ucdata-path!\n",
362 global_ucdata_path = ch_strdup( cargv[1] );
366 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
368 Debug( LDAP_DEBUG_ANY,
369 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
374 defsize = atoi( cargv[1] );
376 be->be_sizelimit = atoi( cargv[1] );
380 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
382 Debug( LDAP_DEBUG_ANY,
383 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
388 deftime = atoi( cargv[1] );
390 be->be_timelimit = atoi( cargv[1] );
393 /* set database suffix */
394 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
397 Debug( LDAP_DEBUG_ANY,
398 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
401 } else if ( cargc > 2 ) {
402 Debug( LDAP_DEBUG_ANY,
403 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
404 fname, lineno, cargv[1] );
407 Debug( LDAP_DEBUG_ANY,
408 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
410 } else if ( ( tmp_be = select_backend( cargv[1] ) ) == be ) {
411 Debug( LDAP_DEBUG_ANY,
412 "%s: line %d: suffix already served by this backend (ignored)\n",
414 } else if ( tmp_be != NULL ) {
415 Debug( LDAP_DEBUG_ANY,
416 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
417 fname, lineno, tmp_be->be_suffix[0] );
419 char *dn = ch_strdup( cargv[1] );
420 if( dn_validate( dn ) == NULL ) {
421 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
422 "suffix DN invalid \"%s\"\n",
423 fname, lineno, cargv[1] );
426 } else if( *dn == '\0' && default_search_nbase != NULL ) {
427 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
428 "suffix DN empty and default "
429 "search base provided \"%s\" (assuming okay)\n",
430 fname, lineno, default_search_base );
432 charray_add( &be->be_suffix, dn );
433 (void) ldap_pvt_str2upper( dn );
434 charray_add( &be->be_nsuffix, dn );
438 /* set database suffixAlias */
439 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
442 Debug( LDAP_DEBUG_ANY,
443 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
446 } else if ( cargc < 3 ) {
447 Debug( LDAP_DEBUG_ANY,
448 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
451 } else if ( cargc > 3 ) {
452 Debug( LDAP_DEBUG_ANY,
453 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
458 Debug( LDAP_DEBUG_ANY,
459 "%s: line %d: suffixAlias line"
460 " must appear inside a database definition (ignored)\n",
462 } else if ( (tmp_be = select_backend( cargv[1] )) != NULL ) {
463 Debug( LDAP_DEBUG_ANY,
464 "%s: line %d: suffixAlias served by"
465 " a preceeding backend \"%s\" (ignored)\n",
466 fname, lineno, tmp_be->be_suffix[0] );
468 } else if ( (tmp_be = select_backend( cargv[2] )) != NULL ) {
469 Debug( LDAP_DEBUG_ANY,
470 "%s: line %d: suffixAlias derefs to differnet backend"
471 " a preceeding backend \"%s\" (ignored)\n",
472 fname, lineno, tmp_be->be_suffix[0] );
475 char *alias, *aliased_dn;
477 alias = ch_strdup( cargv[1] );
478 (void) dn_normalize( alias );
480 aliased_dn = ch_strdup( cargv[2] );
481 (void) dn_normalize( aliased_dn );
483 charray_add( &be->be_suffixAlias, alias );
484 charray_add( &be->be_suffixAlias, aliased_dn );
490 /* set max deref depth */
491 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
494 Debug( LDAP_DEBUG_ANY,
495 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
500 Debug( LDAP_DEBUG_ANY,
501 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
503 } else if ((i = atoi(cargv[1])) < 0) {
504 Debug( LDAP_DEBUG_ANY,
505 "%s: line %d: depth must be positive (ignored)\n",
509 be->be_max_deref_depth = i;
513 /* set magic "root" dn for this database */
514 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
516 Debug( LDAP_DEBUG_ANY,
517 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
522 Debug( LDAP_DEBUG_ANY,
523 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
526 be->be_root_dn = ch_strdup( cargv[1] );
527 be->be_root_ndn = ch_strdup( cargv[1] );
529 if( dn_normalize( be->be_root_ndn ) == NULL ) {
530 free( be->be_root_dn );
531 free( be->be_root_ndn );
532 Debug( LDAP_DEBUG_ANY,
533 "%s: line %d: rootdn DN is invalid\n",
539 /* set super-secret magic database password */
540 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
542 Debug( LDAP_DEBUG_ANY,
543 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
548 Debug( LDAP_DEBUG_ANY,
549 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
552 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
553 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
556 /* make this database read-only */
557 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
559 Debug( LDAP_DEBUG_ANY,
560 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
565 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
566 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
568 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
571 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
572 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
574 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
579 /* allow these features */
580 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
581 strcasecmp( cargv[0], "allow" ) == 0 )
586 Debug( LDAP_DEBUG_ANY,
587 "%s: line %d: allow line must appear prior to database definitions\n",
592 Debug( LDAP_DEBUG_ANY,
593 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
600 for( i=1; i < cargc; i++ ) {
601 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
602 allows |= SLAP_ALLOW_TLS_2_ANON;
604 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
605 Debug( LDAP_DEBUG_ANY,
606 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
607 fname, lineno, cargv[i] );
612 global_allows = allows;
614 /* disallow these features */
615 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
616 strcasecmp( cargv[0], "disallow" ) == 0 )
618 slap_mask_t disallows;
621 Debug( LDAP_DEBUG_ANY,
622 "%s: line %d: disallow line must appear prior to database definitions\n",
627 Debug( LDAP_DEBUG_ANY,
628 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
635 for( i=1; i < cargc; i++ ) {
636 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
637 disallows |= SLAP_DISALLOW_BIND_V2;
639 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
640 disallows |= SLAP_DISALLOW_BIND_ANON;
642 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
643 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
645 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
646 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
648 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
649 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
651 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
652 disallows |= SLAP_DISALLOW_BIND_KRBV4;
654 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
655 disallows |= SLAP_DISALLOW_TLS_AUTHC;
657 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
658 Debug( LDAP_DEBUG_ANY,
659 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
660 fname, lineno, cargv[i] );
665 global_disallows = disallows;
667 /* require these features */
668 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
669 strcasecmp( cargv[0], "require" ) == 0 )
671 slap_mask_t requires;
674 Debug( LDAP_DEBUG_ANY,
675 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
682 for( i=1; i < cargc; i++ ) {
683 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
684 requires |= SLAP_REQUIRE_BIND;
686 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
687 requires |= SLAP_REQUIRE_LDAP_V3;
689 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
690 requires |= SLAP_REQUIRE_AUTHC;
692 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
693 requires |= SLAP_REQUIRE_SASL;
695 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
696 requires |= SLAP_REQUIRE_STRONG;
698 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
699 Debug( LDAP_DEBUG_ANY,
700 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
701 fname, lineno, cargv[i] );
707 global_requires = requires;
709 be->be_requires = requires;
712 /* required security factors */
713 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
717 Debug( LDAP_DEBUG_ANY,
718 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
724 set = &global_ssf_set;
726 set = &be->be_ssf_set;
729 for( i=1; i < cargc; i++ ) {
730 if( strncasecmp( cargv[i], "ssf=",
731 sizeof("ssf") ) == 0 )
734 atoi( &cargv[i][sizeof("ssf")] );
736 } else if( strncasecmp( cargv[i], "transport=",
737 sizeof("transport") ) == 0 )
740 atoi( &cargv[i][sizeof("transport")] );
742 } else if( strncasecmp( cargv[i], "tls=",
743 sizeof("tls") ) == 0 )
746 atoi( &cargv[i][sizeof("tls")] );
748 } else if( strncasecmp( cargv[i], "sasl=",
749 sizeof("sasl") ) == 0 )
752 atoi( &cargv[i][sizeof("sasl")] );
754 } else if( strncasecmp( cargv[i], "update_ssf=",
755 sizeof("update_ssf") ) == 0 )
757 set->sss_update_ssf =
758 atoi( &cargv[i][sizeof("update_ssf")] );
760 } else if( strncasecmp( cargv[i], "update_transport=",
761 sizeof("update_transport") ) == 0 )
763 set->sss_update_transport =
764 atoi( &cargv[i][sizeof("update_transport")] );
766 } else if( strncasecmp( cargv[i], "update_tls=",
767 sizeof("update_tls") ) == 0 )
769 set->sss_update_tls =
770 atoi( &cargv[i][sizeof("update_tls")] );
772 } else if( strncasecmp( cargv[i], "update_sasl=",
773 sizeof("update_sasl") ) == 0 )
775 set->sss_update_sasl =
776 atoi( &cargv[i][sizeof("update_sasl")] );
779 Debug( LDAP_DEBUG_ANY,
780 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
781 fname, lineno, cargv[i] );
787 /* where to send clients when we don't hold it */
788 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
790 Debug( LDAP_DEBUG_ANY,
791 "%s: line %d: missing URL in \"referral <URL>\" line\n",
796 vals[0]->bv_val = cargv[1];
797 vals[0]->bv_len = strlen( vals[0]->bv_val );
798 value_add( &default_referral, vals );
800 /* specify an Object Identifier macro */
801 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
802 parse_oidm( fname, lineno, cargc, cargv );
804 /* specify an objectclass */
805 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
806 if ( *cargv[1] == '(' ) {
808 p = strchr(saveline,'(');
809 parse_oc( fname, lineno, p, cargv );
811 Debug( LDAP_DEBUG_ANY,
812 "%s: line %d: old objectclass format not supported.\n",
816 /* specify an attribute type */
817 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
818 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
820 if ( *cargv[1] == '(' ) {
822 p = strchr(saveline,'(');
823 parse_at( fname, lineno, p, cargv );
825 Debug( LDAP_DEBUG_ANY,
826 "%s: line %d: old attribute type format not supported.\n",
830 /* turn on/off schema checking */
831 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
833 Debug( LDAP_DEBUG_ANY,
834 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
838 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
839 global_schemacheck = 0;
841 global_schemacheck = 1;
844 /* specify access control info */
845 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
846 parse_acl( be, fname, lineno, cargc, cargv );
848 /* specify default access control info */
849 } else if ( strcasecmp( cargv[0], "defaultaccess" ) == 0 ) {
850 slap_access_t access;
853 Debug( LDAP_DEBUG_ANY,
854 "%s: line %d: missing limit in \"defaultaccess <access>\" line\n",
859 access = str2access( cargv[1] );
861 if ( access == ACL_INVALID_ACCESS ) {
862 Debug( LDAP_DEBUG_ANY,
863 "%s: line %d: bad access level \"%s\", "
864 "expecting none|auth|compare|search|read|write\n",
865 fname, lineno, cargv[1] );
870 global_default_access = access;
872 be->be_dfltaccess = access;
875 /* debug level to log things to syslog */
876 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
878 Debug( LDAP_DEBUG_ANY,
879 "%s: line %d: missing level in \"loglevel <level>\" line\n",
886 for( i=1; i < cargc; i++ ) {
887 ldap_syslog += atoi( cargv[1] );
890 /* list of replicas of the data in this backend (master only) */
891 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
893 Debug( LDAP_DEBUG_ANY,
894 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
899 Debug( LDAP_DEBUG_ANY,
900 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
903 for ( i = 1; i < cargc; i++ ) {
904 if ( strncasecmp( cargv[i], "host=", 5 )
906 charray_add( &be->be_replica,
912 Debug( LDAP_DEBUG_ANY,
913 "%s: line %d: missing host in \"replica\" line (ignored)\n",
918 /* dn of master entity allowed to write to replica */
919 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
921 Debug( LDAP_DEBUG_ANY,
922 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
927 Debug( LDAP_DEBUG_ANY,
928 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
931 be->be_update_ndn = ch_strdup( cargv[1] );
932 if( dn_normalize( be->be_update_ndn ) == NULL ) {
933 Debug( LDAP_DEBUG_ANY,
934 "%s: line %d: updatedn DN is invalid\n",
940 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
942 Debug( LDAP_DEBUG_ANY,
943 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
948 Debug( LDAP_DEBUG_ANY,
949 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
951 } else if ( be->be_update_ndn == NULL ) {
952 Debug( LDAP_DEBUG_ANY,
953 "%s: line %d: updateref line must after updatedn (ignored)\n",
956 vals[0]->bv_val = cargv[1];
957 vals[0]->bv_len = strlen( vals[0]->bv_val );
958 value_add( &be->be_update_refs, vals );
961 /* replication log file to which changes are appended */
962 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
964 Debug( LDAP_DEBUG_ANY,
965 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
970 be->be_replogfile = ch_strdup( cargv[1] );
972 replogfile = ch_strdup( cargv[1] );
975 /* maintain lastmodified{by,time} attributes */
976 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
978 Debug( LDAP_DEBUG_ANY,
979 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
983 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
990 be->be_lastmod = OFF;
992 global_lastmod = OFF;
995 /* set idle timeout value */
996 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
999 Debug( LDAP_DEBUG_ANY,
1000 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1005 i = atoi( cargv[1] );
1008 Debug( LDAP_DEBUG_ANY,
1009 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1014 global_idletimeout = i;
1016 /* include another config file */
1017 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1019 Debug( LDAP_DEBUG_ANY,
1020 "%s: line %d: missing filename in \"include <filename>\" line\n",
1024 savefname = ch_strdup( cargv[1] );
1025 savelineno = lineno;
1027 if ( read_config( savefname ) != 0 ) {
1032 lineno = savelineno - 1;
1034 /* location of kerberos srvtab file */
1035 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1037 Debug( LDAP_DEBUG_ANY,
1038 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1042 ldap_srvtab = ch_strdup( cargv[1] );
1044 #ifdef SLAPD_MODULES
1045 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1047 Debug( LDAP_DEBUG_ANY,
1048 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1050 exit( EXIT_FAILURE );
1052 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1053 Debug( LDAP_DEBUG_ANY,
1054 "%s: line %d: failed to load or initialize module %s\n",
1055 fname, lineno, cargv[1]);
1056 exit( EXIT_FAILURE );
1058 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1060 Debug( LDAP_DEBUG_ANY,
1061 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1063 exit( EXIT_FAILURE );
1065 if (module_path( cargv[1] )) {
1066 Debug( LDAP_DEBUG_ANY,
1067 "%s: line %d: failed to set module search path to %s\n",
1068 fname, lineno, cargv[1]);
1069 exit( EXIT_FAILURE );
1072 #endif /*SLAPD_MODULES*/
1075 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1076 rc = ldap_pvt_tls_set_option( NULL,
1077 LDAP_OPT_X_TLS_PROTOCOL,
1082 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1083 rc = ldap_pvt_tls_set_option( NULL,
1084 LDAP_OPT_X_TLS_CIPHER_SUITE,
1089 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1090 rc = ldap_pvt_tls_set_option( NULL,
1091 LDAP_OPT_X_TLS_CERTFILE,
1096 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1097 rc = ldap_pvt_tls_set_option( NULL,
1098 LDAP_OPT_X_TLS_KEYFILE,
1103 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1104 rc = ldap_pvt_tls_set_option( NULL,
1105 LDAP_OPT_X_TLS_CACERTDIR,
1110 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1111 rc = ldap_pvt_tls_set_option( NULL,
1112 LDAP_OPT_X_TLS_CACERTFILE,
1116 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1117 rc = ldap_pvt_tls_set_option( NULL,
1118 LDAP_OPT_X_TLS_REQUIRE_CERT,
1125 /* pass anything else to the current backend info/db config routine */
1128 if ( bi->bi_config == 0 ) {
1129 Debug( LDAP_DEBUG_ANY,
1130 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1131 fname, lineno, cargv[0] );
1133 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1139 } else if ( be != NULL ) {
1140 if ( be->be_config == 0 ) {
1141 Debug( LDAP_DEBUG_ANY,
1142 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1143 fname, lineno, cargv[0] );
1145 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1152 Debug( LDAP_DEBUG_ANY,
1153 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1154 fname, lineno, cargv[0] );
1173 for ( token = strtok_quote( line, " \t" ); token != NULL;
1174 token = strtok_quote( NULL, " \t" ) ) {
1175 if ( *argcp == MAXARGS ) {
1176 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1180 argv[(*argcp)++] = token;
1182 argv[*argcp] = NULL;
1187 strtok_quote( char *line, char *sep )
1193 if ( line != NULL ) {
1196 while ( *next && strchr( sep, *next ) ) {
1200 if ( *next == '\0' ) {
1206 for ( inquote = 0; *next; ) {
1214 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1220 next + 1, strlen( next + 1 ) + 1 );
1221 next++; /* dont parse the escaped character */
1226 if ( strchr( sep, *next ) != NULL ) {
1239 static char buf[BUFSIZ];
1241 static int lmax, lcur;
1243 #define CATLINE( buf ) { \
1245 len = strlen( buf ); \
1246 while ( lcur + len + 1 > lmax ) { \
1248 line = (char *) ch_realloc( line, lmax ); \
1250 strcpy( line + lcur, buf ); \
1255 fp_getline( FILE *fp, int *lineno )
1263 /* hack attack - keeps us from having to keep a stack of bufs... */
1264 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1269 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1270 if ( (p = strchr( buf, '\n' )) != NULL ) {
1273 if ( ! isspace( (unsigned char) buf[0] ) ) {
1282 return( line[0] ? line : NULL );
1286 fp_getline_init( int *lineno )