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], "tls_authc" ) == 0 ) {
580 disallows |= SLAP_DISALLOW_TLS_AUTHC;
582 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
583 Debug( LDAP_DEBUG_ANY,
584 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
585 fname, lineno, cargv[i] );
590 global_disallows = disallows;
592 /* require these features */
593 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
594 strcasecmp( cargv[0], "require" ) == 0 )
596 slap_mask_t requires;
599 Debug( LDAP_DEBUG_ANY,
600 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
607 for( i=1; i < cargc; i++ ) {
608 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
609 requires |= SLAP_REQUIRE_BIND;
611 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
612 requires |= SLAP_REQUIRE_LDAP_V3;
614 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
615 requires |= SLAP_REQUIRE_AUTHC;
617 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
618 requires |= SLAP_REQUIRE_SASL;
620 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
621 requires |= SLAP_REQUIRE_STRONG;
623 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
624 Debug( LDAP_DEBUG_ANY,
625 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
626 fname, lineno, cargv[i] );
632 global_requires = requires;
634 be->be_requires = requires;
637 /* required security factors */
638 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
642 Debug( LDAP_DEBUG_ANY,
643 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
649 set = &global_ssf_set;
651 set = &be->be_ssf_set;
654 for( i=1; i < cargc; i++ ) {
655 if( strncasecmp( cargv[i], "ssf=",
656 sizeof("ssf") ) == 0 )
659 atoi( &cargv[i][sizeof("ssf")] );
661 } else if( strncasecmp( cargv[i], "transport=",
662 sizeof("transport") ) == 0 )
665 atoi( &cargv[i][sizeof("transport")] );
667 } else if( strncasecmp( cargv[i], "tls=",
668 sizeof("tls") ) == 0 )
671 atoi( &cargv[i][sizeof("tls")] );
673 } else if( strncasecmp( cargv[i], "sasl=",
674 sizeof("sasl") ) == 0 )
677 atoi( &cargv[i][sizeof("sasl")] );
679 } else if( strncasecmp( cargv[i], "update_ssf=",
680 sizeof("update_ssf") ) == 0 )
682 set->sss_update_ssf =
683 atoi( &cargv[i][sizeof("update_ssf")] );
685 } else if( strncasecmp( cargv[i], "update_transport=",
686 sizeof("update_transport") ) == 0 )
688 set->sss_update_transport =
689 atoi( &cargv[i][sizeof("update_transport")] );
691 } else if( strncasecmp( cargv[i], "update_tls=",
692 sizeof("update_tls") ) == 0 )
694 set->sss_update_tls =
695 atoi( &cargv[i][sizeof("update_tls")] );
697 } else if( strncasecmp( cargv[i], "update_sasl=",
698 sizeof("update_sasl") ) == 0 )
700 set->sss_update_sasl =
701 atoi( &cargv[i][sizeof("update_sasl")] );
704 Debug( LDAP_DEBUG_ANY,
705 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
706 fname, lineno, cargv[i] );
712 /* where to send clients when we don't hold it */
713 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
715 Debug( LDAP_DEBUG_ANY,
716 "%s: line %d: missing URL in \"referral <URL>\" line\n",
721 vals[0]->bv_val = cargv[1];
722 vals[0]->bv_len = strlen( vals[0]->bv_val );
723 value_add( &default_referral, vals );
725 /* specify an Object Identifier macro */
726 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
727 parse_oidm( fname, lineno, cargc, cargv );
729 /* specify an objectclass */
730 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
731 if ( *cargv[1] == '(' ) {
733 p = strchr(saveline,'(');
734 parse_oc( fname, lineno, p, cargv );
736 Debug( LDAP_DEBUG_ANY,
737 "%s: line %d: old objectclass format not supported.\n",
741 /* specify an attribute type */
742 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
743 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
745 if ( *cargv[1] == '(' ) {
747 p = strchr(saveline,'(');
748 parse_at( fname, lineno, p, cargv );
750 Debug( LDAP_DEBUG_ANY,
751 "%s: line %d: old attribute type format not supported.\n",
755 /* turn on/off schema checking */
756 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
758 Debug( LDAP_DEBUG_ANY,
759 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
763 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
764 global_schemacheck = 0;
766 global_schemacheck = 1;
769 /* specify access control info */
770 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
771 parse_acl( be, fname, lineno, cargc, cargv );
773 /* specify default access control info */
774 } else if ( strcasecmp( cargv[0], "defaultaccess" ) == 0 ) {
775 slap_access_t access;
778 Debug( LDAP_DEBUG_ANY,
779 "%s: line %d: missing limit in \"defaultaccess <access>\" line\n",
784 access = str2access( cargv[1] );
786 if ( access == ACL_INVALID_ACCESS ) {
787 Debug( LDAP_DEBUG_ANY,
788 "%s: line %d: bad access level \"%s\", "
789 "expecting none|auth|compare|search|read|write\n",
790 fname, lineno, cargv[1] );
795 global_default_access = access;
797 be->be_dfltaccess = access;
800 /* debug level to log things to syslog */
801 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
803 Debug( LDAP_DEBUG_ANY,
804 "%s: line %d: missing level in \"loglevel <level>\" line\n",
811 for( i=1; i < cargc; i++ ) {
812 ldap_syslog += atoi( cargv[1] );
815 /* list of replicas of the data in this backend (master only) */
816 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
818 Debug( LDAP_DEBUG_ANY,
819 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
824 Debug( LDAP_DEBUG_ANY,
825 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
828 for ( i = 1; i < cargc; i++ ) {
829 if ( strncasecmp( cargv[i], "host=", 5 )
831 charray_add( &be->be_replica,
837 Debug( LDAP_DEBUG_ANY,
838 "%s: line %d: missing host in \"replica\" line (ignored)\n",
843 /* dn of master entity allowed to write to replica */
844 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
846 Debug( LDAP_DEBUG_ANY,
847 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
852 Debug( LDAP_DEBUG_ANY,
853 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
856 be->be_update_ndn = ch_strdup( cargv[1] );
857 if( dn_normalize( be->be_update_ndn ) == NULL ) {
858 Debug( LDAP_DEBUG_ANY,
859 "%s: line %d: updatedn DN is invalid\n",
865 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
867 Debug( LDAP_DEBUG_ANY,
868 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
873 Debug( LDAP_DEBUG_ANY,
874 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
876 } else if ( be->be_update_ndn == NULL ) {
877 Debug( LDAP_DEBUG_ANY,
878 "%s: line %d: updateref line must after updatedn (ignored)\n",
881 vals[0]->bv_val = cargv[1];
882 vals[0]->bv_len = strlen( vals[0]->bv_val );
883 value_add( &be->be_update_refs, vals );
886 /* replication log file to which changes are appended */
887 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
889 Debug( LDAP_DEBUG_ANY,
890 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
895 be->be_replogfile = ch_strdup( cargv[1] );
897 replogfile = ch_strdup( cargv[1] );
900 /* maintain lastmodified{by,time} attributes */
901 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
903 Debug( LDAP_DEBUG_ANY,
904 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
908 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
915 be->be_lastmod = OFF;
917 global_lastmod = OFF;
920 /* set idle timeout value */
921 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
924 Debug( LDAP_DEBUG_ANY,
925 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
930 i = atoi( cargv[1] );
933 Debug( LDAP_DEBUG_ANY,
934 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
939 global_idletimeout = i;
941 /* include another config file */
942 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
944 Debug( LDAP_DEBUG_ANY,
945 "%s: line %d: missing filename in \"include <filename>\" line\n",
949 savefname = ch_strdup( cargv[1] );
952 if ( read_config( savefname ) != 0 ) {
957 lineno = savelineno - 1;
959 /* location of kerberos srvtab file */
960 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
962 Debug( LDAP_DEBUG_ANY,
963 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
967 ldap_srvtab = ch_strdup( cargv[1] );
970 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
972 Debug( LDAP_DEBUG_ANY,
973 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
975 exit( EXIT_FAILURE );
977 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
978 Debug( LDAP_DEBUG_ANY,
979 "%s: line %d: failed to load or initialize module %s\n",
980 fname, lineno, cargv[1]);
981 exit( EXIT_FAILURE );
983 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
985 Debug( LDAP_DEBUG_ANY,
986 "%s: line %d: missing path in \"modulepath <path>\" line\n",
988 exit( EXIT_FAILURE );
990 if (module_path( cargv[1] )) {
991 Debug( LDAP_DEBUG_ANY,
992 "%s: line %d: failed to set module search path to %s\n",
993 fname, lineno, cargv[1]);
994 exit( EXIT_FAILURE );
997 #endif /*SLAPD_MODULES*/
1000 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1001 rc = ldap_pvt_tls_set_option( NULL,
1002 LDAP_OPT_X_TLS_PROTOCOL,
1007 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1008 rc = ldap_pvt_tls_set_option( NULL,
1009 LDAP_OPT_X_TLS_CIPHER_SUITE,
1014 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1015 rc = ldap_pvt_tls_set_option( NULL,
1016 LDAP_OPT_X_TLS_CERTFILE,
1021 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1022 rc = ldap_pvt_tls_set_option( NULL,
1023 LDAP_OPT_X_TLS_KEYFILE,
1028 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1029 rc = ldap_pvt_tls_set_option( NULL,
1030 LDAP_OPT_X_TLS_CACERTDIR,
1035 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1036 rc = ldap_pvt_tls_set_option( NULL,
1037 LDAP_OPT_X_TLS_CACERTFILE,
1041 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1042 rc = ldap_pvt_tls_set_option( NULL,
1043 LDAP_OPT_X_TLS_REQUIRE_CERT,
1050 /* pass anything else to the current backend info/db config routine */
1053 if ( bi->bi_config == 0 ) {
1054 Debug( LDAP_DEBUG_ANY,
1055 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1056 fname, lineno, cargv[0] );
1058 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1064 } else if ( be != NULL ) {
1065 if ( be->be_config == 0 ) {
1066 Debug( LDAP_DEBUG_ANY,
1067 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1068 fname, lineno, cargv[0] );
1070 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1077 Debug( LDAP_DEBUG_ANY,
1078 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1079 fname, lineno, cargv[0] );
1098 for ( token = strtok_quote( line, " \t" ); token != NULL;
1099 token = strtok_quote( NULL, " \t" ) ) {
1100 if ( *argcp == MAXARGS ) {
1101 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1105 argv[(*argcp)++] = token;
1107 argv[*argcp] = NULL;
1112 strtok_quote( char *line, char *sep )
1118 if ( line != NULL ) {
1121 while ( *next && strchr( sep, *next ) ) {
1125 if ( *next == '\0' ) {
1131 for ( inquote = 0; *next; ) {
1139 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1145 next + 1, strlen( next + 1 ) + 1 );
1146 next++; /* dont parse the escaped character */
1151 if ( strchr( sep, *next ) != NULL ) {
1164 static char buf[BUFSIZ];
1166 static int lmax, lcur;
1168 #define CATLINE( buf ) { \
1170 len = strlen( buf ); \
1171 while ( lcur + len + 1 > lmax ) { \
1173 line = (char *) ch_realloc( line, lmax ); \
1175 strcpy( line + lcur, buf ); \
1180 fp_getline( FILE *fp, int *lineno )
1188 /* hack attack - keeps us from having to keep a stack of bufs... */
1189 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1194 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1195 if ( (p = strchr( buf, '\n' )) != NULL ) {
1198 if ( ! isspace( (unsigned char) buf[0] ) ) {
1207 return( line[0] ? line : NULL );
1211 fp_getline_init( int *lineno )