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>
23 * defaults for various global variables
25 int defsize = SLAPD_DEFAULT_SIZELIMIT;
26 int deftime = SLAPD_DEFAULT_TIMELIMIT;
27 AccessControl *global_acl = NULL;
28 slap_access_t global_default_access = ACL_READ;
29 slap_mask_t global_restrictops = 0;
30 slap_mask_t global_allows = 0;
31 slap_mask_t global_disallows = 0;
32 slap_mask_t global_requires = 0;
33 slap_ssf_set_t global_ssf_set;
35 int global_lastmod = ON;
36 int global_idletimeout = 0;
37 char *global_host = NULL;
38 char *global_realm = NULL;
39 char *global_ucdata_path = NULL;
40 char *ldap_srvtab = "";
41 char *default_passwd_hash;
42 char *default_search_base = NULL;
43 char *default_search_nbase = NULL;
45 char *slapd_pid_file = NULL;
46 char *slapd_args_file = NULL;
49 SaslRegexp_t *SaslRegexp = NULL;
51 static char *fp_getline(FILE *fp, int *lineno);
52 static void fp_getline_init(int *lineno);
53 static int fp_parse_line(char *line, int *argcp, char **argv);
55 static char *strtok_quote(char *line, char *sep);
58 read_config( const char *fname )
61 char *line, *savefname, *saveline;
62 int cargc, savelineno;
63 char *cargv[MAXARGS+1];
68 struct berval *vals[2];
71 static BackendInfo *bi = NULL;
72 static BackendDB *be = NULL;
77 if ( (fp = fopen( fname, "r" )) == NULL ) {
79 Debug( LDAP_DEBUG_ANY,
80 "could not open config file \"%s\" - absolute path?\n",
86 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
88 fp_getline_init( &lineno );
90 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
91 /* skip comments and blank lines */
92 if ( line[0] == '#' || line[0] == '\0' ) {
96 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
98 /* fp_parse_line is destructive, we save a copy */
99 saveline = ch_strdup( line );
101 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
106 Debug( LDAP_DEBUG_ANY,
107 "%s: line %d: bad config line (ignored)\n",
112 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
114 Debug( LDAP_DEBUG_ANY,
115 "%s: line %d: missing type in \"backend <type>\" line\n",
121 Debug( LDAP_DEBUG_ANY,
122 "%s: line %d: backend line must appear before any database definition\n",
127 bi = backend_info( cargv[1] );
130 Debug( LDAP_DEBUG_ANY,
131 "backend %s initialization failed.\n",
136 /* start of a new database definition */
137 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
139 Debug( LDAP_DEBUG_ANY,
140 "%s: line %d: missing type in \"database <type>\" line\n",
146 be = backend_db_init( cargv[1] );
149 Debug( LDAP_DEBUG_ANY,
150 "database %s initialization failed.\n",
155 /* set thread concurrency */
156 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
159 Debug( LDAP_DEBUG_ANY,
160 "%s: line %d: missing level in \"concurrency <level>\" line\n",
165 c = atoi( cargv[1] );
168 Debug( LDAP_DEBUG_ANY,
169 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
174 ldap_pvt_thread_set_concurrency( c );
176 /* default search base */
177 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
179 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
180 "missing dn in \"defaultSearchBase <dn>\" line\n",
184 } else if ( cargc > 2 ) {
185 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
186 "extra cruft after <dn> in \"defaultSearchBase %s\", "
188 fname, lineno, cargv[1] );
191 if ( bi != NULL || be != NULL ) {
192 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
193 "defaultSearchBaase line must appear prior to "
194 "any backend or database definition\n",
199 if ( default_search_nbase != NULL ) {
200 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
201 "default search base \"%s\" already defined "
202 "(discarding old)\n",
203 fname, lineno, default_search_base );
204 free( default_search_base );
205 free( default_search_nbase );
208 default_search_base = ch_strdup( cargv[1] );
209 default_search_nbase = ch_strdup( cargv[1] );
211 if( dn_normalize( default_search_nbase ) == NULL ) {
212 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
213 "invalid default search base \"%s\"\n",
214 fname, lineno, default_search_base );
218 /* set maximum threads in thread pool */
219 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
222 Debug( LDAP_DEBUG_ANY,
223 "%s: line %d: missing count in \"threads <count>\" line\n",
228 c = atoi( cargv[1] );
231 Debug( LDAP_DEBUG_ANY,
232 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
237 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
239 /* get pid file name */
240 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
242 Debug( LDAP_DEBUG_ANY,
243 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
248 slapd_pid_file = ch_strdup( cargv[1] );
250 /* get args file name */
251 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
253 Debug( LDAP_DEBUG_ANY,
254 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
259 slapd_args_file = ch_strdup( cargv[1] );
261 /* default password hash */
262 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
264 Debug( LDAP_DEBUG_ANY,
265 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
269 if ( default_passwd_hash != NULL ) {
270 Debug( LDAP_DEBUG_ANY,
271 "%s: line %d: already set default password_hash!\n",
276 default_passwd_hash = ch_strdup( cargv[1] );
280 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
282 Debug( LDAP_DEBUG_ANY,
283 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
288 if ( global_host != NULL ) {
289 Debug( LDAP_DEBUG_ANY,
290 "%s: line %d: already set sasl-host!\n",
295 global_host = ch_strdup( cargv[1] );
299 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
301 Debug( LDAP_DEBUG_ANY,
302 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
307 if ( global_realm != NULL ) {
308 Debug( LDAP_DEBUG_ANY,
309 "%s: line %d: already set sasl-realm!\n",
314 global_realm = ch_strdup( cargv[1] );
317 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
318 || !strcasecmp( cargv[0], "saslregexp" ) )
322 Debug( LDAP_DEBUG_ANY,
323 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
327 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
332 /* SASL security properties */
333 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
337 Debug( LDAP_DEBUG_ANY,
338 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
343 txt = slap_sasl_secprops( cargv[1] );
345 Debug( LDAP_DEBUG_ANY,
346 "%s: line %d: sasl-secprops: %s\n",
347 fname, lineno, txt );
351 /* set UCDATA path */
352 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
354 Debug( LDAP_DEBUG_ANY,
355 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
360 if ( global_ucdata_path != NULL ) {
361 Debug( LDAP_DEBUG_ANY,
362 "%s: line %d: already set ucdata-path!\n",
367 global_ucdata_path = ch_strdup( cargv[1] );
371 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
373 Debug( LDAP_DEBUG_ANY,
374 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
379 defsize = atoi( cargv[1] );
381 be->be_sizelimit = atoi( cargv[1] );
385 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
387 Debug( LDAP_DEBUG_ANY,
388 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
393 deftime = atoi( cargv[1] );
395 be->be_timelimit = atoi( cargv[1] );
398 /* set database suffix */
399 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
402 Debug( LDAP_DEBUG_ANY,
403 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
406 } else if ( cargc > 2 ) {
407 Debug( LDAP_DEBUG_ANY,
408 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
409 fname, lineno, cargv[1] );
412 Debug( LDAP_DEBUG_ANY,
413 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
415 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
416 Debug( LDAP_DEBUG_ANY,
417 "%s: line %d: suffix already served by this backend (ignored)\n",
419 } else if ( tmp_be != NULL ) {
420 Debug( LDAP_DEBUG_ANY,
421 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
422 fname, lineno, tmp_be->be_suffix[0] );
424 char *dn = ch_strdup( cargv[1] );
425 if( dn_validate( dn ) == NULL ) {
426 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
427 "suffix DN invalid \"%s\"\n",
428 fname, lineno, cargv[1] );
431 } else if( *dn == '\0' && default_search_nbase != NULL ) {
432 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
433 "suffix DN empty and default "
434 "search base provided \"%s\" (assuming okay)\n",
435 fname, lineno, default_search_base );
437 charray_add( &be->be_suffix, dn );
438 (void) ldap_pvt_str2upper( dn );
439 charray_add( &be->be_nsuffix, dn );
443 /* set database suffixAlias */
444 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
447 Debug( LDAP_DEBUG_ANY,
448 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
451 } else if ( cargc < 3 ) {
452 Debug( LDAP_DEBUG_ANY,
453 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
456 } else if ( cargc > 3 ) {
457 Debug( LDAP_DEBUG_ANY,
458 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
463 Debug( LDAP_DEBUG_ANY,
464 "%s: line %d: suffixAlias line"
465 " must appear inside a database definition (ignored)\n",
467 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
468 Debug( LDAP_DEBUG_ANY,
469 "%s: line %d: suffixAlias served by"
470 " a preceeding backend \"%s\" (ignored)\n",
471 fname, lineno, tmp_be->be_suffix[0] );
473 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
474 Debug( LDAP_DEBUG_ANY,
475 "%s: line %d: suffixAlias derefs to differnet backend"
476 " a preceeding backend \"%s\" (ignored)\n",
477 fname, lineno, tmp_be->be_suffix[0] );
480 char *alias, *aliased_dn;
482 alias = ch_strdup( cargv[1] );
483 (void) dn_normalize( alias );
485 aliased_dn = ch_strdup( cargv[2] );
486 (void) dn_normalize( aliased_dn );
488 charray_add( &be->be_suffixAlias, alias );
489 charray_add( &be->be_suffixAlias, aliased_dn );
495 /* set max deref depth */
496 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
499 Debug( LDAP_DEBUG_ANY,
500 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
505 Debug( LDAP_DEBUG_ANY,
506 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
508 } else if ((i = atoi(cargv[1])) < 0) {
509 Debug( LDAP_DEBUG_ANY,
510 "%s: line %d: depth must be positive (ignored)\n",
514 be->be_max_deref_depth = i;
518 /* set magic "root" dn for this database */
519 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
521 Debug( LDAP_DEBUG_ANY,
522 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
527 Debug( LDAP_DEBUG_ANY,
528 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
531 be->be_root_dn = ch_strdup( cargv[1] );
532 be->be_root_ndn = ch_strdup( cargv[1] );
534 if( dn_normalize( be->be_root_ndn ) == NULL ) {
535 free( be->be_root_dn );
536 free( be->be_root_ndn );
537 Debug( LDAP_DEBUG_ANY,
538 "%s: line %d: rootdn DN is invalid\n",
544 /* set super-secret magic database password */
545 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
547 Debug( LDAP_DEBUG_ANY,
548 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
553 Debug( LDAP_DEBUG_ANY,
554 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
557 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
558 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
561 /* make this database read-only */
562 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
564 Debug( LDAP_DEBUG_ANY,
565 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
570 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
571 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
573 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
576 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
577 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
579 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
584 /* allow these features */
585 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
586 strcasecmp( cargv[0], "allow" ) == 0 )
591 Debug( LDAP_DEBUG_ANY,
592 "%s: line %d: allow line must appear prior to database definitions\n",
597 Debug( LDAP_DEBUG_ANY,
598 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
605 for( i=1; i < cargc; i++ ) {
606 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
607 allows |= SLAP_ALLOW_TLS_2_ANON;
609 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
610 Debug( LDAP_DEBUG_ANY,
611 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
612 fname, lineno, cargv[i] );
617 global_allows = allows;
619 /* disallow these features */
620 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
621 strcasecmp( cargv[0], "disallow" ) == 0 )
623 slap_mask_t disallows;
626 Debug( LDAP_DEBUG_ANY,
627 "%s: line %d: disallow line must appear prior to database definitions\n",
632 Debug( LDAP_DEBUG_ANY,
633 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
640 for( i=1; i < cargc; i++ ) {
641 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
642 disallows |= SLAP_DISALLOW_BIND_V2;
644 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
645 disallows |= SLAP_DISALLOW_BIND_ANON;
647 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
648 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
650 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
651 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
653 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
654 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
656 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
657 disallows |= SLAP_DISALLOW_BIND_KRBV4;
659 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
660 disallows |= SLAP_DISALLOW_TLS_AUTHC;
662 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
663 Debug( LDAP_DEBUG_ANY,
664 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
665 fname, lineno, cargv[i] );
670 global_disallows = disallows;
672 /* require these features */
673 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
674 strcasecmp( cargv[0], "require" ) == 0 )
676 slap_mask_t requires;
679 Debug( LDAP_DEBUG_ANY,
680 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
687 for( i=1; i < cargc; i++ ) {
688 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
689 requires |= SLAP_REQUIRE_BIND;
691 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
692 requires |= SLAP_REQUIRE_LDAP_V3;
694 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
695 requires |= SLAP_REQUIRE_AUTHC;
697 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
698 requires |= SLAP_REQUIRE_SASL;
700 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
701 requires |= SLAP_REQUIRE_STRONG;
703 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
704 Debug( LDAP_DEBUG_ANY,
705 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
706 fname, lineno, cargv[i] );
712 global_requires = requires;
714 be->be_requires = requires;
717 /* required security factors */
718 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
722 Debug( LDAP_DEBUG_ANY,
723 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
729 set = &global_ssf_set;
731 set = &be->be_ssf_set;
734 for( i=1; i < cargc; i++ ) {
735 if( strncasecmp( cargv[i], "ssf=",
736 sizeof("ssf") ) == 0 )
739 atoi( &cargv[i][sizeof("ssf")] );
741 } else if( strncasecmp( cargv[i], "transport=",
742 sizeof("transport") ) == 0 )
745 atoi( &cargv[i][sizeof("transport")] );
747 } else if( strncasecmp( cargv[i], "tls=",
748 sizeof("tls") ) == 0 )
751 atoi( &cargv[i][sizeof("tls")] );
753 } else if( strncasecmp( cargv[i], "sasl=",
754 sizeof("sasl") ) == 0 )
757 atoi( &cargv[i][sizeof("sasl")] );
759 } else if( strncasecmp( cargv[i], "update_ssf=",
760 sizeof("update_ssf") ) == 0 )
762 set->sss_update_ssf =
763 atoi( &cargv[i][sizeof("update_ssf")] );
765 } else if( strncasecmp( cargv[i], "update_transport=",
766 sizeof("update_transport") ) == 0 )
768 set->sss_update_transport =
769 atoi( &cargv[i][sizeof("update_transport")] );
771 } else if( strncasecmp( cargv[i], "update_tls=",
772 sizeof("update_tls") ) == 0 )
774 set->sss_update_tls =
775 atoi( &cargv[i][sizeof("update_tls")] );
777 } else if( strncasecmp( cargv[i], "update_sasl=",
778 sizeof("update_sasl") ) == 0 )
780 set->sss_update_sasl =
781 atoi( &cargv[i][sizeof("update_sasl")] );
784 Debug( LDAP_DEBUG_ANY,
785 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
786 fname, lineno, cargv[i] );
792 /* where to send clients when we don't hold it */
793 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
795 Debug( LDAP_DEBUG_ANY,
796 "%s: line %d: missing URL in \"referral <URL>\" line\n",
801 vals[0]->bv_val = cargv[1];
802 vals[0]->bv_len = strlen( vals[0]->bv_val );
803 value_add( &default_referral, vals );
805 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
808 Debug( LDAP_DEBUG_ANY,
809 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
813 level = atoi( cargv[2] );
814 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
815 lutil_set_debug_level( cargv[1], level );
816 /* specify an Object Identifier macro */
817 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
818 parse_oidm( fname, lineno, cargc, cargv );
820 /* specify an objectclass */
821 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
822 if ( *cargv[1] == '(' ) {
824 p = strchr(saveline,'(');
825 parse_oc( fname, lineno, p, cargv );
827 Debug( LDAP_DEBUG_ANY,
828 "%s: line %d: old objectclass format not supported.\n",
832 /* specify an attribute type */
833 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
834 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
836 if ( *cargv[1] == '(' ) {
838 p = strchr(saveline,'(');
839 parse_at( fname, lineno, p, cargv );
841 Debug( LDAP_DEBUG_ANY,
842 "%s: line %d: old attribute type format not supported.\n",
846 /* turn on/off schema checking */
847 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
849 Debug( LDAP_DEBUG_ANY,
850 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
854 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
855 global_schemacheck = 0;
857 global_schemacheck = 1;
860 /* specify access control info */
861 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
862 parse_acl( be, fname, lineno, cargc, cargv );
864 /* debug level to log things to syslog */
865 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
867 Debug( LDAP_DEBUG_ANY,
868 "%s: line %d: missing level in \"loglevel <level>\" line\n",
875 for( i=1; i < cargc; i++ ) {
876 ldap_syslog += atoi( cargv[1] );
879 /* list of replicas of the data in this backend (master only) */
880 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
882 Debug( LDAP_DEBUG_ANY,
883 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
888 Debug( LDAP_DEBUG_ANY,
889 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
892 for ( i = 1; i < cargc; i++ ) {
893 if ( strncasecmp( cargv[i], "host=", 5 )
895 charray_add( &be->be_replica,
901 Debug( LDAP_DEBUG_ANY,
902 "%s: line %d: missing host in \"replica\" line (ignored)\n",
907 /* dn of master entity allowed to write to replica */
908 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
910 Debug( LDAP_DEBUG_ANY,
911 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
916 Debug( LDAP_DEBUG_ANY,
917 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
920 be->be_update_ndn = ch_strdup( cargv[1] );
921 if( dn_normalize( be->be_update_ndn ) == NULL ) {
922 Debug( LDAP_DEBUG_ANY,
923 "%s: line %d: updatedn DN is invalid\n",
929 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
931 Debug( LDAP_DEBUG_ANY,
932 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
937 Debug( LDAP_DEBUG_ANY,
938 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
940 } else if ( be->be_update_ndn == NULL ) {
941 Debug( LDAP_DEBUG_ANY,
942 "%s: line %d: updateref line must after updatedn (ignored)\n",
945 vals[0]->bv_val = cargv[1];
946 vals[0]->bv_len = strlen( vals[0]->bv_val );
947 value_add( &be->be_update_refs, vals );
950 /* replication log file to which changes are appended */
951 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
953 Debug( LDAP_DEBUG_ANY,
954 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
959 be->be_replogfile = ch_strdup( cargv[1] );
961 replogfile = ch_strdup( cargv[1] );
964 /* maintain lastmodified{by,time} attributes */
965 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
967 Debug( LDAP_DEBUG_ANY,
968 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
972 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
979 be->be_lastmod = OFF;
981 global_lastmod = OFF;
984 /* set idle timeout value */
985 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
988 Debug( LDAP_DEBUG_ANY,
989 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
994 i = atoi( cargv[1] );
997 Debug( LDAP_DEBUG_ANY,
998 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1003 global_idletimeout = i;
1005 /* include another config file */
1006 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1008 Debug( LDAP_DEBUG_ANY,
1009 "%s: line %d: missing filename in \"include <filename>\" line\n",
1013 savefname = ch_strdup( cargv[1] );
1014 savelineno = lineno;
1016 if ( read_config( savefname ) != 0 ) {
1021 lineno = savelineno - 1;
1023 /* location of kerberos srvtab file */
1024 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1026 Debug( LDAP_DEBUG_ANY,
1027 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1031 ldap_srvtab = ch_strdup( cargv[1] );
1033 #ifdef SLAPD_MODULES
1034 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1036 Debug( LDAP_DEBUG_ANY,
1037 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1039 exit( EXIT_FAILURE );
1041 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1042 Debug( LDAP_DEBUG_ANY,
1043 "%s: line %d: failed to load or initialize module %s\n",
1044 fname, lineno, cargv[1]);
1045 exit( EXIT_FAILURE );
1047 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1049 Debug( LDAP_DEBUG_ANY,
1050 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1052 exit( EXIT_FAILURE );
1054 if (module_path( cargv[1] )) {
1055 Debug( LDAP_DEBUG_ANY,
1056 "%s: line %d: failed to set module search path to %s\n",
1057 fname, lineno, cargv[1]);
1058 exit( EXIT_FAILURE );
1061 #endif /*SLAPD_MODULES*/
1064 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1065 rc = ldap_pvt_tls_set_option( NULL,
1066 LDAP_OPT_X_TLS_PROTOCOL,
1071 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1072 rc = ldap_pvt_tls_set_option( NULL,
1073 LDAP_OPT_X_TLS_CIPHER_SUITE,
1078 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1079 rc = ldap_pvt_tls_set_option( NULL,
1080 LDAP_OPT_X_TLS_CERTFILE,
1085 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1086 rc = ldap_pvt_tls_set_option( NULL,
1087 LDAP_OPT_X_TLS_KEYFILE,
1092 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1093 rc = ldap_pvt_tls_set_option( NULL,
1094 LDAP_OPT_X_TLS_CACERTDIR,
1099 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1100 rc = ldap_pvt_tls_set_option( NULL,
1101 LDAP_OPT_X_TLS_CACERTFILE,
1105 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1107 rc = ldap_pvt_tls_set_option( NULL,
1108 LDAP_OPT_X_TLS_REQUIRE_CERT,
1115 /* pass anything else to the current backend info/db config routine */
1118 if ( bi->bi_config == 0 ) {
1119 Debug( LDAP_DEBUG_ANY,
1120 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1121 fname, lineno, cargv[0] );
1123 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1129 } else if ( be != NULL ) {
1130 if ( be->be_config == 0 ) {
1131 Debug( LDAP_DEBUG_ANY,
1132 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1133 fname, lineno, cargv[0] );
1135 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1142 Debug( LDAP_DEBUG_ANY,
1143 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1144 fname, lineno, cargv[0] );
1163 for ( token = strtok_quote( line, " \t" ); token != NULL;
1164 token = strtok_quote( NULL, " \t" ) ) {
1165 if ( *argcp == MAXARGS ) {
1166 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1170 argv[(*argcp)++] = token;
1172 argv[*argcp] = NULL;
1177 strtok_quote( char *line, char *sep )
1183 if ( line != NULL ) {
1186 while ( *next && strchr( sep, *next ) ) {
1190 if ( *next == '\0' ) {
1196 for ( inquote = 0; *next; ) {
1204 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1210 next + 1, strlen( next + 1 ) + 1 );
1211 next++; /* dont parse the escaped character */
1216 if ( strchr( sep, *next ) != NULL ) {
1229 static char buf[BUFSIZ];
1231 static int lmax, lcur;
1233 #define CATLINE( buf ) { \
1235 len = strlen( buf ); \
1236 while ( lcur + len + 1 > lmax ) { \
1238 line = (char *) ch_realloc( line, lmax ); \
1240 strcpy( line + lcur, buf ); \
1245 fp_getline( FILE *fp, int *lineno )
1253 /* hack attack - keeps us from having to keep a stack of bufs... */
1254 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1259 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1260 if ( (p = strchr( buf, '\n' )) != NULL ) {
1263 if ( ! isspace( (unsigned char) buf[0] ) ) {
1272 return( line[0] ? line : NULL );
1276 fp_getline_init( int *lineno )