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_nbase != 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 );
201 free( default_search_nbase );
204 default_search_base = ch_strdup( cargv[1] );
205 default_search_nbase = ch_strdup( cargv[1] );
207 if( dn_normalize( default_search_nbase ) == NULL ) {
208 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
209 "invalid default search base \"%s\"\n"
210 fname, lineno, default_search_base );
214 /* set maximum threads in thread pool */
215 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
218 Debug( LDAP_DEBUG_ANY,
219 "%s: line %d: missing count in \"threads <count>\" line\n",
224 c = atoi( cargv[1] );
227 Debug( LDAP_DEBUG_ANY,
228 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
233 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
235 /* get pid file name */
236 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
238 Debug( LDAP_DEBUG_ANY,
239 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
244 slapd_pid_file = ch_strdup( cargv[1] );
246 /* get args file name */
247 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
249 Debug( LDAP_DEBUG_ANY,
250 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
255 slapd_args_file = ch_strdup( cargv[1] );
257 /* default password hash */
258 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
260 Debug( LDAP_DEBUG_ANY,
261 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
265 if ( default_passwd_hash != NULL ) {
266 Debug( LDAP_DEBUG_ANY,
267 "%s: line %d: already set default password_hash!\n",
272 default_passwd_hash = ch_strdup( cargv[1] );
276 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
278 Debug( LDAP_DEBUG_ANY,
279 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
284 if ( global_host != NULL ) {
285 Debug( LDAP_DEBUG_ANY,
286 "%s: line %d: already set sasl-host!\n",
291 global_host = ch_strdup( cargv[1] );
295 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
297 Debug( LDAP_DEBUG_ANY,
298 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
303 if ( global_realm != NULL ) {
304 Debug( LDAP_DEBUG_ANY,
305 "%s: line %d: already set sasl-realm!\n",
310 global_realm = ch_strdup( cargv[1] );
313 /* SASL security properties */
314 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
318 Debug( LDAP_DEBUG_ANY,
319 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
324 txt = slap_sasl_secprops( cargv[1] );
326 Debug( LDAP_DEBUG_ANY,
327 "%s: line %d: sasl-secprops: %s\n",
328 fname, lineno, txt );
332 /* set UCDATA path */
333 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
335 Debug( LDAP_DEBUG_ANY,
336 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
341 if ( global_ucdata_path != NULL ) {
342 Debug( LDAP_DEBUG_ANY,
343 "%s: line %d: already set ucdata-path!\n",
348 global_ucdata_path = ch_strdup( cargv[1] );
352 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
354 Debug( LDAP_DEBUG_ANY,
355 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
360 defsize = atoi( cargv[1] );
362 be->be_sizelimit = atoi( cargv[1] );
366 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
368 Debug( LDAP_DEBUG_ANY,
369 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
374 deftime = atoi( cargv[1] );
376 be->be_timelimit = atoi( cargv[1] );
379 /* set database suffix */
380 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
383 Debug( LDAP_DEBUG_ANY,
384 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
387 } else if ( cargc > 2 ) {
388 Debug( LDAP_DEBUG_ANY,
389 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
390 fname, lineno, cargv[1] );
393 Debug( LDAP_DEBUG_ANY,
394 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
396 } else if ( ( tmp_be = select_backend( cargv[1] ) ) == be ) {
397 Debug( LDAP_DEBUG_ANY,
398 "%s: line %d: suffix already served by this backend (ignored)\n",
400 } else if ( tmp_be != NULL ) {
401 Debug( LDAP_DEBUG_ANY,
402 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
403 fname, lineno, tmp_be->be_suffix[0] );
405 char *dn = ch_strdup( cargv[1] );
406 if( dn_validate( dn ) == NULL ) {
407 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
408 "suffix DN invalid \"%s\"\n",
409 fname, lineno, cargv[1] );
412 } else if( *dn == '\0' && default_search_nbase != NULL ) {
413 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
414 "suffix DN empty and default "
415 "search base provided \"%s\" (assuming okay)\n",
416 fname, lineno, default_search_base );
418 charray_add( &be->be_suffix, dn );
419 (void) ldap_pvt_str2upper( dn );
420 charray_add( &be->be_nsuffix, dn );
424 /* set database suffixAlias */
425 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
428 Debug( LDAP_DEBUG_ANY,
429 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
432 } else if ( cargc < 3 ) {
433 Debug( LDAP_DEBUG_ANY,
434 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
437 } else if ( cargc > 3 ) {
438 Debug( LDAP_DEBUG_ANY,
439 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
444 Debug( LDAP_DEBUG_ANY,
445 "%s: line %d: suffixAlias line"
446 " must appear inside a database definition (ignored)\n",
448 } else if ( (tmp_be = select_backend( cargv[1] )) != NULL ) {
449 Debug( LDAP_DEBUG_ANY,
450 "%s: line %d: suffixAlias served by"
451 " a preceeding backend \"%s\" (ignored)\n",
452 fname, lineno, tmp_be->be_suffix[0] );
454 } else if ( (tmp_be = select_backend( cargv[2] )) != NULL ) {
455 Debug( LDAP_DEBUG_ANY,
456 "%s: line %d: suffixAlias derefs to differnet backend"
457 " a preceeding backend \"%s\" (ignored)\n",
458 fname, lineno, tmp_be->be_suffix[0] );
461 char *alias, *aliased_dn;
463 alias = ch_strdup( cargv[1] );
464 (void) dn_normalize( alias );
466 aliased_dn = ch_strdup( cargv[2] );
467 (void) dn_normalize( aliased_dn );
469 charray_add( &be->be_suffixAlias, alias );
470 charray_add( &be->be_suffixAlias, aliased_dn );
476 /* set max deref depth */
477 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
480 Debug( LDAP_DEBUG_ANY,
481 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
486 Debug( LDAP_DEBUG_ANY,
487 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
489 } else if ((i = atoi(cargv[1])) < 0) {
490 Debug( LDAP_DEBUG_ANY,
491 "%s: line %d: depth must be positive (ignored)\n",
495 be->be_max_deref_depth = i;
499 /* set magic "root" dn for this database */
500 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
502 Debug( LDAP_DEBUG_ANY,
503 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
508 Debug( LDAP_DEBUG_ANY,
509 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
512 be->be_root_dn = ch_strdup( cargv[1] );
513 be->be_root_ndn = ch_strdup( cargv[1] );
515 if( dn_normalize( be->be_root_ndn ) == NULL ) {
516 free( be->be_root_dn );
517 free( be->be_root_ndn );
518 Debug( LDAP_DEBUG_ANY,
519 "%s: line %d: rootdn DN is invalid\n",
525 /* set super-secret magic database password */
526 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
528 Debug( LDAP_DEBUG_ANY,
529 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
534 Debug( LDAP_DEBUG_ANY,
535 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
538 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
539 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
542 /* make this database read-only */
543 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
545 Debug( LDAP_DEBUG_ANY,
546 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
551 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
552 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
554 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
557 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
558 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
560 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
565 /* allow these features */
566 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
567 strcasecmp( cargv[0], "allow" ) == 0 )
572 Debug( LDAP_DEBUG_ANY,
573 "%s: line %d: allow line must appear prior to database definitions\n",
578 Debug( LDAP_DEBUG_ANY,
579 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
586 for( i=1; i < cargc; i++ ) {
587 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
588 allows |= SLAP_ALLOW_TLS_2_ANON;
590 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
591 Debug( LDAP_DEBUG_ANY,
592 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
593 fname, lineno, cargv[i] );
598 global_allows = allows;
600 /* disallow these features */
601 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
602 strcasecmp( cargv[0], "disallow" ) == 0 )
604 slap_mask_t disallows;
607 Debug( LDAP_DEBUG_ANY,
608 "%s: line %d: disallow line must appear prior to database definitions\n",
613 Debug( LDAP_DEBUG_ANY,
614 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
621 for( i=1; i < cargc; i++ ) {
622 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
623 disallows |= SLAP_DISALLOW_BIND_V2;
625 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
626 disallows |= SLAP_DISALLOW_BIND_ANON;
628 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
629 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
631 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
632 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
634 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
635 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
637 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
638 disallows |= SLAP_DISALLOW_BIND_KRBV4;
640 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
641 disallows |= SLAP_DISALLOW_TLS_AUTHC;
643 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
644 Debug( LDAP_DEBUG_ANY,
645 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
646 fname, lineno, cargv[i] );
651 global_disallows = disallows;
653 /* require these features */
654 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
655 strcasecmp( cargv[0], "require" ) == 0 )
657 slap_mask_t requires;
660 Debug( LDAP_DEBUG_ANY,
661 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
668 for( i=1; i < cargc; i++ ) {
669 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
670 requires |= SLAP_REQUIRE_BIND;
672 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
673 requires |= SLAP_REQUIRE_LDAP_V3;
675 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
676 requires |= SLAP_REQUIRE_AUTHC;
678 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
679 requires |= SLAP_REQUIRE_SASL;
681 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
682 requires |= SLAP_REQUIRE_STRONG;
684 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
685 Debug( LDAP_DEBUG_ANY,
686 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
687 fname, lineno, cargv[i] );
693 global_requires = requires;
695 be->be_requires = requires;
698 /* required security factors */
699 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
703 Debug( LDAP_DEBUG_ANY,
704 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
710 set = &global_ssf_set;
712 set = &be->be_ssf_set;
715 for( i=1; i < cargc; i++ ) {
716 if( strncasecmp( cargv[i], "ssf=",
717 sizeof("ssf") ) == 0 )
720 atoi( &cargv[i][sizeof("ssf")] );
722 } else if( strncasecmp( cargv[i], "transport=",
723 sizeof("transport") ) == 0 )
726 atoi( &cargv[i][sizeof("transport")] );
728 } else if( strncasecmp( cargv[i], "tls=",
729 sizeof("tls") ) == 0 )
732 atoi( &cargv[i][sizeof("tls")] );
734 } else if( strncasecmp( cargv[i], "sasl=",
735 sizeof("sasl") ) == 0 )
738 atoi( &cargv[i][sizeof("sasl")] );
740 } else if( strncasecmp( cargv[i], "update_ssf=",
741 sizeof("update_ssf") ) == 0 )
743 set->sss_update_ssf =
744 atoi( &cargv[i][sizeof("update_ssf")] );
746 } else if( strncasecmp( cargv[i], "update_transport=",
747 sizeof("update_transport") ) == 0 )
749 set->sss_update_transport =
750 atoi( &cargv[i][sizeof("update_transport")] );
752 } else if( strncasecmp( cargv[i], "update_tls=",
753 sizeof("update_tls") ) == 0 )
755 set->sss_update_tls =
756 atoi( &cargv[i][sizeof("update_tls")] );
758 } else if( strncasecmp( cargv[i], "update_sasl=",
759 sizeof("update_sasl") ) == 0 )
761 set->sss_update_sasl =
762 atoi( &cargv[i][sizeof("update_sasl")] );
765 Debug( LDAP_DEBUG_ANY,
766 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
767 fname, lineno, cargv[i] );
773 /* where to send clients when we don't hold it */
774 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
776 Debug( LDAP_DEBUG_ANY,
777 "%s: line %d: missing URL in \"referral <URL>\" line\n",
782 vals[0]->bv_val = cargv[1];
783 vals[0]->bv_len = strlen( vals[0]->bv_val );
784 value_add( &default_referral, vals );
786 /* specify an Object Identifier macro */
787 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
788 parse_oidm( fname, lineno, cargc, cargv );
790 /* specify an objectclass */
791 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
792 if ( *cargv[1] == '(' ) {
794 p = strchr(saveline,'(');
795 parse_oc( fname, lineno, p, cargv );
797 Debug( LDAP_DEBUG_ANY,
798 "%s: line %d: old objectclass format not supported.\n",
802 /* specify an attribute type */
803 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
804 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
806 if ( *cargv[1] == '(' ) {
808 p = strchr(saveline,'(');
809 parse_at( fname, lineno, p, cargv );
811 Debug( LDAP_DEBUG_ANY,
812 "%s: line %d: old attribute type format not supported.\n",
816 /* turn on/off schema checking */
817 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
819 Debug( LDAP_DEBUG_ANY,
820 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
824 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
825 global_schemacheck = 0;
827 global_schemacheck = 1;
830 /* specify access control info */
831 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
832 parse_acl( be, fname, lineno, cargc, cargv );
834 /* specify default access control info */
835 } else if ( strcasecmp( cargv[0], "defaultaccess" ) == 0 ) {
836 slap_access_t access;
839 Debug( LDAP_DEBUG_ANY,
840 "%s: line %d: missing limit in \"defaultaccess <access>\" line\n",
845 access = str2access( cargv[1] );
847 if ( access == ACL_INVALID_ACCESS ) {
848 Debug( LDAP_DEBUG_ANY,
849 "%s: line %d: bad access level \"%s\", "
850 "expecting none|auth|compare|search|read|write\n",
851 fname, lineno, cargv[1] );
856 global_default_access = access;
858 be->be_dfltaccess = access;
861 /* debug level to log things to syslog */
862 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
864 Debug( LDAP_DEBUG_ANY,
865 "%s: line %d: missing level in \"loglevel <level>\" line\n",
872 for( i=1; i < cargc; i++ ) {
873 ldap_syslog += atoi( cargv[1] );
876 /* list of replicas of the data in this backend (master only) */
877 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
879 Debug( LDAP_DEBUG_ANY,
880 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
885 Debug( LDAP_DEBUG_ANY,
886 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
889 for ( i = 1; i < cargc; i++ ) {
890 if ( strncasecmp( cargv[i], "host=", 5 )
892 charray_add( &be->be_replica,
898 Debug( LDAP_DEBUG_ANY,
899 "%s: line %d: missing host in \"replica\" line (ignored)\n",
904 /* dn of master entity allowed to write to replica */
905 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
907 Debug( LDAP_DEBUG_ANY,
908 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
913 Debug( LDAP_DEBUG_ANY,
914 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
917 be->be_update_ndn = ch_strdup( cargv[1] );
918 if( dn_normalize( be->be_update_ndn ) == NULL ) {
919 Debug( LDAP_DEBUG_ANY,
920 "%s: line %d: updatedn DN is invalid\n",
926 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
928 Debug( LDAP_DEBUG_ANY,
929 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
934 Debug( LDAP_DEBUG_ANY,
935 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
937 } else if ( be->be_update_ndn == NULL ) {
938 Debug( LDAP_DEBUG_ANY,
939 "%s: line %d: updateref line must after updatedn (ignored)\n",
942 vals[0]->bv_val = cargv[1];
943 vals[0]->bv_len = strlen( vals[0]->bv_val );
944 value_add( &be->be_update_refs, vals );
947 /* replication log file to which changes are appended */
948 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
950 Debug( LDAP_DEBUG_ANY,
951 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
956 be->be_replogfile = ch_strdup( cargv[1] );
958 replogfile = ch_strdup( cargv[1] );
961 /* maintain lastmodified{by,time} attributes */
962 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
964 Debug( LDAP_DEBUG_ANY,
965 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
969 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
976 be->be_lastmod = OFF;
978 global_lastmod = OFF;
981 /* set idle timeout value */
982 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
985 Debug( LDAP_DEBUG_ANY,
986 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
991 i = atoi( cargv[1] );
994 Debug( LDAP_DEBUG_ANY,
995 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1000 global_idletimeout = i;
1002 /* include another config file */
1003 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1005 Debug( LDAP_DEBUG_ANY,
1006 "%s: line %d: missing filename in \"include <filename>\" line\n",
1010 savefname = ch_strdup( cargv[1] );
1011 savelineno = lineno;
1013 if ( read_config( savefname ) != 0 ) {
1018 lineno = savelineno - 1;
1020 /* location of kerberos srvtab file */
1021 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1023 Debug( LDAP_DEBUG_ANY,
1024 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1028 ldap_srvtab = ch_strdup( cargv[1] );
1030 #ifdef SLAPD_MODULES
1031 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1033 Debug( LDAP_DEBUG_ANY,
1034 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1036 exit( EXIT_FAILURE );
1038 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1039 Debug( LDAP_DEBUG_ANY,
1040 "%s: line %d: failed to load or initialize module %s\n",
1041 fname, lineno, cargv[1]);
1042 exit( EXIT_FAILURE );
1044 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1046 Debug( LDAP_DEBUG_ANY,
1047 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1049 exit( EXIT_FAILURE );
1051 if (module_path( cargv[1] )) {
1052 Debug( LDAP_DEBUG_ANY,
1053 "%s: line %d: failed to set module search path to %s\n",
1054 fname, lineno, cargv[1]);
1055 exit( EXIT_FAILURE );
1058 #endif /*SLAPD_MODULES*/
1061 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1062 rc = ldap_pvt_tls_set_option( NULL,
1063 LDAP_OPT_X_TLS_PROTOCOL,
1068 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1069 rc = ldap_pvt_tls_set_option( NULL,
1070 LDAP_OPT_X_TLS_CIPHER_SUITE,
1075 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1076 rc = ldap_pvt_tls_set_option( NULL,
1077 LDAP_OPT_X_TLS_CERTFILE,
1082 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1083 rc = ldap_pvt_tls_set_option( NULL,
1084 LDAP_OPT_X_TLS_KEYFILE,
1089 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1090 rc = ldap_pvt_tls_set_option( NULL,
1091 LDAP_OPT_X_TLS_CACERTDIR,
1096 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1097 rc = ldap_pvt_tls_set_option( NULL,
1098 LDAP_OPT_X_TLS_CACERTFILE,
1102 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1103 rc = ldap_pvt_tls_set_option( NULL,
1104 LDAP_OPT_X_TLS_REQUIRE_CERT,
1111 /* pass anything else to the current backend info/db config routine */
1114 if ( bi->bi_config == 0 ) {
1115 Debug( LDAP_DEBUG_ANY,
1116 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1117 fname, lineno, cargv[0] );
1119 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1125 } else if ( be != NULL ) {
1126 if ( be->be_config == 0 ) {
1127 Debug( LDAP_DEBUG_ANY,
1128 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1129 fname, lineno, cargv[0] );
1131 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1138 Debug( LDAP_DEBUG_ANY,
1139 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1140 fname, lineno, cargv[0] );
1159 for ( token = strtok_quote( line, " \t" ); token != NULL;
1160 token = strtok_quote( NULL, " \t" ) ) {
1161 if ( *argcp == MAXARGS ) {
1162 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1166 argv[(*argcp)++] = token;
1168 argv[*argcp] = NULL;
1173 strtok_quote( char *line, char *sep )
1179 if ( line != NULL ) {
1182 while ( *next && strchr( sep, *next ) ) {
1186 if ( *next == '\0' ) {
1192 for ( inquote = 0; *next; ) {
1200 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1206 next + 1, strlen( next + 1 ) + 1 );
1207 next++; /* dont parse the escaped character */
1212 if ( strchr( sep, *next ) != NULL ) {
1225 static char buf[BUFSIZ];
1227 static int lmax, lcur;
1229 #define CATLINE( buf ) { \
1231 len = strlen( buf ); \
1232 while ( lcur + len + 1 > lmax ) { \
1234 line = (char *) ch_realloc( line, lmax ); \
1236 strcpy( line + lcur, buf ); \
1241 fp_getline( FILE *fp, int *lineno )
1249 /* hack attack - keeps us from having to keep a stack of bufs... */
1250 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1255 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1256 if ( (p = strchr( buf, '\n' )) != NULL ) {
1259 if ( ! isspace( (unsigned char) buf[0] ) ) {
1268 return( line[0] ? line : NULL );
1272 fp_getline_init( int *lineno )