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;
47 static char *fp_getline(FILE *fp, int *lineno);
48 static void fp_getline_init(int *lineno);
49 static int fp_parse_line(char *line, int *argcp, char **argv);
51 static char *strtok_quote(char *line, char *sep);
54 read_config( const char *fname )
57 char *line, *savefname, *saveline;
58 int cargc, savelineno;
59 char *cargv[MAXARGS+1];
64 struct berval *vals[2];
67 static BackendInfo *bi = NULL;
68 static BackendDB *be = NULL;
73 if ( (fp = fopen( fname, "r" )) == NULL ) {
75 Debug( LDAP_DEBUG_ANY,
76 "could not open config file \"%s\" - absolute path?\n",
82 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
84 fp_getline_init( &lineno );
86 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
87 /* skip comments and blank lines */
88 if ( line[0] == '#' || line[0] == '\0' ) {
92 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
94 /* fp_parse_line is destructive, we save a copy */
95 saveline = ch_strdup( line );
97 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
102 Debug( LDAP_DEBUG_ANY,
103 "%s: line %d: bad config line (ignored)\n",
108 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
110 Debug( LDAP_DEBUG_ANY,
111 "%s: line %d: missing type in \"backend <type>\" line\n",
117 Debug( LDAP_DEBUG_ANY,
118 "%s: line %d: backend line must appear before any database definition\n",
123 bi = backend_info( cargv[1] );
126 Debug( LDAP_DEBUG_ANY,
127 "backend %s initialization failed.\n",
132 /* start of a new database definition */
133 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
135 Debug( LDAP_DEBUG_ANY,
136 "%s: line %d: missing type in \"database <type>\" line\n",
142 be = backend_db_init( cargv[1] );
145 Debug( LDAP_DEBUG_ANY,
146 "database %s initialization failed.\n",
151 /* set thread concurrency */
152 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
155 Debug( LDAP_DEBUG_ANY,
156 "%s: line %d: missing level in \"concurrency <level>\" line\n",
161 c = atoi( cargv[1] );
164 Debug( LDAP_DEBUG_ANY,
165 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
170 ldap_pvt_thread_set_concurrency( c );
172 /* default search base */
173 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
175 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
176 "missing dn in \"defaultSearchBase <dn>\" line\n",
180 } else if ( cargc > 2 ) {
181 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
182 "extra cruft after <dn> in \"defaultSearchBase %s\", "
184 fname, lineno, cargv[1] );
187 if ( bi != NULL || be != NULL ) {
188 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
189 "defaultSearchBaase line must appear prior to "
190 "any backend or database definition\n",
195 if ( default_search_base != NULL ) {
196 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
197 "default search base \"%s\" already defined "
198 "(discarding old)\n",
199 fname, lineno, default_search_base );
200 free( default_search_base );
203 default_search_base = ch_strdup( cargv[1] );
204 default_search_nbase = ch_strdup( cargv[1] );
206 if( dn_normalize( default_search_nbase ) == NULL ) {
207 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
208 "invalid default search base \"%s\""
209 "(discarding old)\n",
210 fname, lineno, default_search_base );
213 /* set maximum threads in thread pool */
214 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
217 Debug( LDAP_DEBUG_ANY,
218 "%s: line %d: missing count in \"threads <count>\" line\n",
223 c = atoi( cargv[1] );
226 Debug( LDAP_DEBUG_ANY,
227 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
232 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
234 /* get pid file name */
235 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
237 Debug( LDAP_DEBUG_ANY,
238 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
243 slapd_pid_file = ch_strdup( cargv[1] );
245 /* get args file name */
246 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
248 Debug( LDAP_DEBUG_ANY,
249 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
254 slapd_args_file = ch_strdup( cargv[1] );
256 /* default password hash */
257 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
259 Debug( LDAP_DEBUG_ANY,
260 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
264 if ( default_passwd_hash != NULL ) {
265 Debug( LDAP_DEBUG_ANY,
266 "%s: line %d: already set default password_hash!\n",
271 default_passwd_hash = ch_strdup( cargv[1] );
275 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
277 Debug( LDAP_DEBUG_ANY,
278 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
283 if ( global_host != NULL ) {
284 Debug( LDAP_DEBUG_ANY,
285 "%s: line %d: already set sasl-host!\n",
290 global_host = ch_strdup( cargv[1] );
294 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
296 Debug( LDAP_DEBUG_ANY,
297 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
302 if ( global_realm != NULL ) {
303 Debug( LDAP_DEBUG_ANY,
304 "%s: line %d: already set sasl-realm!\n",
309 global_realm = ch_strdup( cargv[1] );
312 /* SASL security properties */
313 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
317 Debug( LDAP_DEBUG_ANY,
318 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
323 txt = slap_sasl_secprops( cargv[1] );
325 Debug( LDAP_DEBUG_ANY,
326 "%s: line %d: sasl-secprops: %s\n",
327 fname, lineno, txt );
331 /* set UCDATA path */
332 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
334 Debug( LDAP_DEBUG_ANY,
335 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
340 if ( global_ucdata_path != NULL ) {
341 Debug( LDAP_DEBUG_ANY,
342 "%s: line %d: already set ucdata-path!\n",
347 global_ucdata_path = ch_strdup( cargv[1] );
351 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
353 Debug( LDAP_DEBUG_ANY,
354 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
359 defsize = atoi( cargv[1] );
361 be->be_sizelimit = atoi( cargv[1] );
365 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
367 Debug( LDAP_DEBUG_ANY,
368 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
373 deftime = atoi( cargv[1] );
375 be->be_timelimit = atoi( cargv[1] );
378 /* set database suffix */
379 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
382 Debug( LDAP_DEBUG_ANY,
383 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
386 } else if ( cargc > 2 ) {
387 Debug( LDAP_DEBUG_ANY,
388 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
389 fname, lineno, cargv[1] );
392 Debug( LDAP_DEBUG_ANY,
393 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
395 } else if ( ( tmp_be = select_backend( cargv[1] ) ) == be ) {
396 Debug( LDAP_DEBUG_ANY,
397 "%s: line %d: suffix already served by this backend (ignored)\n",
399 } else if ( tmp_be != NULL ) {
400 Debug( LDAP_DEBUG_ANY,
401 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
402 fname, lineno, tmp_be->be_suffix[0] );
404 char *dn = ch_strdup( cargv[1] );
405 if( dn_validate( dn ) == NULL ) {
406 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
407 "suffix DN invalid \"%s\"\n",
408 fname, lineno, cargv[1] );
411 } else if( *dn == '\0' && default_search_nbase != NULL ) {
412 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
413 "suffix DN empty and default "
414 "search base provided \"%s\" (assuming okay)\n",
415 fname, lineno, default_search_base );
417 charray_add( &be->be_suffix, dn );
418 (void) ldap_pvt_str2upper( dn );
419 charray_add( &be->be_nsuffix, dn );
423 /* set database suffixAlias */
424 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
427 Debug( LDAP_DEBUG_ANY,
428 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
431 } else if ( cargc < 3 ) {
432 Debug( LDAP_DEBUG_ANY,
433 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
436 } else if ( cargc > 3 ) {
437 Debug( LDAP_DEBUG_ANY,
438 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
443 Debug( LDAP_DEBUG_ANY,
444 "%s: line %d: suffixAlias line"
445 " must appear inside a database definition (ignored)\n",
447 } else if ( (tmp_be = select_backend( cargv[1] )) != NULL ) {
448 Debug( LDAP_DEBUG_ANY,
449 "%s: line %d: suffixAlias served by"
450 " a preceeding backend \"%s\" (ignored)\n",
451 fname, lineno, tmp_be->be_suffix[0] );
453 } else if ( (tmp_be = select_backend( cargv[2] )) != NULL ) {
454 Debug( LDAP_DEBUG_ANY,
455 "%s: line %d: suffixAlias derefs to differnet backend"
456 " a preceeding backend \"%s\" (ignored)\n",
457 fname, lineno, tmp_be->be_suffix[0] );
460 char *alias, *aliased_dn;
462 alias = ch_strdup( cargv[1] );
463 (void) dn_normalize( alias );
465 aliased_dn = ch_strdup( cargv[2] );
466 (void) dn_normalize( aliased_dn );
468 charray_add( &be->be_suffixAlias, alias );
469 charray_add( &be->be_suffixAlias, aliased_dn );
475 /* set max deref depth */
476 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
479 Debug( LDAP_DEBUG_ANY,
480 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
485 Debug( LDAP_DEBUG_ANY,
486 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
488 } else if ((i = atoi(cargv[1])) < 0) {
489 Debug( LDAP_DEBUG_ANY,
490 "%s: line %d: depth must be positive (ignored)\n",
494 be->be_max_deref_depth = i;
498 /* set magic "root" dn for this database */
499 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
501 Debug( LDAP_DEBUG_ANY,
502 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
507 Debug( LDAP_DEBUG_ANY,
508 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
511 be->be_root_dn = ch_strdup( cargv[1] );
512 be->be_root_ndn = ch_strdup( cargv[1] );
514 if( dn_normalize( be->be_root_ndn ) == NULL ) {
515 free( be->be_root_dn );
516 free( be->be_root_ndn );
517 Debug( LDAP_DEBUG_ANY,
518 "%s: line %d: rootdn DN is invalid\n",
524 /* set super-secret magic database password */
525 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
527 Debug( LDAP_DEBUG_ANY,
528 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
533 Debug( LDAP_DEBUG_ANY,
534 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
537 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
538 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
541 /* make this database read-only */
542 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
544 Debug( LDAP_DEBUG_ANY,
545 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
550 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
551 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
553 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
556 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
557 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
559 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
564 /* allow these features */
565 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
566 strcasecmp( cargv[0], "allow" ) == 0 )
571 Debug( LDAP_DEBUG_ANY,
572 "%s: line %d: allow line must appear prior to database definitions\n",
577 Debug( LDAP_DEBUG_ANY,
578 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
585 for( i=1; i < cargc; i++ ) {
586 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
587 allows |= SLAP_ALLOW_TLS_2_ANON;
589 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
590 Debug( LDAP_DEBUG_ANY,
591 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
592 fname, lineno, cargv[i] );
597 global_allows = allows;
599 /* disallow these features */
600 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
601 strcasecmp( cargv[0], "disallow" ) == 0 )
603 slap_mask_t disallows;
606 Debug( LDAP_DEBUG_ANY,
607 "%s: line %d: disallow line must appear prior to database definitions\n",
612 Debug( LDAP_DEBUG_ANY,
613 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
620 for( i=1; i < cargc; i++ ) {
621 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
622 disallows |= SLAP_DISALLOW_BIND_V2;
624 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
625 disallows |= SLAP_DISALLOW_BIND_ANON;
627 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
628 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
630 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
631 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
633 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
634 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
636 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
637 disallows |= SLAP_DISALLOW_BIND_KRBV4;
639 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
640 disallows |= SLAP_DISALLOW_TLS_AUTHC;
642 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
643 Debug( LDAP_DEBUG_ANY,
644 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
645 fname, lineno, cargv[i] );
650 global_disallows = disallows;
652 /* require these features */
653 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
654 strcasecmp( cargv[0], "require" ) == 0 )
656 slap_mask_t requires;
659 Debug( LDAP_DEBUG_ANY,
660 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
667 for( i=1; i < cargc; i++ ) {
668 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
669 requires |= SLAP_REQUIRE_BIND;
671 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
672 requires |= SLAP_REQUIRE_LDAP_V3;
674 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
675 requires |= SLAP_REQUIRE_AUTHC;
677 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
678 requires |= SLAP_REQUIRE_SASL;
680 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
681 requires |= SLAP_REQUIRE_STRONG;
683 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
684 Debug( LDAP_DEBUG_ANY,
685 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
686 fname, lineno, cargv[i] );
692 global_requires = requires;
694 be->be_requires = requires;
697 /* required security factors */
698 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
702 Debug( LDAP_DEBUG_ANY,
703 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
709 set = &global_ssf_set;
711 set = &be->be_ssf_set;
714 for( i=1; i < cargc; i++ ) {
715 if( strncasecmp( cargv[i], "ssf=",
716 sizeof("ssf") ) == 0 )
719 atoi( &cargv[i][sizeof("ssf")] );
721 } else if( strncasecmp( cargv[i], "transport=",
722 sizeof("transport") ) == 0 )
725 atoi( &cargv[i][sizeof("transport")] );
727 } else if( strncasecmp( cargv[i], "tls=",
728 sizeof("tls") ) == 0 )
731 atoi( &cargv[i][sizeof("tls")] );
733 } else if( strncasecmp( cargv[i], "sasl=",
734 sizeof("sasl") ) == 0 )
737 atoi( &cargv[i][sizeof("sasl")] );
739 } else if( strncasecmp( cargv[i], "update_ssf=",
740 sizeof("update_ssf") ) == 0 )
742 set->sss_update_ssf =
743 atoi( &cargv[i][sizeof("update_ssf")] );
745 } else if( strncasecmp( cargv[i], "update_transport=",
746 sizeof("update_transport") ) == 0 )
748 set->sss_update_transport =
749 atoi( &cargv[i][sizeof("update_transport")] );
751 } else if( strncasecmp( cargv[i], "update_tls=",
752 sizeof("update_tls") ) == 0 )
754 set->sss_update_tls =
755 atoi( &cargv[i][sizeof("update_tls")] );
757 } else if( strncasecmp( cargv[i], "update_sasl=",
758 sizeof("update_sasl") ) == 0 )
760 set->sss_update_sasl =
761 atoi( &cargv[i][sizeof("update_sasl")] );
764 Debug( LDAP_DEBUG_ANY,
765 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
766 fname, lineno, cargv[i] );
772 /* where to send clients when we don't hold it */
773 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
775 Debug( LDAP_DEBUG_ANY,
776 "%s: line %d: missing URL in \"referral <URL>\" line\n",
781 vals[0]->bv_val = cargv[1];
782 vals[0]->bv_len = strlen( vals[0]->bv_val );
783 value_add( &default_referral, vals );
785 /* specify an Object Identifier macro */
786 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
787 parse_oidm( fname, lineno, cargc, cargv );
789 /* specify an objectclass */
790 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
791 if ( *cargv[1] == '(' ) {
793 p = strchr(saveline,'(');
794 parse_oc( fname, lineno, p, cargv );
796 Debug( LDAP_DEBUG_ANY,
797 "%s: line %d: old objectclass format not supported.\n",
801 /* specify an attribute type */
802 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
803 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
805 if ( *cargv[1] == '(' ) {
807 p = strchr(saveline,'(');
808 parse_at( fname, lineno, p, cargv );
810 Debug( LDAP_DEBUG_ANY,
811 "%s: line %d: old attribute type format not supported.\n",
815 /* turn on/off schema checking */
816 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
818 Debug( LDAP_DEBUG_ANY,
819 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
823 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
824 global_schemacheck = 0;
826 global_schemacheck = 1;
829 /* specify access control info */
830 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
831 parse_acl( be, fname, lineno, cargc, cargv );
833 /* specify default access control info */
834 } else if ( strcasecmp( cargv[0], "defaultaccess" ) == 0 ) {
835 slap_access_t access;
838 Debug( LDAP_DEBUG_ANY,
839 "%s: line %d: missing limit in \"defaultaccess <access>\" line\n",
844 access = str2access( cargv[1] );
846 if ( access == ACL_INVALID_ACCESS ) {
847 Debug( LDAP_DEBUG_ANY,
848 "%s: line %d: bad access level \"%s\", "
849 "expecting none|auth|compare|search|read|write\n",
850 fname, lineno, cargv[1] );
855 global_default_access = access;
857 be->be_dfltaccess = access;
860 /* debug level to log things to syslog */
861 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
863 Debug( LDAP_DEBUG_ANY,
864 "%s: line %d: missing level in \"loglevel <level>\" line\n",
871 for( i=1; i < cargc; i++ ) {
872 ldap_syslog += atoi( cargv[1] );
875 /* list of replicas of the data in this backend (master only) */
876 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
878 Debug( LDAP_DEBUG_ANY,
879 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
884 Debug( LDAP_DEBUG_ANY,
885 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
888 for ( i = 1; i < cargc; i++ ) {
889 if ( strncasecmp( cargv[i], "host=", 5 )
891 charray_add( &be->be_replica,
897 Debug( LDAP_DEBUG_ANY,
898 "%s: line %d: missing host in \"replica\" line (ignored)\n",
903 /* dn of master entity allowed to write to replica */
904 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
906 Debug( LDAP_DEBUG_ANY,
907 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
912 Debug( LDAP_DEBUG_ANY,
913 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
916 be->be_update_ndn = ch_strdup( cargv[1] );
917 if( dn_normalize( be->be_update_ndn ) == NULL ) {
918 Debug( LDAP_DEBUG_ANY,
919 "%s: line %d: updatedn DN is invalid\n",
925 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
927 Debug( LDAP_DEBUG_ANY,
928 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
933 Debug( LDAP_DEBUG_ANY,
934 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
936 } else if ( be->be_update_ndn == NULL ) {
937 Debug( LDAP_DEBUG_ANY,
938 "%s: line %d: updateref line must after updatedn (ignored)\n",
941 vals[0]->bv_val = cargv[1];
942 vals[0]->bv_len = strlen( vals[0]->bv_val );
943 value_add( &be->be_update_refs, vals );
946 /* replication log file to which changes are appended */
947 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
949 Debug( LDAP_DEBUG_ANY,
950 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
955 be->be_replogfile = ch_strdup( cargv[1] );
957 replogfile = ch_strdup( cargv[1] );
960 /* maintain lastmodified{by,time} attributes */
961 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
963 Debug( LDAP_DEBUG_ANY,
964 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
968 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
975 be->be_lastmod = OFF;
977 global_lastmod = OFF;
980 /* set idle timeout value */
981 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
984 Debug( LDAP_DEBUG_ANY,
985 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
990 i = atoi( cargv[1] );
993 Debug( LDAP_DEBUG_ANY,
994 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
999 global_idletimeout = i;
1001 /* include another config file */
1002 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1004 Debug( LDAP_DEBUG_ANY,
1005 "%s: line %d: missing filename in \"include <filename>\" line\n",
1009 savefname = ch_strdup( cargv[1] );
1010 savelineno = lineno;
1012 if ( read_config( savefname ) != 0 ) {
1017 lineno = savelineno - 1;
1019 /* location of kerberos srvtab file */
1020 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1022 Debug( LDAP_DEBUG_ANY,
1023 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1027 ldap_srvtab = ch_strdup( cargv[1] );
1029 #ifdef SLAPD_MODULES
1030 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1032 Debug( LDAP_DEBUG_ANY,
1033 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1035 exit( EXIT_FAILURE );
1037 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1038 Debug( LDAP_DEBUG_ANY,
1039 "%s: line %d: failed to load or initialize module %s\n",
1040 fname, lineno, cargv[1]);
1041 exit( EXIT_FAILURE );
1043 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1045 Debug( LDAP_DEBUG_ANY,
1046 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1048 exit( EXIT_FAILURE );
1050 if (module_path( cargv[1] )) {
1051 Debug( LDAP_DEBUG_ANY,
1052 "%s: line %d: failed to set module search path to %s\n",
1053 fname, lineno, cargv[1]);
1054 exit( EXIT_FAILURE );
1057 #endif /*SLAPD_MODULES*/
1060 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1061 rc = ldap_pvt_tls_set_option( NULL,
1062 LDAP_OPT_X_TLS_PROTOCOL,
1067 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1068 rc = ldap_pvt_tls_set_option( NULL,
1069 LDAP_OPT_X_TLS_CIPHER_SUITE,
1074 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1075 rc = ldap_pvt_tls_set_option( NULL,
1076 LDAP_OPT_X_TLS_CERTFILE,
1081 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1082 rc = ldap_pvt_tls_set_option( NULL,
1083 LDAP_OPT_X_TLS_KEYFILE,
1088 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1089 rc = ldap_pvt_tls_set_option( NULL,
1090 LDAP_OPT_X_TLS_CACERTDIR,
1095 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1096 rc = ldap_pvt_tls_set_option( NULL,
1097 LDAP_OPT_X_TLS_CACERTFILE,
1101 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1102 rc = ldap_pvt_tls_set_option( NULL,
1103 LDAP_OPT_X_TLS_REQUIRE_CERT,
1110 /* pass anything else to the current backend info/db config routine */
1113 if ( bi->bi_config == 0 ) {
1114 Debug( LDAP_DEBUG_ANY,
1115 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1116 fname, lineno, cargv[0] );
1118 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1124 } else if ( be != NULL ) {
1125 if ( be->be_config == 0 ) {
1126 Debug( LDAP_DEBUG_ANY,
1127 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1128 fname, lineno, cargv[0] );
1130 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1137 Debug( LDAP_DEBUG_ANY,
1138 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1139 fname, lineno, cargv[0] );
1158 for ( token = strtok_quote( line, " \t" ); token != NULL;
1159 token = strtok_quote( NULL, " \t" ) ) {
1160 if ( *argcp == MAXARGS ) {
1161 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1165 argv[(*argcp)++] = token;
1167 argv[*argcp] = NULL;
1172 strtok_quote( char *line, char *sep )
1178 if ( line != NULL ) {
1181 while ( *next && strchr( sep, *next ) ) {
1185 if ( *next == '\0' ) {
1191 for ( inquote = 0; *next; ) {
1199 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1205 next + 1, strlen( next + 1 ) + 1 );
1206 next++; /* dont parse the escaped character */
1211 if ( strchr( sep, *next ) != NULL ) {
1224 static char buf[BUFSIZ];
1226 static int lmax, lcur;
1228 #define CATLINE( buf ) { \
1230 len = strlen( buf ); \
1231 while ( lcur + len + 1 > lmax ) { \
1233 line = (char *) ch_realloc( line, lmax ); \
1235 strcpy( line + lcur, buf ); \
1240 fp_getline( FILE *fp, int *lineno )
1248 /* hack attack - keeps us from having to keep a stack of bufs... */
1249 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1254 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1255 if ( (p = strchr( buf, '\n' )) != NULL ) {
1258 if ( ! isspace( (unsigned char) buf[0] ) ) {
1267 return( line[0] ? line : NULL );
1271 fp_getline_init( int *lineno )