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;
42 char *slapd_pid_file = NULL;
43 char *slapd_args_file = NULL;
45 static char *fp_getline(FILE *fp, int *lineno);
46 static void fp_getline_init(int *lineno);
47 static int fp_parse_line(char *line, int *argcp, char **argv);
49 static char *strtok_quote(char *line, char *sep);
52 read_config( const char *fname )
55 char *line, *savefname, *saveline;
56 int cargc, savelineno;
57 char *cargv[MAXARGS+1];
62 struct berval *vals[2];
65 static BackendInfo *bi = NULL;
66 static BackendDB *be = NULL;
71 if ( (fp = fopen( fname, "r" )) == NULL ) {
73 Debug( LDAP_DEBUG_ANY,
74 "could not open config file \"%s\" - absolute path?\n",
80 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
82 fp_getline_init( &lineno );
84 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
85 /* skip comments and blank lines */
86 if ( line[0] == '#' || line[0] == '\0' ) {
90 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
92 /* fp_parse_line is destructive, we save a copy */
93 saveline = ch_strdup( line );
95 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
100 Debug( LDAP_DEBUG_ANY,
101 "%s: line %d: bad config line (ignored)\n",
106 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
108 Debug( LDAP_DEBUG_ANY,
109 "%s: line %d: missing type in \"backend <type>\" line\n",
115 Debug( LDAP_DEBUG_ANY,
116 "%s: line %d: backend line must appear before any database definition\n",
121 bi = backend_info( cargv[1] );
124 Debug( LDAP_DEBUG_ANY,
125 "backend %s initialization failed.\n",
130 /* start of a new database definition */
131 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
133 Debug( LDAP_DEBUG_ANY,
134 "%s: line %d: missing type in \"database <type>\" line\n",
140 be = backend_db_init( cargv[1] );
143 Debug( LDAP_DEBUG_ANY,
144 "database %s initialization failed.\n",
149 /* set thread concurrency */
150 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
153 Debug( LDAP_DEBUG_ANY,
154 "%s: line %d: missing level in \"concurrency <level>\" line\n",
159 c = atoi( cargv[1] );
162 Debug( LDAP_DEBUG_ANY,
163 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
168 ldap_pvt_thread_set_concurrency( c );
170 /* set maximum threads in thread pool */
171 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
174 Debug( LDAP_DEBUG_ANY,
175 "%s: line %d: missing count in \"threads <count>\" line\n",
180 c = atoi( cargv[1] );
183 Debug( LDAP_DEBUG_ANY,
184 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
189 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
191 /* get pid file name */
192 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
194 Debug( LDAP_DEBUG_ANY,
195 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
200 slapd_pid_file = ch_strdup( cargv[1] );
202 /* get args file name */
203 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
205 Debug( LDAP_DEBUG_ANY,
206 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
211 slapd_args_file = ch_strdup( cargv[1] );
213 /* default password hash */
214 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
216 Debug( LDAP_DEBUG_ANY,
217 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
221 if ( default_passwd_hash != NULL ) {
222 Debug( LDAP_DEBUG_ANY,
223 "%s: line %d: already set default password_hash!\n",
228 default_passwd_hash = ch_strdup( cargv[1] );
232 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
234 Debug( LDAP_DEBUG_ANY,
235 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
240 if ( global_host != NULL ) {
241 Debug( LDAP_DEBUG_ANY,
242 "%s: line %d: already set sasl-host!\n",
247 global_host = ch_strdup( cargv[1] );
251 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
253 Debug( LDAP_DEBUG_ANY,
254 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
259 if ( global_realm != NULL ) {
260 Debug( LDAP_DEBUG_ANY,
261 "%s: line %d: already set sasl-realm!\n",
266 global_realm = ch_strdup( cargv[1] );
269 /* SASL security properties */
270 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
274 Debug( LDAP_DEBUG_ANY,
275 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
280 txt = slap_sasl_secprops( cargv[1] );
282 Debug( LDAP_DEBUG_ANY,
283 "%s: line %d: sasl-secprops: %s\n",
284 fname, lineno, txt );
288 /* set UCDATA path */
289 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
291 Debug( LDAP_DEBUG_ANY,
292 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
297 if ( global_ucdata_path != NULL ) {
298 Debug( LDAP_DEBUG_ANY,
299 "%s: line %d: already set ucdata-path!\n",
304 global_ucdata_path = ch_strdup( cargv[1] );
308 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
310 Debug( LDAP_DEBUG_ANY,
311 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
316 defsize = atoi( cargv[1] );
318 be->be_sizelimit = atoi( cargv[1] );
322 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
324 Debug( LDAP_DEBUG_ANY,
325 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
330 deftime = atoi( cargv[1] );
332 be->be_timelimit = atoi( cargv[1] );
335 /* set database suffix */
336 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
339 Debug( LDAP_DEBUG_ANY,
340 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
343 } else if ( cargc > 2 ) {
344 Debug( LDAP_DEBUG_ANY,
345 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
346 fname, lineno, cargv[1] );
349 Debug( LDAP_DEBUG_ANY,
350 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
352 } else if ( ( tmp_be = select_backend( cargv[1] ) ) == be ) {
353 Debug( LDAP_DEBUG_ANY,
354 "%s: line %d: suffix already served by this backend (ignored)\n",
356 } else if ( tmp_be != NULL ) {
357 Debug( LDAP_DEBUG_ANY,
358 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
359 fname, lineno, tmp_be->be_suffix[0] );
361 char *dn = ch_strdup( cargv[1] );
362 (void) dn_validate( dn );
363 charray_add( &be->be_suffix, dn );
364 (void) ldap_pvt_str2upper( dn );
365 charray_add( &be->be_nsuffix, dn );
369 /* set database suffixAlias */
370 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
373 Debug( LDAP_DEBUG_ANY,
374 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
377 } else if ( cargc < 3 ) {
378 Debug( LDAP_DEBUG_ANY,
379 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
382 } else if ( cargc > 3 ) {
383 Debug( LDAP_DEBUG_ANY,
384 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
389 Debug( LDAP_DEBUG_ANY,
390 "%s: line %d: suffixAlias line"
391 " must appear inside a database definition (ignored)\n",
393 } else if ( (tmp_be = select_backend( cargv[1] )) != NULL ) {
394 Debug( LDAP_DEBUG_ANY,
395 "%s: line %d: suffixAlias served by"
396 " a preceeding backend \"%s\" (ignored)\n",
397 fname, lineno, tmp_be->be_suffix[0] );
399 } else if ( (tmp_be = select_backend( cargv[2] )) != NULL ) {
400 Debug( LDAP_DEBUG_ANY,
401 "%s: line %d: suffixAlias derefs to differnet backend"
402 " a preceeding backend \"%s\" (ignored)\n",
403 fname, lineno, tmp_be->be_suffix[0] );
406 char *alias, *aliased_dn;
408 alias = ch_strdup( cargv[1] );
409 (void) dn_normalize( alias );
411 aliased_dn = ch_strdup( cargv[2] );
412 (void) dn_normalize( aliased_dn );
414 charray_add( &be->be_suffixAlias, alias );
415 charray_add( &be->be_suffixAlias, aliased_dn );
421 /* set max deref depth */
422 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
425 Debug( LDAP_DEBUG_ANY,
426 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
431 Debug( LDAP_DEBUG_ANY,
432 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
434 } else if ((i = atoi(cargv[1])) < 0) {
435 Debug( LDAP_DEBUG_ANY,
436 "%s: line %d: depth must be positive (ignored)\n",
440 be->be_max_deref_depth = i;
444 /* set magic "root" dn for this database */
445 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
447 Debug( LDAP_DEBUG_ANY,
448 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
453 Debug( LDAP_DEBUG_ANY,
454 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
457 be->be_root_dn = ch_strdup( cargv[1] );
458 be->be_root_ndn = ch_strdup( cargv[1] );
460 if( dn_normalize( be->be_root_ndn ) == NULL ) {
461 free( be->be_root_dn );
462 free( be->be_root_ndn );
463 Debug( LDAP_DEBUG_ANY,
464 "%s: line %d: rootdn DN is invalid\n",
470 /* set super-secret magic database password */
471 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
473 Debug( LDAP_DEBUG_ANY,
474 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
479 Debug( LDAP_DEBUG_ANY,
480 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
483 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
484 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
487 /* make this database read-only */
488 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
490 Debug( LDAP_DEBUG_ANY,
491 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
496 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
497 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
499 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
502 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
503 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
505 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
510 /* allow these features */
511 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
512 strcasecmp( cargv[0], "allow" ) == 0 )
517 Debug( LDAP_DEBUG_ANY,
518 "%s: line %d: allow line must appear prior to database definitions\n",
523 Debug( LDAP_DEBUG_ANY,
524 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
531 for( i=1; i < cargc; i++ ) {
532 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
533 allows |= SLAP_ALLOW_TLS_2_ANON;
535 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
536 Debug( LDAP_DEBUG_ANY,
537 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
538 fname, lineno, cargv[i] );
543 global_allows = allows;
545 /* disallow these features */
546 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
547 strcasecmp( cargv[0], "disallow" ) == 0 )
549 slap_mask_t disallows;
552 Debug( LDAP_DEBUG_ANY,
553 "%s: line %d: disallow line must appear prior to database definitions\n",
558 Debug( LDAP_DEBUG_ANY,
559 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
566 for( i=1; i < cargc; i++ ) {
567 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
568 disallows |= SLAP_DISALLOW_BIND_V2;
570 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
571 disallows |= SLAP_DISALLOW_BIND_ANON;
573 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
574 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
576 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
577 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
579 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
580 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
582 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
583 disallows |= SLAP_DISALLOW_BIND_KRBV4;
585 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
586 disallows |= SLAP_DISALLOW_TLS_AUTHC;
588 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
589 Debug( LDAP_DEBUG_ANY,
590 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
591 fname, lineno, cargv[i] );
596 global_disallows = disallows;
598 /* require these features */
599 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
600 strcasecmp( cargv[0], "require" ) == 0 )
602 slap_mask_t requires;
605 Debug( LDAP_DEBUG_ANY,
606 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
613 for( i=1; i < cargc; i++ ) {
614 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
615 requires |= SLAP_REQUIRE_BIND;
617 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
618 requires |= SLAP_REQUIRE_LDAP_V3;
620 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
621 requires |= SLAP_REQUIRE_AUTHC;
623 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
624 requires |= SLAP_REQUIRE_SASL;
626 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
627 requires |= SLAP_REQUIRE_STRONG;
629 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
630 Debug( LDAP_DEBUG_ANY,
631 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
632 fname, lineno, cargv[i] );
638 global_requires = requires;
640 be->be_requires = requires;
643 /* required security factors */
644 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
648 Debug( LDAP_DEBUG_ANY,
649 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
655 set = &global_ssf_set;
657 set = &be->be_ssf_set;
660 for( i=1; i < cargc; i++ ) {
661 if( strncasecmp( cargv[i], "ssf=",
662 sizeof("ssf") ) == 0 )
665 atoi( &cargv[i][sizeof("ssf")] );
667 } else if( strncasecmp( cargv[i], "transport=",
668 sizeof("transport") ) == 0 )
671 atoi( &cargv[i][sizeof("transport")] );
673 } else if( strncasecmp( cargv[i], "tls=",
674 sizeof("tls") ) == 0 )
677 atoi( &cargv[i][sizeof("tls")] );
679 } else if( strncasecmp( cargv[i], "sasl=",
680 sizeof("sasl") ) == 0 )
683 atoi( &cargv[i][sizeof("sasl")] );
685 } else if( strncasecmp( cargv[i], "update_ssf=",
686 sizeof("update_ssf") ) == 0 )
688 set->sss_update_ssf =
689 atoi( &cargv[i][sizeof("update_ssf")] );
691 } else if( strncasecmp( cargv[i], "update_transport=",
692 sizeof("update_transport") ) == 0 )
694 set->sss_update_transport =
695 atoi( &cargv[i][sizeof("update_transport")] );
697 } else if( strncasecmp( cargv[i], "update_tls=",
698 sizeof("update_tls") ) == 0 )
700 set->sss_update_tls =
701 atoi( &cargv[i][sizeof("update_tls")] );
703 } else if( strncasecmp( cargv[i], "update_sasl=",
704 sizeof("update_sasl") ) == 0 )
706 set->sss_update_sasl =
707 atoi( &cargv[i][sizeof("update_sasl")] );
710 Debug( LDAP_DEBUG_ANY,
711 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
712 fname, lineno, cargv[i] );
718 /* where to send clients when we don't hold it */
719 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
721 Debug( LDAP_DEBUG_ANY,
722 "%s: line %d: missing URL in \"referral <URL>\" line\n",
727 vals[0]->bv_val = cargv[1];
728 vals[0]->bv_len = strlen( vals[0]->bv_val );
729 value_add( &default_referral, vals );
731 /* specify an Object Identifier macro */
732 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
733 parse_oidm( fname, lineno, cargc, cargv );
735 /* specify an objectclass */
736 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
737 if ( *cargv[1] == '(' ) {
739 p = strchr(saveline,'(');
740 parse_oc( fname, lineno, p, cargv );
742 Debug( LDAP_DEBUG_ANY,
743 "%s: line %d: old objectclass format not supported.\n",
747 /* specify an attribute type */
748 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
749 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
751 if ( *cargv[1] == '(' ) {
753 p = strchr(saveline,'(');
754 parse_at( fname, lineno, p, cargv );
756 Debug( LDAP_DEBUG_ANY,
757 "%s: line %d: old attribute type format not supported.\n",
761 /* turn on/off schema checking */
762 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
764 Debug( LDAP_DEBUG_ANY,
765 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
769 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
770 global_schemacheck = 0;
772 global_schemacheck = 1;
775 /* specify access control info */
776 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
777 parse_acl( be, fname, lineno, cargc, cargv );
779 /* specify default access control info */
780 } else if ( strcasecmp( cargv[0], "defaultaccess" ) == 0 ) {
781 slap_access_t access;
784 Debug( LDAP_DEBUG_ANY,
785 "%s: line %d: missing limit in \"defaultaccess <access>\" line\n",
790 access = str2access( cargv[1] );
792 if ( access == ACL_INVALID_ACCESS ) {
793 Debug( LDAP_DEBUG_ANY,
794 "%s: line %d: bad access level \"%s\", "
795 "expecting none|auth|compare|search|read|write\n",
796 fname, lineno, cargv[1] );
801 global_default_access = access;
803 be->be_dfltaccess = access;
806 /* debug level to log things to syslog */
807 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
809 Debug( LDAP_DEBUG_ANY,
810 "%s: line %d: missing level in \"loglevel <level>\" line\n",
817 for( i=1; i < cargc; i++ ) {
818 ldap_syslog += atoi( cargv[1] );
821 /* list of replicas of the data in this backend (master only) */
822 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
824 Debug( LDAP_DEBUG_ANY,
825 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
830 Debug( LDAP_DEBUG_ANY,
831 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
834 for ( i = 1; i < cargc; i++ ) {
835 if ( strncasecmp( cargv[i], "host=", 5 )
837 charray_add( &be->be_replica,
843 Debug( LDAP_DEBUG_ANY,
844 "%s: line %d: missing host in \"replica\" line (ignored)\n",
849 /* dn of master entity allowed to write to replica */
850 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
852 Debug( LDAP_DEBUG_ANY,
853 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
858 Debug( LDAP_DEBUG_ANY,
859 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
862 be->be_update_ndn = ch_strdup( cargv[1] );
863 if( dn_normalize( be->be_update_ndn ) == NULL ) {
864 Debug( LDAP_DEBUG_ANY,
865 "%s: line %d: updatedn DN is invalid\n",
871 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
873 Debug( LDAP_DEBUG_ANY,
874 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
879 Debug( LDAP_DEBUG_ANY,
880 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
882 } else if ( be->be_update_ndn == NULL ) {
883 Debug( LDAP_DEBUG_ANY,
884 "%s: line %d: updateref line must after updatedn (ignored)\n",
887 vals[0]->bv_val = cargv[1];
888 vals[0]->bv_len = strlen( vals[0]->bv_val );
889 value_add( &be->be_update_refs, vals );
892 /* replication log file to which changes are appended */
893 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
895 Debug( LDAP_DEBUG_ANY,
896 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
901 be->be_replogfile = ch_strdup( cargv[1] );
903 replogfile = ch_strdup( cargv[1] );
906 /* maintain lastmodified{by,time} attributes */
907 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
909 Debug( LDAP_DEBUG_ANY,
910 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
914 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
921 be->be_lastmod = OFF;
923 global_lastmod = OFF;
926 /* set idle timeout value */
927 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
930 Debug( LDAP_DEBUG_ANY,
931 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
936 i = atoi( cargv[1] );
939 Debug( LDAP_DEBUG_ANY,
940 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
945 global_idletimeout = i;
947 /* include another config file */
948 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
950 Debug( LDAP_DEBUG_ANY,
951 "%s: line %d: missing filename in \"include <filename>\" line\n",
955 savefname = ch_strdup( cargv[1] );
958 if ( read_config( savefname ) != 0 ) {
963 lineno = savelineno - 1;
965 /* location of kerberos srvtab file */
966 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
968 Debug( LDAP_DEBUG_ANY,
969 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
973 ldap_srvtab = ch_strdup( cargv[1] );
976 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
978 Debug( LDAP_DEBUG_ANY,
979 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
981 exit( EXIT_FAILURE );
983 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
984 Debug( LDAP_DEBUG_ANY,
985 "%s: line %d: failed to load or initialize module %s\n",
986 fname, lineno, cargv[1]);
987 exit( EXIT_FAILURE );
989 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
991 Debug( LDAP_DEBUG_ANY,
992 "%s: line %d: missing path in \"modulepath <path>\" line\n",
994 exit( EXIT_FAILURE );
996 if (module_path( cargv[1] )) {
997 Debug( LDAP_DEBUG_ANY,
998 "%s: line %d: failed to set module search path to %s\n",
999 fname, lineno, cargv[1]);
1000 exit( EXIT_FAILURE );
1003 #endif /*SLAPD_MODULES*/
1006 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1007 rc = ldap_pvt_tls_set_option( NULL,
1008 LDAP_OPT_X_TLS_PROTOCOL,
1013 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1014 rc = ldap_pvt_tls_set_option( NULL,
1015 LDAP_OPT_X_TLS_CIPHER_SUITE,
1020 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1021 rc = ldap_pvt_tls_set_option( NULL,
1022 LDAP_OPT_X_TLS_CERTFILE,
1027 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1028 rc = ldap_pvt_tls_set_option( NULL,
1029 LDAP_OPT_X_TLS_KEYFILE,
1034 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1035 rc = ldap_pvt_tls_set_option( NULL,
1036 LDAP_OPT_X_TLS_CACERTDIR,
1041 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1042 rc = ldap_pvt_tls_set_option( NULL,
1043 LDAP_OPT_X_TLS_CACERTFILE,
1047 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1048 rc = ldap_pvt_tls_set_option( NULL,
1049 LDAP_OPT_X_TLS_REQUIRE_CERT,
1056 /* pass anything else to the current backend info/db config routine */
1059 if ( bi->bi_config == 0 ) {
1060 Debug( LDAP_DEBUG_ANY,
1061 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1062 fname, lineno, cargv[0] );
1064 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1070 } else if ( be != NULL ) {
1071 if ( be->be_config == 0 ) {
1072 Debug( LDAP_DEBUG_ANY,
1073 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1074 fname, lineno, cargv[0] );
1076 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1083 Debug( LDAP_DEBUG_ANY,
1084 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1085 fname, lineno, cargv[0] );
1104 for ( token = strtok_quote( line, " \t" ); token != NULL;
1105 token = strtok_quote( NULL, " \t" ) ) {
1106 if ( *argcp == MAXARGS ) {
1107 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1111 argv[(*argcp)++] = token;
1113 argv[*argcp] = NULL;
1118 strtok_quote( char *line, char *sep )
1124 if ( line != NULL ) {
1127 while ( *next && strchr( sep, *next ) ) {
1131 if ( *next == '\0' ) {
1137 for ( inquote = 0; *next; ) {
1145 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1151 next + 1, strlen( next + 1 ) + 1 );
1152 next++; /* dont parse the escaped character */
1157 if ( strchr( sep, *next ) != NULL ) {
1170 static char buf[BUFSIZ];
1172 static int lmax, lcur;
1174 #define CATLINE( buf ) { \
1176 len = strlen( buf ); \
1177 while ( lcur + len + 1 > lmax ) { \
1179 line = (char *) ch_realloc( line, lmax ); \
1181 strcpy( line + lcur, buf ); \
1186 fp_getline( FILE *fp, int *lineno )
1194 /* hack attack - keeps us from having to keep a stack of bufs... */
1195 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1200 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1201 if ( (p = strchr( buf, '\n' )) != NULL ) {
1204 if ( ! isspace( (unsigned char) buf[0] ) ) {
1213 return( line[0] ? line : NULL );
1217 fp_getline_init( int *lineno )