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",
135 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
137 Debug( LDAP_DEBUG_ANY,
138 "%s: line %d: missing type in \"database <type>\" line\n",
144 be = backend_db_init( cargv[1] );
147 Debug( LDAP_DEBUG_ANY,
148 "database %s initialization failed.\n",
153 /* set thread concurrency */
154 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
157 Debug( LDAP_DEBUG_ANY,
158 "%s: line %d: missing level in \"concurrency <level>\" line\n",
163 c = atoi( cargv[1] );
166 Debug( LDAP_DEBUG_ANY,
167 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
172 ldap_pvt_thread_set_concurrency( c );
174 /* default search base */
175 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
177 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
178 "missing dn in \"defaultSearchBase <dn>\" line\n",
182 } else if ( cargc > 2 ) {
183 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
184 "extra cruft after <dn> in \"defaultSearchBase %s\", "
186 fname, lineno, cargv[1] );
189 if ( bi != NULL || be != NULL ) {
190 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
191 "defaultSearchBaase line must appear prior to "
192 "any backend or database definition\n",
197 if ( default_search_nbase != NULL ) {
198 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
199 "default search base \"%s\" already defined "
200 "(discarding old)\n",
201 fname, lineno, default_search_base );
202 free( default_search_base );
203 free( default_search_nbase );
206 default_search_base = ch_strdup( cargv[1] );
207 default_search_nbase = ch_strdup( cargv[1] );
209 if ( load_ucdata( NULL ) < 0 ) {
212 if( dn_normalize( default_search_nbase ) == NULL ) {
213 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
214 "invalid default search base \"%s\"\n",
215 fname, lineno, default_search_base );
219 /* set maximum threads in thread pool */
220 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
223 Debug( LDAP_DEBUG_ANY,
224 "%s: line %d: missing count in \"threads <count>\" line\n",
229 c = atoi( cargv[1] );
232 Debug( LDAP_DEBUG_ANY,
233 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
238 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
240 /* get pid file name */
241 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
243 Debug( LDAP_DEBUG_ANY,
244 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
249 slapd_pid_file = ch_strdup( cargv[1] );
251 /* get args file name */
252 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
254 Debug( LDAP_DEBUG_ANY,
255 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
260 slapd_args_file = ch_strdup( cargv[1] );
262 /* default password hash */
263 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
265 Debug( LDAP_DEBUG_ANY,
266 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
270 if ( default_passwd_hash != NULL ) {
271 Debug( LDAP_DEBUG_ANY,
272 "%s: line %d: already set default password_hash!\n",
277 default_passwd_hash = ch_strdup( cargv[1] );
281 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
283 Debug( LDAP_DEBUG_ANY,
284 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
289 if ( global_host != NULL ) {
290 Debug( LDAP_DEBUG_ANY,
291 "%s: line %d: already set sasl-host!\n",
296 global_host = ch_strdup( cargv[1] );
300 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
302 Debug( LDAP_DEBUG_ANY,
303 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
308 if ( global_realm != NULL ) {
309 Debug( LDAP_DEBUG_ANY,
310 "%s: line %d: already set sasl-realm!\n",
315 global_realm = ch_strdup( cargv[1] );
318 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
319 || !strcasecmp( cargv[0], "saslregexp" ) )
323 Debug( LDAP_DEBUG_ANY,
324 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
328 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
333 /* SASL security properties */
334 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
338 Debug( LDAP_DEBUG_ANY,
339 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
344 txt = slap_sasl_secprops( cargv[1] );
346 Debug( LDAP_DEBUG_ANY,
347 "%s: line %d: sasl-secprops: %s\n",
348 fname, lineno, txt );
352 /* set UCDATA path */
353 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
356 Debug( LDAP_DEBUG_ANY,
357 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
362 err = load_ucdata( cargv[1] );
365 Debug( LDAP_DEBUG_ANY,
366 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
373 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
375 Debug( LDAP_DEBUG_ANY,
376 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
381 defsize = atoi( cargv[1] );
383 be->be_sizelimit = atoi( cargv[1] );
387 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
389 Debug( LDAP_DEBUG_ANY,
390 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
395 deftime = atoi( cargv[1] );
397 be->be_timelimit = atoi( cargv[1] );
400 /* set database suffix */
401 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
404 Debug( LDAP_DEBUG_ANY,
405 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
408 } else if ( cargc > 2 ) {
409 Debug( LDAP_DEBUG_ANY,
410 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
411 fname, lineno, cargv[1] );
414 Debug( LDAP_DEBUG_ANY,
415 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
417 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
418 Debug( LDAP_DEBUG_ANY,
419 "%s: line %d: suffix already served by this backend (ignored)\n",
421 } else if ( tmp_be != NULL ) {
422 Debug( LDAP_DEBUG_ANY,
423 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
424 fname, lineno, tmp_be->be_suffix[0] );
426 char *dn = ch_strdup( cargv[1] );
427 if ( load_ucdata( NULL ) < 0 ) {
430 if( dn_validate( dn ) == NULL ) {
431 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
432 "suffix DN invalid \"%s\"\n",
433 fname, lineno, cargv[1] );
436 } else if( *dn == '\0' && default_search_nbase != NULL ) {
437 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
438 "suffix DN empty and default "
439 "search base provided \"%s\" (assuming okay)\n",
440 fname, lineno, default_search_base );
442 charray_add( &be->be_suffix, dn );
443 (void) ldap_pvt_str2upper( dn );
444 charray_add( &be->be_nsuffix, dn );
448 /* set database suffixAlias */
449 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
452 Debug( LDAP_DEBUG_ANY,
453 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
456 } else if ( cargc < 3 ) {
457 Debug( LDAP_DEBUG_ANY,
458 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
461 } else if ( cargc > 3 ) {
462 Debug( LDAP_DEBUG_ANY,
463 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
468 Debug( LDAP_DEBUG_ANY,
469 "%s: line %d: suffixAlias line"
470 " must appear inside a database definition (ignored)\n",
472 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
473 Debug( LDAP_DEBUG_ANY,
474 "%s: line %d: suffixAlias served by"
475 " a preceeding backend \"%s\" (ignored)\n",
476 fname, lineno, tmp_be->be_suffix[0] );
478 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
479 Debug( LDAP_DEBUG_ANY,
480 "%s: line %d: suffixAlias derefs to differnet backend"
481 " a preceeding backend \"%s\" (ignored)\n",
482 fname, lineno, tmp_be->be_suffix[0] );
485 char *alias, *aliased_dn;
487 alias = ch_strdup( cargv[1] );
488 if ( load_ucdata( NULL ) < 0 ) {
491 (void) dn_normalize( alias );
493 aliased_dn = ch_strdup( cargv[2] );
494 (void) dn_normalize( aliased_dn );
496 charray_add( &be->be_suffixAlias, alias );
497 charray_add( &be->be_suffixAlias, aliased_dn );
503 /* set max deref depth */
504 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
507 Debug( LDAP_DEBUG_ANY,
508 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
513 Debug( LDAP_DEBUG_ANY,
514 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
516 } else if ((i = atoi(cargv[1])) < 0) {
517 Debug( LDAP_DEBUG_ANY,
518 "%s: line %d: depth must be positive (ignored)\n",
522 be->be_max_deref_depth = i;
526 /* set magic "root" dn for this database */
527 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
529 Debug( LDAP_DEBUG_ANY,
530 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
535 Debug( LDAP_DEBUG_ANY,
536 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
539 be->be_root_dn = ch_strdup( cargv[1] );
540 be->be_root_ndn = ch_strdup( cargv[1] );
542 if ( load_ucdata( NULL ) < 0 ) {
545 if( dn_normalize( be->be_root_ndn ) == NULL ) {
546 free( be->be_root_dn );
547 free( be->be_root_ndn );
548 Debug( LDAP_DEBUG_ANY,
549 "%s: line %d: rootdn DN is invalid\n",
555 /* set super-secret magic database password */
556 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
558 Debug( LDAP_DEBUG_ANY,
559 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
564 Debug( LDAP_DEBUG_ANY,
565 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
568 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
569 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
572 /* make this database read-only */
573 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
575 Debug( LDAP_DEBUG_ANY,
576 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
581 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
582 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
584 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
587 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
588 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
590 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
595 /* allow these features */
596 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
597 strcasecmp( cargv[0], "allow" ) == 0 )
602 Debug( LDAP_DEBUG_ANY,
603 "%s: line %d: allow line must appear prior to database definitions\n",
608 Debug( LDAP_DEBUG_ANY,
609 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
616 for( i=1; i < cargc; i++ ) {
617 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
618 allows |= SLAP_ALLOW_TLS_2_ANON;
620 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
621 Debug( LDAP_DEBUG_ANY,
622 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
623 fname, lineno, cargv[i] );
628 global_allows = allows;
630 /* disallow these features */
631 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
632 strcasecmp( cargv[0], "disallow" ) == 0 )
634 slap_mask_t disallows;
637 Debug( LDAP_DEBUG_ANY,
638 "%s: line %d: disallow line must appear prior to database definitions\n",
643 Debug( LDAP_DEBUG_ANY,
644 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
651 for( i=1; i < cargc; i++ ) {
652 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
653 disallows |= SLAP_DISALLOW_BIND_V2;
655 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
656 disallows |= SLAP_DISALLOW_BIND_ANON;
658 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
659 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
661 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
662 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
664 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
665 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
667 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
668 disallows |= SLAP_DISALLOW_BIND_KRBV4;
670 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
671 disallows |= SLAP_DISALLOW_TLS_AUTHC;
673 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
674 Debug( LDAP_DEBUG_ANY,
675 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
676 fname, lineno, cargv[i] );
681 global_disallows = disallows;
683 /* require these features */
684 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
685 strcasecmp( cargv[0], "require" ) == 0 )
687 slap_mask_t requires;
690 Debug( LDAP_DEBUG_ANY,
691 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
698 for( i=1; i < cargc; i++ ) {
699 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
700 requires |= SLAP_REQUIRE_BIND;
702 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
703 requires |= SLAP_REQUIRE_LDAP_V3;
705 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
706 requires |= SLAP_REQUIRE_AUTHC;
708 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
709 requires |= SLAP_REQUIRE_SASL;
711 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
712 requires |= SLAP_REQUIRE_STRONG;
714 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
715 Debug( LDAP_DEBUG_ANY,
716 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
717 fname, lineno, cargv[i] );
723 global_requires = requires;
725 be->be_requires = requires;
728 /* required security factors */
729 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
733 Debug( LDAP_DEBUG_ANY,
734 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
740 set = &global_ssf_set;
742 set = &be->be_ssf_set;
745 for( i=1; i < cargc; i++ ) {
746 if( strncasecmp( cargv[i], "ssf=",
747 sizeof("ssf") ) == 0 )
750 atoi( &cargv[i][sizeof("ssf")] );
752 } else if( strncasecmp( cargv[i], "transport=",
753 sizeof("transport") ) == 0 )
756 atoi( &cargv[i][sizeof("transport")] );
758 } else if( strncasecmp( cargv[i], "tls=",
759 sizeof("tls") ) == 0 )
762 atoi( &cargv[i][sizeof("tls")] );
764 } else if( strncasecmp( cargv[i], "sasl=",
765 sizeof("sasl") ) == 0 )
768 atoi( &cargv[i][sizeof("sasl")] );
770 } else if( strncasecmp( cargv[i], "update_ssf=",
771 sizeof("update_ssf") ) == 0 )
773 set->sss_update_ssf =
774 atoi( &cargv[i][sizeof("update_ssf")] );
776 } else if( strncasecmp( cargv[i], "update_transport=",
777 sizeof("update_transport") ) == 0 )
779 set->sss_update_transport =
780 atoi( &cargv[i][sizeof("update_transport")] );
782 } else if( strncasecmp( cargv[i], "update_tls=",
783 sizeof("update_tls") ) == 0 )
785 set->sss_update_tls =
786 atoi( &cargv[i][sizeof("update_tls")] );
788 } else if( strncasecmp( cargv[i], "update_sasl=",
789 sizeof("update_sasl") ) == 0 )
791 set->sss_update_sasl =
792 atoi( &cargv[i][sizeof("update_sasl")] );
795 Debug( LDAP_DEBUG_ANY,
796 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
797 fname, lineno, cargv[i] );
801 /* where to send clients when we don't hold it */
802 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
804 Debug( LDAP_DEBUG_ANY,
805 "%s: line %d: missing URL in \"referral <URL>\" line\n",
810 vals[0]->bv_val = cargv[1];
811 vals[0]->bv_len = strlen( vals[0]->bv_val );
812 value_add( &default_referral, vals );
815 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
818 Debug( LDAP_DEBUG_ANY,
819 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
823 logfile = fopen( cargv[1], "w" );
824 if ( logfile != NULL ) lutil_debug_file( logfile );
827 /* start of a new database definition */
828 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
831 Debug( LDAP_DEBUG_ANY,
832 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
836 level = atoi( cargv[2] );
837 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
838 lutil_set_debug_level( cargv[1], level );
839 /* specify an Object Identifier macro */
840 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
841 parse_oidm( fname, lineno, cargc, cargv );
843 /* specify an objectclass */
844 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
845 if ( *cargv[1] == '(' ) {
847 p = strchr(saveline,'(');
848 parse_oc( fname, lineno, p, cargv );
850 Debug( LDAP_DEBUG_ANY,
851 "%s: line %d: old objectclass format not supported.\n",
855 /* specify an attribute type */
856 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
857 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
859 if ( *cargv[1] == '(' ) {
861 p = strchr(saveline,'(');
862 parse_at( fname, lineno, p, cargv );
864 Debug( LDAP_DEBUG_ANY,
865 "%s: line %d: old attribute type format not supported.\n",
869 /* turn on/off schema checking */
870 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
872 Debug( LDAP_DEBUG_ANY,
873 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
877 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
878 global_schemacheck = 0;
880 global_schemacheck = 1;
883 /* specify access control info */
884 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
885 parse_acl( be, fname, lineno, cargc, cargv );
887 /* debug level to log things to syslog */
888 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
890 Debug( LDAP_DEBUG_ANY,
891 "%s: line %d: missing level in \"loglevel <level>\" line\n",
898 for( i=1; i < cargc; i++ ) {
899 ldap_syslog += atoi( cargv[1] );
902 /* list of replicas of the data in this backend (master only) */
903 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
905 Debug( LDAP_DEBUG_ANY,
906 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
911 Debug( LDAP_DEBUG_ANY,
912 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
915 for ( i = 1; i < cargc; i++ ) {
916 if ( strncasecmp( cargv[i], "host=", 5 )
918 charray_add( &be->be_replica,
924 Debug( LDAP_DEBUG_ANY,
925 "%s: line %d: missing host in \"replica\" line (ignored)\n",
930 /* dn of master entity allowed to write to replica */
931 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
933 Debug( LDAP_DEBUG_ANY,
934 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
939 Debug( LDAP_DEBUG_ANY,
940 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
943 be->be_update_ndn = ch_strdup( cargv[1] );
944 if ( load_ucdata( NULL ) < 0 ) {
947 if( dn_normalize( be->be_update_ndn ) == NULL ) {
948 Debug( LDAP_DEBUG_ANY,
949 "%s: line %d: updatedn DN is invalid\n",
955 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
957 Debug( LDAP_DEBUG_ANY,
958 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
963 Debug( LDAP_DEBUG_ANY,
964 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
966 } else if ( be->be_update_ndn == NULL ) {
967 Debug( LDAP_DEBUG_ANY,
968 "%s: line %d: updateref line must after updatedn (ignored)\n",
971 vals[0]->bv_val = cargv[1];
972 vals[0]->bv_len = strlen( vals[0]->bv_val );
973 value_add( &be->be_update_refs, vals );
976 /* replication log file to which changes are appended */
977 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
979 Debug( LDAP_DEBUG_ANY,
980 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
985 be->be_replogfile = ch_strdup( cargv[1] );
987 replogfile = ch_strdup( cargv[1] );
990 /* maintain lastmodified{by,time} attributes */
991 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
993 Debug( LDAP_DEBUG_ANY,
994 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
998 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1000 be->be_lastmod = ON;
1002 global_lastmod = ON;
1005 be->be_lastmod = OFF;
1007 global_lastmod = OFF;
1010 /* set idle timeout value */
1011 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1014 Debug( LDAP_DEBUG_ANY,
1015 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1020 i = atoi( cargv[1] );
1023 Debug( LDAP_DEBUG_ANY,
1024 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1029 global_idletimeout = i;
1031 /* include another config file */
1032 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1034 Debug( LDAP_DEBUG_ANY,
1035 "%s: line %d: missing filename in \"include <filename>\" line\n",
1039 savefname = ch_strdup( cargv[1] );
1040 savelineno = lineno;
1042 if ( read_config( savefname ) != 0 ) {
1047 lineno = savelineno - 1;
1049 /* location of kerberos srvtab file */
1050 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1052 Debug( LDAP_DEBUG_ANY,
1053 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1057 ldap_srvtab = ch_strdup( cargv[1] );
1059 #ifdef SLAPD_MODULES
1060 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1062 Debug( LDAP_DEBUG_ANY,
1063 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1065 exit( EXIT_FAILURE );
1067 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1068 Debug( LDAP_DEBUG_ANY,
1069 "%s: line %d: failed to load or initialize module %s\n",
1070 fname, lineno, cargv[1]);
1071 exit( EXIT_FAILURE );
1073 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1075 Debug( LDAP_DEBUG_ANY,
1076 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1078 exit( EXIT_FAILURE );
1080 if (module_path( cargv[1] )) {
1081 Debug( LDAP_DEBUG_ANY,
1082 "%s: line %d: failed to set module search path to %s\n",
1083 fname, lineno, cargv[1]);
1084 exit( EXIT_FAILURE );
1087 #endif /*SLAPD_MODULES*/
1090 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1091 rc = ldap_pvt_tls_set_option( NULL,
1092 LDAP_OPT_X_TLS_PROTOCOL,
1097 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1098 rc = ldap_pvt_tls_set_option( NULL,
1099 LDAP_OPT_X_TLS_CIPHER_SUITE,
1104 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1105 rc = ldap_pvt_tls_set_option( NULL,
1106 LDAP_OPT_X_TLS_CERTFILE,
1111 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1112 rc = ldap_pvt_tls_set_option( NULL,
1113 LDAP_OPT_X_TLS_KEYFILE,
1118 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1119 rc = ldap_pvt_tls_set_option( NULL,
1120 LDAP_OPT_X_TLS_CACERTDIR,
1125 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1126 rc = ldap_pvt_tls_set_option( NULL,
1127 LDAP_OPT_X_TLS_CACERTFILE,
1131 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1133 rc = ldap_pvt_tls_set_option( NULL,
1134 LDAP_OPT_X_TLS_REQUIRE_CERT,
1141 /* pass anything else to the current backend info/db config routine */
1144 if ( bi->bi_config == 0 ) {
1145 Debug( LDAP_DEBUG_ANY,
1146 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1147 fname, lineno, cargv[0] );
1149 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1155 } else if ( be != NULL ) {
1156 if ( be->be_config == 0 ) {
1157 Debug( LDAP_DEBUG_ANY,
1158 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1159 fname, lineno, cargv[0] );
1161 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1168 Debug( LDAP_DEBUG_ANY,
1169 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1170 fname, lineno, cargv[0] );
1176 if ( load_ucdata( NULL ) < 0 ) {
1192 for ( token = strtok_quote( line, " \t" ); token != NULL;
1193 token = strtok_quote( NULL, " \t" ) ) {
1194 if ( *argcp == MAXARGS ) {
1195 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1199 argv[(*argcp)++] = token;
1201 argv[*argcp] = NULL;
1206 strtok_quote( char *line, char *sep )
1212 if ( line != NULL ) {
1215 while ( *next && strchr( sep, *next ) ) {
1219 if ( *next == '\0' ) {
1225 for ( inquote = 0; *next; ) {
1233 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1239 next + 1, strlen( next + 1 ) + 1 );
1240 next++; /* dont parse the escaped character */
1245 if ( strchr( sep, *next ) != NULL ) {
1258 static char buf[BUFSIZ];
1260 static int lmax, lcur;
1262 #define CATLINE( buf ) { \
1264 len = strlen( buf ); \
1265 while ( lcur + len + 1 > lmax ) { \
1267 line = (char *) ch_realloc( line, lmax ); \
1269 strcpy( line + lcur, buf ); \
1274 fp_getline( FILE *fp, int *lineno )
1282 /* hack attack - keeps us from having to keep a stack of bufs... */
1283 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1288 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1289 if ( (p = strchr( buf, '\n' )) != NULL ) {
1292 if ( ! isspace( (unsigned char) buf[0] ) ) {
1301 return( line[0] ? line : NULL );
1305 fp_getline_init( int *lineno )
1311 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
1313 load_ucdata( char *path )
1315 static int loaded = 0;
1321 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA,
1322 UCDATA_CASE|UCDATA_CTYPE|UCDATA_NUM );
1324 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",