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_host = NULL;
36 char *global_realm = NULL;
37 char *global_ucdata_path = NULL;
38 char *ldap_srvtab = "";
39 char *default_passwd_hash;
41 char *slapd_pid_file = NULL;
42 char *slapd_args_file = NULL;
44 static char *fp_getline(FILE *fp, int *lineno);
45 static void fp_getline_init(int *lineno);
46 static int fp_parse_line(char *line, int *argcp, char **argv);
48 static char *strtok_quote(char *line, char *sep);
51 read_config( const char *fname )
54 char *line, *savefname, *saveline;
55 int cargc, savelineno;
56 char *cargv[MAXARGS+1];
61 struct berval *vals[2];
64 static BackendInfo *bi = NULL;
65 static BackendDB *be = NULL;
70 if ( (fp = fopen( fname, "r" )) == NULL ) {
72 Debug( LDAP_DEBUG_ANY,
73 "could not open config file \"%s\" - absolute path?\n",
79 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
81 fp_getline_init( &lineno );
83 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
84 /* skip comments and blank lines */
85 if ( line[0] == '#' || line[0] == '\0' ) {
89 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
91 /* fp_parse_line is destructive, we save a copy */
92 saveline = ch_strdup( line );
94 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
99 Debug( LDAP_DEBUG_ANY,
100 "%s: line %d: bad config line (ignored)\n",
105 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
107 Debug( LDAP_DEBUG_ANY,
108 "%s: line %d: missing type in \"backend <type>\" line\n",
114 Debug( LDAP_DEBUG_ANY,
115 "%s: line %d: backend line must appear before any database definition\n",
120 bi = backend_info( cargv[1] );
123 Debug( LDAP_DEBUG_ANY,
124 "backend %s initialization failed.\n",
129 /* start of a new database definition */
130 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
132 Debug( LDAP_DEBUG_ANY,
133 "%s: line %d: missing type in \"database <type>\" line\n",
139 be = backend_db_init( cargv[1] );
142 Debug( LDAP_DEBUG_ANY,
143 "database %s initialization failed.\n",
148 /* set thread concurrency */
149 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
152 Debug( LDAP_DEBUG_ANY,
153 "%s: line %d: missing level in \"concurrency <level>\" line\n",
158 c = atoi( cargv[1] );
161 Debug( LDAP_DEBUG_ANY,
162 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
167 ldap_pvt_thread_set_concurrency( c );
169 /* set maximum threads in thread pool */
170 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
173 Debug( LDAP_DEBUG_ANY,
174 "%s: line %d: missing count in \"threads <count>\" line\n",
179 c = atoi( cargv[1] );
182 Debug( LDAP_DEBUG_ANY,
183 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
188 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
190 /* get pid file name */
191 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
193 Debug( LDAP_DEBUG_ANY,
194 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
199 slapd_pid_file = ch_strdup( cargv[1] );
201 /* get args file name */
202 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
204 Debug( LDAP_DEBUG_ANY,
205 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
210 slapd_args_file = ch_strdup( cargv[1] );
212 /* default password hash */
213 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
215 Debug( LDAP_DEBUG_ANY,
216 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
220 if ( default_passwd_hash != NULL ) {
221 Debug( LDAP_DEBUG_ANY,
222 "%s: line %d: already set default password_hash!\n",
227 default_passwd_hash = ch_strdup( cargv[1] );
231 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
233 Debug( LDAP_DEBUG_ANY,
234 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
239 if ( global_host != NULL ) {
240 Debug( LDAP_DEBUG_ANY,
241 "%s: line %d: already set sasl-host!\n",
246 global_host = ch_strdup( cargv[1] );
250 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
252 Debug( LDAP_DEBUG_ANY,
253 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
258 if ( global_realm != NULL ) {
259 Debug( LDAP_DEBUG_ANY,
260 "%s: line %d: already set sasl-realm!\n",
265 global_realm = ch_strdup( cargv[1] );
268 /* SASL security properties */
269 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
273 Debug( LDAP_DEBUG_ANY,
274 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
279 txt = slap_sasl_secprops( cargv[1] );
281 Debug( LDAP_DEBUG_ANY,
282 "%s: line %d: sasl-secprops: %s\n",
283 fname, lineno, txt );
287 /* set UCDATA path */
288 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
290 Debug( LDAP_DEBUG_ANY,
291 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
296 if ( global_ucdata_path != NULL ) {
297 Debug( LDAP_DEBUG_ANY,
298 "%s: line %d: already set ucdata-path!\n",
303 global_ucdata_path = ch_strdup( cargv[1] );
307 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
309 Debug( LDAP_DEBUG_ANY,
310 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
315 defsize = atoi( cargv[1] );
317 be->be_sizelimit = atoi( cargv[1] );
321 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
323 Debug( LDAP_DEBUG_ANY,
324 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
329 deftime = atoi( cargv[1] );
331 be->be_timelimit = atoi( cargv[1] );
334 /* set database suffix */
335 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
338 Debug( LDAP_DEBUG_ANY,
339 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
342 } else if ( cargc > 2 ) {
343 Debug( LDAP_DEBUG_ANY,
344 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
345 fname, lineno, cargv[1] );
348 Debug( LDAP_DEBUG_ANY,
349 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
351 } else if ( ( tmp_be = select_backend( cargv[1] ) ) == be ) {
352 Debug( LDAP_DEBUG_ANY,
353 "%s: line %d: suffix already served by this backend (ignored)\n",
355 } else if ( tmp_be != NULL ) {
356 Debug( LDAP_DEBUG_ANY,
357 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
358 fname, lineno, tmp_be->be_suffix[0] );
360 char *dn = ch_strdup( cargv[1] );
361 (void) dn_validate( dn );
362 charray_add( &be->be_suffix, dn );
363 (void) ldap_pvt_str2upper( dn );
364 charray_add( &be->be_nsuffix, dn );
368 /* set database suffixAlias */
369 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
372 Debug( LDAP_DEBUG_ANY,
373 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
376 } else if ( cargc < 3 ) {
377 Debug( LDAP_DEBUG_ANY,
378 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
381 } else if ( cargc > 3 ) {
382 Debug( LDAP_DEBUG_ANY,
383 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
388 Debug( LDAP_DEBUG_ANY,
389 "%s: line %d: suffixAlias line"
390 " must appear inside a database definition (ignored)\n",
392 } else if ( (tmp_be = select_backend( cargv[1] )) != NULL ) {
393 Debug( LDAP_DEBUG_ANY,
394 "%s: line %d: suffixAlias served by"
395 " a preceeding backend \"%s\" (ignored)\n",
396 fname, lineno, tmp_be->be_suffix[0] );
398 } else if ( (tmp_be = select_backend( cargv[2] )) != NULL ) {
399 Debug( LDAP_DEBUG_ANY,
400 "%s: line %d: suffixAlias derefs to differnet backend"
401 " a preceeding backend \"%s\" (ignored)\n",
402 fname, lineno, tmp_be->be_suffix[0] );
405 char *alias, *aliased_dn;
407 alias = ch_strdup( cargv[1] );
408 (void) dn_normalize( alias );
410 aliased_dn = ch_strdup( cargv[2] );
411 (void) dn_normalize( aliased_dn );
413 charray_add( &be->be_suffixAlias, alias );
414 charray_add( &be->be_suffixAlias, aliased_dn );
420 /* set max deref depth */
421 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
424 Debug( LDAP_DEBUG_ANY,
425 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
430 Debug( LDAP_DEBUG_ANY,
431 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
433 } else if ((i = atoi(cargv[1])) < 0) {
434 Debug( LDAP_DEBUG_ANY,
435 "%s: line %d: depth must be positive (ignored)\n",
439 be->be_max_deref_depth = i;
443 /* set magic "root" dn for this database */
444 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
446 Debug( LDAP_DEBUG_ANY,
447 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
452 Debug( LDAP_DEBUG_ANY,
453 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
456 be->be_root_dn = ch_strdup( cargv[1] );
457 be->be_root_ndn = ch_strdup( cargv[1] );
459 if( dn_normalize( be->be_root_ndn ) == NULL ) {
460 free( be->be_root_dn );
461 free( be->be_root_ndn );
462 Debug( LDAP_DEBUG_ANY,
463 "%s: line %d: rootdn DN is invalid\n",
469 /* set super-secret magic database password */
470 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
472 Debug( LDAP_DEBUG_ANY,
473 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
478 Debug( LDAP_DEBUG_ANY,
479 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
482 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
483 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
486 /* make this database read-only */
487 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
489 Debug( LDAP_DEBUG_ANY,
490 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
495 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
496 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
498 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
501 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
502 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
504 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
509 /* disallow these features */
510 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
511 strcasecmp( cargv[0], "disallow" ) == 0 )
513 slap_mask_t disallows;
516 Debug( LDAP_DEBUG_ANY,
517 "%s: line %d: disallow line must appear prior to database definitions\n",
522 Debug( LDAP_DEBUG_ANY,
523 "%s: line %d: missing feature(s) in \"disallows <features>\" line\n",
530 for( i=1; i < cargc; i++ ) {
531 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
532 disallows |= SLAP_DISALLOW_BIND_V2;
534 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
535 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
537 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
538 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
540 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
541 Debug( LDAP_DEBUG_ANY,
542 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
543 fname, lineno, cargv[i] );
548 global_disallows = disallows;
550 /* require these features */
551 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
552 strcasecmp( cargv[0], "require" ) == 0 )
554 slap_mask_t requires;
557 Debug( LDAP_DEBUG_ANY,
558 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
565 for( i=1; i < cargc; i++ ) {
566 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
567 requires |= SLAP_REQUIRE_BIND;
569 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
570 requires |= SLAP_REQUIRE_LDAP_V3;
572 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
573 requires |= SLAP_REQUIRE_AUTHC;
575 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
576 requires |= SLAP_REQUIRE_SASL;
578 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
579 requires |= SLAP_REQUIRE_STRONG;
581 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
582 Debug( LDAP_DEBUG_ANY,
583 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
584 fname, lineno, cargv[i] );
590 global_requires = requires;
592 be->be_requires = requires;
595 /* required security factors */
596 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
600 Debug( LDAP_DEBUG_ANY,
601 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
607 set = &global_ssf_set;
609 set = &be->be_ssf_set;
612 for( i=1; i < cargc; i++ ) {
613 if( strncasecmp( cargv[i], "ssf=",
614 sizeof("ssf") ) == 0 )
617 atoi( &cargv[i][sizeof("ssf")] );
619 } else if( strncasecmp( cargv[i], "transport=",
620 sizeof("transport") ) == 0 )
623 atoi( &cargv[i][sizeof("transport")] );
625 } else if( strncasecmp( cargv[i], "tls=",
626 sizeof("tls") ) == 0 )
629 atoi( &cargv[i][sizeof("tls")] );
631 } else if( strncasecmp( cargv[i], "sasl=",
632 sizeof("sasl") ) == 0 )
635 atoi( &cargv[i][sizeof("sasl")] );
637 } else if( strncasecmp( cargv[i], "update_ssf=",
638 sizeof("update_ssf") ) == 0 )
640 set->sss_update_ssf =
641 atoi( &cargv[i][sizeof("update_ssf")] );
643 } else if( strncasecmp( cargv[i], "update_transport=",
644 sizeof("update_transport") ) == 0 )
646 set->sss_update_transport =
647 atoi( &cargv[i][sizeof("update_transport")] );
649 } else if( strncasecmp( cargv[i], "update_tls=",
650 sizeof("update_tls") ) == 0 )
652 set->sss_update_tls =
653 atoi( &cargv[i][sizeof("update_tls")] );
655 } else if( strncasecmp( cargv[i], "update_sasl=",
656 sizeof("update_sasl") ) == 0 )
658 set->sss_update_sasl =
659 atoi( &cargv[i][sizeof("update_sasl")] );
662 Debug( LDAP_DEBUG_ANY,
663 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
664 fname, lineno, cargv[i] );
670 /* where to send clients when we don't hold it */
671 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
673 Debug( LDAP_DEBUG_ANY,
674 "%s: line %d: missing URL in \"referral <URL>\" line\n",
679 vals[0]->bv_val = cargv[1];
680 vals[0]->bv_len = strlen( vals[0]->bv_val );
681 value_add( &default_referral, vals );
683 /* specify an Object Identifier macro */
684 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
685 parse_oidm( fname, lineno, cargc, cargv );
687 /* specify an objectclass */
688 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
689 if ( *cargv[1] == '(' ) {
691 p = strchr(saveline,'(');
692 parse_oc( fname, lineno, p, cargv );
694 Debug( LDAP_DEBUG_ANY,
695 "%s: line %d: old objectclass format not supported.\n",
699 /* specify an attribute type */
700 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
701 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
703 if ( *cargv[1] == '(' ) {
705 p = strchr(saveline,'(');
706 parse_at( fname, lineno, p, cargv );
708 Debug( LDAP_DEBUG_ANY,
709 "%s: line %d: old attribute type format not supported.\n",
713 /* turn on/off schema checking */
714 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
716 Debug( LDAP_DEBUG_ANY,
717 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
721 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
722 global_schemacheck = 0;
724 global_schemacheck = 1;
727 /* specify access control info */
728 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
729 parse_acl( be, fname, lineno, cargc, cargv );
731 /* specify default access control info */
732 } else if ( strcasecmp( cargv[0], "defaultaccess" ) == 0 ) {
733 slap_access_t access;
736 Debug( LDAP_DEBUG_ANY,
737 "%s: line %d: missing limit in \"defaultaccess <access>\" line\n",
742 access = str2access( cargv[1] );
744 if ( access == ACL_INVALID_ACCESS ) {
745 Debug( LDAP_DEBUG_ANY,
746 "%s: line %d: bad access level \"%s\", "
747 "expecting none|auth|compare|search|read|write\n",
748 fname, lineno, cargv[1] );
753 global_default_access = access;
755 be->be_dfltaccess = access;
758 /* debug level to log things to syslog */
759 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
761 Debug( LDAP_DEBUG_ANY,
762 "%s: line %d: missing level in \"loglevel <level>\" line\n",
769 for( i=1; i < cargc; i++ ) {
770 ldap_syslog += atoi( cargv[1] );
773 /* list of replicas of the data in this backend (master only) */
774 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
776 Debug( LDAP_DEBUG_ANY,
777 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
782 Debug( LDAP_DEBUG_ANY,
783 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
786 for ( i = 1; i < cargc; i++ ) {
787 if ( strncasecmp( cargv[i], "host=", 5 )
789 charray_add( &be->be_replica,
795 Debug( LDAP_DEBUG_ANY,
796 "%s: line %d: missing host in \"replica\" line (ignored)\n",
801 /* dn of master entity allowed to write to replica */
802 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
804 Debug( LDAP_DEBUG_ANY,
805 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
810 Debug( LDAP_DEBUG_ANY,
811 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
814 be->be_update_ndn = ch_strdup( cargv[1] );
815 if( dn_normalize( be->be_update_ndn ) == NULL ) {
816 Debug( LDAP_DEBUG_ANY,
817 "%s: line %d: updatedn DN is invalid\n",
823 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
825 Debug( LDAP_DEBUG_ANY,
826 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
831 Debug( LDAP_DEBUG_ANY,
832 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
834 } else if ( be->be_update_ndn == NULL ) {
835 Debug( LDAP_DEBUG_ANY,
836 "%s: line %d: updateref line must after updatedn (ignored)\n",
839 vals[0]->bv_val = cargv[1];
840 vals[0]->bv_len = strlen( vals[0]->bv_val );
841 value_add( &be->be_update_refs, vals );
844 /* replication log file to which changes are appended */
845 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
847 Debug( LDAP_DEBUG_ANY,
848 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
853 be->be_replogfile = ch_strdup( cargv[1] );
855 replogfile = ch_strdup( cargv[1] );
858 /* maintain lastmodified{by,time} attributes */
859 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
861 Debug( LDAP_DEBUG_ANY,
862 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
866 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
873 be->be_lastmod = OFF;
875 global_lastmod = OFF;
878 /* set idle timeout value */
879 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
882 Debug( LDAP_DEBUG_ANY,
883 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
888 i = atoi( cargv[1] );
891 Debug( LDAP_DEBUG_ANY,
892 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
897 global_idletimeout = i;
899 /* include another config file */
900 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
902 Debug( LDAP_DEBUG_ANY,
903 "%s: line %d: missing filename in \"include <filename>\" line\n",
907 savefname = ch_strdup( cargv[1] );
910 if ( read_config( savefname ) != 0 ) {
915 lineno = savelineno - 1;
917 /* location of kerberos srvtab file */
918 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
920 Debug( LDAP_DEBUG_ANY,
921 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
925 ldap_srvtab = ch_strdup( cargv[1] );
928 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
930 Debug( LDAP_DEBUG_ANY,
931 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
933 exit( EXIT_FAILURE );
935 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
936 Debug( LDAP_DEBUG_ANY,
937 "%s: line %d: failed to load or initialize module %s\n",
938 fname, lineno, cargv[1]);
939 exit( EXIT_FAILURE );
941 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
943 Debug( LDAP_DEBUG_ANY,
944 "%s: line %d: missing path in \"modulepath <path>\" line\n",
946 exit( EXIT_FAILURE );
948 if (module_path( cargv[1] )) {
949 Debug( LDAP_DEBUG_ANY,
950 "%s: line %d: failed to set module search path to %s\n",
951 fname, lineno, cargv[1]);
952 exit( EXIT_FAILURE );
955 #endif /*SLAPD_MODULES*/
958 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
959 rc = ldap_pvt_tls_set_option( NULL,
960 LDAP_OPT_X_TLS_PROTOCOL,
965 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
966 rc = ldap_pvt_tls_set_option( NULL,
967 LDAP_OPT_X_TLS_CIPHER_SUITE,
972 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
973 rc = ldap_pvt_tls_set_option( NULL,
974 LDAP_OPT_X_TLS_CERTFILE,
979 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
980 rc = ldap_pvt_tls_set_option( NULL,
981 LDAP_OPT_X_TLS_KEYFILE,
986 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
987 rc = ldap_pvt_tls_set_option( NULL,
988 LDAP_OPT_X_TLS_CACERTDIR,
993 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
994 rc = ldap_pvt_tls_set_option( NULL,
995 LDAP_OPT_X_TLS_CACERTFILE,
999 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1000 rc = ldap_pvt_tls_set_option( NULL,
1001 LDAP_OPT_X_TLS_REQUIRE_CERT,
1008 /* pass anything else to the current backend info/db config routine */
1011 if ( bi->bi_config == 0 ) {
1012 Debug( LDAP_DEBUG_ANY,
1013 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1014 fname, lineno, cargv[0] );
1016 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1022 } else if ( be != NULL ) {
1023 if ( be->be_config == 0 ) {
1024 Debug( LDAP_DEBUG_ANY,
1025 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1026 fname, lineno, cargv[0] );
1028 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1035 Debug( LDAP_DEBUG_ANY,
1036 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1037 fname, lineno, cargv[0] );
1056 for ( token = strtok_quote( line, " \t" ); token != NULL;
1057 token = strtok_quote( NULL, " \t" ) ) {
1058 if ( *argcp == MAXARGS ) {
1059 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1063 argv[(*argcp)++] = token;
1065 argv[*argcp] = NULL;
1070 strtok_quote( char *line, char *sep )
1076 if ( line != NULL ) {
1079 while ( *next && strchr( sep, *next ) ) {
1083 if ( *next == '\0' ) {
1089 for ( inquote = 0; *next; ) {
1097 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1103 next + 1, strlen( next + 1 ) + 1 );
1104 next++; /* dont parse the escaped character */
1109 if ( strchr( sep, *next ) != NULL ) {
1122 static char buf[BUFSIZ];
1124 static int lmax, lcur;
1126 #define CATLINE( buf ) { \
1128 len = strlen( buf ); \
1129 while ( lcur + len + 1 > lmax ) { \
1131 line = (char *) ch_realloc( line, lmax ); \
1133 strcpy( line + lcur, buf ); \
1138 fp_getline( FILE *fp, int *lineno )
1146 /* hack attack - keeps us from having to keep a stack of bufs... */
1147 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1152 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1153 if ( (p = strchr( buf, '\n' )) != NULL ) {
1156 if ( ! isspace( (unsigned char) buf[0] ) ) {
1165 return( line[0] ? line : NULL );
1169 fp_getline_init( int *lineno )