1 /* config.c - configuration file handling routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
31 #include <ac/string.h>
33 #include <ac/signal.h>
34 #include <ac/socket.h>
40 #include "slapi/slapi.h"
47 * defaults for various global variables
49 struct slap_limits_set deflimit = {
50 SLAPD_DEFAULT_TIMELIMIT, /* backward compatible limits */
53 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
55 -1, /* no limit on unchecked size */
57 0, /* hide number of entries left */
58 0 /* number of total entries returned by pagedResults equal to hard limit */
61 AccessControl *global_acl = NULL;
62 slap_access_t global_default_access = ACL_READ;
63 slap_mask_t global_restrictops = 0;
64 slap_mask_t global_allows = 0;
65 slap_mask_t global_disallows = 0;
66 slap_mask_t global_requires = 0;
67 slap_ssf_set_t global_ssf_set;
69 int global_gentlehup = 0;
70 int global_idletimeout = 0;
71 char *global_host = NULL;
72 char *global_realm = NULL;
73 char *ldap_srvtab = "";
74 char **default_passwd_hash = NULL;
75 int cargc = 0, cargv_size = 0;
77 struct berval default_search_base = BER_BVNULL;
78 struct berval default_search_nbase = BER_BVNULL;
79 unsigned num_subordinates = 0;
80 struct berval global_schemadn = BER_BVNULL;
81 struct berval global_schemandn = BER_BVNULL;
83 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
84 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
86 int slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
87 int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
89 char *slapd_pid_file = NULL;
90 char *slapd_args_file = NULL;
92 char *strtok_quote_ptr;
94 int use_reverse_lookup = 0;
97 int slapi_plugins_used = 0;
100 static char *fp_getline(FILE *fp, int *lineno);
101 static void fp_getline_init(int *lineno);
102 static int fp_parse_line(int lineno, char *line);
104 static char *strtok_quote(char *line, char *sep);
105 static int load_ucdata(char *path);
107 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
108 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
111 read_config( const char *fname, int depth )
114 char *line, *savefname, *saveline;
118 struct berval vals[2];
121 static int lastmod = 1;
122 static BackendInfo *bi = NULL;
123 static BackendDB *be = NULL;
125 vals[1].bv_val = NULL;
128 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
129 cargv_size = ARGS_STEP + 1;
132 if ( (fp = fopen( fname, "r" )) == NULL ) {
135 LDAP_LOG( CONFIG, ENTRY,
136 "read_config: " "could not open config file \"%s\": %s (%d)\n",
137 fname, strerror(errno), errno );
139 Debug( LDAP_DEBUG_ANY,
140 "could not open config file \"%s\": %s (%d)\n",
141 fname, strerror(errno), errno );
147 LDAP_LOG( CONFIG, ENTRY,
148 "read_config: reading config file %s\n", fname, 0, 0 );
150 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
154 fp_getline_init( &lineno );
156 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
157 /* skip comments and blank lines */
158 if ( line[0] == '#' || line[0] == '\0' ) {
162 /* fp_parse_line is destructive, we save a copy */
163 saveline = ch_strdup( line );
165 if ( fp_parse_line( lineno, line ) != 0 ) {
171 LDAP_LOG( CONFIG, INFO,
172 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
174 Debug( LDAP_DEBUG_ANY,
175 "%s: line %d: bad config line (ignored)\n",
182 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
185 LDAP_LOG( CONFIG, CRIT,
186 "%s : line %d: missing type in \"backend\" line.\n",
189 Debug( LDAP_DEBUG_ANY,
190 "%s: line %d: missing type in \"backend <type>\" line\n",
199 LDAP_LOG( CONFIG, CRIT,
200 "%s: line %d: backend line must appear before any "
201 "database definition.\n", fname, lineno , 0 );
203 Debug( LDAP_DEBUG_ANY,
204 "%s: line %d: backend line must appear before any database definition\n",
211 bi = backend_info( cargv[1] );
215 LDAP_LOG( CONFIG, CRIT,
216 "read_config: backend %s initialization failed.\n",
219 Debug( LDAP_DEBUG_ANY,
220 "backend %s initialization failed.\n",
226 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
229 LDAP_LOG( CONFIG, CRIT,
230 "%s: line %d: missing type in \"database <type>\" line\n",
233 Debug( LDAP_DEBUG_ANY,
234 "%s: line %d: missing type in \"database <type>\" line\n",
242 be = backend_db_init( cargv[1] );
246 LDAP_LOG( CONFIG, CRIT,
247 "database %s initialization failed.\n", cargv[1], 0, 0 );
249 Debug( LDAP_DEBUG_ANY,
250 "database %s initialization failed.\n",
257 /* set thread concurrency */
258 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
262 LDAP_LOG( CONFIG, CRIT,
263 "%s: line %d: missing level in \"concurrency <level\" "
264 " line\n", fname, lineno, 0 );
266 Debug( LDAP_DEBUG_ANY,
267 "%s: line %d: missing level in \"concurrency <level>\" line\n",
274 c = atoi( cargv[1] );
278 LDAP_LOG( CONFIG, CRIT,
279 "%s: line %d: invalid level (%d) in "
280 "\"concurrency <level>\" line.\n", fname, lineno, c );
282 Debug( LDAP_DEBUG_ANY,
283 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
290 ldap_pvt_thread_set_concurrency( c );
292 /* set sockbuf max */
293 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
297 LDAP_LOG( CONFIG, CRIT,
298 "%s: line %d: missing max in \"sockbuf_max_incoming "
299 "<bytes>\" line\n", fname, lineno, 0 );
301 Debug( LDAP_DEBUG_ANY,
302 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
309 max = atol( cargv[1] );
313 LDAP_LOG( CONFIG, CRIT,
314 "%s: line %d: invalid max value (%ld) in "
315 "\"sockbuf_max_incoming <bytes>\" line.\n",
316 fname, lineno, max );
318 Debug( LDAP_DEBUG_ANY,
319 "%s: line %d: invalid max value (%ld) in "
320 "\"sockbuf_max_incoming <bytes>\" line.\n",
321 fname, lineno, max );
327 sockbuf_max_incoming = max;
329 /* set sockbuf max authenticated */
330 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
334 LDAP_LOG( CONFIG, CRIT,
335 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
336 "<bytes>\" line\n", fname, lineno, 0 );
338 Debug( LDAP_DEBUG_ANY,
339 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
346 max = atol( cargv[1] );
350 LDAP_LOG( CONFIG, CRIT,
351 "%s: line %d: invalid max value (%ld) in "
352 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
353 fname, lineno, max );
355 Debug( LDAP_DEBUG_ANY,
356 "%s: line %d: invalid max value (%ld) in "
357 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
358 fname, lineno, max );
364 sockbuf_max_incoming_auth = max;
366 /* set conn pending max */
367 } else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) {
371 LDAP_LOG( CONFIG, CRIT,
372 "%s: line %d: missing max in \"conn_max_pending "
373 "<requests>\" line\n", fname, lineno, 0 );
375 Debug( LDAP_DEBUG_ANY,
376 "%s: line %d: missing max in \"conn_max_pending <requests>\" line\n",
383 max = atol( cargv[1] );
387 LDAP_LOG( CONFIG, CRIT,
388 "%s: line %d: invalid max value (%ld) in "
389 "\"conn_max_pending <requests>\" line.\n",
390 fname, lineno, max );
392 Debug( LDAP_DEBUG_ANY,
393 "%s: line %d: invalid max value (%ld) in "
394 "\"conn_max_pending <requests>\" line.\n",
395 fname, lineno, max );
401 slap_conn_max_pending = max;
403 /* set conn pending max authenticated */
404 } else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) {
408 LDAP_LOG( CONFIG, CRIT,
409 "%s: line %d: missing max in \"conn_max_pending_auth "
410 "<requests>\" line\n", fname, lineno, 0 );
412 Debug( LDAP_DEBUG_ANY,
413 "%s: line %d: missing max in \"conn_max_pending_auth <requests>\" line\n",
420 max = atol( cargv[1] );
424 LDAP_LOG( CONFIG, CRIT,
425 "%s: line %d: invalid max value (%ld) in "
426 "\"conn_max_pending_auth <requests>\" line.\n",
427 fname, lineno, max );
429 Debug( LDAP_DEBUG_ANY,
430 "%s: line %d: invalid max value (%ld) in "
431 "\"conn_max_pending_auth <requests>\" line.\n",
432 fname, lineno, max );
438 slap_conn_max_pending_auth = max;
440 /* default search base */
441 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
444 LDAP_LOG( CONFIG, CRIT,
445 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
446 "line\n", fname, lineno, 0 );
448 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
449 "missing dn in \"defaultSearchBase <dn>\" line\n",
455 } else if ( cargc > 2 ) {
457 LDAP_LOG( CONFIG, INFO,
458 "%s: line %d: extra cruft after <dn> in "
459 "\"defaultSearchBase %s\" line (ignored)\n",
460 fname, lineno, cargv[1] );
462 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
463 "extra cruft after <dn> in \"defaultSearchBase %s\", "
465 fname, lineno, cargv[1] );
469 if ( bi != NULL || be != NULL ) {
471 LDAP_LOG( CONFIG, CRIT,
472 "%s: line %d: defaultSearchBase line must appear "
473 "prior to any backend or database definitions\n",
476 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
477 "defaultSearchBaase line must appear prior to "
478 "any backend or database definition\n",
485 if ( default_search_nbase.bv_len ) {
487 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
488 "default search base \"%s\" already defined "
489 "(discarding old)\n", fname, lineno,
490 default_search_base.bv_val );
492 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
493 "default search base \"%s\" already defined "
494 "(discarding old)\n",
495 fname, lineno, default_search_base.bv_val );
498 free( default_search_base.bv_val );
499 free( default_search_nbase.bv_val );
502 if ( load_ucdata( NULL ) < 0 ) return 1;
507 dn.bv_val = cargv[1];
508 dn.bv_len = strlen( dn.bv_val );
510 rc = dnPrettyNormal( NULL, &dn,
511 &default_search_base,
512 &default_search_nbase, NULL );
514 if( rc != LDAP_SUCCESS ) {
516 LDAP_LOG( CONFIG, CRIT,
517 "%s: line %d: defaultSearchBase DN is invalid.\n",
520 Debug( LDAP_DEBUG_ANY,
521 "%s: line %d: defaultSearchBase DN is invalid\n",
528 /* set maximum threads in thread pool */
529 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
533 LDAP_LOG( CONFIG, CRIT,
534 "%s: line %d: missing count in \"threads <count>\" line\n",
537 Debug( LDAP_DEBUG_ANY,
538 "%s: line %d: missing count in \"threads <count>\" line\n",
545 c = atoi( cargv[1] );
549 LDAP_LOG( CONFIG, CRIT,
550 "%s: line %d: invalid level (%d) in \"threads <count>\""
551 "line\n", fname, lineno, c );
553 Debug( LDAP_DEBUG_ANY,
554 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
561 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
563 /* save for later use */
564 connection_pool_max = c;
566 /* get pid file name */
567 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
570 LDAP_LOG( CONFIG, CRIT,
571 "%s: line %d missing file name in \"pidfile <file>\" "
572 "line.\n", fname, lineno, 0 );
574 Debug( LDAP_DEBUG_ANY,
575 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
582 slapd_pid_file = ch_strdup( cargv[1] );
584 /* get args file name */
585 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
588 LDAP_LOG( CONFIG, CRIT,
589 "%s: %d: missing file name in "
590 "\"argsfile <file>\" line.\n",
593 Debug( LDAP_DEBUG_ANY,
594 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
601 slapd_args_file = ch_strdup( cargv[1] );
603 } else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) {
606 } else if ( strcasecmp( cargv[0], "replica-argsfile" ) == 0 ) {
609 /* default password hash */
610 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
613 LDAP_LOG( CONFIG, CRIT,
614 "%s: line %d: missing hash in "
615 "\"password-hash <hash>\" line.\n",
618 Debug( LDAP_DEBUG_ANY,
619 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
625 if ( default_passwd_hash != NULL ) {
627 LDAP_LOG( CONFIG, CRIT,
628 "%s: line %d: already set default password_hash!\n",
631 Debug( LDAP_DEBUG_ANY,
632 "%s: line %d: already set default password_hash!\n",
639 for(i = 1; i < cargc; i++) {
640 if ( lutil_passwd_scheme( cargv[i] ) == 0 ) {
642 LDAP_LOG( CONFIG, CRIT,
643 "%s: line %d: password scheme \"%s\" not available\n",
644 fname, lineno, cargv[i] );
646 Debug( LDAP_DEBUG_ANY,
647 "%s: line %d: password scheme \"%s\" not available\n",
648 fname, lineno, cargv[i] );
651 ldap_charray_add( &default_passwd_hash, cargv[i] );
654 if( !default_passwd_hash ) {
656 LDAP_LOG( CONFIG, CRIT,
657 "%s: line %d: no valid hashes found\n",
660 Debug( LDAP_DEBUG_ANY,
661 "%s: line %d: no valid hashes found\n",
667 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
671 LDAP_LOG( CONFIG, CRIT,
672 "%s: line %d: missing format in "
673 "\"password-crypt-salt-format <format>\" line\n",
676 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
677 "\"password-crypt-salt-format <format>\" line\n",
684 lutil_salt_format( cargv[1] );
686 #ifdef SLAP_AUTH_REWRITE
687 /* use authid rewrite instead of sasl regexp */
688 } else if ( strncasecmp( cargv[0], "auth-rewrite",
689 STRLENOF("auth-rewrite") ) == 0 )
691 int rc = slap_sasl_rewrite_config( fname, lineno,
696 #endif /* SLAP_AUTH_REWRITE */
698 /* Auth + SASL config options */
699 } else if ( !strncasecmp( cargv[0], "auth", STRLENOF("auth") ) ||
700 !strncasecmp( cargv[0], "sasl", STRLENOF("sasl") ))
702 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
706 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
710 LDAP_LOG( CONFIG, CRIT,
711 "%s: line %d: missing dn in "
712 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
714 Debug( LDAP_DEBUG_ANY,
715 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
720 ber_str2bv( cargv[1], 0, 0, &dn );
722 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
723 &be->be_schemandn, NULL );
725 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
726 &global_schemandn, NULL );
728 if ( rc != LDAP_SUCCESS ) {
730 LDAP_LOG( CONFIG, CRIT,
731 "%s: line %d: schemadn DN is invalid.\n",
734 Debug( LDAP_DEBUG_ANY,
735 "%s: line %d: schemadn DN is invalid\n",
741 /* set UCDATA path */
742 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
746 LDAP_LOG( CONFIG, CRIT,
747 "%s: line %d: missing path in "
748 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
750 Debug( LDAP_DEBUG_ANY,
751 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
758 err = load_ucdata( cargv[1] );
762 LDAP_LOG( CONFIG, CRIT,
763 "%s: line %d: ucdata already loaded, ucdata-path "
764 "must be set earlier in the file and/or be "
765 "specified only once!\n", fname, lineno, 0 );
767 Debug( LDAP_DEBUG_ANY,
768 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
777 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
779 struct slap_limits_set *lim;
783 LDAP_LOG( CONFIG, CRIT,
784 "%s: line %d: missing limit in \"sizelimit <limit>\" "
785 "line.\n", fname, lineno, 0 );
787 Debug( LDAP_DEBUG_ANY,
788 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
798 lim = &be->be_def_limit;
801 for ( i = 1; i < cargc; i++ ) {
802 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
803 rc = limits_parse_one( cargv[i], lim );
806 LDAP_LOG( CONFIG, CRIT,
807 "%s: line %d: unable "
808 "to parse value \"%s\" in \"sizelimit "
809 "<limit>\" line.\n", fname, lineno, cargv[i] );
811 Debug( LDAP_DEBUG_ANY,
812 "%s: line %d: unable "
813 "to parse value \"%s\" "
816 fname, lineno, cargv[i] );
822 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
823 lim->lms_s_soft = -1;
827 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
828 if ( next == cargv[i] ) {
830 LDAP_LOG( CONFIG, CRIT,
831 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
832 "line.\n", fname, lineno, cargv[i] );
834 Debug( LDAP_DEBUG_ANY,
835 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
836 fname, lineno, cargv[i] );
840 } else if ( next[0] != '\0' ) {
842 LDAP_LOG( CONFIG, CRIT,
843 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
844 "line ignored.\n", fname, lineno, next );
846 Debug( LDAP_DEBUG_ANY,
847 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
848 fname, lineno, next );
857 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
859 struct slap_limits_set *lim;
863 LDAP_LOG( CONFIG, CRIT,
864 "%s: line %d missing limit in \"timelimit <limit>\" "
865 "line.\n", fname, lineno, 0 );
867 Debug( LDAP_DEBUG_ANY,
868 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
878 lim = &be->be_def_limit;
881 for ( i = 1; i < cargc; i++ ) {
882 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
883 rc = limits_parse_one( cargv[i], lim );
886 LDAP_LOG( CONFIG, CRIT,
887 "%s: line %d: unable to parse value \"%s\" "
888 "in \"timelimit <limit>\" line.\n",
889 fname, lineno, cargv[i] );
891 Debug( LDAP_DEBUG_ANY,
892 "%s: line %d: unable "
893 "to parse value \"%s\" "
896 fname, lineno, cargv[i] );
902 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
903 lim->lms_t_soft = -1;
907 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
908 if ( next == cargv[i] ) {
910 LDAP_LOG( CONFIG, CRIT,
911 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
912 "line.\n", fname, lineno, cargv[i] );
914 Debug( LDAP_DEBUG_ANY,
915 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
916 fname, lineno, cargv[i] );
920 } else if ( next[0] != '\0' ) {
922 LDAP_LOG( CONFIG, CRIT,
923 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
924 "line ignored.\n", fname, lineno, next );
926 Debug( LDAP_DEBUG_ANY,
927 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
928 fname, lineno, next );
936 /* set regex-based limits */
937 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
940 LDAP_LOG( CONFIG, WARNING,
941 "%s: line %d \"limits\" allowed only in database "
942 "environment.\n", fname, lineno, 0 );
944 Debug( LDAP_DEBUG_ANY,
945 "%s: line %d \"limits\" allowed only in database environment.\n%s",
951 if ( limits_parse( be, fname, lineno, cargc, cargv ) ) {
955 /* mark this as a subordinate database */
956 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
959 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
960 "subordinate keyword must appear inside a database "
961 "definition.\n", fname, lineno, 0 );
963 Debug( LDAP_DEBUG_ANY, "%s: line %d: subordinate keyword "
964 "must appear inside a database definition.\n",
970 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
974 /* add an overlay to this backend */
975 } else if ( strcasecmp( cargv[0], "overlay" ) == 0 ) {
978 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
979 "overlay keyword must appear inside a database "
980 "definition.\n", fname, lineno, 0 );
982 Debug( LDAP_DEBUG_ANY, "%s: line %d: overlay keyword "
983 "must appear inside a database definition.\n",
989 if ( cargv[1][0] == '-' && overlay_config( be, &cargv[1][1] ) ) {
992 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
993 "(optional) overlay \"%s\" configuration "
994 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
996 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
997 "(optional) overlay \"%s\" configuration "
998 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
1000 } else if ( overlay_config( be, cargv[1] ) ) {
1005 /* set database suffix */
1006 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
1008 struct berval dn, pdn, ndn;
1012 LDAP_LOG( CONFIG, CRIT,
1013 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
1016 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1017 "missing dn in \"suffix <dn>\" line\n",
1023 } else if ( cargc > 2 ) {
1025 LDAP_LOG( CONFIG, INFO,
1026 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
1027 " line (ignored).\n", fname, lineno, cargv[1] );
1029 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
1030 "after <dn> in \"suffix %s\" line (ignored)\n",
1031 fname, lineno, cargv[1] );
1037 LDAP_LOG( CONFIG, INFO,
1038 "%s: line %d: suffix line must appear inside a database "
1039 "definition.\n", fname, lineno, 0 );
1041 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
1042 "must appear inside a database definition\n",
1047 #if defined(SLAPD_MONITOR_DN)
1048 /* "cn=Monitor" is reserved for monitoring slap */
1049 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
1051 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
1052 "%s\" is reserved for monitoring slapd\n",
1053 fname, lineno, SLAPD_MONITOR_DN );
1055 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
1056 "%s\" is reserved for monitoring slapd\n",
1057 fname, lineno, SLAPD_MONITOR_DN );
1060 #endif /* SLAPD_MONITOR_DN */
1063 if ( load_ucdata( NULL ) < 0 ) return 1;
1065 dn.bv_val = cargv[1];
1066 dn.bv_len = strlen( cargv[1] );
1068 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
1069 if( rc != LDAP_SUCCESS ) {
1071 LDAP_LOG( CONFIG, CRIT,
1072 "%s: line %d: suffix DN is invalid.\n",
1075 Debug( LDAP_DEBUG_ANY,
1076 "%s: line %d: suffix DN is invalid\n",
1082 tmp_be = select_backend( &ndn, 0, 0 );
1083 if ( tmp_be == be ) {
1085 LDAP_LOG( CONFIG, INFO,
1086 "%s: line %d: suffix already served by this backend "
1087 "(ignored)\n", fname, lineno, 0 );
1089 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1090 "already served by this backend (ignored)\n",
1096 } else if ( tmp_be != NULL ) {
1098 LDAP_LOG( CONFIG, INFO,
1099 "%s: line %d: suffix already served by a preceding "
1100 "backend \"%s\"\n", fname, lineno,
1101 tmp_be->be_suffix[0].bv_val );
1103 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1104 "already served by a preceeding backend \"%s\"\n",
1105 fname, lineno, tmp_be->be_suffix[0].bv_val );
1111 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
1113 LDAP_LOG( CONFIG, INFO,
1114 "%s: line %d: suffix DN empty and default search "
1115 "base provided \"%s\" (assuming okay).\n",
1116 fname, lineno, default_search_base.bv_val );
1118 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1119 "suffix DN empty and default "
1120 "search base provided \"%s\" (assuming okay)\n",
1121 fname, lineno, default_search_base.bv_val );
1125 ber_bvarray_add( &be->be_suffix, &pdn );
1126 ber_bvarray_add( &be->be_nsuffix, &ndn );
1128 /* set max deref depth */
1129 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1133 LDAP_LOG( CONFIG, CRIT,
1134 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1135 " line\n", fname, lineno, 0 );
1137 Debug( LDAP_DEBUG_ANY,
1138 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1146 LDAP_LOG( CONFIG, INFO,
1147 "%s: line %d: depth line must appear inside a database "
1148 "definition.\n", fname, lineno ,0 );
1150 Debug( LDAP_DEBUG_ANY,
1151 "%s: line %d: depth line must appear inside a database definition.\n",
1156 } else if ((i = atoi(cargv[1])) < 0) {
1158 LDAP_LOG( CONFIG, INFO,
1159 "%s: line %d: depth must be positive.\n",
1162 Debug( LDAP_DEBUG_ANY,
1163 "%s: line %d: depth must be positive.\n",
1170 be->be_max_deref_depth = i;
1174 /* set magic "root" dn for this database */
1175 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1178 LDAP_LOG( CONFIG, INFO,
1179 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1182 Debug( LDAP_DEBUG_ANY,
1183 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1192 LDAP_LOG( CONFIG, INFO,
1193 "%s: line %d: rootdn line must appear inside a database "
1194 "definition.\n", fname, lineno ,0 );
1196 Debug( LDAP_DEBUG_ANY,
1197 "%s: line %d: rootdn line must appear inside a database definition.\n",
1205 if ( load_ucdata( NULL ) < 0 ) return 1;
1207 dn.bv_val = cargv[1];
1208 dn.bv_len = strlen( cargv[1] );
1210 rc = dnPrettyNormal( NULL, &dn,
1212 &be->be_rootndn, NULL );
1214 if( rc != LDAP_SUCCESS ) {
1216 LDAP_LOG( CONFIG, CRIT,
1217 "%s: line %d: rootdn DN is invalid.\n",
1220 Debug( LDAP_DEBUG_ANY,
1221 "%s: line %d: rootdn DN is invalid\n",
1228 /* set super-secret magic database password */
1229 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1232 LDAP_LOG( CONFIG, CRIT,
1233 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1234 " line\n", fname, lineno ,0 );
1236 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1237 "missing passwd in \"rootpw <passwd>\" line\n",
1246 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1247 "rootpw line must appear inside a database "
1248 "definition.\n", fname, lineno ,0 );
1250 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1251 "rootpw line must appear inside a database "
1258 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1260 if( tmp_be != be ) {
1262 LDAP_LOG( CONFIG, INFO,
1264 "rootpw can only be set when rootdn is under suffix\n",
1265 fname, lineno, "" );
1267 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1268 "rootpw can only be set when rootdn is under suffix\n",
1274 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1275 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1278 /* make this database read-only */
1279 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1282 LDAP_LOG( CONFIG, CRIT,
1283 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1284 "line.\n", fname, lineno ,0 );
1286 Debug( LDAP_DEBUG_ANY,
1287 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1294 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1295 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1297 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1300 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1301 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1303 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1307 /* restricts specific operations */
1308 } else if ( strcasecmp( cargv[0], "restrict" ) == 0 ) {
1309 slap_mask_t restrict = 0;
1310 struct restrictable_exops_t {
1313 } restrictable_exops[] = {
1314 { LDAP_EXOP_START_TLS, SLAP_RESTRICT_EXOP_START_TLS },
1315 { LDAP_EXOP_MODIFY_PASSWD, SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
1316 { LDAP_EXOP_X_WHO_AM_I, SLAP_RESTRICT_EXOP_WHOAMI },
1317 { LDAP_EXOP_X_CANCEL, SLAP_RESTRICT_EXOP_CANCEL },
1324 LDAP_LOG( CONFIG, CRIT,
1325 "%s: line %d: missing <op_list> in \"restrict <op_list>\" "
1326 "line.\n", fname, lineno ,0 );
1328 Debug( LDAP_DEBUG_ANY,
1329 "%s: line %d: missing <op_list> in \"restrict <op_list>\" "
1330 "line.\n", fname, lineno, 0 );
1336 for ( i = 1; i < cargc; i++ ) {
1337 if ( strcasecmp( cargv[ i ], "read" ) == 0 ) {
1338 restrict |= SLAP_RESTRICT_OP_READS;
1340 } else if ( strcasecmp( cargv[ i ], "write" ) == 0 ) {
1341 restrict |= SLAP_RESTRICT_OP_WRITES;
1343 } else if ( strcasecmp( cargv[ i ], "add" ) == 0 ) {
1344 restrict |= SLAP_RESTRICT_OP_ADD;
1346 } else if ( strcasecmp( cargv[ i ], "bind" ) == 0 ) {
1347 restrict |= SLAP_RESTRICT_OP_BIND;
1349 } else if ( strcasecmp( cargv[ i ], "compare" ) == 0 ) {
1350 restrict |= SLAP_RESTRICT_OP_COMPARE;
1352 } else if ( strcasecmp( cargv[ i ], "delete" ) == 0 ) {
1353 restrict |= SLAP_RESTRICT_OP_DELETE;
1355 } else if ( strncasecmp( cargv[ i ], "extended",
1356 STRLENOF( "extended" ) ) == 0 ) {
1357 char *e = cargv[ i ] + STRLENOF( "extended" );
1359 if ( e[0] == '=' ) {
1363 for ( j = 0; restrictable_exops[ j ].name; j++ ) {
1364 if ( strcmp( e, restrictable_exops[ j ].name ) == 0 ) {
1365 restrict |= restrictable_exops[ j ].flag;
1370 if ( restrictable_exops[ j ].name == NULL ) {
1371 goto restrict_unknown;
1374 restrict &= ~SLAP_RESTRICT_OP_EXTENDED;
1376 } else if ( e[0] == '\0' ) {
1377 restrict &= ~SLAP_RESTRICT_EXOP_MASK;
1378 restrict |= SLAP_RESTRICT_OP_EXTENDED;
1381 goto restrict_unknown;
1384 } else if ( strcasecmp( cargv[ i ], "modify" ) == 0 ) {
1385 restrict |= SLAP_RESTRICT_OP_MODIFY;
1387 } else if ( strcasecmp( cargv[ i ], "rename" ) == 0
1388 || strcasecmp( cargv[ i ], "modrdn" ) == 0 ) {
1389 restrict |= SLAP_RESTRICT_OP_RENAME;
1391 } else if ( strcasecmp( cargv[ i ], "search" ) == 0 ) {
1392 restrict |= SLAP_RESTRICT_OP_SEARCH;
1398 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1399 "unknown operation %s in \"allow <features>\" line.\n",
1400 fname, lineno, cargv[i] );
1402 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1403 "unknown operation %s in \"allow <features>\" line\n",
1404 fname, lineno, cargv[i] );
1411 global_restrictops |= restrict;
1414 be->be_restrictops |= restrict;
1417 /* allow these features */
1418 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1419 strcasecmp( cargv[0], "allow" ) == 0 )
1425 LDAP_LOG( CONFIG, INFO,
1426 "%s: line %d: allow line must appear prior to "
1427 "database definitions.\n", fname, lineno ,0 );
1429 Debug( LDAP_DEBUG_ANY,
1430 "%s: line %d: allow line must appear prior to database definitions\n",
1438 LDAP_LOG( CONFIG, CRIT,
1439 "%s: line %d: missing feature(s) in \"allow <features>\""
1440 " line\n", fname, lineno ,0 );
1442 Debug( LDAP_DEBUG_ANY,
1443 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1452 for( i=1; i < cargc; i++ ) {
1453 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1454 allows |= SLAP_ALLOW_BIND_V2;
1456 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1457 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1459 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1460 allows |= SLAP_ALLOW_BIND_ANON_DN;
1462 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1463 allows |= SLAP_ALLOW_UPDATE_ANON;
1465 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1467 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1468 "unknown feature %s in \"allow <features>\" line.\n",
1469 fname, lineno, cargv[i] );
1471 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1472 "unknown feature %s in \"allow <features>\" line\n",
1473 fname, lineno, cargv[i] );
1480 global_allows = allows;
1482 /* disallow these features */
1483 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1484 strcasecmp( cargv[0], "disallow" ) == 0 )
1486 slap_mask_t disallows;
1490 LDAP_LOG( CONFIG, INFO,
1491 "%s: line %d: disallow line must appear prior to "
1492 "database definitions.\n", fname, lineno ,0 );
1494 Debug( LDAP_DEBUG_ANY,
1495 "%s: line %d: disallow line must appear prior to database definitions\n",
1503 LDAP_LOG( CONFIG, CRIT,
1504 "%s: line %d: missing feature(s) in \"disallow <features>\""
1505 " line.\n", fname, lineno ,0 );
1507 Debug( LDAP_DEBUG_ANY,
1508 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1517 for( i=1; i < cargc; i++ ) {
1518 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1519 disallows |= SLAP_DISALLOW_BIND_ANON;
1521 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1522 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1524 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1525 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1527 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1528 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1530 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1531 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1533 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1535 LDAP_LOG( CONFIG, CRIT,
1536 "%s: line %d: unknown feature %s in "
1537 "\"disallow <features>\" line.\n",
1538 fname, lineno, cargv[i] );
1540 Debug( LDAP_DEBUG_ANY,
1541 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1542 fname, lineno, cargv[i] );
1549 global_disallows = disallows;
1551 /* require these features */
1552 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1553 strcasecmp( cargv[0], "require" ) == 0 )
1555 slap_mask_t requires;
1559 LDAP_LOG( CONFIG, CRIT,
1560 "%s: line %d: missing feature(s) in "
1561 "\"require <features>\" line.\n", fname, lineno ,0 );
1563 Debug( LDAP_DEBUG_ANY,
1564 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1573 for( i=1; i < cargc; i++ ) {
1574 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1575 requires |= SLAP_REQUIRE_BIND;
1577 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1578 requires |= SLAP_REQUIRE_LDAP_V3;
1580 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1581 requires |= SLAP_REQUIRE_AUTHC;
1583 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1584 requires |= SLAP_REQUIRE_SASL;
1586 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1587 requires |= SLAP_REQUIRE_STRONG;
1589 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1591 LDAP_LOG( CONFIG, CRIT,
1592 "%s: line %d: unknown feature %s in "
1593 "\"require <features>\" line.\n",
1594 fname, lineno , cargv[i] );
1596 Debug( LDAP_DEBUG_ANY,
1597 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1598 fname, lineno, cargv[i] );
1606 global_requires = requires;
1608 be->be_requires = requires;
1611 /* required security factors */
1612 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1613 slap_ssf_set_t *set;
1617 LDAP_LOG( CONFIG, CRIT,
1618 "%s: line %d: missing factor(s) in \"security <factors>\""
1619 " line.\n", fname, lineno ,0 );
1621 Debug( LDAP_DEBUG_ANY,
1622 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1630 set = &global_ssf_set;
1632 set = &be->be_ssf_set;
1635 for( i=1; i < cargc; i++ ) {
1636 if( strncasecmp( cargv[i], "ssf=",
1637 sizeof("ssf") ) == 0 )
1640 atoi( &cargv[i][sizeof("ssf")] );
1642 } else if( strncasecmp( cargv[i], "transport=",
1643 sizeof("transport") ) == 0 )
1645 set->sss_transport =
1646 atoi( &cargv[i][sizeof("transport")] );
1648 } else if( strncasecmp( cargv[i], "tls=",
1649 sizeof("tls") ) == 0 )
1652 atoi( &cargv[i][sizeof("tls")] );
1654 } else if( strncasecmp( cargv[i], "sasl=",
1655 sizeof("sasl") ) == 0 )
1658 atoi( &cargv[i][sizeof("sasl")] );
1660 } else if( strncasecmp( cargv[i], "update_ssf=",
1661 sizeof("update_ssf") ) == 0 )
1663 set->sss_update_ssf =
1664 atoi( &cargv[i][sizeof("update_ssf")] );
1666 } else if( strncasecmp( cargv[i], "update_transport=",
1667 sizeof("update_transport") ) == 0 )
1669 set->sss_update_transport =
1670 atoi( &cargv[i][sizeof("update_transport")] );
1672 } else if( strncasecmp( cargv[i], "update_tls=",
1673 sizeof("update_tls") ) == 0 )
1675 set->sss_update_tls =
1676 atoi( &cargv[i][sizeof("update_tls")] );
1678 } else if( strncasecmp( cargv[i], "update_sasl=",
1679 sizeof("update_sasl") ) == 0 )
1681 set->sss_update_sasl =
1682 atoi( &cargv[i][sizeof("update_sasl")] );
1684 } else if( strncasecmp( cargv[i], "simple_bind=",
1685 sizeof("simple_bind") ) == 0 )
1687 set->sss_simple_bind =
1688 atoi( &cargv[i][sizeof("simple_bind")] );
1692 LDAP_LOG( CONFIG, CRIT,
1693 "%s: line %d: unknown factor %S in "
1694 "\"security <factors>\" line.\n",
1695 fname, lineno, cargv[1] );
1697 Debug( LDAP_DEBUG_ANY,
1698 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1699 fname, lineno, cargv[i] );
1705 /* where to send clients when we don't hold it */
1706 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1709 LDAP_LOG( CONFIG, CRIT,
1710 "%s: line %d: missing URL in \"referral <URL>\""
1711 " line.\n", fname, lineno , 0 );
1713 Debug( LDAP_DEBUG_ANY,
1714 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1721 if( validate_global_referral( cargv[1] ) ) {
1723 LDAP_LOG( CONFIG, CRIT,
1724 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1725 fname, lineno, cargv[1] );
1727 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1728 "invalid URL (%s) in \"referral\" line.\n",
1729 fname, lineno, cargv[1] );
1734 vals[0].bv_val = cargv[1];
1735 vals[0].bv_len = strlen( vals[0].bv_val );
1736 if( value_add( &default_referral, vals ) )
1740 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1744 LDAP_LOG( CONFIG, CRIT,
1745 "%s: line %d: Error in logfile directive, "
1746 "\"logfile <filename>\"\n", fname, lineno , 0 );
1748 Debug( LDAP_DEBUG_ANY,
1749 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1755 logfile = fopen( cargv[1], "w" );
1756 if ( logfile != NULL ) lutil_debug_file( logfile );
1759 /* start of a new database definition */
1760 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1764 LDAP_LOG( CONFIG, CRIT,
1765 "%s: line %d: Error in debug directive, "
1766 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1768 Debug( LDAP_DEBUG_ANY,
1769 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1775 level = atoi( cargv[2] );
1776 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1777 lutil_set_debug_level( cargv[1], level );
1778 /* specify an Object Identifier macro */
1779 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1780 rc = parse_oidm( fname, lineno, cargc, cargv );
1783 /* specify an objectclass */
1784 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1787 LDAP_LOG( CONFIG, INFO,
1788 "%s: line %d: illegal objectclass format.\n",
1789 fname, lineno , 0 );
1791 Debug( LDAP_DEBUG_ANY,
1792 "%s: line %d: illegal objectclass format.\n",
1797 } else if ( *cargv[1] == '(' /*')'*/) {
1799 p = strchr(saveline,'(' /*')'*/);
1800 rc = parse_oc( fname, lineno, p, cargv );
1805 LDAP_LOG( CONFIG, INFO,
1806 "%s: line %d: old objectclass format not supported\n",
1807 fname, lineno , 0 );
1809 Debug( LDAP_DEBUG_ANY,
1810 "%s: line %d: old objectclass format not supported.\n",
1815 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1817 p = strchr(saveline,'(' /*')'*/);
1818 rc = parse_cr( fname, lineno, p, cargv );
1821 /* specify an attribute type */
1822 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1823 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1827 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1828 "illegal attribute type format.\n",
1829 fname, lineno , 0 );
1831 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1832 "illegal attribute type format.\n",
1837 } else if ( *cargv[1] == '(' /*')'*/) {
1839 p = strchr(saveline,'(' /*')'*/);
1840 rc = parse_at( fname, lineno, p, cargv );
1845 LDAP_LOG( CONFIG, INFO,
1846 "%s: line %d: old attribute type format not supported.\n",
1847 fname, lineno , 0 );
1849 Debug( LDAP_DEBUG_ANY,
1850 "%s: line %d: old attribute type format not supported.\n",
1856 /* define attribute option(s) */
1857 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1858 ad_define_option( NULL, NULL, 0 );
1859 for ( i = 1; i < cargc; i++ )
1860 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1863 /* turn on/off schema checking */
1864 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1867 LDAP_LOG( CONFIG, CRIT,
1868 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1869 " line.\n", fname, lineno , 0 );
1871 Debug( LDAP_DEBUG_ANY,
1872 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1878 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1880 LDAP_LOG( CONFIG, CRIT,
1881 "%s: line %d: schema checking disabled! your mileage may "
1882 "vary!\n", fname, lineno , 0 );
1884 Debug( LDAP_DEBUG_ANY,
1885 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1888 global_schemacheck = 0;
1890 global_schemacheck = 1;
1893 /* specify access control info */
1894 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1895 parse_acl( be, fname, lineno, cargc, cargv );
1897 /* debug level to log things to syslog */
1898 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1901 LDAP_LOG( CONFIG, CRIT,
1902 "%s: line %d: missing level in \"loglevel <level>\""
1903 " line.\n", fname, lineno , 0 );
1905 Debug( LDAP_DEBUG_ANY,
1906 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1915 for( i=1; i < cargc; i++ ) {
1916 ldap_syslog += atoi( cargv[1] );
1919 /* list of sync replication information in this backend (slave only) */
1920 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
1924 LDAP_LOG( CONFIG, INFO,
1925 "%s: line %d: syncrepl line must appear inside "
1926 "a database definition.\n", fname, lineno, 0);
1928 Debug( LDAP_DEBUG_ANY,
1929 "%s: line %d: syncrepl line must appear inside "
1930 "a database definition.\n", fname, lineno, 0);
1934 } else if ( SLAP_SHADOW( be )) {
1936 LDAP_LOG( CONFIG, INFO,
1937 "%s: line %d: syncrepl: database already shadowed.\n",
1940 Debug( LDAP_DEBUG_ANY,
1941 "%s: line %d: syncrepl: database already shadowed.\n",
1946 } else if ( add_syncrepl( be, cargv, cargc )) {
1950 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW );
1952 /* list of replicas of the data in this backend (master only) */
1953 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1956 LDAP_LOG( CONFIG, CRIT,
1957 "%s: line %d: missing host or uri in \"replica "
1958 " <host[:port]\" line\n", fname, lineno , 0 );
1960 Debug( LDAP_DEBUG_ANY,
1961 "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
1969 LDAP_LOG( CONFIG, INFO,
1970 "%s: line %d: replica line must appear inside "
1971 "a database definition.\n", fname, lineno, 0);
1973 Debug( LDAP_DEBUG_ANY,
1974 "%s: line %d: replica line must appear inside a database definition\n",
1982 for ( i = 1; i < cargc; i++ ) {
1983 if ( strncasecmp( cargv[i], "host=", 5 )
1985 nr = add_replica_info( be,
1988 } else if (strncasecmp( cargv[i], "uri=", 4 )
1990 if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
1993 LDAP_LOG( CONFIG, INFO,
1994 "%s: line %d: replica line contains invalid "
1995 "uri definition.\n", fname, lineno, 0);
1997 Debug( LDAP_DEBUG_ANY,
1998 "%s: line %d: replica line contains invalid "
1999 "uri definition.\n", fname, lineno, 0);
2003 if (ludp->lud_host == NULL ) {
2005 LDAP_LOG( CONFIG, INFO,
2006 "%s: line %d: replica line contains invalid "
2007 "uri definition - missing hostname.\n",
2010 Debug( LDAP_DEBUG_ANY,
2011 "%s: line %d: replica line contains invalid "
2012 "uri definition - missing hostname.\n", fname, lineno, 0);
2016 replicahost = ch_malloc( strlen( cargv[ i ] ) );
2017 if ( replicahost == NULL ) {
2019 LDAP_LOG( CONFIG, ERR,
2020 "out of memory in read_config\n", 0, 0,0 );
2022 Debug( LDAP_DEBUG_ANY,
2023 "out of memory in read_config\n", 0, 0, 0 );
2025 ldap_free_urldesc( ludp );
2026 exit( EXIT_FAILURE );
2028 sprintf(replicahost, "%s:%d",
2029 ludp->lud_host, ludp->lud_port);
2030 nr = add_replica_info( be, replicahost );
2031 ldap_free_urldesc( ludp );
2032 ch_free(replicahost);
2038 LDAP_LOG( CONFIG, INFO,
2039 "%s: line %d: missing host or uri in \"replica\" line\n",
2040 fname, lineno , 0 );
2042 Debug( LDAP_DEBUG_ANY,
2043 "%s: line %d: missing host or uri in \"replica\" line\n",
2048 } else if ( nr == -1 ) {
2050 LDAP_LOG( CONFIG, INFO,
2051 "%s: line %d: unable to add"
2052 " replica \"%s\"\n",
2056 Debug( LDAP_DEBUG_ANY,
2057 "%s: line %d: unable to add replica \"%s\"\n",
2058 fname, lineno, cargv[i] + 5 );
2062 for ( i = 1; i < cargc; i++ ) {
2063 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
2065 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
2068 LDAP_LOG( CONFIG, INFO,
2069 "%s: line %d: suffix \"%s\" in \"replica\""
2070 " line is not valid for backend(ignored)\n",
2071 fname, lineno, cargv[i] + 7 );
2073 Debug( LDAP_DEBUG_ANY,
2074 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
2075 fname, lineno, cargv[i] + 7 );
2081 LDAP_LOG( CONFIG, INFO,
2082 "%s: line %d: unable to normalize suffix"
2083 " in \"replica\" line (ignored)\n",
2084 fname, lineno , 0 );
2086 Debug( LDAP_DEBUG_ANY,
2087 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
2093 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
2095 char *arg = cargv[i] + 4;
2097 if ( arg[0] == '!' ) {
2102 if ( arg[0] != '=' ) {
2106 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
2108 LDAP_LOG( CONFIG, INFO,
2109 "%s: line %d: attribute \"%s\" in "
2110 "\"replica\" line is unknown\n",
2111 fname, lineno, arg + 1 );
2113 Debug( LDAP_DEBUG_ANY,
2114 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
2115 fname, lineno, arg + 1 );
2124 } else if ( strcasecmp( cargv[0], "replicationInterval" ) == 0 ) {
2127 /* dn of slave entity allowed to write to replica */
2128 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
2131 LDAP_LOG( CONFIG, CRIT,
2132 "%s: line %d: missing dn in \"updatedn <dn>\""
2133 " line.\n", fname, lineno , 0 );
2135 Debug( LDAP_DEBUG_ANY,
2136 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
2144 LDAP_LOG( CONFIG, INFO,
2145 "%s: line %d: updatedn line must appear inside "
2146 "a database definition\n",
2147 fname, lineno , 0 );
2149 Debug( LDAP_DEBUG_ANY,
2150 "%s: line %d: updatedn line must appear inside a database definition\n",
2155 } else if ( SLAP_SHADOW(be) ) {
2157 LDAP_LOG( CONFIG, INFO,
2158 "%s: line %d: updatedn: database already shadowed.\n",
2161 Debug( LDAP_DEBUG_ANY,
2162 "%s: line %d: updatedn: database already shadowed.\n",
2170 if ( load_ucdata( NULL ) < 0 ) return 1;
2172 dn.bv_val = cargv[1];
2173 dn.bv_len = strlen( cargv[1] );
2175 rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
2176 if( rc != LDAP_SUCCESS ) {
2178 LDAP_LOG( CONFIG, CRIT,
2179 "%s: line %d: updatedn DN is invalid.\n",
2180 fname, lineno , 0 );
2182 Debug( LDAP_DEBUG_ANY,
2183 "%s: line %d: updatedn DN is invalid\n",
2190 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW );
2192 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
2195 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2196 "missing url in \"updateref <ldapurl>\" line.\n",
2197 fname, lineno , 0 );
2199 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2200 "missing url in \"updateref <ldapurl>\" line\n",
2208 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
2209 " line must appear inside a database definition\n",
2210 fname, lineno , 0 );
2212 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
2213 " line must appear inside a database definition\n",
2218 } else if ( !SLAP_SHADOW(be) ) {
2220 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
2221 "updateref line must come after syncrepl or updatedn.\n",
2222 fname, lineno , 0 );
2224 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2225 "updateref line must after syncrepl or updatedn.\n",
2231 if( validate_global_referral( cargv[1] ) ) {
2233 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2234 "invalid URL (%s) in \"updateref\" line.\n",
2235 fname, lineno, cargv[1] );
2237 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2238 "invalid URL (%s) in \"updateref\" line.\n",
2239 fname, lineno, cargv[1] );
2244 vals[0].bv_val = cargv[1];
2245 vals[0].bv_len = strlen( vals[0].bv_val );
2246 if( value_add( &be->be_update_refs, vals ) ) {
2250 /* replication log file to which changes are appended */
2251 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
2254 LDAP_LOG( CONFIG, CRIT,
2255 "%s: line %d: missing filename in \"replogfile <filename>\""
2256 " line.\n", fname, lineno , 0 );
2258 Debug( LDAP_DEBUG_ANY,
2259 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2266 be->be_replogfile = ch_strdup( cargv[1] );
2268 replogfile = ch_strdup( cargv[1] );
2271 /* file from which to read additional rootdse attrs */
2272 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2275 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2276 "missing filename in \"rootDSE <filename>\" line.\n",
2277 fname, lineno , 0 );
2279 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2280 "missing filename in \"rootDSE <filename>\" line.\n",
2286 if( read_root_dse_file( cargv[1] ) ) {
2288 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2289 "could not read \"rootDSE <filename>\" line.\n",
2290 fname, lineno , 0 );
2292 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2293 "could not read \"rootDSE <filename>\" line\n",
2299 /* maintain lastmodified{by,time} attributes */
2300 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2303 LDAP_LOG( CONFIG, CRIT,
2304 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2305 " line.\n", fname, lineno , 0 );
2307 Debug( LDAP_DEBUG_ANY,
2308 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2314 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2316 SLAP_DBFLAGS(be) &= ~SLAP_DBFLAG_NOLASTMOD;
2322 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NOLASTMOD;
2329 /* turn on/off gentle SIGHUP handling */
2330 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2332 Debug( LDAP_DEBUG_ANY,
2333 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2337 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2338 global_gentlehup = 0;
2340 global_gentlehup = 1;
2344 /* set idle timeout value */
2345 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2349 LDAP_LOG( CONFIG, CRIT,
2350 "%s: line %d: missing timeout value in "
2351 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2353 Debug( LDAP_DEBUG_ANY,
2354 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2361 i = atoi( cargv[1] );
2365 LDAP_LOG( CONFIG, CRIT,
2366 "%s: line %d: timeout value (%d) invalid "
2367 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2369 Debug( LDAP_DEBUG_ANY,
2370 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2377 global_idletimeout = i;
2379 /* include another config file */
2380 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2383 LDAP_LOG( CONFIG, CRIT,
2384 "%s: line %d: missing filename in \"include "
2385 "<filename>\" line.\n", fname, lineno , 0 );
2387 Debug( LDAP_DEBUG_ANY,
2388 "%s: line %d: missing filename in \"include <filename>\" line\n",
2394 savefname = ch_strdup( cargv[1] );
2395 savelineno = lineno;
2397 if ( read_config( savefname, depth+1 ) != 0 ) {
2402 lineno = savelineno - 1;
2404 /* location of kerberos srvtab file */
2405 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2408 LDAP_LOG( CONFIG, CRIT,
2409 "%s: line %d: missing filename in \"srvtab "
2410 "<filename>\" line.\n", fname, lineno , 0 );
2412 Debug( LDAP_DEBUG_ANY,
2413 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2419 ldap_srvtab = ch_strdup( cargv[1] );
2421 #ifdef SLAPD_MODULES
2422 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2425 LDAP_LOG( CONFIG, INFO,
2426 "%s: line %d: missing filename in \"moduleload "
2427 "<filename>\" line.\n", fname, lineno , 0 );
2429 Debug( LDAP_DEBUG_ANY,
2430 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2434 exit( EXIT_FAILURE );
2436 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2438 LDAP_LOG( CONFIG, CRIT,
2439 "%s: line %d: failed to load or initialize module %s\n",
2440 fname, lineno, cargv[1] );
2442 Debug( LDAP_DEBUG_ANY,
2443 "%s: line %d: failed to load or initialize module %s\n",
2444 fname, lineno, cargv[1]);
2447 exit( EXIT_FAILURE );
2449 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2452 LDAP_LOG( CONFIG, INFO,
2453 "%s: line %d: missing path in \"modulepath <path>\""
2454 " line\n", fname, lineno , 0 );
2456 Debug( LDAP_DEBUG_ANY,
2457 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2461 exit( EXIT_FAILURE );
2463 if (module_path( cargv[1] )) {
2465 LDAP_LOG( CONFIG, CRIT,
2466 "%s: line %d: failed to set module search path to %s.\n",
2467 fname, lineno, cargv[1] );
2469 Debug( LDAP_DEBUG_ANY,
2470 "%s: line %d: failed to set module search path to %s\n",
2471 fname, lineno, cargv[1]);
2474 exit( EXIT_FAILURE );
2477 #endif /*SLAPD_MODULES*/
2480 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2481 rc = ldap_pvt_tls_set_option( NULL,
2482 LDAP_OPT_X_TLS_RANDOM_FILE,
2487 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2488 rc = ldap_pvt_tls_set_option( NULL,
2489 LDAP_OPT_X_TLS_CIPHER_SUITE,
2494 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2495 rc = ldap_pvt_tls_set_option( NULL,
2496 LDAP_OPT_X_TLS_CERTFILE,
2501 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2502 rc = ldap_pvt_tls_set_option( NULL,
2503 LDAP_OPT_X_TLS_KEYFILE,
2508 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2509 rc = ldap_pvt_tls_set_option( NULL,
2510 LDAP_OPT_X_TLS_CACERTDIR,
2515 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2516 rc = ldap_pvt_tls_set_option( NULL,
2517 LDAP_OPT_X_TLS_CACERTFILE,
2521 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2522 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2524 rc = ldap_pvt_tls_set_option( NULL,
2525 LDAP_OPT_X_TLS_REQUIRE_CERT,
2528 rc = ldap_int_tls_config( NULL,
2529 LDAP_OPT_X_TLS_REQUIRE_CERT,
2538 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2539 #ifdef SLAPD_RLOOKUPS
2542 LDAP_LOG( CONFIG, INFO,
2543 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2544 fname, lineno , 0 );
2546 Debug( LDAP_DEBUG_ANY,
2547 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2553 if ( !strcasecmp( cargv[1], "on" ) ) {
2554 use_reverse_lookup = 1;
2555 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2556 use_reverse_lookup = 0;
2559 LDAP_LOG( CONFIG, INFO,
2560 "%s: line %d: reverse-lookup: "
2561 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2563 Debug( LDAP_DEBUG_ANY,
2564 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2570 #else /* !SLAPD_RLOOKUPS */
2572 LDAP_LOG( CONFIG, INFO,
2573 "%s: line %d: reverse lookups "
2574 "are not configured (ignored).\n", fname, lineno , 0 );
2576 Debug( LDAP_DEBUG_ANY,
2577 "%s: line %d: reverse lookups are not configured (ignored).\n",
2580 #endif /* !SLAPD_RLOOKUPS */
2582 /* Netscape plugins */
2583 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2584 #if defined( LDAP_SLAPI )
2586 #ifdef notdef /* allow global plugins, too */
2588 * a "plugin" line must be inside a database
2589 * definition, since we implement pre-,post-
2590 * and extended operation plugins
2594 LDAP_LOG( CONFIG, INFO,
2595 "%s: line %d: plugin line must appear "
2596 "insid a database definition.\n",
2599 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2600 "line must appear inside a database "
2601 "definition\n", fname, lineno, 0 );
2607 if ( slapi_int_read_config( be, fname, lineno, cargc, cargv )
2611 LDAP_LOG( CONFIG, INFO,
2612 "%s: line %d: SLAPI config read failed.\n",
2615 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2616 "config read failed.\n", fname, lineno, 0 );
2620 slapi_plugins_used++;
2622 #else /* !defined( LDAP_SLAPI ) */
2624 LDAP_LOG( CONFIG, INFO,
2625 "%s: line %d: SLAPI not supported.\n",
2628 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2629 "not supported.\n", fname, lineno, 0 );
2633 #endif /* !defined( LDAP_SLAPI ) */
2635 /* Netscape plugins */
2636 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2637 #if defined( LDAP_SLAPI )
2640 LDAP_LOG( CONFIG, INFO,
2641 "%s: line %d: missing file name "
2642 "in pluginlog <filename> line.\n",
2645 Debug( LDAP_DEBUG_ANY,
2646 "%s: line %d: missing file name "
2647 "in pluginlog <filename> line.\n",
2653 if ( slapi_log_file != NULL ) {
2654 ch_free( slapi_log_file );
2657 slapi_log_file = ch_strdup( cargv[1] );
2658 #endif /* !defined( LDAP_SLAPI ) */
2660 /* pass anything else to the current backend info/db config routine */
2663 if ( bi->bi_config ) {
2664 rc = (*bi->bi_config)( bi, fname, lineno, cargc, cargv );
2670 case SLAP_CONF_UNKNOWN:
2672 LDAP_LOG( CONFIG, INFO,
2673 "%s: line %d: unknown directive \"%s\" inside "
2674 "backend info definition (ignored).\n",
2675 fname, lineno, cargv[0] );
2677 Debug( LDAP_DEBUG_ANY,
2678 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2679 fname, lineno, cargv[0] );
2688 } else if ( be != NULL ) {
2689 if ( be->be_config ) {
2690 rc = (*be->be_config)( be, fname, lineno, cargc, cargv );
2696 case SLAP_CONF_UNKNOWN:
2698 LDAP_LOG( CONFIG, INFO,
2699 "%s: line %d: unknown directive \"%s\" inside "
2700 "backend database definition (ignored).\n",
2701 fname, lineno, cargv[0] );
2703 Debug( LDAP_DEBUG_ANY,
2704 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2705 fname, lineno, cargv[0] );
2716 LDAP_LOG( CONFIG, INFO,
2717 "%s: line %d: unknown directive \"%s\" outside backend "
2718 "info and database definitions (ignored).\n",
2719 fname, lineno, cargv[0] );
2721 Debug( LDAP_DEBUG_ANY,
2722 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2723 fname, lineno, cargv[0] );
2732 if ( depth == 0 ) ch_free( cargv );
2734 if ( !global_schemadn.bv_val ) {
2735 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2737 dnNormalize( 0, NULL, NULL, &global_schemadn, &global_schemandn, NULL );
2740 if ( load_ucdata( NULL ) < 0 ) return 1;
2752 char logbuf[sizeof("pseudorootpw ***")];
2755 token = strtok_quote( line, " \t" );
2759 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2760 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2761 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2762 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2763 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2765 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2768 if ( strtok_quote_ptr ) {
2769 *strtok_quote_ptr = ' ';
2773 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2775 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2778 if ( strtok_quote_ptr ) {
2779 *strtok_quote_ptr = '\0';
2782 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2783 if ( cargc == cargv_size - 1 ) {
2785 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2787 if ( tmp == NULL ) {
2789 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2791 Debug( LDAP_DEBUG_ANY,
2792 "line %d: out of memory\n",
2798 cargv_size += ARGS_STEP;
2800 cargv[cargc++] = token;
2802 cargv[cargc] = NULL;
2807 strtok_quote( char *line, char *sep )
2813 strtok_quote_ptr = NULL;
2814 if ( line != NULL ) {
2817 while ( *next && strchr( sep, *next ) ) {
2821 if ( *next == '\0' ) {
2827 for ( inquote = 0; *next; ) {
2835 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2841 next + 1, strlen( next + 1 ) + 1 );
2842 next++; /* dont parse the escaped character */
2847 if ( strchr( sep, *next ) != NULL ) {
2848 strtok_quote_ptr = next;
2861 static char buf[BUFSIZ];
2863 static size_t lmax, lcur;
2865 #define CATLINE( buf ) \
2867 size_t len = strlen( buf ); \
2868 while ( lcur + len + 1 > lmax ) { \
2870 line = (char *) ch_realloc( line, lmax ); \
2872 strcpy( line + lcur, buf ); \
2877 fp_getline( FILE *fp, int *lineno )
2885 /* hack attack - keeps us from having to keep a stack of bufs... */
2886 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2891 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2892 /* trim off \r\n or \n */
2893 if ( (p = strchr( buf, '\n' )) != NULL ) {
2894 if( p > buf && p[-1] == '\r' ) --p;
2898 /* trim off trailing \ and append the next line */
2899 if ( line[ 0 ] != '\0'
2900 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2901 && p[ -1 ] != '\\' ) {
2906 if ( ! isspace( (unsigned char) buf[0] ) ) {
2910 /* change leading whitespace to a space */
2919 return( line[0] ? line : NULL );
2923 fp_getline_init( int *lineno )
2929 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2931 load_ucdata( char *path )
2933 static int loaded = 0;
2939 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2942 LDAP_LOG( CONFIG, CRIT,
2943 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2945 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2958 ucdata_unload( UCDATA_ALL );
2959 free( global_schemandn.bv_val );
2960 free( global_schemadn.bv_val );
2962 if ( slapd_args_file )
2963 free ( slapd_args_file );
2964 if ( slapd_pid_file )
2965 free ( slapd_pid_file );
2966 if ( default_passwd_hash )
2967 ldap_charray_free( default_passwd_hash );
2968 acl_destroy( global_acl, NULL );
2979 syncinfo_t *si_entry;
2981 int duplicated_replica_id = 0;
2983 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2987 LDAP_LOG( CONFIG, ERR, "out of memory in add_syncrepl\n", 0, 0,0 );
2989 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2994 si->si_tls = SYNCINFO_TLS_OFF;
2995 if ( be->be_rootndn.bv_val ) {
2996 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
2998 si->si_bindmethod = LDAP_AUTH_SIMPLE;
2999 si->si_schemachecking = 0;
3000 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 0,
3001 &si->si_filterstr );
3002 si->si_base.bv_val = NULL;
3003 si->si_scope = LDAP_SCOPE_SUBTREE;
3004 si->si_attrsonly = 0;
3005 si->si_attrs = (char **) ch_calloc( 1, sizeof( char * ));
3006 si->si_attrs[0] = NULL;
3007 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3008 si->si_interval = 86400;
3009 si->si_syncCookie.ctxcsn = NULL;
3010 si->si_syncCookie.octet_str = NULL;
3011 si->si_syncCookie.sid = -1;
3012 si->si_manageDSAit = 0;
3015 si->si_syncUUID_ndn.bv_val = NULL;
3016 si->si_syncUUID_ndn.bv_len = 0;
3018 si->si_presentlist = NULL;
3019 LDAP_LIST_INIT( &si->si_nonpresentlist );
3021 rc = parse_syncrepl_line( cargv, cargc, si );
3023 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
3024 if ( si->si_rid == si_entry->si_rid ) {
3026 LDAP_LOG( CONFIG, ERR,
3027 "add_syncrepl: duplicated replica id\n", 0, 0,0 );
3029 Debug( LDAP_DEBUG_ANY,
3030 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
3032 duplicated_replica_id = 1;
3037 if ( rc < 0 || duplicated_replica_id ) {
3038 syncinfo_t *si_entry;
3039 /* Something bad happened - back out */
3041 LDAP_LOG( CONFIG, ERR, "failed to add syncinfo\n", 0, 0,0 );
3043 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
3046 /* If error, remove all syncinfo */
3047 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
3048 if ( si_entry->si_updatedn.bv_val ) {
3049 ch_free( si->si_updatedn.bv_val );
3051 if ( si_entry->si_filterstr.bv_val ) {
3052 ch_free( si->si_filterstr.bv_val );
3054 if ( si_entry->si_attrs ) {
3056 while ( si_entry->si_attrs[i] != NULL ) {
3057 ch_free( si_entry->si_attrs[i] );
3060 ch_free( si_entry->si_attrs );
3064 while ( !LDAP_STAILQ_EMPTY( &be->be_syncinfo )) {
3065 si_entry = LDAP_STAILQ_FIRST( &be->be_syncinfo );
3066 LDAP_STAILQ_REMOVE_HEAD( &be->be_syncinfo, si_next );
3067 ch_free( si_entry );
3069 LDAP_STAILQ_INIT( &be->be_syncinfo );
3073 LDAP_LOG ( CONFIG, RESULTS,
3074 "add_syncrepl: Config: ** successfully added syncrepl \"%s\"\n",
3075 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
3077 Debug( LDAP_DEBUG_CONFIG,
3078 "Config: ** successfully added syncrepl \"%s\"\n",
3079 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
3081 if ( !si->si_schemachecking ) {
3082 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
3085 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
3091 #define PROVIDERSTR "provider"
3092 #define SUFFIXSTR "suffix"
3093 #define UPDATEDNSTR "updatedn"
3094 #define BINDMETHSTR "bindmethod"
3095 #define SIMPLESTR "simple"
3096 #define SASLSTR "sasl"
3097 #define BINDDNSTR "binddn"
3098 #define CREDSTR "credentials"
3099 #define OLDAUTHCSTR "bindprincipal"
3100 #define AUTHCSTR "authcID"
3101 #define AUTHZSTR "authzID"
3102 #define SRVTABSTR "srvtab"
3103 #define SASLMECHSTR "saslmech"
3104 #define REALMSTR "realm"
3105 #define SECPROPSSTR "secprops"
3106 #define STARTTLSSTR "starttls"
3107 #define CRITICALSTR "critical"
3109 #define SCHEMASTR "schemachecking"
3110 #define FILTERSTR "filter"
3111 #define SEARCHBASESTR "searchbase"
3112 #define SCOPESTR "scope"
3113 #define ATTRSSTR "attrs"
3114 #define ATTRSONLYSTR "attrsonly"
3115 #define TYPESTR "type"
3116 #define INTERVALSTR "interval"
3117 #define LASTMODSTR "lastmod"
3118 #define LMREQSTR "req"
3119 #define LMGENSTR "gen"
3120 #define LMNOSTR "no"
3121 #define MANAGEDSAITSTR "manageDSAit"
3122 #define SLIMITSTR "sizelimit"
3123 #define TLIMITSTR "timelimit"
3125 #define GOT_ID 0x0001
3126 #define GOT_PROVIDER 0x0002
3127 #define GOT_METHOD 0x0004
3128 #define GOT_ALL 0x0007
3131 parse_syncrepl_line(
3142 for ( i = 1; i < cargc; i++ ) {
3143 if ( !strncasecmp( cargv[ i ], IDSTR, sizeof( IDSTR ) - 1 )) {
3145 /* '\0' string terminator accounts for '=' */
3146 val = cargv[ i ] + sizeof( IDSTR );
3148 if ( tmp >= 1000 || tmp < 0 ) {
3149 fprintf( stderr, "Error: parse_syncrepl_line: "
3150 "syncrepl id %d is out of range [0..999]\n", tmp );
3155 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR,
3156 sizeof( PROVIDERSTR ) - 1 )) {
3157 val = cargv[ i ] + sizeof( PROVIDERSTR );
3158 si->si_provideruri = ch_strdup( val );
3159 si->si_provideruri_bv = (BerVarray)
3160 ch_calloc( 2, sizeof( struct berval ));
3161 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
3162 0, &si->si_provideruri_bv[0] );
3163 si->si_provideruri_bv[1].bv_len = 0;
3164 si->si_provideruri_bv[1].bv_val = NULL;
3165 gots |= GOT_PROVIDER;
3166 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR,
3167 sizeof(STARTTLSSTR) - 1 ) )
3169 val = cargv[ i ] + sizeof( STARTTLSSTR );
3170 if( !strcasecmp( val, CRITICALSTR ) ) {
3171 si->si_tls = SYNCINFO_TLS_CRITICAL;
3173 si->si_tls = SYNCINFO_TLS_ON;
3175 } else if ( !strncasecmp( cargv[ i ],
3176 UPDATEDNSTR, sizeof( UPDATEDNSTR ) - 1 ) )
3178 struct berval updatedn = {0, NULL};
3179 val = cargv[ i ] + sizeof( UPDATEDNSTR );
3180 ber_str2bv( val, 0, 0, &updatedn );
3181 ch_free( si->si_updatedn.bv_val );
3182 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
3183 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR,
3184 sizeof( BINDMETHSTR ) - 1 ) )
3186 val = cargv[ i ] + sizeof( BINDMETHSTR );
3187 if ( !strcasecmp( val, SIMPLESTR )) {
3188 si->si_bindmethod = LDAP_AUTH_SIMPLE;
3190 } else if ( !strcasecmp( val, SASLSTR )) {
3191 #ifdef HAVE_CYRUS_SASL
3192 si->si_bindmethod = LDAP_AUTH_SASL;
3194 #else /* HAVE_CYRUS_SASL */
3195 fprintf( stderr, "Error: parse_syncrepl_line: "
3196 "not compiled with SASL support\n" );
3198 #endif /* HAVE_CYRUS_SASL */
3200 si->si_bindmethod = -1;
3202 } else if ( !strncasecmp( cargv[ i ],
3203 BINDDNSTR, sizeof( BINDDNSTR ) - 1 ) ) {
3204 val = cargv[ i ] + sizeof( BINDDNSTR );
3205 si->si_binddn = ch_strdup( val );
3206 } else if ( !strncasecmp( cargv[ i ],
3207 CREDSTR, sizeof( CREDSTR ) - 1 ) ) {
3208 val = cargv[ i ] + sizeof( CREDSTR );
3209 si->si_passwd = ch_strdup( val );
3210 } else if ( !strncasecmp( cargv[ i ],
3211 SASLMECHSTR, sizeof( SASLMECHSTR ) - 1 ) ) {
3212 val = cargv[ i ] + sizeof( SASLMECHSTR );
3213 si->si_saslmech = ch_strdup( val );
3214 } else if ( !strncasecmp( cargv[ i ],
3215 SECPROPSSTR, sizeof( SECPROPSSTR ) - 1 ) ) {
3216 val = cargv[ i ] + sizeof( SECPROPSSTR );
3217 si->si_secprops = ch_strdup( val );
3218 } else if ( !strncasecmp( cargv[ i ],
3219 REALMSTR, sizeof( REALMSTR ) - 1 ) ) {
3220 val = cargv[ i ] + sizeof( REALMSTR );
3221 si->si_realm = ch_strdup( val );
3222 } else if ( !strncasecmp( cargv[ i ],
3223 AUTHCSTR, sizeof( AUTHCSTR ) - 1 ) ) {
3224 val = cargv[ i ] + sizeof( AUTHCSTR );
3225 si->si_authcId = ch_strdup( val );
3226 } else if ( !strncasecmp( cargv[ i ],
3227 OLDAUTHCSTR, sizeof( OLDAUTHCSTR ) - 1 ) ) {
3228 /* Old authcID is provided for some backwards compatibility */
3229 val = cargv[ i ] + sizeof( OLDAUTHCSTR );
3230 si->si_authcId = ch_strdup( val );
3231 } else if ( !strncasecmp( cargv[ i ],
3232 AUTHZSTR, sizeof( AUTHZSTR ) - 1 ) ) {
3233 val = cargv[ i ] + sizeof( AUTHZSTR );
3234 si->si_authzId = ch_strdup( val );
3235 } else if ( !strncasecmp( cargv[ i ],
3236 SCHEMASTR, sizeof( SCHEMASTR ) - 1 ) )
3238 val = cargv[ i ] + sizeof( SCHEMASTR );
3239 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
3240 si->si_schemachecking = 1;
3241 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
3242 si->si_schemachecking = 0;
3244 si->si_schemachecking = 1;
3246 } else if ( !strncasecmp( cargv[ i ],
3247 FILTERSTR, sizeof( FILTERSTR ) - 1 ) )
3249 val = cargv[ i ] + sizeof( FILTERSTR );
3250 ber_str2bv( val, 0, 1, &si->si_filterstr );
3251 } else if ( !strncasecmp( cargv[ i ],
3252 SEARCHBASESTR, sizeof( SEARCHBASESTR ) - 1 ) )
3255 val = cargv[ i ] + sizeof( SEARCHBASESTR );
3256 if ( si->si_base.bv_val ) {
3257 ch_free( si->si_base.bv_val );
3259 ber_str2bv( val, 0, 0, &bv );
3260 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
3261 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
3264 } else if ( !strncasecmp( cargv[ i ],
3265 SCOPESTR, sizeof( SCOPESTR ) - 1 ) )
3267 val = cargv[ i ] + sizeof( SCOPESTR );
3268 if ( !strncasecmp( val, "base", STRLENOF( "base" ) )) {
3269 si->si_scope = LDAP_SCOPE_BASE;
3270 } else if ( !strncasecmp( val, "one", STRLENOF( "one" ) )) {
3271 si->si_scope = LDAP_SCOPE_ONELEVEL;
3272 #ifdef LDAP_SCOPE_SUBORDINATE
3273 } else if ( !strcasecmp( val, "subordinate" ) ||
3274 !strcasecmp( val, "children" ))
3276 si->si_scope = LDAP_SCOPE_SUBORDINATE;
3278 } else if ( !strncasecmp( val, "sub", STRLENOF( "sub" ) )) {
3279 si->si_scope = LDAP_SCOPE_SUBTREE;
3281 fprintf( stderr, "Error: parse_syncrepl_line: "
3282 "unknown scope \"%s\"\n", val);
3285 } else if ( !strncasecmp( cargv[ i ],
3286 ATTRSONLYSTR, sizeof( ATTRSONLYSTR ) - 1 ) )
3288 si->si_attrsonly = 1;
3289 } else if ( !strncasecmp( cargv[ i ],
3290 ATTRSSTR, sizeof( ATTRSSTR ) - 1 ) )
3292 val = cargv[ i ] + sizeof( ATTRSSTR );
3293 str2clist( &si->si_attrs, val, "," );
3294 } else if ( !strncasecmp( cargv[ i ],
3295 TYPESTR, sizeof( TYPESTR ) - 1 ) )
3297 val = cargv[ i ] + sizeof( TYPESTR );
3298 if ( !strncasecmp( val, "refreshOnly", STRLENOF("refreshOnly") )) {
3299 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3300 } else if ( !strncasecmp( val, "refreshAndPersist",
3301 STRLENOF("refreshAndPersist") ))
3303 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
3304 si->si_interval = 60;
3306 fprintf( stderr, "Error: parse_syncrepl_line: "
3307 "unknown sync type \"%s\"\n", val);
3310 } else if ( !strncasecmp( cargv[ i ],
3311 INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) )
3318 val = cargv[ i ] + sizeof( INTERVALSTR );
3320 hstr = strchr( dstr, ':' );
3321 if ( hstr == NULL ) {
3322 fprintf( stderr, "Error: parse_syncrepl_line: "
3323 "invalid interval \"%s\"\n", val );
3327 mstr = strchr( hstr, ':' );
3328 if ( mstr == NULL ) {
3329 fprintf( stderr, "Error: parse_syncrepl_line: "
3330 "invalid interval \"%s\"\n", val );
3334 sstr = strchr( mstr, ':' );
3335 if ( sstr == NULL ) {
3336 fprintf( stderr, "Error: parse_syncrepl_line: "
3337 "invalid interval \"%s\"\n", val );
3346 if (( hh > 24 ) || ( hh < 0 ) ||
3347 ( mm > 60 ) || ( mm < 0 ) ||
3348 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
3349 fprintf( stderr, "Error: parse_syncrepl_line: "
3350 "invalid interval \"%s\"\n", val );
3353 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
3355 if ( si->si_interval < 0 ) {
3356 fprintf( stderr, "Error: parse_syncrepl_line: "
3357 "invalid interval \"%ld\"\n",
3358 (long) si->si_interval);
3361 } else if ( !strncasecmp( cargv[ i ],
3362 MANAGEDSAITSTR, sizeof( MANAGEDSAITSTR ) - 1 ) )
3364 val = cargv[ i ] + sizeof( MANAGEDSAITSTR );
3365 si->si_manageDSAit = atoi( val );
3366 } else if ( !strncasecmp( cargv[ i ],
3367 SLIMITSTR, sizeof( SLIMITSTR ) - 1 ) )
3369 val = cargv[ i ] + sizeof( SLIMITSTR );
3370 si->si_slimit = atoi( val );
3371 } else if ( !strncasecmp( cargv[ i ],
3372 TLIMITSTR, sizeof( TLIMITSTR ) - 1 ) )
3374 val = cargv[ i ] + sizeof( TLIMITSTR );
3375 si->si_tlimit = atoi( val );
3377 fprintf( stderr, "Error: parse_syncrepl_line: "
3378 "unknown keyword \"%s\"\n", cargv[ i ] );
3382 if ( gots != GOT_ALL ) {
3384 "Error: Malformed \"syncrepl\" line in slapd config file" );
3392 str2clist( char ***out, char *in, const char *brkstr )
3401 /* find last element in list */
3402 for (i = 0; *out && *out[i]; i++);
3404 /* protect the input string from strtok */
3405 str = ch_strdup( in );
3407 if ( *str == '\0' ) {
3412 /* Count words in string */
3414 for ( s = str; *s; s++ ) {
3415 if ( strchr( brkstr, *s ) != NULL ) {
3420 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
3422 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
3424 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
3426 *new = ch_strdup( s );