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 */
60 AccessControl *global_acl = NULL;
61 slap_access_t global_default_access = ACL_READ;
62 slap_mask_t global_restrictops = 0;
63 slap_mask_t global_allows = 0;
64 slap_mask_t global_disallows = 0;
65 slap_mask_t global_requires = 0;
66 slap_ssf_set_t global_ssf_set;
68 int global_gentlehup = 0;
69 int global_idletimeout = 0;
70 char *global_host = NULL;
71 char *global_realm = NULL;
72 char *ldap_srvtab = "";
73 char **default_passwd_hash = NULL;
74 int cargc = 0, cargv_size = 0;
76 struct berval default_search_base = { 0, NULL };
77 struct berval default_search_nbase = { 0, NULL };
78 unsigned num_subordinates = 0;
79 struct berval global_schemadn = { 0, NULL };
80 struct berval global_schemandn = { 0, NULL };
82 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
83 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
85 int slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
86 int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
88 char *slapd_pid_file = NULL;
89 char *slapd_args_file = NULL;
91 char *strtok_quote_ptr;
93 int use_reverse_lookup = 0;
96 int slapi_plugins_used = 0;
99 static char *fp_getline(FILE *fp, int *lineno);
100 static void fp_getline_init(int *lineno);
101 static int fp_parse_line(int lineno, char *line);
103 static char *strtok_quote(char *line, char *sep);
104 static int load_ucdata(char *path);
106 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
107 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
110 read_config( const char *fname, int depth )
113 char *line, *savefname, *saveline;
117 struct berval vals[2];
120 static int lastmod = 1;
121 static BackendInfo *bi = NULL;
122 static BackendDB *be = NULL;
124 vals[1].bv_val = NULL;
127 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
128 cargv_size = ARGS_STEP + 1;
131 if ( (fp = fopen( fname, "r" )) == NULL ) {
134 LDAP_LOG( CONFIG, ENTRY,
135 "read_config: " "could not open config file \"%s\": %s (%d)\n",
136 fname, strerror(errno), errno );
138 Debug( LDAP_DEBUG_ANY,
139 "could not open config file \"%s\": %s (%d)\n",
140 fname, strerror(errno), errno );
146 LDAP_LOG( CONFIG, ENTRY,
147 "read_config: reading config file %s\n", fname, 0, 0 );
149 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
153 fp_getline_init( &lineno );
155 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
156 /* skip comments and blank lines */
157 if ( line[0] == '#' || line[0] == '\0' ) {
161 /* fp_parse_line is destructive, we save a copy */
162 saveline = ch_strdup( line );
164 if ( fp_parse_line( lineno, line ) != 0 ) {
170 LDAP_LOG( CONFIG, INFO,
171 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
173 Debug( LDAP_DEBUG_ANY,
174 "%s: line %d: bad config line (ignored)\n",
181 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
184 LDAP_LOG( CONFIG, CRIT,
185 "%s : line %d: missing type in \"backend\" line.\n",
188 Debug( LDAP_DEBUG_ANY,
189 "%s: line %d: missing type in \"backend <type>\" line\n",
198 LDAP_LOG( CONFIG, CRIT,
199 "%s: line %d: backend line must appear before any "
200 "database definition.\n", fname, lineno , 0 );
202 Debug( LDAP_DEBUG_ANY,
203 "%s: line %d: backend line must appear before any database definition\n",
210 bi = backend_info( cargv[1] );
214 LDAP_LOG( CONFIG, CRIT,
215 "read_config: backend %s initialization failed.\n",
218 Debug( LDAP_DEBUG_ANY,
219 "backend %s initialization failed.\n",
225 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
228 LDAP_LOG( CONFIG, CRIT,
229 "%s: line %d: missing type in \"database <type>\" line\n",
232 Debug( LDAP_DEBUG_ANY,
233 "%s: line %d: missing type in \"database <type>\" line\n",
241 be = backend_db_init( cargv[1] );
245 LDAP_LOG( CONFIG, CRIT,
246 "database %s initialization failed.\n", cargv[1], 0, 0 );
248 Debug( LDAP_DEBUG_ANY,
249 "database %s initialization failed.\n",
256 /* set thread concurrency */
257 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
261 LDAP_LOG( CONFIG, CRIT,
262 "%s: line %d: missing level in \"concurrency <level\" "
263 " line\n", fname, lineno, 0 );
265 Debug( LDAP_DEBUG_ANY,
266 "%s: line %d: missing level in \"concurrency <level>\" line\n",
273 c = atoi( cargv[1] );
277 LDAP_LOG( CONFIG, CRIT,
278 "%s: line %d: invalid level (%d) in "
279 "\"concurrency <level>\" line.\n", fname, lineno, c );
281 Debug( LDAP_DEBUG_ANY,
282 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
289 ldap_pvt_thread_set_concurrency( c );
291 /* set sockbuf max */
292 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
296 LDAP_LOG( CONFIG, CRIT,
297 "%s: line %d: missing max in \"sockbuf_max_incoming "
298 "<bytes>\" line\n", fname, lineno, 0 );
300 Debug( LDAP_DEBUG_ANY,
301 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
308 max = atol( cargv[1] );
312 LDAP_LOG( CONFIG, CRIT,
313 "%s: line %d: invalid max value (%ld) in "
314 "\"sockbuf_max_incoming <bytes>\" line.\n",
315 fname, lineno, max );
317 Debug( LDAP_DEBUG_ANY,
318 "%s: line %d: invalid max value (%ld) in "
319 "\"sockbuf_max_incoming <bytes>\" line.\n",
320 fname, lineno, max );
326 sockbuf_max_incoming = max;
328 /* set sockbuf max authenticated */
329 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
333 LDAP_LOG( CONFIG, CRIT,
334 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
335 "<bytes>\" line\n", fname, lineno, 0 );
337 Debug( LDAP_DEBUG_ANY,
338 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
345 max = atol( cargv[1] );
349 LDAP_LOG( CONFIG, CRIT,
350 "%s: line %d: invalid max value (%ld) in "
351 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
352 fname, lineno, max );
354 Debug( LDAP_DEBUG_ANY,
355 "%s: line %d: invalid max value (%ld) in "
356 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
357 fname, lineno, max );
363 sockbuf_max_incoming_auth = max;
365 /* set conn pending max */
366 } else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) {
370 LDAP_LOG( CONFIG, CRIT,
371 "%s: line %d: missing max in \"conn_max_pending "
372 "<requests>\" line\n", fname, lineno, 0 );
374 Debug( LDAP_DEBUG_ANY,
375 "%s: line %d: missing max in \"conn_max_pending <requests>\" line\n",
382 max = atol( cargv[1] );
386 LDAP_LOG( CONFIG, CRIT,
387 "%s: line %d: invalid max value (%ld) in "
388 "\"conn_max_pending <requests>\" line.\n",
389 fname, lineno, max );
391 Debug( LDAP_DEBUG_ANY,
392 "%s: line %d: invalid max value (%ld) in "
393 "\"conn_max_pending <requests>\" line.\n",
394 fname, lineno, max );
400 slap_conn_max_pending = max;
402 /* set conn pending max authenticated */
403 } else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) {
407 LDAP_LOG( CONFIG, CRIT,
408 "%s: line %d: missing max in \"conn_max_pending_auth "
409 "<requests>\" line\n", fname, lineno, 0 );
411 Debug( LDAP_DEBUG_ANY,
412 "%s: line %d: missing max in \"conn_max_pending_auth <requests>\" line\n",
419 max = atol( cargv[1] );
423 LDAP_LOG( CONFIG, CRIT,
424 "%s: line %d: invalid max value (%ld) in "
425 "\"conn_max_pending_auth <requests>\" line.\n",
426 fname, lineno, max );
428 Debug( LDAP_DEBUG_ANY,
429 "%s: line %d: invalid max value (%ld) in "
430 "\"conn_max_pending_auth <requests>\" line.\n",
431 fname, lineno, max );
437 slap_conn_max_pending_auth = max;
439 /* default search base */
440 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
443 LDAP_LOG( CONFIG, CRIT,
444 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
445 "line\n", fname, lineno, 0 );
447 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
448 "missing dn in \"defaultSearchBase <dn>\" line\n",
454 } else if ( cargc > 2 ) {
456 LDAP_LOG( CONFIG, INFO,
457 "%s: line %d: extra cruft after <dn> in "
458 "\"defaultSearchBase %s\" line (ignored)\n",
459 fname, lineno, cargv[1] );
461 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
462 "extra cruft after <dn> in \"defaultSearchBase %s\", "
464 fname, lineno, cargv[1] );
468 if ( bi != NULL || be != NULL ) {
470 LDAP_LOG( CONFIG, CRIT,
471 "%s: line %d: defaultSearchBase line must appear "
472 "prior to any backend or database definitions\n",
475 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
476 "defaultSearchBaase line must appear prior to "
477 "any backend or database definition\n",
484 if ( default_search_nbase.bv_len ) {
486 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
487 "default search base \"%s\" already defined "
488 "(discarding old)\n", fname, lineno,
489 default_search_base.bv_val );
491 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
492 "default search base \"%s\" already defined "
493 "(discarding old)\n",
494 fname, lineno, default_search_base.bv_val );
497 free( default_search_base.bv_val );
498 free( default_search_nbase.bv_val );
501 if ( load_ucdata( NULL ) < 0 ) return 1;
506 dn.bv_val = cargv[1];
507 dn.bv_len = strlen( dn.bv_val );
509 rc = dnPrettyNormal( NULL, &dn,
510 &default_search_base,
511 &default_search_nbase, NULL );
513 if( rc != LDAP_SUCCESS ) {
515 LDAP_LOG( CONFIG, CRIT,
516 "%s: line %d: defaultSearchBase DN is invalid.\n",
519 Debug( LDAP_DEBUG_ANY,
520 "%s: line %d: defaultSearchBase DN is invalid\n",
527 /* set maximum threads in thread pool */
528 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
532 LDAP_LOG( CONFIG, CRIT,
533 "%s: line %d: missing count in \"threads <count>\" line\n",
536 Debug( LDAP_DEBUG_ANY,
537 "%s: line %d: missing count in \"threads <count>\" line\n",
544 c = atoi( cargv[1] );
548 LDAP_LOG( CONFIG, CRIT,
549 "%s: line %d: invalid level (%d) in \"threads <count>\""
550 "line\n", fname, lineno, c );
552 Debug( LDAP_DEBUG_ANY,
553 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
560 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
562 /* save for later use */
563 connection_pool_max = c;
565 /* get pid file name */
566 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
569 LDAP_LOG( CONFIG, CRIT,
570 "%s: line %d missing file name in \"pidfile <file>\" "
571 "line.\n", fname, lineno, 0 );
573 Debug( LDAP_DEBUG_ANY,
574 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
581 slapd_pid_file = ch_strdup( cargv[1] );
583 /* get args file name */
584 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
587 LDAP_LOG( CONFIG, CRIT,
588 "%s: %d: missing file name in "
589 "\"argsfile <file>\" line.\n",
592 Debug( LDAP_DEBUG_ANY,
593 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
600 slapd_args_file = ch_strdup( cargv[1] );
602 } else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) {
605 } else if ( strcasecmp( cargv[0], "replica-argsfile" ) == 0 ) {
608 /* default password hash */
609 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
612 LDAP_LOG( CONFIG, CRIT,
613 "%s: line %d: missing hash in "
614 "\"password-hash <hash>\" line.\n",
617 Debug( LDAP_DEBUG_ANY,
618 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
624 if ( default_passwd_hash != NULL ) {
626 LDAP_LOG( CONFIG, CRIT,
627 "%s: line %d: already set default password_hash!\n",
630 Debug( LDAP_DEBUG_ANY,
631 "%s: line %d: already set default password_hash!\n",
638 for(i = 1; i < cargc; i++) {
639 if ( lutil_passwd_scheme( cargv[i] ) == 0 ) {
641 LDAP_LOG( CONFIG, CRIT,
642 "%s: line %d: password scheme \"%s\" not available\n",
643 fname, lineno, cargv[i] );
645 Debug( LDAP_DEBUG_ANY,
646 "%s: line %d: password scheme \"%s\" not available\n",
647 fname, lineno, cargv[i] );
650 ldap_charray_add( &default_passwd_hash, cargv[i] );
653 if( !default_passwd_hash ) {
655 LDAP_LOG( CONFIG, CRIT,
656 "%s: line %d: no valid hashes found\n",
659 Debug( LDAP_DEBUG_ANY,
660 "%s: line %d: no valid hashes found\n",
666 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
670 LDAP_LOG( CONFIG, CRIT,
671 "%s: line %d: missing format in "
672 "\"password-crypt-salt-format <format>\" line\n",
675 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
676 "\"password-crypt-salt-format <format>\" line\n",
683 lutil_salt_format( cargv[1] );
685 /* SASL config options */
686 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
687 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
689 #ifdef SLAP_X_SASL_REWRITE
690 /* use authid rewrite instead of sasl regexp */
691 } else if ( strncasecmp( cargv[0], "authid-rewrite", sizeof("authid-rewrite") - 1 ) == 0 ) {
692 int rc = slap_sasl_rewrite_config( fname, lineno,
697 #endif /* SLAP_X_SASL_REWRITE */
699 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
703 LDAP_LOG( CONFIG, CRIT,
704 "%s: line %d: missing dn in "
705 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
707 Debug( LDAP_DEBUG_ANY,
708 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
713 ber_str2bv( cargv[1], 0, 0, &dn );
715 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
716 &be->be_schemandn, NULL );
718 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
719 &global_schemandn, NULL );
721 if ( rc != LDAP_SUCCESS ) {
723 LDAP_LOG( CONFIG, CRIT,
724 "%s: line %d: schemadn DN is invalid.\n",
727 Debug( LDAP_DEBUG_ANY,
728 "%s: line %d: schemadn DN is invalid\n",
734 /* set UCDATA path */
735 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
739 LDAP_LOG( CONFIG, CRIT,
740 "%s: line %d: missing path in "
741 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
743 Debug( LDAP_DEBUG_ANY,
744 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
751 err = load_ucdata( cargv[1] );
755 LDAP_LOG( CONFIG, CRIT,
756 "%s: line %d: ucdata already loaded, ucdata-path "
757 "must be set earlier in the file and/or be "
758 "specified only once!\n", fname, lineno, 0 );
760 Debug( LDAP_DEBUG_ANY,
761 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
770 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
772 struct slap_limits_set *lim;
776 LDAP_LOG( CONFIG, CRIT,
777 "%s: line %d: missing limit in \"sizelimit <limit>\" "
778 "line.\n", fname, lineno, 0 );
780 Debug( LDAP_DEBUG_ANY,
781 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
791 lim = &be->be_def_limit;
794 for ( i = 1; i < cargc; i++ ) {
795 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
796 rc = limits_parse_one( cargv[i], lim );
799 LDAP_LOG( CONFIG, CRIT,
800 "%s: line %d: unable "
801 "to parse value \"%s\" in \"sizelimit "
802 "<limit>\" line.\n", fname, lineno, cargv[i] );
804 Debug( LDAP_DEBUG_ANY,
805 "%s: line %d: unable "
806 "to parse value \"%s\" "
809 fname, lineno, cargv[i] );
815 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
816 lim->lms_s_soft = -1;
820 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
821 if ( next == cargv[i] ) {
823 LDAP_LOG( CONFIG, CRIT,
824 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
825 "line.\n", fname, lineno, cargv[i] );
827 Debug( LDAP_DEBUG_ANY,
828 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
829 fname, lineno, cargv[i] );
833 } else if ( next[0] != '\0' ) {
835 LDAP_LOG( CONFIG, CRIT,
836 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
837 "line ignored.\n", fname, lineno, next );
839 Debug( LDAP_DEBUG_ANY,
840 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
841 fname, lineno, next );
850 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
852 struct slap_limits_set *lim;
856 LDAP_LOG( CONFIG, CRIT,
857 "%s: line %d missing limit in \"timelimit <limit>\" "
858 "line.\n", fname, lineno, 0 );
860 Debug( LDAP_DEBUG_ANY,
861 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
871 lim = &be->be_def_limit;
874 for ( i = 1; i < cargc; i++ ) {
875 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
876 rc = limits_parse_one( cargv[i], lim );
879 LDAP_LOG( CONFIG, CRIT,
880 "%s: line %d: unable to parse value \"%s\" "
881 "in \"timelimit <limit>\" line.\n",
882 fname, lineno, cargv[i] );
884 Debug( LDAP_DEBUG_ANY,
885 "%s: line %d: unable "
886 "to parse value \"%s\" "
889 fname, lineno, cargv[i] );
895 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
896 lim->lms_t_soft = -1;
900 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
901 if ( next == cargv[i] ) {
903 LDAP_LOG( CONFIG, CRIT,
904 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
905 "line.\n", fname, lineno, cargv[i] );
907 Debug( LDAP_DEBUG_ANY,
908 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
909 fname, lineno, cargv[i] );
913 } else if ( next[0] != '\0' ) {
915 LDAP_LOG( CONFIG, CRIT,
916 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
917 "line ignored.\n", fname, lineno, next );
919 Debug( LDAP_DEBUG_ANY,
920 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
921 fname, lineno, next );
929 /* set regex-based limits */
930 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
933 LDAP_LOG( CONFIG, WARNING,
934 "%s: line %d \"limits\" allowed only in database "
935 "environment.\n", fname, lineno, 0 );
937 Debug( LDAP_DEBUG_ANY,
938 "%s: line %d \"limits\" allowed only in database environment.\n%s",
944 if ( limits_parse( be, fname, lineno, cargc, cargv ) ) {
948 /* mark this as a subordinate database */
949 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
952 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
953 "subordinate keyword must appear inside a database "
954 "definition.\n", fname, lineno, 0 );
956 Debug( LDAP_DEBUG_ANY, "%s: line %d: subordinate keyword "
957 "must appear inside a database definition.\n",
963 be->be_flags |= SLAP_DBFLAG_GLUE_SUBORDINATE;
967 /* add an overlay to this backend */
968 } else if ( strcasecmp( cargv[0], "overlay" ) == 0 ) {
971 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
972 "overlay keyword must appear inside a database "
973 "definition.\n", fname, lineno, 0 );
975 Debug( LDAP_DEBUG_ANY, "%s: line %d: overlay keyword "
976 "must appear inside a database definition.\n",
981 } else if ( overlay_config( be, cargv[1] )) {
985 /* set database suffix */
986 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
988 struct berval dn, pdn, ndn;
992 LDAP_LOG( CONFIG, CRIT,
993 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
996 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
997 "missing dn in \"suffix <dn>\" line\n",
1003 } else if ( cargc > 2 ) {
1005 LDAP_LOG( CONFIG, INFO,
1006 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
1007 " line (ignored).\n", fname, lineno, cargv[1] );
1009 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
1010 "after <dn> in \"suffix %s\" line (ignored)\n",
1011 fname, lineno, cargv[1] );
1017 LDAP_LOG( CONFIG, INFO,
1018 "%s: line %d: suffix line must appear inside a database "
1019 "definition.\n", fname, lineno, 0 );
1021 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
1022 "must appear inside a database definition\n",
1027 #if defined(SLAPD_MONITOR_DN)
1028 /* "cn=Monitor" is reserved for monitoring slap */
1029 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
1031 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
1032 "%s\" is reserved for monitoring slapd\n",
1033 fname, lineno, SLAPD_MONITOR_DN );
1035 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
1036 "%s\" is reserved for monitoring slapd\n",
1037 fname, lineno, SLAPD_MONITOR_DN );
1040 #endif /* SLAPD_MONITOR_DN */
1043 if ( load_ucdata( NULL ) < 0 ) return 1;
1045 dn.bv_val = cargv[1];
1046 dn.bv_len = strlen( cargv[1] );
1048 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
1049 if( rc != LDAP_SUCCESS ) {
1051 LDAP_LOG( CONFIG, CRIT,
1052 "%s: line %d: suffix DN is invalid.\n",
1055 Debug( LDAP_DEBUG_ANY,
1056 "%s: line %d: suffix DN is invalid\n",
1062 tmp_be = select_backend( &ndn, 0, 0 );
1063 if ( tmp_be == be ) {
1065 LDAP_LOG( CONFIG, INFO,
1066 "%s: line %d: suffix already served by this backend "
1067 "(ignored)\n", fname, lineno, 0 );
1069 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1070 "already served by this backend (ignored)\n",
1076 } else if ( tmp_be != NULL ) {
1078 LDAP_LOG( CONFIG, INFO,
1079 "%s: line %d: suffix already served by a preceding "
1080 "backend \"%s\"\n", fname, lineno,
1081 tmp_be->be_suffix[0].bv_val );
1083 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1084 "already served by a preceeding backend \"%s\"\n",
1085 fname, lineno, tmp_be->be_suffix[0].bv_val );
1091 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
1093 LDAP_LOG( CONFIG, INFO,
1094 "%s: line %d: suffix DN empty and default search "
1095 "base provided \"%s\" (assuming okay).\n",
1096 fname, lineno, default_search_base.bv_val );
1098 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1099 "suffix DN empty and default "
1100 "search base provided \"%s\" (assuming okay)\n",
1101 fname, lineno, default_search_base.bv_val );
1105 ber_bvarray_add( &be->be_suffix, &pdn );
1106 ber_bvarray_add( &be->be_nsuffix, &ndn );
1108 /* set max deref depth */
1109 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1113 LDAP_LOG( CONFIG, CRIT,
1114 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1115 " line\n", fname, lineno, 0 );
1117 Debug( LDAP_DEBUG_ANY,
1118 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1126 LDAP_LOG( CONFIG, INFO,
1127 "%s: line %d: depth line must appear inside a database "
1128 "definition.\n", fname, lineno ,0 );
1130 Debug( LDAP_DEBUG_ANY,
1131 "%s: line %d: depth line must appear inside a database definition.\n",
1136 } else if ((i = atoi(cargv[1])) < 0) {
1138 LDAP_LOG( CONFIG, INFO,
1139 "%s: line %d: depth must be positive.\n",
1142 Debug( LDAP_DEBUG_ANY,
1143 "%s: line %d: depth must be positive.\n",
1150 be->be_max_deref_depth = i;
1154 /* set magic "root" dn for this database */
1155 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1158 LDAP_LOG( CONFIG, INFO,
1159 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1162 Debug( LDAP_DEBUG_ANY,
1163 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1172 LDAP_LOG( CONFIG, INFO,
1173 "%s: line %d: rootdn line must appear inside a database "
1174 "definition.\n", fname, lineno ,0 );
1176 Debug( LDAP_DEBUG_ANY,
1177 "%s: line %d: rootdn line must appear inside a database definition.\n",
1185 if ( load_ucdata( NULL ) < 0 ) return 1;
1187 dn.bv_val = cargv[1];
1188 dn.bv_len = strlen( cargv[1] );
1190 rc = dnPrettyNormal( NULL, &dn,
1192 &be->be_rootndn, NULL );
1194 if( rc != LDAP_SUCCESS ) {
1196 LDAP_LOG( CONFIG, CRIT,
1197 "%s: line %d: rootdn DN is invalid.\n",
1200 Debug( LDAP_DEBUG_ANY,
1201 "%s: line %d: rootdn DN is invalid\n",
1208 /* set super-secret magic database password */
1209 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1212 LDAP_LOG( CONFIG, CRIT,
1213 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1214 " line\n", fname, lineno ,0 );
1216 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1217 "missing passwd in \"rootpw <passwd>\" line\n",
1226 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1227 "rootpw line must appear inside a database "
1228 "definition.\n", fname, lineno ,0 );
1230 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1231 "rootpw line must appear inside a database "
1238 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1240 if( tmp_be != be ) {
1242 LDAP_LOG( CONFIG, INFO,
1244 "rootpw can only be set when rootdn is under suffix\n",
1245 fname, lineno, "" );
1247 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1248 "rootpw can only be set when rootdn is under suffix\n",
1254 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1255 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1258 /* make this database read-only */
1259 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1262 LDAP_LOG( CONFIG, CRIT,
1263 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1264 "line.\n", fname, lineno ,0 );
1266 Debug( LDAP_DEBUG_ANY,
1267 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1274 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1275 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1277 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1280 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1281 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1283 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1288 /* allow these features */
1289 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1290 strcasecmp( cargv[0], "allow" ) == 0 )
1296 LDAP_LOG( CONFIG, INFO,
1297 "%s: line %d: allow line must appear prior to "
1298 "database definitions.\n", fname, lineno ,0 );
1300 Debug( LDAP_DEBUG_ANY,
1301 "%s: line %d: allow line must appear prior to database definitions\n",
1309 LDAP_LOG( CONFIG, CRIT,
1310 "%s: line %d: missing feature(s) in \"allow <features>\""
1311 " line\n", fname, lineno ,0 );
1313 Debug( LDAP_DEBUG_ANY,
1314 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1323 for( i=1; i < cargc; i++ ) {
1324 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1325 allows |= SLAP_ALLOW_BIND_V2;
1327 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1328 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1330 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1331 allows |= SLAP_ALLOW_BIND_ANON_DN;
1333 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1334 allows |= SLAP_ALLOW_UPDATE_ANON;
1336 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1338 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1339 "unknown feature %s in \"allow <features>\" line.\n",
1340 fname, lineno, cargv[1] );
1342 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1343 "unknown feature %s in \"allow <features>\" line\n",
1344 fname, lineno, cargv[i] );
1351 global_allows = allows;
1353 /* disallow these features */
1354 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1355 strcasecmp( cargv[0], "disallow" ) == 0 )
1357 slap_mask_t disallows;
1361 LDAP_LOG( CONFIG, INFO,
1362 "%s: line %d: disallow line must appear prior to "
1363 "database definitions.\n", fname, lineno ,0 );
1365 Debug( LDAP_DEBUG_ANY,
1366 "%s: line %d: disallow line must appear prior to database definitions\n",
1374 LDAP_LOG( CONFIG, CRIT,
1375 "%s: line %d: missing feature(s) in \"disallow <features>\""
1376 " line.\n", fname, lineno ,0 );
1378 Debug( LDAP_DEBUG_ANY,
1379 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1388 for( i=1; i < cargc; i++ ) {
1389 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1390 disallows |= SLAP_DISALLOW_BIND_ANON;
1392 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1393 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1395 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1396 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1398 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1399 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1401 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1402 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1404 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1406 LDAP_LOG( CONFIG, CRIT,
1407 "%s: line %d: unknown feature %s in "
1408 "\"disallow <features>\" line.\n",
1409 fname, lineno, cargv[i] );
1411 Debug( LDAP_DEBUG_ANY,
1412 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1413 fname, lineno, cargv[i] );
1420 global_disallows = disallows;
1422 /* require these features */
1423 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1424 strcasecmp( cargv[0], "require" ) == 0 )
1426 slap_mask_t requires;
1430 LDAP_LOG( CONFIG, CRIT,
1431 "%s: line %d: missing feature(s) in "
1432 "\"require <features>\" line.\n", fname, lineno ,0 );
1434 Debug( LDAP_DEBUG_ANY,
1435 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1444 for( i=1; i < cargc; i++ ) {
1445 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1446 requires |= SLAP_REQUIRE_BIND;
1448 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1449 requires |= SLAP_REQUIRE_LDAP_V3;
1451 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1452 requires |= SLAP_REQUIRE_AUTHC;
1454 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1455 requires |= SLAP_REQUIRE_SASL;
1457 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1458 requires |= SLAP_REQUIRE_STRONG;
1460 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1462 LDAP_LOG( CONFIG, CRIT,
1463 "%s: line %d: unknown feature %s in "
1464 "\"require <features>\" line.\n",
1465 fname, lineno , cargv[i] );
1467 Debug( LDAP_DEBUG_ANY,
1468 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1469 fname, lineno, cargv[i] );
1477 global_requires = requires;
1479 be->be_requires = requires;
1482 /* required security factors */
1483 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1484 slap_ssf_set_t *set;
1488 LDAP_LOG( CONFIG, CRIT,
1489 "%s: line %d: missing factor(s) in \"security <factors>\""
1490 " line.\n", fname, lineno ,0 );
1492 Debug( LDAP_DEBUG_ANY,
1493 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1501 set = &global_ssf_set;
1503 set = &be->be_ssf_set;
1506 for( i=1; i < cargc; i++ ) {
1507 if( strncasecmp( cargv[i], "ssf=",
1508 sizeof("ssf") ) == 0 )
1511 atoi( &cargv[i][sizeof("ssf")] );
1513 } else if( strncasecmp( cargv[i], "transport=",
1514 sizeof("transport") ) == 0 )
1516 set->sss_transport =
1517 atoi( &cargv[i][sizeof("transport")] );
1519 } else if( strncasecmp( cargv[i], "tls=",
1520 sizeof("tls") ) == 0 )
1523 atoi( &cargv[i][sizeof("tls")] );
1525 } else if( strncasecmp( cargv[i], "sasl=",
1526 sizeof("sasl") ) == 0 )
1529 atoi( &cargv[i][sizeof("sasl")] );
1531 } else if( strncasecmp( cargv[i], "update_ssf=",
1532 sizeof("update_ssf") ) == 0 )
1534 set->sss_update_ssf =
1535 atoi( &cargv[i][sizeof("update_ssf")] );
1537 } else if( strncasecmp( cargv[i], "update_transport=",
1538 sizeof("update_transport") ) == 0 )
1540 set->sss_update_transport =
1541 atoi( &cargv[i][sizeof("update_transport")] );
1543 } else if( strncasecmp( cargv[i], "update_tls=",
1544 sizeof("update_tls") ) == 0 )
1546 set->sss_update_tls =
1547 atoi( &cargv[i][sizeof("update_tls")] );
1549 } else if( strncasecmp( cargv[i], "update_sasl=",
1550 sizeof("update_sasl") ) == 0 )
1552 set->sss_update_sasl =
1553 atoi( &cargv[i][sizeof("update_sasl")] );
1555 } else if( strncasecmp( cargv[i], "simple_bind=",
1556 sizeof("simple_bind") ) == 0 )
1558 set->sss_simple_bind =
1559 atoi( &cargv[i][sizeof("simple_bind")] );
1563 LDAP_LOG( CONFIG, CRIT,
1564 "%s: line %d: unknown factor %S in "
1565 "\"security <factors>\" line.\n",
1566 fname, lineno, cargv[1] );
1568 Debug( LDAP_DEBUG_ANY,
1569 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1570 fname, lineno, cargv[i] );
1576 /* where to send clients when we don't hold it */
1577 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1580 LDAP_LOG( CONFIG, CRIT,
1581 "%s: line %d: missing URL in \"referral <URL>\""
1582 " line.\n", fname, lineno , 0 );
1584 Debug( LDAP_DEBUG_ANY,
1585 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1592 if( validate_global_referral( cargv[1] ) ) {
1594 LDAP_LOG( CONFIG, CRIT,
1595 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1596 fname, lineno, cargv[1] );
1598 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1599 "invalid URL (%s) in \"referral\" line.\n",
1600 fname, lineno, cargv[1] );
1605 vals[0].bv_val = cargv[1];
1606 vals[0].bv_len = strlen( vals[0].bv_val );
1607 if( value_add( &default_referral, vals ) )
1611 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1615 LDAP_LOG( CONFIG, CRIT,
1616 "%s: line %d: Error in logfile directive, "
1617 "\"logfile <filename>\"\n", fname, lineno , 0 );
1619 Debug( LDAP_DEBUG_ANY,
1620 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1626 logfile = fopen( cargv[1], "w" );
1627 if ( logfile != NULL ) lutil_debug_file( logfile );
1630 /* start of a new database definition */
1631 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1635 LDAP_LOG( CONFIG, CRIT,
1636 "%s: line %d: Error in debug directive, "
1637 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1639 Debug( LDAP_DEBUG_ANY,
1640 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1646 level = atoi( cargv[2] );
1647 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1648 lutil_set_debug_level( cargv[1], level );
1649 /* specify an Object Identifier macro */
1650 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1651 rc = parse_oidm( fname, lineno, cargc, cargv );
1654 /* specify an objectclass */
1655 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1658 LDAP_LOG( CONFIG, INFO,
1659 "%s: line %d: illegal objectclass format.\n",
1660 fname, lineno , 0 );
1662 Debug( LDAP_DEBUG_ANY,
1663 "%s: line %d: illegal objectclass format.\n",
1668 } else if ( *cargv[1] == '(' /*')'*/) {
1670 p = strchr(saveline,'(' /*')'*/);
1671 rc = parse_oc( fname, lineno, p, cargv );
1676 LDAP_LOG( CONFIG, INFO,
1677 "%s: line %d: old objectclass format not supported\n",
1678 fname, lineno , 0 );
1680 Debug( LDAP_DEBUG_ANY,
1681 "%s: line %d: old objectclass format not supported.\n",
1686 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1688 p = strchr(saveline,'(' /*')'*/);
1689 rc = parse_cr( fname, lineno, p, cargv );
1692 /* specify an attribute type */
1693 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1694 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1698 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1699 "illegal attribute type format.\n",
1700 fname, lineno , 0 );
1702 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1703 "illegal attribute type format.\n",
1708 } else if ( *cargv[1] == '(' /*')'*/) {
1710 p = strchr(saveline,'(' /*')'*/);
1711 rc = parse_at( fname, lineno, p, cargv );
1716 LDAP_LOG( CONFIG, INFO,
1717 "%s: line %d: old attribute type format not supported.\n",
1718 fname, lineno , 0 );
1720 Debug( LDAP_DEBUG_ANY,
1721 "%s: line %d: old attribute type format not supported.\n",
1727 /* define attribute option(s) */
1728 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1729 ad_define_option( NULL, NULL, 0 );
1730 for ( i = 1; i < cargc; i++ )
1731 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1734 /* turn on/off schema checking */
1735 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1738 LDAP_LOG( CONFIG, CRIT,
1739 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1740 " line.\n", fname, lineno , 0 );
1742 Debug( LDAP_DEBUG_ANY,
1743 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1749 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1751 LDAP_LOG( CONFIG, CRIT,
1752 "%s: line %d: schema checking disabled! your mileage may "
1753 "vary!\n", fname, lineno , 0 );
1755 Debug( LDAP_DEBUG_ANY,
1756 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1759 global_schemacheck = 0;
1761 global_schemacheck = 1;
1764 /* specify access control info */
1765 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1766 parse_acl( be, fname, lineno, cargc, cargv );
1768 /* debug level to log things to syslog */
1769 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1772 LDAP_LOG( CONFIG, CRIT,
1773 "%s: line %d: missing level in \"loglevel <level>\""
1774 " line.\n", fname, lineno , 0 );
1776 Debug( LDAP_DEBUG_ANY,
1777 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1786 for( i=1; i < cargc; i++ ) {
1787 ldap_syslog += atoi( cargv[1] );
1790 /* list of sync replication information in this backend (slave only) */
1791 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
1795 LDAP_LOG( CONFIG, INFO,
1796 "%s: line %d: syncrepl line must appear inside "
1797 "a database definition.\n", fname, lineno, 0);
1799 Debug( LDAP_DEBUG_ANY,
1800 "%s: line %d: syncrepl line must appear inside "
1801 "a database definition.\n", fname, lineno, 0);
1805 } else if ( SLAP_SHADOW( be )) {
1807 LDAP_LOG( CONFIG, INFO,
1808 "%s: line %d: syncrepl: database already shadowed.\n",
1811 Debug( LDAP_DEBUG_ANY,
1812 "%s: line %d: syncrepl: database already shadowed.\n",
1817 } else if ( add_syncrepl( be, cargv, cargc )) {
1821 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_SHADOW;
1823 /* list of replicas of the data in this backend (master only) */
1824 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1827 LDAP_LOG( CONFIG, CRIT,
1828 "%s: line %d: missing host or uri in \"replica "
1829 " <host[:port]\" line\n", fname, lineno , 0 );
1831 Debug( LDAP_DEBUG_ANY,
1832 "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
1840 LDAP_LOG( CONFIG, INFO,
1841 "%s: line %d: replica line must appear inside "
1842 "a database definition.\n", fname, lineno, 0);
1844 Debug( LDAP_DEBUG_ANY,
1845 "%s: line %d: replica line must appear inside a database definition\n",
1853 for ( i = 1; i < cargc; i++ ) {
1854 if ( strncasecmp( cargv[i], "host=", 5 )
1856 nr = add_replica_info( be,
1859 } else if (strncasecmp( cargv[i], "uri=", 4 )
1861 if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
1864 LDAP_LOG( CONFIG, INFO,
1865 "%s: line %d: replica line contains invalid "
1866 "uri definition.\n", fname, lineno, 0);
1868 Debug( LDAP_DEBUG_ANY,
1869 "%s: line %d: replica line contains invalid "
1870 "uri definition.\n", fname, lineno, 0);
1874 if (ludp->lud_host == NULL ) {
1876 LDAP_LOG( CONFIG, INFO,
1877 "%s: line %d: replica line contains invalid "
1878 "uri definition - missing hostname.\n",
1881 Debug( LDAP_DEBUG_ANY,
1882 "%s: line %d: replica line contains invalid "
1883 "uri definition - missing hostname.\n", fname, lineno, 0);
1887 replicahost = ch_malloc( strlen( cargv[ i ] ) );
1888 if ( replicahost == NULL ) {
1890 LDAP_LOG( CONFIG, ERR,
1891 "out of memory in read_config\n", 0, 0,0 );
1893 Debug( LDAP_DEBUG_ANY,
1894 "out of memory in read_config\n", 0, 0, 0 );
1896 ldap_free_urldesc( ludp );
1897 exit( EXIT_FAILURE );
1899 sprintf(replicahost, "%s:%d",
1900 ludp->lud_host, ludp->lud_port);
1901 nr = add_replica_info( be, replicahost );
1902 ldap_free_urldesc( ludp );
1903 ch_free(replicahost);
1909 LDAP_LOG( CONFIG, INFO,
1910 "%s: line %d: missing host or uri in \"replica\" line\n",
1911 fname, lineno , 0 );
1913 Debug( LDAP_DEBUG_ANY,
1914 "%s: line %d: missing host or uri in \"replica\" line\n",
1919 } else if ( nr == -1 ) {
1921 LDAP_LOG( CONFIG, INFO,
1922 "%s: line %d: unable to add"
1923 " replica \"%s\"\n",
1927 Debug( LDAP_DEBUG_ANY,
1928 "%s: line %d: unable to add replica \"%s\"\n",
1929 fname, lineno, cargv[i] + 5 );
1933 for ( i = 1; i < cargc; i++ ) {
1934 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1936 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1939 LDAP_LOG( CONFIG, INFO,
1940 "%s: line %d: suffix \"%s\" in \"replica\""
1941 " line is not valid for backend(ignored)\n",
1942 fname, lineno, cargv[i] + 7 );
1944 Debug( LDAP_DEBUG_ANY,
1945 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1946 fname, lineno, cargv[i] + 7 );
1952 LDAP_LOG( CONFIG, INFO,
1953 "%s: line %d: unable to normalize suffix"
1954 " in \"replica\" line (ignored)\n",
1955 fname, lineno , 0 );
1957 Debug( LDAP_DEBUG_ANY,
1958 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1964 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1966 char *arg = cargv[i] + 4;
1968 if ( arg[0] == '!' ) {
1973 if ( arg[0] != '=' ) {
1977 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1979 LDAP_LOG( CONFIG, INFO,
1980 "%s: line %d: attribute \"%s\" in "
1981 "\"replica\" line is unknown\n",
1982 fname, lineno, arg + 1 );
1984 Debug( LDAP_DEBUG_ANY,
1985 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1986 fname, lineno, arg + 1 );
1995 } else if ( strcasecmp( cargv[0], "replicationInterval" ) == 0 ) {
1998 /* dn of slave entity allowed to write to replica */
1999 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
2002 LDAP_LOG( CONFIG, CRIT,
2003 "%s: line %d: missing dn in \"updatedn <dn>\""
2004 " line.\n", fname, lineno , 0 );
2006 Debug( LDAP_DEBUG_ANY,
2007 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
2015 LDAP_LOG( CONFIG, INFO,
2016 "%s: line %d: updatedn line must appear inside "
2017 "a database definition\n",
2018 fname, lineno , 0 );
2020 Debug( LDAP_DEBUG_ANY,
2021 "%s: line %d: updatedn line must appear inside a database definition\n",
2026 } else if ( SLAP_SHADOW(be) ) {
2028 LDAP_LOG( CONFIG, INFO,
2029 "%s: line %d: updatedn: database already shadowed.\n",
2032 Debug( LDAP_DEBUG_ANY,
2033 "%s: line %d: updatedn: database already shadowed.\n",
2041 if ( load_ucdata( NULL ) < 0 ) return 1;
2043 dn.bv_val = cargv[1];
2044 dn.bv_len = strlen( cargv[1] );
2046 rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
2047 if( rc != LDAP_SUCCESS ) {
2049 LDAP_LOG( CONFIG, CRIT,
2050 "%s: line %d: updatedn DN is invalid.\n",
2051 fname, lineno , 0 );
2053 Debug( LDAP_DEBUG_ANY,
2054 "%s: line %d: updatedn DN is invalid\n",
2061 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_SHADOW;
2063 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
2066 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2067 "missing url in \"updateref <ldapurl>\" line.\n",
2068 fname, lineno , 0 );
2070 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2071 "missing url in \"updateref <ldapurl>\" line\n",
2079 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
2080 " line must appear inside a database definition\n",
2081 fname, lineno , 0 );
2083 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
2084 " line must appear inside a database definition\n",
2089 } else if ( !SLAP_SHADOW(be) ) {
2091 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
2092 "updateref line must come after syncrepl or updatedn.\n",
2093 fname, lineno , 0 );
2095 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2096 "updateref line must after syncrepl or updatedn.\n",
2102 if( validate_global_referral( cargv[1] ) ) {
2104 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2105 "invalid URL (%s) in \"updateref\" line.\n",
2106 fname, lineno, cargv[1] );
2108 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2109 "invalid URL (%s) in \"updateref\" line.\n",
2110 fname, lineno, cargv[1] );
2115 vals[0].bv_val = cargv[1];
2116 vals[0].bv_len = strlen( vals[0].bv_val );
2117 if( value_add( &be->be_update_refs, vals ) ) {
2121 /* replication log file to which changes are appended */
2122 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
2125 LDAP_LOG( CONFIG, CRIT,
2126 "%s: line %d: missing filename in \"replogfile <filename>\""
2127 " line.\n", fname, lineno , 0 );
2129 Debug( LDAP_DEBUG_ANY,
2130 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2137 be->be_replogfile = ch_strdup( cargv[1] );
2139 replogfile = ch_strdup( cargv[1] );
2142 /* file from which to read additional rootdse attrs */
2143 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2146 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2147 "missing filename in \"rootDSE <filename>\" line.\n",
2148 fname, lineno , 0 );
2150 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2151 "missing filename in \"rootDSE <filename>\" line.\n",
2157 if( read_root_dse_file( cargv[1] ) ) {
2159 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2160 "could not read \"rootDSE <filename>\" line.\n",
2161 fname, lineno , 0 );
2163 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2164 "could not read \"rootDSE <filename>\" line\n",
2170 /* maintain lastmodified{by,time} attributes */
2171 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2174 LDAP_LOG( CONFIG, CRIT,
2175 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2176 " line.\n", fname, lineno , 0 );
2178 Debug( LDAP_DEBUG_ANY,
2179 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2185 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2187 be->be_flags &= ~SLAP_DBFLAG_NOLASTMOD;
2193 be->be_flags |= SLAP_DBFLAG_NOLASTMOD;
2200 /* turn on/off gentle SIGHUP handling */
2201 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2203 Debug( LDAP_DEBUG_ANY,
2204 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2208 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2209 global_gentlehup = 0;
2211 global_gentlehup = 1;
2215 /* set idle timeout value */
2216 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2220 LDAP_LOG( CONFIG, CRIT,
2221 "%s: line %d: missing timeout value in "
2222 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2224 Debug( LDAP_DEBUG_ANY,
2225 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2232 i = atoi( cargv[1] );
2236 LDAP_LOG( CONFIG, CRIT,
2237 "%s: line %d: timeout value (%d) invalid "
2238 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2240 Debug( LDAP_DEBUG_ANY,
2241 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2248 global_idletimeout = i;
2250 /* include another config file */
2251 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2254 LDAP_LOG( CONFIG, CRIT,
2255 "%s: line %d: missing filename in \"include "
2256 "<filename>\" line.\n", fname, lineno , 0 );
2258 Debug( LDAP_DEBUG_ANY,
2259 "%s: line %d: missing filename in \"include <filename>\" line\n",
2265 savefname = ch_strdup( cargv[1] );
2266 savelineno = lineno;
2268 if ( read_config( savefname, depth+1 ) != 0 ) {
2273 lineno = savelineno - 1;
2275 /* location of kerberos srvtab file */
2276 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2279 LDAP_LOG( CONFIG, CRIT,
2280 "%s: line %d: missing filename in \"srvtab "
2281 "<filename>\" line.\n", fname, lineno , 0 );
2283 Debug( LDAP_DEBUG_ANY,
2284 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2290 ldap_srvtab = ch_strdup( cargv[1] );
2292 #ifdef SLAPD_MODULES
2293 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2296 LDAP_LOG( CONFIG, INFO,
2297 "%s: line %d: missing filename in \"moduleload "
2298 "<filename>\" line.\n", fname, lineno , 0 );
2300 Debug( LDAP_DEBUG_ANY,
2301 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2305 exit( EXIT_FAILURE );
2307 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2309 LDAP_LOG( CONFIG, CRIT,
2310 "%s: line %d: failed to load or initialize module %s\n",
2311 fname, lineno, cargv[1] );
2313 Debug( LDAP_DEBUG_ANY,
2314 "%s: line %d: failed to load or initialize module %s\n",
2315 fname, lineno, cargv[1]);
2318 exit( EXIT_FAILURE );
2320 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2323 LDAP_LOG( CONFIG, INFO,
2324 "%s: line %d: missing path in \"modulepath <path>\""
2325 " line\n", fname, lineno , 0 );
2327 Debug( LDAP_DEBUG_ANY,
2328 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2332 exit( EXIT_FAILURE );
2334 if (module_path( cargv[1] )) {
2336 LDAP_LOG( CONFIG, CRIT,
2337 "%s: line %d: failed to set module search path to %s.\n",
2338 fname, lineno, cargv[1] );
2340 Debug( LDAP_DEBUG_ANY,
2341 "%s: line %d: failed to set module search path to %s\n",
2342 fname, lineno, cargv[1]);
2345 exit( EXIT_FAILURE );
2348 #endif /*SLAPD_MODULES*/
2351 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2352 rc = ldap_pvt_tls_set_option( NULL,
2353 LDAP_OPT_X_TLS_RANDOM_FILE,
2358 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2359 rc = ldap_pvt_tls_set_option( NULL,
2360 LDAP_OPT_X_TLS_CIPHER_SUITE,
2365 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2366 rc = ldap_pvt_tls_set_option( NULL,
2367 LDAP_OPT_X_TLS_CERTFILE,
2372 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2373 rc = ldap_pvt_tls_set_option( NULL,
2374 LDAP_OPT_X_TLS_KEYFILE,
2379 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2380 rc = ldap_pvt_tls_set_option( NULL,
2381 LDAP_OPT_X_TLS_CACERTDIR,
2386 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2387 rc = ldap_pvt_tls_set_option( NULL,
2388 LDAP_OPT_X_TLS_CACERTFILE,
2392 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2393 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2395 rc = ldap_pvt_tls_set_option( NULL,
2396 LDAP_OPT_X_TLS_REQUIRE_CERT,
2399 rc = ldap_int_tls_config( NULL,
2400 LDAP_OPT_X_TLS_REQUIRE_CERT,
2409 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2410 #ifdef SLAPD_RLOOKUPS
2413 LDAP_LOG( CONFIG, INFO,
2414 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2415 fname, lineno , 0 );
2417 Debug( LDAP_DEBUG_ANY,
2418 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2424 if ( !strcasecmp( cargv[1], "on" ) ) {
2425 use_reverse_lookup = 1;
2426 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2427 use_reverse_lookup = 0;
2430 LDAP_LOG( CONFIG, INFO,
2431 "%s: line %d: reverse-lookup: "
2432 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2434 Debug( LDAP_DEBUG_ANY,
2435 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2441 #else /* !SLAPD_RLOOKUPS */
2443 LDAP_LOG( CONFIG, INFO,
2444 "%s: line %d: reverse lookups "
2445 "are not configured (ignored).\n", fname, lineno , 0 );
2447 Debug( LDAP_DEBUG_ANY,
2448 "%s: line %d: reverse lookups are not configured (ignored).\n",
2451 #endif /* !SLAPD_RLOOKUPS */
2453 /* Netscape plugins */
2454 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2455 #if defined( LDAP_SLAPI )
2457 #ifdef notdef /* allow global plugins, too */
2459 * a "plugin" line must be inside a database
2460 * definition, since we implement pre-,post-
2461 * and extended operation plugins
2465 LDAP_LOG( CONFIG, INFO,
2466 "%s: line %d: plugin line must appear "
2467 "insid a database definition.\n",
2470 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2471 "line must appear inside a database "
2472 "definition\n", fname, lineno, 0 );
2478 if ( slapi_int_read_config( be, fname, lineno, cargc, cargv )
2482 slapi_plugins_used++;
2484 #else /* !defined( LDAP_SLAPI ) */
2486 LDAP_LOG( CONFIG, INFO,
2487 "%s: line %d: SLAPI not supported.\n",
2490 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2491 "not supported.\n", fname, lineno, 0 );
2495 #endif /* !defined( LDAP_SLAPI ) */
2497 /* Netscape plugins */
2498 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2499 #if defined( LDAP_SLAPI )
2502 LDAP_LOG( CONFIG, INFO,
2503 "%s: line %d: missing file name "
2504 "in pluginlog <filename> line.\n",
2507 Debug( LDAP_DEBUG_ANY,
2508 "%s: line %d: missing file name "
2509 "in pluginlog <filename> line.\n",
2515 if ( slapi_log_file != NULL ) {
2516 ch_free( slapi_log_file );
2519 slapi_log_file = ch_strdup( cargv[1] );
2520 #endif /* !defined( LDAP_SLAPI ) */
2522 /* pass anything else to the current backend info/db config routine */
2525 if ( bi->bi_config ) {
2526 rc = (*bi->bi_config)( bi, fname, lineno, cargc, cargv );
2532 case SLAP_CONF_UNKNOWN:
2534 LDAP_LOG( CONFIG, INFO,
2535 "%s: line %d: unknown directive \"%s\" inside "
2536 "backend info definition (ignored).\n",
2537 fname, lineno, cargv[0] );
2539 Debug( LDAP_DEBUG_ANY,
2540 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2541 fname, lineno, cargv[0] );
2550 } else if ( be != NULL ) {
2551 if ( be->be_config ) {
2552 rc = (*be->be_config)( be, fname, lineno, cargc, cargv );
2558 case SLAP_CONF_UNKNOWN:
2560 LDAP_LOG( CONFIG, INFO,
2561 "%s: line %d: unknown directive \"%s\" inside "
2562 "backend database definition (ignored).\n",
2563 fname, lineno, cargv[0] );
2565 Debug( LDAP_DEBUG_ANY,
2566 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2567 fname, lineno, cargv[0] );
2578 LDAP_LOG( CONFIG, INFO,
2579 "%s: line %d: unknown directive \"%s\" outside backend "
2580 "info and database definitions (ignored).\n",
2581 fname, lineno, cargv[0] );
2583 Debug( LDAP_DEBUG_ANY,
2584 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2585 fname, lineno, cargv[0] );
2594 if ( depth == 0 ) ch_free( cargv );
2596 if ( !global_schemadn.bv_val ) {
2597 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2599 dnNormalize( 0, NULL, NULL, &global_schemadn, &global_schemandn, NULL );
2602 if ( load_ucdata( NULL ) < 0 ) return 1;
2614 char logbuf[sizeof("pseudorootpw ***")];
2617 token = strtok_quote( line, " \t" );
2621 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2622 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2623 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2624 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2625 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2627 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2630 if ( strtok_quote_ptr ) {
2631 *strtok_quote_ptr = ' ';
2635 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2637 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2640 if ( strtok_quote_ptr ) {
2641 *strtok_quote_ptr = '\0';
2644 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2645 if ( cargc == cargv_size - 1 ) {
2647 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2649 if ( tmp == NULL ) {
2651 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2653 Debug( LDAP_DEBUG_ANY,
2654 "line %d: out of memory\n",
2660 cargv_size += ARGS_STEP;
2662 cargv[cargc++] = token;
2664 cargv[cargc] = NULL;
2669 strtok_quote( char *line, char *sep )
2675 strtok_quote_ptr = NULL;
2676 if ( line != NULL ) {
2679 while ( *next && strchr( sep, *next ) ) {
2683 if ( *next == '\0' ) {
2689 for ( inquote = 0; *next; ) {
2697 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2703 next + 1, strlen( next + 1 ) + 1 );
2704 next++; /* dont parse the escaped character */
2709 if ( strchr( sep, *next ) != NULL ) {
2710 strtok_quote_ptr = next;
2723 static char buf[BUFSIZ];
2725 static size_t lmax, lcur;
2727 #define CATLINE( buf ) \
2729 size_t len = strlen( buf ); \
2730 while ( lcur + len + 1 > lmax ) { \
2732 line = (char *) ch_realloc( line, lmax ); \
2734 strcpy( line + lcur, buf ); \
2739 fp_getline( FILE *fp, int *lineno )
2747 /* hack attack - keeps us from having to keep a stack of bufs... */
2748 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2753 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2754 /* trim off \r\n or \n */
2755 if ( (p = strchr( buf, '\n' )) != NULL ) {
2756 if( p > buf && p[-1] == '\r' ) --p;
2760 /* trim off trailing \ and append the next line */
2761 if ( line[ 0 ] != '\0'
2762 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2763 && p[ -1 ] != '\\' ) {
2768 if ( ! isspace( (unsigned char) buf[0] ) ) {
2772 /* change leading whitespace to a space */
2781 return( line[0] ? line : NULL );
2785 fp_getline_init( int *lineno )
2791 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2793 load_ucdata( char *path )
2795 static int loaded = 0;
2801 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2804 LDAP_LOG( CONFIG, CRIT,
2805 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2807 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2820 ucdata_unload( UCDATA_ALL );
2821 free( global_schemandn.bv_val );
2822 free( global_schemadn.bv_val );
2824 if ( slapd_args_file )
2825 free ( slapd_args_file );
2826 if ( slapd_pid_file )
2827 free ( slapd_pid_file );
2828 if ( default_passwd_hash )
2829 ldap_charray_free( default_passwd_hash );
2830 acl_destroy( global_acl, NULL );
2841 syncinfo_t *si_entry;
2843 int duplicated_replica_id = 0;
2845 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2849 LDAP_LOG( CONFIG, ERR, "out of memory in add_syncrepl\n", 0, 0,0 );
2851 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2856 si->si_tls = SYNCINFO_TLS_OFF;
2857 if ( be->be_rootndn.bv_val ) {
2858 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
2860 si->si_bindmethod = LDAP_AUTH_SIMPLE;
2861 si->si_schemachecking = 0;
2862 ber_str2bv( "(objectclass=*)", sizeof("(objectclass=*)")-1, 0,
2863 &si->si_filterstr );
2864 si->si_base.bv_val = NULL;
2865 si->si_scope = LDAP_SCOPE_SUBTREE;
2866 si->si_attrsonly = 0;
2867 si->si_attrs = (char **) ch_calloc( 1, sizeof( char * ));
2868 si->si_attrs[0] = NULL;
2869 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2870 si->si_interval = 86400;
2871 si->si_syncCookie.ctxcsn = NULL;
2872 si->si_syncCookie.octet_str = NULL;
2873 si->si_syncCookie.sid = -1;
2874 si->si_manageDSAit = 0;
2877 si->si_syncUUID_ndn.bv_val = NULL;
2878 si->si_syncUUID_ndn.bv_len = 0;
2880 si->si_presentlist = NULL;
2881 LDAP_LIST_INIT( &si->si_nonpresentlist );
2883 rc = parse_syncrepl_line( cargv, cargc, si );
2885 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
2886 if ( si->si_rid == si_entry->si_rid ) {
2888 LDAP_LOG( CONFIG, ERR,
2889 "add_syncrepl: duplicated replica id\n", 0, 0,0 );
2891 Debug( LDAP_DEBUG_ANY,
2892 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
2894 duplicated_replica_id = 1;
2899 if ( rc < 0 || duplicated_replica_id ) {
2900 syncinfo_t *si_entry;
2901 /* Something bad happened - back out */
2903 LDAP_LOG( CONFIG, ERR, "failed to add syncinfo\n", 0, 0,0 );
2905 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2908 /* If error, remove all syncinfo */
2909 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
2910 if ( si_entry->si_updatedn.bv_val ) {
2911 ch_free( si->si_updatedn.bv_val );
2913 if ( si_entry->si_filterstr.bv_val ) {
2914 ch_free( si->si_filterstr.bv_val );
2916 if ( si_entry->si_attrs ) {
2918 while ( si_entry->si_attrs[i] != NULL ) {
2919 ch_free( si_entry->si_attrs[i] );
2922 ch_free( si_entry->si_attrs );
2926 while ( !LDAP_STAILQ_EMPTY( &be->be_syncinfo )) {
2927 si_entry = LDAP_STAILQ_FIRST( &be->be_syncinfo );
2928 LDAP_STAILQ_REMOVE_HEAD( &be->be_syncinfo, si_next );
2929 ch_free( si_entry );
2931 LDAP_STAILQ_INIT( &be->be_syncinfo );
2935 LDAP_LOG ( CONFIG, RESULTS,
2936 "add_syncrepl: Config: ** successfully added syncrepl \"%s\"\n",
2937 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2939 Debug( LDAP_DEBUG_CONFIG,
2940 "Config: ** successfully added syncrepl \"%s\"\n",
2941 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2943 if ( !si->si_schemachecking ) {
2944 be->be_flags |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
2947 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
2953 #define PROVIDERSTR "provider"
2954 #define SUFFIXSTR "suffix"
2955 #define UPDATEDNSTR "updatedn"
2956 #define BINDMETHSTR "bindmethod"
2957 #define SIMPLESTR "simple"
2958 #define SASLSTR "sasl"
2959 #define BINDDNSTR "binddn"
2960 #define CREDSTR "credentials"
2961 #define OLDAUTHCSTR "bindprincipal"
2962 #define AUTHCSTR "authcID"
2963 #define AUTHZSTR "authzID"
2964 #define SRVTABSTR "srvtab"
2965 #define SASLMECHSTR "saslmech"
2966 #define REALMSTR "realm"
2967 #define SECPROPSSTR "secprops"
2968 #define STARTTLSSTR "starttls"
2969 #define CRITICALSTR "critical"
2971 #define SCHEMASTR "schemachecking"
2972 #define FILTERSTR "filter"
2973 #define SEARCHBASESTR "searchbase"
2974 #define SCOPESTR "scope"
2975 #define ATTRSSTR "attrs"
2976 #define ATTRSONLYSTR "attrsonly"
2977 #define TYPESTR "type"
2978 #define INTERVALSTR "interval"
2979 #define LASTMODSTR "lastmod"
2980 #define LMREQSTR "req"
2981 #define LMGENSTR "gen"
2982 #define LMNOSTR "no"
2983 #define MANAGEDSAITSTR "manageDSAit"
2984 #define SLIMITSTR "sizelimit"
2985 #define TLIMITSTR "timelimit"
2987 #define GOT_ID 0x0001
2988 #define GOT_PROVIDER 0x0002
2989 #define GOT_METHOD 0x0004
2990 #define GOT_ALL 0x0007
2993 parse_syncrepl_line(
3004 for ( i = 1; i < cargc; i++ ) {
3005 if ( !strncasecmp( cargv[ i ], IDSTR, sizeof( IDSTR ) - 1 )) {
3007 /* '\0' string terminator accounts for '=' */
3008 val = cargv[ i ] + sizeof( IDSTR );
3010 if ( tmp >= 1000 || tmp < 0 ) {
3011 fprintf( stderr, "Error: parse_syncrepl_line: "
3012 "syncrepl id %d is out of range [0..999]\n", tmp );
3017 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR,
3018 sizeof( PROVIDERSTR ) - 1 )) {
3019 val = cargv[ i ] + sizeof( PROVIDERSTR );
3020 si->si_provideruri = ch_strdup( val );
3021 si->si_provideruri_bv = (BerVarray)
3022 ch_calloc( 2, sizeof( struct berval ));
3023 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
3024 0, &si->si_provideruri_bv[0] );
3025 si->si_provideruri_bv[1].bv_len = 0;
3026 si->si_provideruri_bv[1].bv_val = NULL;
3027 gots |= GOT_PROVIDER;
3028 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR,
3029 sizeof(STARTTLSSTR) - 1 ) )
3031 val = cargv[ i ] + sizeof( STARTTLSSTR );
3032 if( !strcasecmp( val, CRITICALSTR ) ) {
3033 si->si_tls = SYNCINFO_TLS_CRITICAL;
3035 si->si_tls = SYNCINFO_TLS_ON;
3037 } else if ( !strncasecmp( cargv[ i ],
3038 UPDATEDNSTR, sizeof( UPDATEDNSTR ) - 1 ) )
3040 struct berval updatedn = {0, NULL};
3041 val = cargv[ i ] + sizeof( UPDATEDNSTR );
3042 ber_str2bv( val, 0, 0, &updatedn );
3043 ch_free( si->si_updatedn.bv_val );
3044 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
3045 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR,
3046 sizeof( BINDMETHSTR ) - 1 ) )
3048 val = cargv[ i ] + sizeof( BINDMETHSTR );
3049 if ( !strcasecmp( val, SIMPLESTR )) {
3050 si->si_bindmethod = LDAP_AUTH_SIMPLE;
3052 } else if ( !strcasecmp( val, SASLSTR )) {
3053 #ifdef HAVE_CYRUS_SASL
3054 si->si_bindmethod = LDAP_AUTH_SASL;
3056 #else /* HAVE_CYRUS_SASL */
3057 fprintf( stderr, "Error: parse_syncrepl_line: "
3058 "not compiled with SASL support\n" );
3060 #endif /* HAVE_CYRUS_SASL */
3062 si->si_bindmethod = -1;
3064 } else if ( !strncasecmp( cargv[ i ],
3065 BINDDNSTR, sizeof( BINDDNSTR ) - 1 ) ) {
3066 val = cargv[ i ] + sizeof( BINDDNSTR );
3067 si->si_binddn = ch_strdup( val );
3068 } else if ( !strncasecmp( cargv[ i ],
3069 CREDSTR, sizeof( CREDSTR ) - 1 ) ) {
3070 val = cargv[ i ] + sizeof( CREDSTR );
3071 si->si_passwd = ch_strdup( val );
3072 } else if ( !strncasecmp( cargv[ i ],
3073 SASLMECHSTR, sizeof( SASLMECHSTR ) - 1 ) ) {
3074 val = cargv[ i ] + sizeof( SASLMECHSTR );
3075 si->si_saslmech = ch_strdup( val );
3076 } else if ( !strncasecmp( cargv[ i ],
3077 SECPROPSSTR, sizeof( SECPROPSSTR ) - 1 ) ) {
3078 val = cargv[ i ] + sizeof( SECPROPSSTR );
3079 si->si_secprops = ch_strdup( val );
3080 } else if ( !strncasecmp( cargv[ i ],
3081 REALMSTR, sizeof( REALMSTR ) - 1 ) ) {
3082 val = cargv[ i ] + sizeof( REALMSTR );
3083 si->si_realm = ch_strdup( val );
3084 } else if ( !strncasecmp( cargv[ i ],
3085 AUTHCSTR, sizeof( AUTHCSTR ) - 1 ) ) {
3086 val = cargv[ i ] + sizeof( AUTHCSTR );
3087 si->si_authcId = ch_strdup( val );
3088 } else if ( !strncasecmp( cargv[ i ],
3089 OLDAUTHCSTR, sizeof( OLDAUTHCSTR ) - 1 ) ) {
3090 /* Old authcID is provided for some backwards compatibility */
3091 val = cargv[ i ] + sizeof( OLDAUTHCSTR );
3092 si->si_authcId = ch_strdup( val );
3093 } else if ( !strncasecmp( cargv[ i ],
3094 AUTHZSTR, sizeof( AUTHZSTR ) - 1 ) ) {
3095 val = cargv[ i ] + sizeof( AUTHZSTR );
3096 si->si_authzId = ch_strdup( val );
3097 } else if ( !strncasecmp( cargv[ i ],
3098 SCHEMASTR, sizeof( SCHEMASTR ) - 1 ) )
3100 val = cargv[ i ] + sizeof( SCHEMASTR );
3101 if ( !strncasecmp( val, "on", sizeof( "on" ) - 1 )) {
3102 si->si_schemachecking = 1;
3103 } else if ( !strncasecmp( val, "off", sizeof( "off" ) - 1 ) ) {
3104 si->si_schemachecking = 0;
3106 si->si_schemachecking = 1;
3108 } else if ( !strncasecmp( cargv[ i ],
3109 FILTERSTR, sizeof( FILTERSTR ) - 1 ) )
3111 val = cargv[ i ] + sizeof( FILTERSTR );
3112 ber_str2bv( val, 0, 1, &si->si_filterstr );
3113 } else if ( !strncasecmp( cargv[ i ],
3114 SEARCHBASESTR, sizeof( SEARCHBASESTR ) - 1 ) )
3117 val = cargv[ i ] + sizeof( SEARCHBASESTR );
3118 if ( si->si_base.bv_val ) {
3119 ch_free( si->si_base.bv_val );
3121 ber_str2bv( val, 0, 0, &bv );
3122 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
3123 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
3126 } else if ( !strncasecmp( cargv[ i ],
3127 SCOPESTR, sizeof( SCOPESTR ) - 1 ) )
3129 val = cargv[ i ] + sizeof( SCOPESTR );
3130 if ( !strncasecmp( val, "base", sizeof( "base" ) - 1 )) {
3131 si->si_scope = LDAP_SCOPE_BASE;
3132 } else if ( !strncasecmp( val, "one", sizeof( "one" ) - 1 )) {
3133 si->si_scope = LDAP_SCOPE_ONELEVEL;
3134 #ifdef LDAP_SCOPE_SUBORDINATE
3135 } else if ( !strcasecmp( val, "subordinate" ) ||
3136 !strcasecmp( val, "children" ))
3138 si->si_scope = LDAP_SCOPE_SUBORDINATE;
3140 } else if ( !strncasecmp( val, "sub", sizeof( "sub" ) - 1 )) {
3141 si->si_scope = LDAP_SCOPE_SUBTREE;
3143 fprintf( stderr, "Error: parse_syncrepl_line: "
3144 "unknown scope \"%s\"\n", val);
3147 } else if ( !strncasecmp( cargv[ i ],
3148 ATTRSONLYSTR, sizeof( ATTRSONLYSTR ) - 1 ) )
3150 si->si_attrsonly = 1;
3151 } else if ( !strncasecmp( cargv[ i ],
3152 ATTRSSTR, sizeof( ATTRSSTR ) - 1 ) )
3154 val = cargv[ i ] + sizeof( ATTRSSTR );
3155 str2clist( &si->si_attrs, val, "," );
3156 } else if ( !strncasecmp( cargv[ i ],
3157 TYPESTR, sizeof( TYPESTR ) - 1 ) )
3159 val = cargv[ i ] + sizeof( TYPESTR );
3160 if ( !strncasecmp( val, "refreshOnly", sizeof("refreshOnly")-1 )) {
3161 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3162 } else if ( !strncasecmp( val, "refreshAndPersist",
3163 sizeof("refreshAndPersist")-1 ))
3165 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
3166 si->si_interval = 60;
3168 fprintf( stderr, "Error: parse_syncrepl_line: "
3169 "unknown sync type \"%s\"\n", val);
3172 } else if ( !strncasecmp( cargv[ i ],
3173 INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) )
3175 val = cargv[ i ] + sizeof( INTERVALSTR );
3176 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
3177 si->si_interval = 0;
3185 hstr = strchr( dstr, ':' );
3186 if ( hstr == NULL ) {
3187 fprintf( stderr, "Error: parse_syncrepl_line: "
3188 "invalid interval \"%s\"\n", val );
3192 mstr = strchr( hstr, ':' );
3193 if ( mstr == NULL ) {
3194 fprintf( stderr, "Error: parse_syncrepl_line: "
3195 "invalid interval \"%s\"\n", val );
3199 sstr = strchr( mstr, ':' );
3200 if ( sstr == NULL ) {
3201 fprintf( stderr, "Error: parse_syncrepl_line: "
3202 "invalid interval \"%s\"\n", val );
3211 if (( hh > 24 ) || ( hh < 0 ) ||
3212 ( mm > 60 ) || ( mm < 0 ) ||
3213 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
3214 fprintf( stderr, "Error: parse_syncrepl_line: "
3215 "invalid interval \"%s\"\n", val );
3218 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
3220 if ( si->si_interval < 0 ) {
3221 fprintf( stderr, "Error: parse_syncrepl_line: "
3222 "invalid interval \"%ld\"\n",
3223 (long) si->si_interval);
3226 } else if ( !strncasecmp( cargv[ i ],
3227 MANAGEDSAITSTR, sizeof( MANAGEDSAITSTR ) - 1 ) )
3229 val = cargv[ i ] + sizeof( MANAGEDSAITSTR );
3230 si->si_manageDSAit = atoi( val );
3231 } else if ( !strncasecmp( cargv[ i ],
3232 SLIMITSTR, sizeof( SLIMITSTR ) - 1 ) )
3234 val = cargv[ i ] + sizeof( SLIMITSTR );
3235 si->si_slimit = atoi( val );
3236 } else if ( !strncasecmp( cargv[ i ],
3237 TLIMITSTR, sizeof( TLIMITSTR ) - 1 ) )
3239 val = cargv[ i ] + sizeof( TLIMITSTR );
3240 si->si_tlimit = atoi( val );
3242 fprintf( stderr, "Error: parse_syncrepl_line: "
3243 "unknown keyword \"%s\"\n", cargv[ i ] );
3247 if ( gots != GOT_ALL ) {
3249 "Error: Malformed \"syncrepl\" line in slapd config file" );
3257 str2clist( char ***out, char *in, const char *brkstr )
3266 /* find last element in list */
3267 for (i = 0; *out && *out[i]; i++);
3269 /* protect the input string from strtok */
3270 str = ch_strdup( in );
3272 if ( *str == '\0' ) {
3277 /* Count words in string */
3279 for ( s = str; *s; s++ ) {
3280 if ( strchr( brkstr, *s ) != NULL ) {
3285 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
3287 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
3289 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
3291 *new = ch_strdup( s );