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 *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);
55 static int load_ucdata(char *path);
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 ( load_ucdata( NULL ) < 0 ) {
214 if( dn_normalize( default_search_nbase ) == NULL ) {
215 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
216 "invalid default search base \"%s\"\n",
217 fname, lineno, default_search_base );
221 /* set maximum threads in thread pool */
222 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
225 Debug( LDAP_DEBUG_ANY,
226 "%s: line %d: missing count in \"threads <count>\" line\n",
231 c = atoi( cargv[1] );
234 Debug( LDAP_DEBUG_ANY,
235 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
240 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
242 /* get pid file name */
243 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
245 Debug( LDAP_DEBUG_ANY,
246 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
251 slapd_pid_file = ch_strdup( cargv[1] );
253 /* get args file name */
254 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
256 Debug( LDAP_DEBUG_ANY,
257 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
262 slapd_args_file = ch_strdup( cargv[1] );
264 /* default password hash */
265 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
267 Debug( LDAP_DEBUG_ANY,
268 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
272 if ( default_passwd_hash != NULL ) {
273 Debug( LDAP_DEBUG_ANY,
274 "%s: line %d: already set default password_hash!\n",
279 default_passwd_hash = ch_strdup( cargv[1] );
283 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
285 Debug( LDAP_DEBUG_ANY,
286 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
291 if ( global_host != NULL ) {
292 Debug( LDAP_DEBUG_ANY,
293 "%s: line %d: already set sasl-host!\n",
298 global_host = ch_strdup( cargv[1] );
302 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
304 Debug( LDAP_DEBUG_ANY,
305 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
310 if ( global_realm != NULL ) {
311 Debug( LDAP_DEBUG_ANY,
312 "%s: line %d: already set sasl-realm!\n",
317 global_realm = ch_strdup( cargv[1] );
320 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
321 || !strcasecmp( cargv[0], "saslregexp" ) )
325 Debug( LDAP_DEBUG_ANY,
326 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
330 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
335 /* SASL security properties */
336 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
340 Debug( LDAP_DEBUG_ANY,
341 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
346 txt = slap_sasl_secprops( cargv[1] );
348 Debug( LDAP_DEBUG_ANY,
349 "%s: line %d: sasl-secprops: %s\n",
350 fname, lineno, txt );
354 /* set UCDATA path */
355 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
358 Debug( LDAP_DEBUG_ANY,
359 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
364 err = load_ucdata( cargv[1] );
367 Debug( LDAP_DEBUG_ANY,
368 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
375 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
377 Debug( LDAP_DEBUG_ANY,
378 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
383 defsize = atoi( cargv[1] );
385 be->be_sizelimit = atoi( cargv[1] );
389 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
391 Debug( LDAP_DEBUG_ANY,
392 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
397 deftime = atoi( cargv[1] );
399 be->be_timelimit = atoi( cargv[1] );
402 /* set database suffix */
403 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
406 Debug( LDAP_DEBUG_ANY,
407 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
410 } else if ( cargc > 2 ) {
411 Debug( LDAP_DEBUG_ANY,
412 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
413 fname, lineno, cargv[1] );
416 Debug( LDAP_DEBUG_ANY,
417 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
419 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
420 Debug( LDAP_DEBUG_ANY,
421 "%s: line %d: suffix already served by this backend (ignored)\n",
423 } else if ( tmp_be != NULL ) {
424 Debug( LDAP_DEBUG_ANY,
425 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
426 fname, lineno, tmp_be->be_suffix[0] );
428 char *dn = ch_strdup( cargv[1] );
429 if ( load_ucdata( NULL ) < 0 ) {
432 if( dn_validate( dn ) == NULL ) {
433 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
434 "suffix DN invalid \"%s\"\n",
435 fname, lineno, cargv[1] );
438 } else if( *dn == '\0' && default_search_nbase != NULL ) {
439 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
440 "suffix DN empty and default "
441 "search base provided \"%s\" (assuming okay)\n",
442 fname, lineno, default_search_base );
444 charray_add( &be->be_suffix, dn );
445 (void) ldap_pvt_str2upper( dn );
446 charray_add( &be->be_nsuffix, dn );
450 /* set database suffixAlias */
451 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
454 Debug( LDAP_DEBUG_ANY,
455 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
458 } else if ( cargc < 3 ) {
459 Debug( LDAP_DEBUG_ANY,
460 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
463 } else if ( cargc > 3 ) {
464 Debug( LDAP_DEBUG_ANY,
465 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
470 Debug( LDAP_DEBUG_ANY,
471 "%s: line %d: suffixAlias line"
472 " must appear inside a database definition (ignored)\n",
474 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
475 Debug( LDAP_DEBUG_ANY,
476 "%s: line %d: suffixAlias served by"
477 " a preceeding backend \"%s\" (ignored)\n",
478 fname, lineno, tmp_be->be_suffix[0] );
480 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
481 Debug( LDAP_DEBUG_ANY,
482 "%s: line %d: suffixAlias derefs to differnet backend"
483 " a preceeding backend \"%s\" (ignored)\n",
484 fname, lineno, tmp_be->be_suffix[0] );
487 char *alias, *aliased_dn;
489 alias = ch_strdup( cargv[1] );
490 if ( load_ucdata( NULL ) < 0 ) {
493 (void) dn_normalize( alias );
495 aliased_dn = ch_strdup( cargv[2] );
496 (void) dn_normalize( aliased_dn );
498 charray_add( &be->be_suffixAlias, alias );
499 charray_add( &be->be_suffixAlias, aliased_dn );
505 /* set max deref depth */
506 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
509 Debug( LDAP_DEBUG_ANY,
510 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
515 Debug( LDAP_DEBUG_ANY,
516 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
518 } else if ((i = atoi(cargv[1])) < 0) {
519 Debug( LDAP_DEBUG_ANY,
520 "%s: line %d: depth must be positive (ignored)\n",
524 be->be_max_deref_depth = i;
528 /* set magic "root" dn for this database */
529 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
531 Debug( LDAP_DEBUG_ANY,
532 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
537 Debug( LDAP_DEBUG_ANY,
538 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
541 be->be_root_dn = ch_strdup( cargv[1] );
542 be->be_root_ndn = ch_strdup( cargv[1] );
544 if ( load_ucdata( NULL ) < 0 ) {
547 if( dn_normalize( be->be_root_ndn ) == NULL ) {
548 free( be->be_root_dn );
549 free( be->be_root_ndn );
550 Debug( LDAP_DEBUG_ANY,
551 "%s: line %d: rootdn DN is invalid\n",
557 /* set super-secret magic database password */
558 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
560 Debug( LDAP_DEBUG_ANY,
561 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
566 Debug( LDAP_DEBUG_ANY,
567 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
570 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
571 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
574 /* make this database read-only */
575 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
577 Debug( LDAP_DEBUG_ANY,
578 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
583 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
584 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
586 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
589 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
590 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
592 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
597 /* allow these features */
598 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
599 strcasecmp( cargv[0], "allow" ) == 0 )
604 Debug( LDAP_DEBUG_ANY,
605 "%s: line %d: allow line must appear prior to database definitions\n",
610 Debug( LDAP_DEBUG_ANY,
611 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
618 for( i=1; i < cargc; i++ ) {
619 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
620 allows |= SLAP_ALLOW_TLS_2_ANON;
622 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
623 Debug( LDAP_DEBUG_ANY,
624 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
625 fname, lineno, cargv[i] );
630 global_allows = allows;
632 /* disallow these features */
633 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
634 strcasecmp( cargv[0], "disallow" ) == 0 )
636 slap_mask_t disallows;
639 Debug( LDAP_DEBUG_ANY,
640 "%s: line %d: disallow line must appear prior to database definitions\n",
645 Debug( LDAP_DEBUG_ANY,
646 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
653 for( i=1; i < cargc; i++ ) {
654 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
655 disallows |= SLAP_DISALLOW_BIND_V2;
657 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
658 disallows |= SLAP_DISALLOW_BIND_ANON;
660 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
661 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
663 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
664 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
666 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
667 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
669 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
670 disallows |= SLAP_DISALLOW_BIND_KRBV4;
672 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
673 disallows |= SLAP_DISALLOW_TLS_AUTHC;
675 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
676 Debug( LDAP_DEBUG_ANY,
677 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
678 fname, lineno, cargv[i] );
683 global_disallows = disallows;
685 /* require these features */
686 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
687 strcasecmp( cargv[0], "require" ) == 0 )
689 slap_mask_t requires;
692 Debug( LDAP_DEBUG_ANY,
693 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
700 for( i=1; i < cargc; i++ ) {
701 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
702 requires |= SLAP_REQUIRE_BIND;
704 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
705 requires |= SLAP_REQUIRE_LDAP_V3;
707 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
708 requires |= SLAP_REQUIRE_AUTHC;
710 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
711 requires |= SLAP_REQUIRE_SASL;
713 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
714 requires |= SLAP_REQUIRE_STRONG;
716 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
717 Debug( LDAP_DEBUG_ANY,
718 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
719 fname, lineno, cargv[i] );
725 global_requires = requires;
727 be->be_requires = requires;
730 /* required security factors */
731 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
735 Debug( LDAP_DEBUG_ANY,
736 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
742 set = &global_ssf_set;
744 set = &be->be_ssf_set;
747 for( i=1; i < cargc; i++ ) {
748 if( strncasecmp( cargv[i], "ssf=",
749 sizeof("ssf") ) == 0 )
752 atoi( &cargv[i][sizeof("ssf")] );
754 } else if( strncasecmp( cargv[i], "transport=",
755 sizeof("transport") ) == 0 )
758 atoi( &cargv[i][sizeof("transport")] );
760 } else if( strncasecmp( cargv[i], "tls=",
761 sizeof("tls") ) == 0 )
764 atoi( &cargv[i][sizeof("tls")] );
766 } else if( strncasecmp( cargv[i], "sasl=",
767 sizeof("sasl") ) == 0 )
770 atoi( &cargv[i][sizeof("sasl")] );
772 } else if( strncasecmp( cargv[i], "update_ssf=",
773 sizeof("update_ssf") ) == 0 )
775 set->sss_update_ssf =
776 atoi( &cargv[i][sizeof("update_ssf")] );
778 } else if( strncasecmp( cargv[i], "update_transport=",
779 sizeof("update_transport") ) == 0 )
781 set->sss_update_transport =
782 atoi( &cargv[i][sizeof("update_transport")] );
784 } else if( strncasecmp( cargv[i], "update_tls=",
785 sizeof("update_tls") ) == 0 )
787 set->sss_update_tls =
788 atoi( &cargv[i][sizeof("update_tls")] );
790 } else if( strncasecmp( cargv[i], "update_sasl=",
791 sizeof("update_sasl") ) == 0 )
793 set->sss_update_sasl =
794 atoi( &cargv[i][sizeof("update_sasl")] );
797 Debug( LDAP_DEBUG_ANY,
798 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
799 fname, lineno, cargv[i] );
805 /* where to send clients when we don't hold it */
806 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
808 Debug( LDAP_DEBUG_ANY,
809 "%s: line %d: missing URL in \"referral <URL>\" line\n",
814 vals[0]->bv_val = cargv[1];
815 vals[0]->bv_len = strlen( vals[0]->bv_val );
816 value_add( &default_referral, vals );
818 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
821 Debug( LDAP_DEBUG_ANY,
822 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
826 level = atoi( cargv[2] );
827 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
828 lutil_set_debug_level( cargv[1], level );
829 /* specify an Object Identifier macro */
831 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
834 Debug( LDAP_DEBUG_ANY,
835 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
839 logfile = fopen( cargv[1], "w" );
840 if ( logfile != NULL ) lutil_debug_file( logfile );
843 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
844 parse_oidm( fname, lineno, cargc, cargv );
846 /* specify an objectclass */
847 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
848 if ( *cargv[1] == '(' ) {
850 p = strchr(saveline,'(');
851 parse_oc( fname, lineno, p, cargv );
853 Debug( LDAP_DEBUG_ANY,
854 "%s: line %d: old objectclass format not supported.\n",
858 /* specify an attribute type */
859 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
860 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
862 if ( *cargv[1] == '(' ) {
864 p = strchr(saveline,'(');
865 parse_at( fname, lineno, p, cargv );
867 Debug( LDAP_DEBUG_ANY,
868 "%s: line %d: old attribute type format not supported.\n",
872 /* turn on/off schema checking */
873 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
875 Debug( LDAP_DEBUG_ANY,
876 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
880 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
881 global_schemacheck = 0;
883 global_schemacheck = 1;
886 /* specify access control info */
887 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
888 parse_acl( be, fname, lineno, cargc, cargv );
890 /* debug level to log things to syslog */
891 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
893 Debug( LDAP_DEBUG_ANY,
894 "%s: line %d: missing level in \"loglevel <level>\" line\n",
901 for( i=1; i < cargc; i++ ) {
902 ldap_syslog += atoi( cargv[1] );
905 /* list of replicas of the data in this backend (master only) */
906 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
908 Debug( LDAP_DEBUG_ANY,
909 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
914 Debug( LDAP_DEBUG_ANY,
915 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
918 for ( i = 1; i < cargc; i++ ) {
919 if ( strncasecmp( cargv[i], "host=", 5 )
921 charray_add( &be->be_replica,
927 Debug( LDAP_DEBUG_ANY,
928 "%s: line %d: missing host in \"replica\" line (ignored)\n",
933 /* dn of master entity allowed to write to replica */
934 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
936 Debug( LDAP_DEBUG_ANY,
937 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
942 Debug( LDAP_DEBUG_ANY,
943 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
946 be->be_update_ndn = ch_strdup( cargv[1] );
947 if ( load_ucdata( NULL ) < 0 ) {
950 if( dn_normalize( be->be_update_ndn ) == NULL ) {
951 Debug( LDAP_DEBUG_ANY,
952 "%s: line %d: updatedn DN is invalid\n",
958 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
960 Debug( LDAP_DEBUG_ANY,
961 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
966 Debug( LDAP_DEBUG_ANY,
967 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
969 } else if ( be->be_update_ndn == NULL ) {
970 Debug( LDAP_DEBUG_ANY,
971 "%s: line %d: updateref line must after updatedn (ignored)\n",
974 vals[0]->bv_val = cargv[1];
975 vals[0]->bv_len = strlen( vals[0]->bv_val );
976 value_add( &be->be_update_refs, vals );
979 /* replication log file to which changes are appended */
980 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
982 Debug( LDAP_DEBUG_ANY,
983 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
988 be->be_replogfile = ch_strdup( cargv[1] );
990 replogfile = ch_strdup( cargv[1] );
993 /* maintain lastmodified{by,time} attributes */
994 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
996 Debug( LDAP_DEBUG_ANY,
997 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1001 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1003 be->be_lastmod = ON;
1005 global_lastmod = ON;
1008 be->be_lastmod = OFF;
1010 global_lastmod = OFF;
1013 /* set idle timeout value */
1014 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1017 Debug( LDAP_DEBUG_ANY,
1018 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1023 i = atoi( cargv[1] );
1026 Debug( LDAP_DEBUG_ANY,
1027 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1032 global_idletimeout = i;
1034 /* include another config file */
1035 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1037 Debug( LDAP_DEBUG_ANY,
1038 "%s: line %d: missing filename in \"include <filename>\" line\n",
1042 savefname = ch_strdup( cargv[1] );
1043 savelineno = lineno;
1045 if ( read_config( savefname ) != 0 ) {
1050 lineno = savelineno - 1;
1052 /* location of kerberos srvtab file */
1053 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1055 Debug( LDAP_DEBUG_ANY,
1056 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1060 ldap_srvtab = ch_strdup( cargv[1] );
1062 #ifdef SLAPD_MODULES
1063 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1065 Debug( LDAP_DEBUG_ANY,
1066 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1068 exit( EXIT_FAILURE );
1070 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1071 Debug( LDAP_DEBUG_ANY,
1072 "%s: line %d: failed to load or initialize module %s\n",
1073 fname, lineno, cargv[1]);
1074 exit( EXIT_FAILURE );
1076 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1078 Debug( LDAP_DEBUG_ANY,
1079 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1081 exit( EXIT_FAILURE );
1083 if (module_path( cargv[1] )) {
1084 Debug( LDAP_DEBUG_ANY,
1085 "%s: line %d: failed to set module search path to %s\n",
1086 fname, lineno, cargv[1]);
1087 exit( EXIT_FAILURE );
1090 #endif /*SLAPD_MODULES*/
1093 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1094 rc = ldap_pvt_tls_set_option( NULL,
1095 LDAP_OPT_X_TLS_PROTOCOL,
1100 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1101 rc = ldap_pvt_tls_set_option( NULL,
1102 LDAP_OPT_X_TLS_CIPHER_SUITE,
1107 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1108 rc = ldap_pvt_tls_set_option( NULL,
1109 LDAP_OPT_X_TLS_CERTFILE,
1114 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1115 rc = ldap_pvt_tls_set_option( NULL,
1116 LDAP_OPT_X_TLS_KEYFILE,
1121 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1122 rc = ldap_pvt_tls_set_option( NULL,
1123 LDAP_OPT_X_TLS_CACERTDIR,
1128 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1129 rc = ldap_pvt_tls_set_option( NULL,
1130 LDAP_OPT_X_TLS_CACERTFILE,
1134 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1136 rc = ldap_pvt_tls_set_option( NULL,
1137 LDAP_OPT_X_TLS_REQUIRE_CERT,
1144 /* pass anything else to the current backend info/db config routine */
1147 if ( bi->bi_config == 0 ) {
1148 Debug( LDAP_DEBUG_ANY,
1149 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1150 fname, lineno, cargv[0] );
1152 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1158 } else if ( be != NULL ) {
1159 if ( be->be_config == 0 ) {
1160 Debug( LDAP_DEBUG_ANY,
1161 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1162 fname, lineno, cargv[0] );
1164 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1171 Debug( LDAP_DEBUG_ANY,
1172 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1173 fname, lineno, cargv[0] );
1179 if ( load_ucdata( NULL ) < 0 ) {
1195 for ( token = strtok_quote( line, " \t" ); token != NULL;
1196 token = strtok_quote( NULL, " \t" ) ) {
1197 if ( *argcp == MAXARGS ) {
1198 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1202 argv[(*argcp)++] = token;
1204 argv[*argcp] = NULL;
1209 strtok_quote( char *line, char *sep )
1215 if ( line != NULL ) {
1218 while ( *next && strchr( sep, *next ) ) {
1222 if ( *next == '\0' ) {
1228 for ( inquote = 0; *next; ) {
1236 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1242 next + 1, strlen( next + 1 ) + 1 );
1243 next++; /* dont parse the escaped character */
1248 if ( strchr( sep, *next ) != NULL ) {
1261 static char buf[BUFSIZ];
1263 static int lmax, lcur;
1265 #define CATLINE( buf ) { \
1267 len = strlen( buf ); \
1268 while ( lcur + len + 1 > lmax ) { \
1270 line = (char *) ch_realloc( line, lmax ); \
1272 strcpy( line + lcur, buf ); \
1277 fp_getline( FILE *fp, int *lineno )
1285 /* hack attack - keeps us from having to keep a stack of bufs... */
1286 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1291 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1292 if ( (p = strchr( buf, '\n' )) != NULL ) {
1295 if ( ! isspace( (unsigned char) buf[0] ) ) {
1304 return( line[0] ? line : NULL );
1308 fp_getline_init( int *lineno )
1314 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
1316 load_ucdata( char *path )
1318 static int loaded = 0;
1324 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA,
1325 UCDATA_CASE|UCDATA_CTYPE|UCDATA_NUM );
1327 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",