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 *ldap_srvtab = "";
38 char *default_passwd_hash;
40 char *slapd_pid_file = NULL;
41 char *slapd_args_file = NULL;
43 static char *fp_getline(FILE *fp, int *lineno);
44 static void fp_getline_init(int *lineno);
45 static int fp_parse_line(char *line, int *argcp, char **argv);
47 static char *strtok_quote(char *line, char *sep);
50 read_config( const char *fname )
53 char *line, *savefname, *saveline;
54 int cargc, savelineno;
55 char *cargv[MAXARGS+1];
60 struct berval *vals[2];
63 static BackendInfo *bi = NULL;
64 static BackendDB *be = NULL;
69 if ( (fp = fopen( fname, "r" )) == NULL ) {
71 Debug( LDAP_DEBUG_ANY,
72 "could not open config file \"%s\" - absolute path?\n",
78 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
80 fp_getline_init( &lineno );
82 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
83 /* skip comments and blank lines */
84 if ( line[0] == '#' || line[0] == '\0' ) {
88 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
90 /* fp_parse_line is destructive, we save a copy */
91 saveline = ch_strdup( line );
93 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
98 Debug( LDAP_DEBUG_ANY,
99 "%s: line %d: bad config line (ignored)\n",
104 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
106 Debug( LDAP_DEBUG_ANY,
107 "%s: line %d: missing type in \"backend <type>\" line\n",
113 Debug( LDAP_DEBUG_ANY,
114 "%s: line %d: backend line must appear before any database definition\n",
119 bi = backend_info( cargv[1] );
122 Debug( LDAP_DEBUG_ANY,
123 "backend %s initialization failed.\n",
128 /* start of a new database definition */
129 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
131 Debug( LDAP_DEBUG_ANY,
132 "%s: line %d: missing type in \"database <type>\" line\n",
138 be = backend_db_init( cargv[1] );
141 Debug( LDAP_DEBUG_ANY,
142 "database %s initialization failed.\n",
147 /* set thread concurrency */
148 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
151 Debug( LDAP_DEBUG_ANY,
152 "%s: line %d: missing level in \"concurrency <level>\" line\n",
157 c = atoi( cargv[1] );
160 Debug( LDAP_DEBUG_ANY,
161 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
166 ldap_pvt_thread_set_concurrency( c );
168 /* set maximum threads in thread pool */
169 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
172 Debug( LDAP_DEBUG_ANY,
173 "%s: line %d: missing count in \"threads <count>\" line\n",
178 c = atoi( cargv[1] );
181 Debug( LDAP_DEBUG_ANY,
182 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
187 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
189 /* get pid file name */
190 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
192 Debug( LDAP_DEBUG_ANY,
193 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
198 slapd_pid_file = ch_strdup( cargv[1] );
200 /* get args file name */
201 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
203 Debug( LDAP_DEBUG_ANY,
204 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
209 slapd_args_file = ch_strdup( cargv[1] );
211 /* default password hash */
212 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
214 Debug( LDAP_DEBUG_ANY,
215 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
219 if ( default_passwd_hash != NULL ) {
220 Debug( LDAP_DEBUG_ANY,
221 "%s: line %d: already set default password_hash!\n",
226 default_passwd_hash = ch_strdup( cargv[1] );
230 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
232 Debug( LDAP_DEBUG_ANY,
233 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
238 if ( global_host != NULL ) {
239 Debug( LDAP_DEBUG_ANY,
240 "%s: line %d: already set sasl-host!\n",
245 global_host = ch_strdup( cargv[1] );
249 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
251 Debug( LDAP_DEBUG_ANY,
252 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
257 if ( global_realm != NULL ) {
258 Debug( LDAP_DEBUG_ANY,
259 "%s: line %d: already set sasl-realm!\n",
264 global_realm = ch_strdup( cargv[1] );
267 /* SASL security properties */
268 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
272 Debug( LDAP_DEBUG_ANY,
273 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
278 txt = slap_sasl_secprops( cargv[1] );
280 Debug( LDAP_DEBUG_ANY,
281 "%s: line %d: sasl-secprops: %s\n",
282 fname, lineno, txt );
287 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
289 Debug( LDAP_DEBUG_ANY,
290 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
295 defsize = atoi( cargv[1] );
297 be->be_sizelimit = atoi( cargv[1] );
301 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
303 Debug( LDAP_DEBUG_ANY,
304 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
309 deftime = atoi( cargv[1] );
311 be->be_timelimit = atoi( cargv[1] );
314 /* set database suffix */
315 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
318 Debug( LDAP_DEBUG_ANY,
319 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
322 } else if ( cargc > 2 ) {
323 Debug( LDAP_DEBUG_ANY,
324 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
325 fname, lineno, cargv[1] );
328 Debug( LDAP_DEBUG_ANY,
329 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
331 } else if ( ( tmp_be = select_backend( cargv[1] ) ) == be ) {
332 Debug( LDAP_DEBUG_ANY,
333 "%s: line %d: suffix already served by this backend (ignored)\n",
335 } else if ( tmp_be != NULL ) {
336 Debug( LDAP_DEBUG_ANY,
337 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
338 fname, lineno, tmp_be->be_suffix[0] );
340 char *dn = ch_strdup( cargv[1] );
341 (void) dn_validate( dn );
342 charray_add( &be->be_suffix, dn );
343 (void) ldap_pvt_str2upper( dn );
344 charray_add( &be->be_nsuffix, dn );
348 /* set database suffixAlias */
349 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
352 Debug( LDAP_DEBUG_ANY,
353 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
356 } else if ( cargc < 3 ) {
357 Debug( LDAP_DEBUG_ANY,
358 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
361 } else if ( cargc > 3 ) {
362 Debug( LDAP_DEBUG_ANY,
363 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
368 Debug( LDAP_DEBUG_ANY,
369 "%s: line %d: suffixAlias line"
370 " must appear inside a database definition (ignored)\n",
372 } else if ( (tmp_be = select_backend( cargv[1] )) != NULL ) {
373 Debug( LDAP_DEBUG_ANY,
374 "%s: line %d: suffixAlias served by"
375 " a preceeding backend \"%s\" (ignored)\n",
376 fname, lineno, tmp_be->be_suffix[0] );
378 } else if ( (tmp_be = select_backend( cargv[2] )) != NULL ) {
379 Debug( LDAP_DEBUG_ANY,
380 "%s: line %d: suffixAlias derefs to differnet backend"
381 " a preceeding backend \"%s\" (ignored)\n",
382 fname, lineno, tmp_be->be_suffix[0] );
385 char *alias, *aliased_dn;
387 alias = ch_strdup( cargv[1] );
388 (void) dn_normalize( alias );
390 aliased_dn = ch_strdup( cargv[2] );
391 (void) dn_normalize( aliased_dn );
393 charray_add( &be->be_suffixAlias, alias );
394 charray_add( &be->be_suffixAlias, aliased_dn );
400 /* set max deref depth */
401 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
404 Debug( LDAP_DEBUG_ANY,
405 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
410 Debug( LDAP_DEBUG_ANY,
411 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
413 } else if ((i = atoi(cargv[1])) < 0) {
414 Debug( LDAP_DEBUG_ANY,
415 "%s: line %d: depth must be positive (ignored)\n",
419 be->be_max_deref_depth = i;
423 /* set magic "root" dn for this database */
424 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
426 Debug( LDAP_DEBUG_ANY,
427 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
432 Debug( LDAP_DEBUG_ANY,
433 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
436 be->be_root_dn = ch_strdup( cargv[1] );
437 be->be_root_ndn = ch_strdup( cargv[1] );
439 if( dn_normalize( be->be_root_ndn ) == NULL ) {
440 free( be->be_root_dn );
441 free( be->be_root_ndn );
442 Debug( LDAP_DEBUG_ANY,
443 "%s: line %d: rootdn DN is invalid\n",
449 /* set super-secret magic database password */
450 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
452 Debug( LDAP_DEBUG_ANY,
453 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
458 Debug( LDAP_DEBUG_ANY,
459 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
462 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
463 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
466 /* make this database read-only */
467 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
469 Debug( LDAP_DEBUG_ANY,
470 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
475 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
476 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
478 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
481 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
482 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
484 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
489 /* disallow these features */
490 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
491 strcasecmp( cargv[0], "disallow" ) == 0 )
493 slap_mask_t disallows;
496 Debug( LDAP_DEBUG_ANY,
497 "%s: line %d: disallow line must appear prior to database definitions\n",
502 Debug( LDAP_DEBUG_ANY,
503 "%s: line %d: missing feature(s) in \"disallows <features>\" line\n",
510 for( i=1; i < cargc; i++ ) {
511 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
512 disallows |= SLAP_DISALLOW_BIND_V2;
514 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
515 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
517 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
518 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
520 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
521 Debug( LDAP_DEBUG_ANY,
522 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
523 fname, lineno, cargv[i] );
528 global_disallows = disallows;
530 /* require these features */
531 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
532 strcasecmp( cargv[0], "require" ) == 0 )
534 slap_mask_t requires;
537 Debug( LDAP_DEBUG_ANY,
538 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
545 for( i=1; i < cargc; i++ ) {
546 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
547 requires |= SLAP_REQUIRE_BIND;
549 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
550 requires |= SLAP_REQUIRE_LDAP_V3;
552 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
553 requires |= SLAP_REQUIRE_AUTHC;
555 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
556 requires |= SLAP_REQUIRE_SASL;
558 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
559 requires |= SLAP_REQUIRE_STRONG;
561 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
562 Debug( LDAP_DEBUG_ANY,
563 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
564 fname, lineno, cargv[i] );
570 global_requires = requires;
572 be->be_requires = requires;
575 /* required security factors */
576 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
580 Debug( LDAP_DEBUG_ANY,
581 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
587 set = &global_ssf_set;
589 set = &be->be_ssf_set;
592 for( i=1; i < cargc; i++ ) {
593 if( strncasecmp( cargv[i], "ssf=",
594 sizeof("ssf") ) == 0 )
597 atoi( &cargv[i][sizeof("ssf")] );
599 } else if( strncasecmp( cargv[i], "transport=",
600 sizeof("transport") ) == 0 )
603 atoi( &cargv[i][sizeof("transport")] );
605 } else if( strncasecmp( cargv[i], "tls=",
606 sizeof("tls") ) == 0 )
609 atoi( &cargv[i][sizeof("tls")] );
611 } else if( strncasecmp( cargv[i], "sasl=",
612 sizeof("sasl") ) == 0 )
615 atoi( &cargv[i][sizeof("sasl")] );
617 } else if( strncasecmp( cargv[i], "update_ssf=",
618 sizeof("update_ssf") ) == 0 )
620 set->sss_update_ssf =
621 atoi( &cargv[i][sizeof("update_ssf")] );
623 } else if( strncasecmp( cargv[i], "update_transport=",
624 sizeof("update_transport") ) == 0 )
626 set->sss_update_transport =
627 atoi( &cargv[i][sizeof("update_transport")] );
629 } else if( strncasecmp( cargv[i], "update_tls=",
630 sizeof("update_tls") ) == 0 )
632 set->sss_update_tls =
633 atoi( &cargv[i][sizeof("update_tls")] );
635 } else if( strncasecmp( cargv[i], "update_sasl=",
636 sizeof("update_sasl") ) == 0 )
638 set->sss_update_sasl =
639 atoi( &cargv[i][sizeof("update_sasl")] );
642 Debug( LDAP_DEBUG_ANY,
643 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
644 fname, lineno, cargv[i] );
650 /* where to send clients when we don't hold it */
651 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
653 Debug( LDAP_DEBUG_ANY,
654 "%s: line %d: missing URL in \"referral <URL>\" line\n",
659 vals[0]->bv_val = cargv[1];
660 vals[0]->bv_len = strlen( vals[0]->bv_val );
661 value_add( &default_referral, vals );
663 /* specify an Object Identifier macro */
664 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
665 parse_oidm( fname, lineno, cargc, cargv );
667 /* specify an objectclass */
668 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
669 if ( *cargv[1] == '(' ) {
671 p = strchr(saveline,'(');
672 parse_oc( fname, lineno, p, cargv );
674 Debug( LDAP_DEBUG_ANY,
675 "%s: line %d: old objectclass format not supported.\n",
679 /* specify an attribute type */
680 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
681 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
683 if ( *cargv[1] == '(' ) {
685 p = strchr(saveline,'(');
686 parse_at( fname, lineno, p, cargv );
688 Debug( LDAP_DEBUG_ANY,
689 "%s: line %d: old attribute type format not supported.\n",
693 /* turn on/off schema checking */
694 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
696 Debug( LDAP_DEBUG_ANY,
697 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
701 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
702 global_schemacheck = 0;
704 global_schemacheck = 1;
707 /* specify access control info */
708 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
709 parse_acl( be, fname, lineno, cargc, cargv );
711 /* specify default access control info */
712 } else if ( strcasecmp( cargv[0], "defaultaccess" ) == 0 ) {
713 slap_access_t access;
716 Debug( LDAP_DEBUG_ANY,
717 "%s: line %d: missing limit in \"defaultaccess <access>\" line\n",
722 access = str2access( cargv[1] );
724 if ( access == ACL_INVALID_ACCESS ) {
725 Debug( LDAP_DEBUG_ANY,
726 "%s: line %d: bad access level \"%s\", "
727 "expecting none|auth|compare|search|read|write\n",
728 fname, lineno, cargv[1] );
733 global_default_access = access;
735 be->be_dfltaccess = access;
738 /* debug level to log things to syslog */
739 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
741 Debug( LDAP_DEBUG_ANY,
742 "%s: line %d: missing level in \"loglevel <level>\" line\n",
749 for( i=1; i < cargc; i++ ) {
750 ldap_syslog += atoi( cargv[1] );
753 /* list of replicas of the data in this backend (master only) */
754 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
756 Debug( LDAP_DEBUG_ANY,
757 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
762 Debug( LDAP_DEBUG_ANY,
763 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
766 for ( i = 1; i < cargc; i++ ) {
767 if ( strncasecmp( cargv[i], "host=", 5 )
769 charray_add( &be->be_replica,
775 Debug( LDAP_DEBUG_ANY,
776 "%s: line %d: missing host in \"replica\" line (ignored)\n",
781 /* dn of master entity allowed to write to replica */
782 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
784 Debug( LDAP_DEBUG_ANY,
785 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
790 Debug( LDAP_DEBUG_ANY,
791 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
794 be->be_update_ndn = ch_strdup( cargv[1] );
795 if( dn_normalize( be->be_update_ndn ) == NULL ) {
796 Debug( LDAP_DEBUG_ANY,
797 "%s: line %d: updatedn DN is invalid\n",
803 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
805 Debug( LDAP_DEBUG_ANY,
806 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
811 Debug( LDAP_DEBUG_ANY,
812 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
814 } else if ( be->be_update_ndn == NULL ) {
815 Debug( LDAP_DEBUG_ANY,
816 "%s: line %d: updateref line must after updatedn (ignored)\n",
819 vals[0]->bv_val = cargv[1];
820 vals[0]->bv_len = strlen( vals[0]->bv_val );
821 value_add( &be->be_update_refs, vals );
824 /* replication log file to which changes are appended */
825 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
827 Debug( LDAP_DEBUG_ANY,
828 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
833 be->be_replogfile = ch_strdup( cargv[1] );
835 replogfile = ch_strdup( cargv[1] );
838 /* maintain lastmodified{by,time} attributes */
839 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
841 Debug( LDAP_DEBUG_ANY,
842 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
846 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
853 be->be_lastmod = OFF;
855 global_lastmod = OFF;
858 /* set idle timeout value */
859 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
862 Debug( LDAP_DEBUG_ANY,
863 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
868 i = atoi( cargv[1] );
871 Debug( LDAP_DEBUG_ANY,
872 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
877 global_idletimeout = i;
879 /* include another config file */
880 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
882 Debug( LDAP_DEBUG_ANY,
883 "%s: line %d: missing filename in \"include <filename>\" line\n",
887 savefname = ch_strdup( cargv[1] );
890 if ( read_config( savefname ) != 0 ) {
895 lineno = savelineno - 1;
897 /* location of kerberos srvtab file */
898 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
900 Debug( LDAP_DEBUG_ANY,
901 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
905 ldap_srvtab = ch_strdup( cargv[1] );
908 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
910 Debug( LDAP_DEBUG_ANY,
911 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
913 exit( EXIT_FAILURE );
915 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
916 Debug( LDAP_DEBUG_ANY,
917 "%s: line %d: failed to load or initialize module %s\n",
918 fname, lineno, cargv[1]);
919 exit( EXIT_FAILURE );
921 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
923 Debug( LDAP_DEBUG_ANY,
924 "%s: line %d: missing path in \"modulepath <path>\" line\n",
926 exit( EXIT_FAILURE );
928 if (module_path( cargv[1] )) {
929 Debug( LDAP_DEBUG_ANY,
930 "%s: line %d: failed to set module search path to %s\n",
931 fname, lineno, cargv[1]);
932 exit( EXIT_FAILURE );
935 #endif /*SLAPD_MODULES*/
938 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
939 rc = ldap_pvt_tls_set_option( NULL,
940 LDAP_OPT_X_TLS_PROTOCOL,
945 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
946 rc = ldap_pvt_tls_set_option( NULL,
947 LDAP_OPT_X_TLS_CIPHER_SUITE,
952 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
953 rc = ldap_pvt_tls_set_option( NULL,
954 LDAP_OPT_X_TLS_CERTFILE,
959 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
960 rc = ldap_pvt_tls_set_option( NULL,
961 LDAP_OPT_X_TLS_KEYFILE,
966 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
967 rc = ldap_pvt_tls_set_option( NULL,
968 LDAP_OPT_X_TLS_CACERTDIR,
973 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
974 rc = ldap_pvt_tls_set_option( NULL,
975 LDAP_OPT_X_TLS_CACERTFILE,
979 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
980 rc = ldap_pvt_tls_set_option( NULL,
981 LDAP_OPT_X_TLS_REQUIRE_CERT,
988 /* pass anything else to the current backend info/db config routine */
991 if ( bi->bi_config == 0 ) {
992 Debug( LDAP_DEBUG_ANY,
993 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
994 fname, lineno, cargv[0] );
996 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1002 } else if ( be != NULL ) {
1003 if ( be->be_config == 0 ) {
1004 Debug( LDAP_DEBUG_ANY,
1005 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1006 fname, lineno, cargv[0] );
1008 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1015 Debug( LDAP_DEBUG_ANY,
1016 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1017 fname, lineno, cargv[0] );
1036 for ( token = strtok_quote( line, " \t" ); token != NULL;
1037 token = strtok_quote( NULL, " \t" ) ) {
1038 if ( *argcp == MAXARGS ) {
1039 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1043 argv[(*argcp)++] = token;
1045 argv[*argcp] = NULL;
1050 strtok_quote( char *line, char *sep )
1056 if ( line != NULL ) {
1059 while ( *next && strchr( sep, *next ) ) {
1063 if ( *next == '\0' ) {
1069 for ( inquote = 0; *next; ) {
1077 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1083 next + 1, strlen( next + 1 ) + 1 );
1084 next++; /* dont parse the escaped character */
1089 if ( strchr( sep, *next ) != NULL ) {
1102 static char buf[BUFSIZ];
1104 static int lmax, lcur;
1106 #define CATLINE( buf ) { \
1108 len = strlen( buf ); \
1109 while ( lcur + len + 1 > lmax ) { \
1111 line = (char *) ch_realloc( line, lmax ); \
1113 strcpy( line + lcur, buf ); \
1118 fp_getline( FILE *fp, int *lineno )
1126 /* hack attack - keeps us from having to keep a stack of bufs... */
1127 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1132 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1133 if ( (p = strchr( buf, '\n' )) != NULL ) {
1136 if ( ! isspace( (unsigned char) buf[0] ) ) {
1145 return( line[0] ? line : NULL );
1149 fp_getline_init( int *lineno )