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_disallows = 0;
30 slap_mask_t global_requires = 0;
31 slap_ssf_set_t global_ssf_set;
33 int global_lastmod = ON;
34 int global_idletimeout = 0;
35 char *global_realm = NULL;
36 char *ldap_srvtab = "";
37 char *default_passwd_hash;
39 char *slapd_pid_file = NULL;
40 char *slapd_args_file = NULL;
42 static char *fp_getline(FILE *fp, int *lineno);
43 static void fp_getline_init(int *lineno);
44 static int fp_parse_line(char *line, int *argcp, char **argv);
46 static char *strtok_quote(char *line, char *sep);
49 read_config( const char *fname )
52 char *line, *savefname, *saveline;
53 int cargc, savelineno;
54 char *cargv[MAXARGS+1];
59 struct berval *vals[2];
62 static BackendInfo *bi = NULL;
63 static BackendDB *be = NULL;
68 if ( (fp = fopen( fname, "r" )) == NULL ) {
70 Debug( LDAP_DEBUG_ANY,
71 "could not open config file \"%s\" - absolute path?\n",
77 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
79 fp_getline_init( &lineno );
81 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
82 /* skip comments and blank lines */
83 if ( line[0] == '#' || line[0] == '\0' ) {
87 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
89 /* fp_parse_line is destructive, we save a copy */
90 saveline = ch_strdup( line );
92 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
97 Debug( LDAP_DEBUG_ANY,
98 "%s: line %d: bad config line (ignored)\n",
103 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
105 Debug( LDAP_DEBUG_ANY,
106 "%s: line %d: missing type in \"backend <type>\" line\n",
112 Debug( LDAP_DEBUG_ANY,
113 "%s: line %d: backend line must appear before any database definition\n",
118 bi = backend_info( cargv[1] );
121 Debug( LDAP_DEBUG_ANY,
122 "backend %s initialization failed.\n",
127 /* start of a new database definition */
128 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
130 Debug( LDAP_DEBUG_ANY,
131 "%s: line %d: missing type in \"database <type>\" line\n",
137 be = backend_db_init( cargv[1] );
140 Debug( LDAP_DEBUG_ANY,
141 "database %s initialization failed.\n",
146 /* set thread concurrency */
147 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
150 Debug( LDAP_DEBUG_ANY,
151 "%s: line %d: missing level in \"concurrency <level>\" line\n",
156 c = atoi( cargv[1] );
159 Debug( LDAP_DEBUG_ANY,
160 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
165 ldap_pvt_thread_set_concurrency( c );
167 /* set maximum threads in thread pool */
168 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
171 Debug( LDAP_DEBUG_ANY,
172 "%s: line %d: missing count in \"threads <count>\" line\n",
177 c = atoi( cargv[1] );
180 Debug( LDAP_DEBUG_ANY,
181 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
186 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
188 /* get pid file name */
189 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
191 Debug( LDAP_DEBUG_ANY,
192 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
197 slapd_pid_file = ch_strdup( cargv[1] );
199 /* get args file name */
200 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
202 Debug( LDAP_DEBUG_ANY,
203 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
208 slapd_args_file = ch_strdup( cargv[1] );
210 /* default password hash */
211 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
213 Debug( LDAP_DEBUG_ANY,
214 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
218 if ( default_passwd_hash != NULL ) {
219 Debug( LDAP_DEBUG_ANY,
220 "%s: line %d: already set default password_hash!\n",
225 default_passwd_hash = ch_strdup( cargv[1] );
229 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
231 Debug( LDAP_DEBUG_ANY,
232 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
237 be->be_realm = ch_strdup( cargv[1] );
239 } else if ( global_realm != NULL ) {
240 Debug( LDAP_DEBUG_ANY,
241 "%s: line %d: already set global realm!\n",
246 global_realm = ch_strdup( cargv[1] );
249 /* SASL security properties */
250 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
254 Debug( LDAP_DEBUG_ANY,
255 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
260 txt = slap_sasl_secprops( cargv[1] );
262 Debug( LDAP_DEBUG_ANY,
263 "%s: line %d: sasl-secprops: %s\n",
264 fname, lineno, txt );
269 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
271 Debug( LDAP_DEBUG_ANY,
272 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
277 defsize = atoi( cargv[1] );
279 be->be_sizelimit = atoi( cargv[1] );
283 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
285 Debug( LDAP_DEBUG_ANY,
286 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
291 deftime = atoi( cargv[1] );
293 be->be_timelimit = atoi( cargv[1] );
296 /* set database suffix */
297 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
300 Debug( LDAP_DEBUG_ANY,
301 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
304 } else if ( cargc > 2 ) {
305 Debug( LDAP_DEBUG_ANY,
306 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
307 fname, lineno, cargv[1] );
310 Debug( LDAP_DEBUG_ANY,
311 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
313 } else if ( ( tmp_be = select_backend( cargv[1] ) ) == be ) {
314 Debug( LDAP_DEBUG_ANY,
315 "%s: line %d: suffix already served by this backend (ignored)\n",
317 } else if ( tmp_be != NULL ) {
318 Debug( LDAP_DEBUG_ANY,
319 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
320 fname, lineno, tmp_be->be_suffix[0] );
322 char *dn = ch_strdup( cargv[1] );
323 (void) dn_validate( dn );
324 charray_add( &be->be_suffix, dn );
325 (void) ldap_pvt_str2upper( dn );
326 charray_add( &be->be_nsuffix, dn );
330 /* set database suffixAlias */
331 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
334 Debug( LDAP_DEBUG_ANY,
335 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
338 } else if ( cargc < 3 ) {
339 Debug( LDAP_DEBUG_ANY,
340 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
343 } else if ( cargc > 3 ) {
344 Debug( LDAP_DEBUG_ANY,
345 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
350 Debug( LDAP_DEBUG_ANY,
351 "%s: line %d: suffixAlias line"
352 " must appear inside a database definition (ignored)\n",
354 } else if ( (tmp_be = select_backend( cargv[1] )) != NULL ) {
355 Debug( LDAP_DEBUG_ANY,
356 "%s: line %d: suffixAlias served by"
357 " a preceeding backend \"%s\" (ignored)\n",
358 fname, lineno, tmp_be->be_suffix[0] );
360 } else if ( (tmp_be = select_backend( cargv[2] )) != NULL ) {
361 Debug( LDAP_DEBUG_ANY,
362 "%s: line %d: suffixAlias derefs to differnet backend"
363 " a preceeding backend \"%s\" (ignored)\n",
364 fname, lineno, tmp_be->be_suffix[0] );
367 char *alias, *aliased_dn;
369 alias = ch_strdup( cargv[1] );
370 (void) dn_normalize( alias );
372 aliased_dn = ch_strdup( cargv[2] );
373 (void) dn_normalize( aliased_dn );
375 charray_add( &be->be_suffixAlias, alias );
376 charray_add( &be->be_suffixAlias, aliased_dn );
382 /* set max deref depth */
383 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
386 Debug( LDAP_DEBUG_ANY,
387 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
392 Debug( LDAP_DEBUG_ANY,
393 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
395 } else if ((i = atoi(cargv[1])) < 0) {
396 Debug( LDAP_DEBUG_ANY,
397 "%s: line %d: depth must be positive (ignored)\n",
401 be->be_max_deref_depth = i;
405 /* set magic "root" dn for this database */
406 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
408 Debug( LDAP_DEBUG_ANY,
409 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
414 Debug( LDAP_DEBUG_ANY,
415 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
418 be->be_root_dn = ch_strdup( cargv[1] );
419 be->be_root_ndn = ch_strdup( cargv[1] );
421 if( dn_normalize( be->be_root_ndn ) == NULL ) {
422 free( be->be_root_dn );
423 free( be->be_root_ndn );
424 Debug( LDAP_DEBUG_ANY,
425 "%s: line %d: rootdn DN is invalid\n",
431 /* set super-secret magic database password */
432 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
434 Debug( LDAP_DEBUG_ANY,
435 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
440 Debug( LDAP_DEBUG_ANY,
441 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
444 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
445 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
448 /* make this database read-only */
449 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
451 Debug( LDAP_DEBUG_ANY,
452 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
457 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
458 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
460 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
463 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
464 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
466 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
471 /* disallow these features */
472 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
473 strcasecmp( cargv[0], "disallow" ) == 0 )
475 slap_mask_t disallows;
478 Debug( LDAP_DEBUG_ANY,
479 "%s: line %d: disallow line must appear prior to database definitions\n",
484 Debug( LDAP_DEBUG_ANY,
485 "%s: line %d: missing feature(s) in \"disallows <features>\" line\n",
492 for( i=1; i < cargc; i++ ) {
493 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
494 disallows |= SLAP_DISALLOW_BIND_V2;
496 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
497 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
499 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
500 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
502 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
503 Debug( LDAP_DEBUG_ANY,
504 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
505 fname, lineno, cargv[i] );
510 global_disallows = disallows;
512 /* require these features */
513 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
514 strcasecmp( cargv[0], "require" ) == 0 )
516 slap_mask_t requires;
519 Debug( LDAP_DEBUG_ANY,
520 "%s: line %d: missing feature(s) in \"requires <features>\" line\n",
527 for( i=1; i < cargc; i++ ) {
528 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
529 requires |= SLAP_REQUIRE_BIND;
531 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
532 requires |= SLAP_REQUIRE_LDAP_V3;
534 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
535 requires |= SLAP_REQUIRE_AUTHC;
537 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
538 requires |= SLAP_REQUIRE_SASL;
540 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
541 requires |= SLAP_REQUIRE_STRONG;
543 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
544 Debug( LDAP_DEBUG_ANY,
545 "%s: line %d: unknown feature %s in \"requires <features>\" line\n",
546 fname, lineno, cargv[i] );
552 global_requires = requires;
554 be->be_requires = requires;
557 /* required security factors */
558 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
562 Debug( LDAP_DEBUG_ANY,
563 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
569 set = &global_ssf_set;
571 set = &be->be_ssf_set;
574 for( i=1; i < cargc; i++ ) {
575 if( strncasecmp( cargv[i], "ssf=",
576 sizeof("ssf") ) == 0 )
579 atoi( &cargv[i][sizeof("ssf")] );
581 } else if( strncasecmp( cargv[i], "transport=",
582 sizeof("transport") ) == 0 )
585 atoi( &cargv[i][sizeof("transport")] );
587 } else if( strncasecmp( cargv[i], "tls=",
588 sizeof("tls") ) == 0 )
591 atoi( &cargv[i][sizeof("tls")] );
593 } else if( strncasecmp( cargv[i], "sasl=",
594 sizeof("sasl") ) == 0 )
597 atoi( &cargv[i][sizeof("sasl")] );
599 } else if( strncasecmp( cargv[i], "update_ssf=",
600 sizeof("update_ssf") ) == 0 )
602 set->sss_update_ssf =
603 atoi( &cargv[i][sizeof("update_ssf")] );
605 } else if( strncasecmp( cargv[i], "update_transport=",
606 sizeof("update_transport") ) == 0 )
608 set->sss_update_transport =
609 atoi( &cargv[i][sizeof("update_transport")] );
611 } else if( strncasecmp( cargv[i], "update_tls=",
612 sizeof("update_tls") ) == 0 )
614 set->sss_update_tls =
615 atoi( &cargv[i][sizeof("update_tls")] );
617 } else if( strncasecmp( cargv[i], "update_sasl=",
618 sizeof("update_sasl") ) == 0 )
620 set->sss_update_sasl =
621 atoi( &cargv[i][sizeof("update_sasl")] );
624 Debug( LDAP_DEBUG_ANY,
625 "%s: line %d: unknown feature %s in \"requires <features>\" line\n",
626 fname, lineno, cargv[i] );
632 /* where to send clients when we don't hold it */
633 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
635 Debug( LDAP_DEBUG_ANY,
636 "%s: line %d: missing URL in \"referral <URL>\" line\n",
641 vals[0]->bv_val = cargv[1];
642 vals[0]->bv_len = strlen( vals[0]->bv_val );
643 value_add( &default_referral, vals );
645 /* specify an Object Identifier macro */
646 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
647 parse_oidm( fname, lineno, cargc, cargv );
649 /* specify an objectclass */
650 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
651 if ( *cargv[1] == '(' ) {
653 p = strchr(saveline,'(');
654 parse_oc( fname, lineno, p, cargv );
656 Debug( LDAP_DEBUG_ANY,
657 "%s: line %d: old objectclass format not supported.\n",
661 /* specify an attribute type */
662 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
663 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
665 if ( *cargv[1] == '(' ) {
667 p = strchr(saveline,'(');
668 parse_at( fname, lineno, p, cargv );
670 Debug( LDAP_DEBUG_ANY,
671 "%s: line %d: old attribute type format not supported.\n",
675 /* turn on/off schema checking */
676 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
678 Debug( LDAP_DEBUG_ANY,
679 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
683 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
684 global_schemacheck = 0;
686 global_schemacheck = 1;
689 /* specify access control info */
690 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
691 parse_acl( be, fname, lineno, cargc, cargv );
693 /* specify default access control info */
694 } else if ( strcasecmp( cargv[0], "defaultaccess" ) == 0 ) {
695 slap_access_t access;
698 Debug( LDAP_DEBUG_ANY,
699 "%s: line %d: missing limit in \"defaultaccess <access>\" line\n",
704 access = str2access( cargv[1] );
706 if ( access == ACL_INVALID_ACCESS ) {
707 Debug( LDAP_DEBUG_ANY,
708 "%s: line %d: bad access level \"%s\", "
709 "expecting none|auth|compare|search|read|write\n",
710 fname, lineno, cargv[1] );
715 global_default_access = access;
717 be->be_dfltaccess = access;
720 /* debug level to log things to syslog */
721 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
723 Debug( LDAP_DEBUG_ANY,
724 "%s: line %d: missing level in \"loglevel <level>\" line\n",
731 for( i=1; i < cargc; i++ ) {
732 ldap_syslog += atoi( cargv[1] );
735 /* list of replicas of the data in this backend (master only) */
736 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
738 Debug( LDAP_DEBUG_ANY,
739 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
744 Debug( LDAP_DEBUG_ANY,
745 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
748 for ( i = 1; i < cargc; i++ ) {
749 if ( strncasecmp( cargv[i], "host=", 5 )
751 charray_add( &be->be_replica,
757 Debug( LDAP_DEBUG_ANY,
758 "%s: line %d: missing host in \"replica\" line (ignored)\n",
763 /* dn of master entity allowed to write to replica */
764 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
766 Debug( LDAP_DEBUG_ANY,
767 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
772 Debug( LDAP_DEBUG_ANY,
773 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
776 be->be_update_ndn = ch_strdup( cargv[1] );
777 if( dn_normalize( be->be_update_ndn ) == NULL ) {
778 Debug( LDAP_DEBUG_ANY,
779 "%s: line %d: updatedn DN is invalid\n",
785 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
787 Debug( LDAP_DEBUG_ANY,
788 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
793 Debug( LDAP_DEBUG_ANY,
794 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
796 } else if ( be->be_update_ndn == NULL ) {
797 Debug( LDAP_DEBUG_ANY,
798 "%s: line %d: updateref line must after updatedn (ignored)\n",
801 vals[0]->bv_val = cargv[1];
802 vals[0]->bv_len = strlen( vals[0]->bv_val );
803 value_add( &be->be_update_refs, vals );
806 /* replication log file to which changes are appended */
807 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
809 Debug( LDAP_DEBUG_ANY,
810 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
815 be->be_replogfile = ch_strdup( cargv[1] );
817 replogfile = ch_strdup( cargv[1] );
820 /* maintain lastmodified{by,time} attributes */
821 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
823 Debug( LDAP_DEBUG_ANY,
824 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
828 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
835 be->be_lastmod = OFF;
837 global_lastmod = OFF;
840 /* set idle timeout value */
841 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
844 Debug( LDAP_DEBUG_ANY,
845 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
850 i = atoi( cargv[1] );
853 Debug( LDAP_DEBUG_ANY,
854 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
859 global_idletimeout = i;
861 /* include another config file */
862 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
864 Debug( LDAP_DEBUG_ANY,
865 "%s: line %d: missing filename in \"include <filename>\" line\n",
869 savefname = ch_strdup( cargv[1] );
872 if ( read_config( savefname ) != 0 ) {
877 lineno = savelineno - 1;
879 /* location of kerberos srvtab file */
880 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
882 Debug( LDAP_DEBUG_ANY,
883 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
887 ldap_srvtab = ch_strdup( cargv[1] );
890 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
892 Debug( LDAP_DEBUG_ANY,
893 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
895 exit( EXIT_FAILURE );
897 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
898 Debug( LDAP_DEBUG_ANY,
899 "%s: line %d: failed to load or initialize module %s\n",
900 fname, lineno, cargv[1]);
901 exit( EXIT_FAILURE );
903 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
905 Debug( LDAP_DEBUG_ANY,
906 "%s: line %d: missing path in \"modulepath <path>\" line\n",
908 exit( EXIT_FAILURE );
910 if (module_path( cargv[1] )) {
911 Debug( LDAP_DEBUG_ANY,
912 "%s: line %d: failed to set module search path to %s\n",
913 fname, lineno, cargv[1]);
914 exit( EXIT_FAILURE );
917 #endif /*SLAPD_MODULES*/
920 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
921 rc = ldap_pvt_tls_set_option( NULL,
922 LDAP_OPT_X_TLS_PROTOCOL,
927 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
928 rc = ldap_pvt_tls_set_option( NULL,
929 LDAP_OPT_X_TLS_CIPHER_SUITE,
934 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
935 rc = ldap_pvt_tls_set_option( NULL,
936 LDAP_OPT_X_TLS_CERTFILE,
941 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
942 rc = ldap_pvt_tls_set_option( NULL,
943 LDAP_OPT_X_TLS_KEYFILE,
948 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
949 rc = ldap_pvt_tls_set_option( NULL,
950 LDAP_OPT_X_TLS_CACERTDIR,
955 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
956 rc = ldap_pvt_tls_set_option( NULL,
957 LDAP_OPT_X_TLS_CACERTFILE,
961 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
962 rc = ldap_pvt_tls_set_option( NULL,
963 LDAP_OPT_X_TLS_REQUIRE_CERT,
970 /* pass anything else to the current backend info/db config routine */
973 if ( bi->bi_config == 0 ) {
974 Debug( LDAP_DEBUG_ANY,
975 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
976 fname, lineno, cargv[0] );
978 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
984 } else if ( be != NULL ) {
985 if ( be->be_config == 0 ) {
986 Debug( LDAP_DEBUG_ANY,
987 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
988 fname, lineno, cargv[0] );
990 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
997 Debug( LDAP_DEBUG_ANY,
998 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
999 fname, lineno, cargv[0] );
1018 for ( token = strtok_quote( line, " \t" ); token != NULL;
1019 token = strtok_quote( NULL, " \t" ) ) {
1020 if ( *argcp == MAXARGS ) {
1021 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1025 argv[(*argcp)++] = token;
1027 argv[*argcp] = NULL;
1032 strtok_quote( char *line, char *sep )
1038 if ( line != NULL ) {
1041 while ( *next && strchr( sep, *next ) ) {
1045 if ( *next == '\0' ) {
1051 for ( inquote = 0; *next; ) {
1059 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1065 next + 1, strlen( next + 1 ) + 1 );
1066 next++; /* dont parse the escaped character */
1071 if ( strchr( sep, *next ) != NULL ) {
1084 static char buf[BUFSIZ];
1086 static int lmax, lcur;
1088 #define CATLINE( buf ) { \
1090 len = strlen( buf ); \
1091 while ( lcur + len + 1 > lmax ) { \
1093 line = (char *) ch_realloc( line, lmax ); \
1095 strcpy( line + lcur, buf ); \
1100 fp_getline( FILE *fp, int *lineno )
1108 /* hack attack - keeps us from having to keep a stack of bufs... */
1109 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1114 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1115 if ( (p = strchr( buf, '\n' )) != NULL ) {
1118 if ( ! isspace( (unsigned char) buf[0] ) ) {
1127 return( line[0] ? line : NULL );
1131 fp_getline_init( int *lineno )