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",
639 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
641 LDAP_LOG( CONFIG, CRIT,
642 "%s: line %d: password scheme \"%s\" not available\n",
643 fname, lineno, cargv[1] );
645 Debug( LDAP_DEBUG_ANY,
646 "%s: line %d: password scheme \"%s\" not available\n",
647 fname, lineno, cargv[1] );
652 default_passwd_hash = ch_strdup( cargv[1] );
654 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
658 LDAP_LOG( CONFIG, CRIT,
659 "%s: line %d: missing format in "
660 "\"password-crypt-salt-format <format>\" line\n",
663 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
664 "\"password-crypt-salt-format <format>\" line\n",
671 lutil_salt_format( cargv[1] );
673 /* SASL config options */
674 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
675 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
678 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
682 LDAP_LOG( CONFIG, CRIT,
683 "%s: line %d: missing dn in "
684 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
686 Debug( LDAP_DEBUG_ANY,
687 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
692 ber_str2bv( cargv[1], 0, 0, &dn );
694 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
695 &be->be_schemandn, NULL );
697 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
698 &global_schemandn, NULL );
700 if ( rc != LDAP_SUCCESS ) {
702 LDAP_LOG( CONFIG, CRIT,
703 "%s: line %d: schemadn DN is invalid.\n",
706 Debug( LDAP_DEBUG_ANY,
707 "%s: line %d: schemadn DN is invalid\n",
713 /* set UCDATA path */
714 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
718 LDAP_LOG( CONFIG, CRIT,
719 "%s: line %d: missing path in "
720 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
722 Debug( LDAP_DEBUG_ANY,
723 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
730 err = load_ucdata( cargv[1] );
734 LDAP_LOG( CONFIG, CRIT,
735 "%s: line %d: ucdata already loaded, ucdata-path "
736 "must be set earlier in the file and/or be "
737 "specified only once!\n", fname, lineno, 0 );
739 Debug( LDAP_DEBUG_ANY,
740 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
749 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
751 struct slap_limits_set *lim;
755 LDAP_LOG( CONFIG, CRIT,
756 "%s: line %d: missing limit in \"sizelimit <limit>\" "
757 "line.\n", fname, lineno, 0 );
759 Debug( LDAP_DEBUG_ANY,
760 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
770 lim = &be->be_def_limit;
773 for ( i = 1; i < cargc; i++ ) {
774 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
775 rc = parse_limit( cargv[i], lim );
778 LDAP_LOG( CONFIG, CRIT,
779 "%s: line %d: unable "
780 "to parse value \"%s\" in \"sizelimit "
781 "<limit>\" line.\n", fname, lineno, cargv[i] );
783 Debug( LDAP_DEBUG_ANY,
784 "%s: line %d: unable "
785 "to parse value \"%s\" "
788 fname, lineno, cargv[i] );
794 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
795 lim->lms_s_soft = -1;
799 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
800 if ( next == cargv[i] ) {
802 LDAP_LOG( CONFIG, CRIT,
803 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
804 "line.\n", fname, lineno, cargv[i] );
806 Debug( LDAP_DEBUG_ANY,
807 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
808 fname, lineno, cargv[i] );
812 } else if ( next[0] != '\0' ) {
814 LDAP_LOG( CONFIG, CRIT,
815 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
816 "line ignored.\n", fname, lineno, next );
818 Debug( LDAP_DEBUG_ANY,
819 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
820 fname, lineno, next );
829 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
831 struct slap_limits_set *lim;
835 LDAP_LOG( CONFIG, CRIT,
836 "%s: line %d missing limit in \"timelimit <limit>\" "
837 "line.\n", fname, lineno, 0 );
839 Debug( LDAP_DEBUG_ANY,
840 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
850 lim = &be->be_def_limit;
853 for ( i = 1; i < cargc; i++ ) {
854 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
855 rc = parse_limit( cargv[i], lim );
858 LDAP_LOG( CONFIG, CRIT,
859 "%s: line %d: unable to parse value \"%s\" "
860 "in \"timelimit <limit>\" line.\n",
861 fname, lineno, cargv[i] );
863 Debug( LDAP_DEBUG_ANY,
864 "%s: line %d: unable "
865 "to parse value \"%s\" "
868 fname, lineno, cargv[i] );
874 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
875 lim->lms_t_soft = -1;
879 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
880 if ( next == cargv[i] ) {
882 LDAP_LOG( CONFIG, CRIT,
883 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
884 "line.\n", fname, lineno, cargv[i] );
886 Debug( LDAP_DEBUG_ANY,
887 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
888 fname, lineno, cargv[i] );
892 } else if ( next[0] != '\0' ) {
894 LDAP_LOG( CONFIG, CRIT,
895 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
896 "line ignored.\n", fname, lineno, next );
898 Debug( LDAP_DEBUG_ANY,
899 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
900 fname, lineno, next );
908 /* set regex-based limits */
909 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
912 LDAP_LOG( CONFIG, WARNING,
913 "%s: line %d \"limits\" allowed only in database "
914 "environment.\n", fname, lineno, 0 );
916 Debug( LDAP_DEBUG_ANY,
917 "%s: line %d \"limits\" allowed only in database environment.\n%s",
923 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
927 /* mark this as a subordinate database */
928 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
931 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
932 "subordinate keyword must appear inside a database "
933 "definition.\n", fname, lineno, 0 );
935 Debug( LDAP_DEBUG_ANY, "%s: line %d: subordinate keyword "
936 "must appear inside a database definition.\n",
942 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
946 /* add an overlay to this backend */
947 } else if ( strcasecmp( cargv[0], "overlay" ) == 0 ) {
950 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
951 "overlay keyword must appear inside a database "
952 "definition.\n", fname, lineno, 0 );
954 Debug( LDAP_DEBUG_ANY, "%s: line %d: overlay keyword "
955 "must appear inside a database definition.\n",
960 } else if ( overlay_config( be, cargv[1] )) {
964 /* set database suffix */
965 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
967 struct berval dn, pdn, ndn;
971 LDAP_LOG( CONFIG, CRIT,
972 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
975 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
976 "missing dn in \"suffix <dn>\" line\n",
982 } else if ( cargc > 2 ) {
984 LDAP_LOG( CONFIG, INFO,
985 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
986 " line (ignored).\n", fname, lineno, cargv[1] );
988 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
989 "after <dn> in \"suffix %s\" line (ignored)\n",
990 fname, lineno, cargv[1] );
996 LDAP_LOG( CONFIG, INFO,
997 "%s: line %d: suffix line must appear inside a database "
998 "definition.\n", fname, lineno, 0 );
1000 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
1001 "must appear inside a database definition\n",
1006 #if defined(SLAPD_MONITOR_DN)
1007 /* "cn=Monitor" is reserved for monitoring slap */
1008 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
1010 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
1011 "%s\" is reserved for monitoring slapd\n",
1012 fname, lineno, SLAPD_MONITOR_DN );
1014 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
1015 "%s\" is reserved for monitoring slapd\n",
1016 fname, lineno, SLAPD_MONITOR_DN );
1019 #endif /* SLAPD_MONITOR_DN */
1022 if ( load_ucdata( NULL ) < 0 ) return 1;
1024 dn.bv_val = cargv[1];
1025 dn.bv_len = strlen( cargv[1] );
1027 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
1028 if( rc != LDAP_SUCCESS ) {
1030 LDAP_LOG( CONFIG, CRIT,
1031 "%s: line %d: suffix DN is invalid.\n",
1034 Debug( LDAP_DEBUG_ANY,
1035 "%s: line %d: suffix DN is invalid\n",
1041 tmp_be = select_backend( &ndn, 0, 0 );
1042 if ( tmp_be == be ) {
1044 LDAP_LOG( CONFIG, INFO,
1045 "%s: line %d: suffix already served by this backend "
1046 "(ignored)\n", fname, lineno, 0 );
1048 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1049 "already served by this backend (ignored)\n",
1055 } else if ( tmp_be != NULL ) {
1057 LDAP_LOG( CONFIG, INFO,
1058 "%s: line %d: suffix already served by a preceding "
1059 "backend \"%s\"\n", fname, lineno,
1060 tmp_be->be_suffix[0].bv_val );
1062 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1063 "already served by a preceeding backend \"%s\"\n",
1064 fname, lineno, tmp_be->be_suffix[0].bv_val );
1070 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
1072 LDAP_LOG( CONFIG, INFO,
1073 "%s: line %d: suffix DN empty and default search "
1074 "base provided \"%s\" (assuming okay).\n",
1075 fname, lineno, default_search_base.bv_val );
1077 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1078 "suffix DN empty and default "
1079 "search base provided \"%s\" (assuming okay)\n",
1080 fname, lineno, default_search_base.bv_val );
1084 ber_bvarray_add( &be->be_suffix, &pdn );
1085 ber_bvarray_add( &be->be_nsuffix, &ndn );
1087 /* set max deref depth */
1088 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1092 LDAP_LOG( CONFIG, CRIT,
1093 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1094 " line\n", fname, lineno, 0 );
1096 Debug( LDAP_DEBUG_ANY,
1097 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1105 LDAP_LOG( CONFIG, INFO,
1106 "%s: line %d: depth line must appear inside a database "
1107 "definition.\n", fname, lineno ,0 );
1109 Debug( LDAP_DEBUG_ANY,
1110 "%s: line %d: depth line must appear inside a database definition.\n",
1115 } else if ((i = atoi(cargv[1])) < 0) {
1117 LDAP_LOG( CONFIG, INFO,
1118 "%s: line %d: depth must be positive.\n",
1121 Debug( LDAP_DEBUG_ANY,
1122 "%s: line %d: depth must be positive.\n",
1129 be->be_max_deref_depth = i;
1133 /* set magic "root" dn for this database */
1134 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1137 LDAP_LOG( CONFIG, INFO,
1138 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1141 Debug( LDAP_DEBUG_ANY,
1142 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1151 LDAP_LOG( CONFIG, INFO,
1152 "%s: line %d: rootdn line must appear inside a database "
1153 "definition.\n", fname, lineno ,0 );
1155 Debug( LDAP_DEBUG_ANY,
1156 "%s: line %d: rootdn line must appear inside a database definition.\n",
1164 if ( load_ucdata( NULL ) < 0 ) return 1;
1166 dn.bv_val = cargv[1];
1167 dn.bv_len = strlen( cargv[1] );
1169 rc = dnPrettyNormal( NULL, &dn,
1171 &be->be_rootndn, NULL );
1173 if( rc != LDAP_SUCCESS ) {
1175 LDAP_LOG( CONFIG, CRIT,
1176 "%s: line %d: rootdn DN is invalid.\n",
1179 Debug( LDAP_DEBUG_ANY,
1180 "%s: line %d: rootdn DN is invalid\n",
1187 /* set super-secret magic database password */
1188 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1191 LDAP_LOG( CONFIG, CRIT,
1192 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1193 " line\n", fname, lineno ,0 );
1195 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1196 "missing passwd in \"rootpw <passwd>\" line\n",
1205 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1206 "rootpw line must appear inside a database "
1207 "definition.\n", fname, lineno ,0 );
1209 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1210 "rootpw line must appear inside a database "
1217 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1219 if( tmp_be != be ) {
1221 LDAP_LOG( CONFIG, INFO,
1223 "rootpw can only be set when rootdn is under suffix\n",
1224 fname, lineno, "" );
1226 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1227 "rootpw can only be set when rootdn is under suffix\n",
1233 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1234 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1237 /* make this database read-only */
1238 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1241 LDAP_LOG( CONFIG, CRIT,
1242 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1243 "line.\n", fname, lineno ,0 );
1245 Debug( LDAP_DEBUG_ANY,
1246 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1253 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1254 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1256 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1259 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1260 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1262 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1267 /* allow these features */
1268 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1269 strcasecmp( cargv[0], "allow" ) == 0 )
1275 LDAP_LOG( CONFIG, INFO,
1276 "%s: line %d: allow line must appear prior to "
1277 "database definitions.\n", fname, lineno ,0 );
1279 Debug( LDAP_DEBUG_ANY,
1280 "%s: line %d: allow line must appear prior to database definitions\n",
1288 LDAP_LOG( CONFIG, CRIT,
1289 "%s: line %d: missing feature(s) in \"allow <features>\""
1290 " line\n", fname, lineno ,0 );
1292 Debug( LDAP_DEBUG_ANY,
1293 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1302 for( i=1; i < cargc; i++ ) {
1303 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1304 allows |= SLAP_ALLOW_BIND_V2;
1306 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1307 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1309 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1310 allows |= SLAP_ALLOW_BIND_ANON_DN;
1312 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1313 allows |= SLAP_ALLOW_UPDATE_ANON;
1315 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1317 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1318 "unknown feature %s in \"allow <features>\" line.\n",
1319 fname, lineno, cargv[1] );
1321 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1322 "unknown feature %s in \"allow <features>\" line\n",
1323 fname, lineno, cargv[i] );
1330 global_allows = allows;
1332 /* disallow these features */
1333 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1334 strcasecmp( cargv[0], "disallow" ) == 0 )
1336 slap_mask_t disallows;
1340 LDAP_LOG( CONFIG, INFO,
1341 "%s: line %d: disallow line must appear prior to "
1342 "database definitions.\n", fname, lineno ,0 );
1344 Debug( LDAP_DEBUG_ANY,
1345 "%s: line %d: disallow line must appear prior to database definitions\n",
1353 LDAP_LOG( CONFIG, CRIT,
1354 "%s: line %d: missing feature(s) in \"disallow <features>\""
1355 " line.\n", fname, lineno ,0 );
1357 Debug( LDAP_DEBUG_ANY,
1358 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1367 for( i=1; i < cargc; i++ ) {
1368 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1369 disallows |= SLAP_DISALLOW_BIND_ANON;
1371 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1372 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1374 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1375 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1377 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1378 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1380 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1381 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1383 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1385 LDAP_LOG( CONFIG, CRIT,
1386 "%s: line %d: unknown feature %s in "
1387 "\"disallow <features>\" line.\n",
1388 fname, lineno, cargv[i] );
1390 Debug( LDAP_DEBUG_ANY,
1391 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1392 fname, lineno, cargv[i] );
1399 global_disallows = disallows;
1401 /* require these features */
1402 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1403 strcasecmp( cargv[0], "require" ) == 0 )
1405 slap_mask_t requires;
1409 LDAP_LOG( CONFIG, CRIT,
1410 "%s: line %d: missing feature(s) in "
1411 "\"require <features>\" line.\n", fname, lineno ,0 );
1413 Debug( LDAP_DEBUG_ANY,
1414 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1423 for( i=1; i < cargc; i++ ) {
1424 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1425 requires |= SLAP_REQUIRE_BIND;
1427 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1428 requires |= SLAP_REQUIRE_LDAP_V3;
1430 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1431 requires |= SLAP_REQUIRE_AUTHC;
1433 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1434 requires |= SLAP_REQUIRE_SASL;
1436 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1437 requires |= SLAP_REQUIRE_STRONG;
1439 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1441 LDAP_LOG( CONFIG, CRIT,
1442 "%s: line %d: unknown feature %s in "
1443 "\"require <features>\" line.\n",
1444 fname, lineno , cargv[i] );
1446 Debug( LDAP_DEBUG_ANY,
1447 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1448 fname, lineno, cargv[i] );
1456 global_requires = requires;
1458 be->be_requires = requires;
1461 /* required security factors */
1462 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1463 slap_ssf_set_t *set;
1467 LDAP_LOG( CONFIG, CRIT,
1468 "%s: line %d: missing factor(s) in \"security <factors>\""
1469 " line.\n", fname, lineno ,0 );
1471 Debug( LDAP_DEBUG_ANY,
1472 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1480 set = &global_ssf_set;
1482 set = &be->be_ssf_set;
1485 for( i=1; i < cargc; i++ ) {
1486 if( strncasecmp( cargv[i], "ssf=",
1487 sizeof("ssf") ) == 0 )
1490 atoi( &cargv[i][sizeof("ssf")] );
1492 } else if( strncasecmp( cargv[i], "transport=",
1493 sizeof("transport") ) == 0 )
1495 set->sss_transport =
1496 atoi( &cargv[i][sizeof("transport")] );
1498 } else if( strncasecmp( cargv[i], "tls=",
1499 sizeof("tls") ) == 0 )
1502 atoi( &cargv[i][sizeof("tls")] );
1504 } else if( strncasecmp( cargv[i], "sasl=",
1505 sizeof("sasl") ) == 0 )
1508 atoi( &cargv[i][sizeof("sasl")] );
1510 } else if( strncasecmp( cargv[i], "update_ssf=",
1511 sizeof("update_ssf") ) == 0 )
1513 set->sss_update_ssf =
1514 atoi( &cargv[i][sizeof("update_ssf")] );
1516 } else if( strncasecmp( cargv[i], "update_transport=",
1517 sizeof("update_transport") ) == 0 )
1519 set->sss_update_transport =
1520 atoi( &cargv[i][sizeof("update_transport")] );
1522 } else if( strncasecmp( cargv[i], "update_tls=",
1523 sizeof("update_tls") ) == 0 )
1525 set->sss_update_tls =
1526 atoi( &cargv[i][sizeof("update_tls")] );
1528 } else if( strncasecmp( cargv[i], "update_sasl=",
1529 sizeof("update_sasl") ) == 0 )
1531 set->sss_update_sasl =
1532 atoi( &cargv[i][sizeof("update_sasl")] );
1534 } else if( strncasecmp( cargv[i], "simple_bind=",
1535 sizeof("simple_bind") ) == 0 )
1537 set->sss_simple_bind =
1538 atoi( &cargv[i][sizeof("simple_bind")] );
1542 LDAP_LOG( CONFIG, CRIT,
1543 "%s: line %d: unknown factor %S in "
1544 "\"security <factors>\" line.\n",
1545 fname, lineno, cargv[1] );
1547 Debug( LDAP_DEBUG_ANY,
1548 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1549 fname, lineno, cargv[i] );
1555 /* where to send clients when we don't hold it */
1556 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1559 LDAP_LOG( CONFIG, CRIT,
1560 "%s: line %d: missing URL in \"referral <URL>\""
1561 " line.\n", fname, lineno , 0 );
1563 Debug( LDAP_DEBUG_ANY,
1564 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1571 if( validate_global_referral( cargv[1] ) ) {
1573 LDAP_LOG( CONFIG, CRIT,
1574 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1575 fname, lineno, cargv[1] );
1577 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1578 "invalid URL (%s) in \"referral\" line.\n",
1579 fname, lineno, cargv[1] );
1584 vals[0].bv_val = cargv[1];
1585 vals[0].bv_len = strlen( vals[0].bv_val );
1586 if( value_add( &default_referral, vals ) )
1590 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1594 LDAP_LOG( CONFIG, CRIT,
1595 "%s: line %d: Error in logfile directive, "
1596 "\"logfile <filename>\"\n", fname, lineno , 0 );
1598 Debug( LDAP_DEBUG_ANY,
1599 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1605 logfile = fopen( cargv[1], "w" );
1606 if ( logfile != NULL ) lutil_debug_file( logfile );
1609 /* start of a new database definition */
1610 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1614 LDAP_LOG( CONFIG, CRIT,
1615 "%s: line %d: Error in debug directive, "
1616 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1618 Debug( LDAP_DEBUG_ANY,
1619 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1625 level = atoi( cargv[2] );
1626 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1627 lutil_set_debug_level( cargv[1], level );
1628 /* specify an Object Identifier macro */
1629 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1630 rc = parse_oidm( fname, lineno, cargc, cargv );
1633 /* specify an objectclass */
1634 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1637 LDAP_LOG( CONFIG, INFO,
1638 "%s: line %d: illegal objectclass format.\n",
1639 fname, lineno , 0 );
1641 Debug( LDAP_DEBUG_ANY,
1642 "%s: line %d: illegal objectclass format.\n",
1647 } else if ( *cargv[1] == '(' /*')'*/) {
1649 p = strchr(saveline,'(' /*')'*/);
1650 rc = parse_oc( fname, lineno, p, cargv );
1655 LDAP_LOG( CONFIG, INFO,
1656 "%s: line %d: old objectclass format not supported\n",
1657 fname, lineno , 0 );
1659 Debug( LDAP_DEBUG_ANY,
1660 "%s: line %d: old objectclass format not supported.\n",
1665 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1667 p = strchr(saveline,'(' /*')'*/);
1668 rc = parse_cr( fname, lineno, p, cargv );
1671 /* specify an attribute type */
1672 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1673 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1677 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1678 "illegal attribute type format.\n",
1679 fname, lineno , 0 );
1681 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1682 "illegal attribute type format.\n",
1687 } else if ( *cargv[1] == '(' /*')'*/) {
1689 p = strchr(saveline,'(' /*')'*/);
1690 rc = parse_at( fname, lineno, p, cargv );
1695 LDAP_LOG( CONFIG, INFO,
1696 "%s: line %d: old attribute type format not supported.\n",
1697 fname, lineno , 0 );
1699 Debug( LDAP_DEBUG_ANY,
1700 "%s: line %d: old attribute type format not supported.\n",
1706 /* define attribute option(s) */
1707 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1708 ad_define_option( NULL, NULL, 0 );
1709 for ( i = 1; i < cargc; i++ )
1710 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1713 /* turn on/off schema checking */
1714 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1717 LDAP_LOG( CONFIG, CRIT,
1718 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1719 " line.\n", fname, lineno , 0 );
1721 Debug( LDAP_DEBUG_ANY,
1722 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1728 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1730 LDAP_LOG( CONFIG, CRIT,
1731 "%s: line %d: schema checking disabled! your mileage may "
1732 "vary!\n", fname, lineno , 0 );
1734 Debug( LDAP_DEBUG_ANY,
1735 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1738 global_schemacheck = 0;
1740 global_schemacheck = 1;
1743 /* specify access control info */
1744 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1745 parse_acl( be, fname, lineno, cargc, cargv );
1747 /* debug level to log things to syslog */
1748 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1751 LDAP_LOG( CONFIG, CRIT,
1752 "%s: line %d: missing level in \"loglevel <level>\""
1753 " line.\n", fname, lineno , 0 );
1755 Debug( LDAP_DEBUG_ANY,
1756 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1765 for( i=1; i < cargc; i++ ) {
1766 ldap_syslog += atoi( cargv[1] );
1769 /* list of sync replication information in this backend (slave only) */
1770 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
1774 LDAP_LOG( CONFIG, INFO,
1775 "%s: line %d: syncrepl line must appear inside "
1776 "a database definition.\n", fname, lineno, 0);
1778 Debug( LDAP_DEBUG_ANY,
1779 "%s: line %d: syncrepl line must appear inside "
1780 "a database definition.\n", fname, lineno, 0);
1784 if ( add_syncrepl( be, cargv, cargc )) {
1789 /* list of replicas of the data in this backend (master only) */
1790 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1793 LDAP_LOG( CONFIG, CRIT,
1794 "%s: line %d: missing host or uri in \"replica "
1795 " <host[:port]\" line\n", fname, lineno , 0 );
1797 Debug( LDAP_DEBUG_ANY,
1798 "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
1806 LDAP_LOG( CONFIG, INFO,
1807 "%s: line %d: replica line must appear inside "
1808 "a database definition.\n", fname, lineno, 0);
1810 Debug( LDAP_DEBUG_ANY,
1811 "%s: line %d: replica line must appear inside a database definition\n",
1819 for ( i = 1; i < cargc; i++ ) {
1820 if ( strncasecmp( cargv[i], "host=", 5 )
1822 nr = add_replica_info( be,
1825 } else if (strncasecmp( cargv[i], "uri=", 4 )
1827 if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
1830 LDAP_LOG( CONFIG, INFO,
1831 "%s: line %d: replica line contains invalid "
1832 "uri definition.\n", fname, lineno, 0);
1834 Debug( LDAP_DEBUG_ANY,
1835 "%s: line %d: replica line contains invalid "
1836 "uri definition.\n", fname, lineno, 0);
1840 if (ludp->lud_host == NULL ) {
1842 LDAP_LOG( CONFIG, INFO,
1843 "%s: line %d: replica line contains invalid "
1844 "uri definition - missing hostname.\n",
1847 Debug( LDAP_DEBUG_ANY,
1848 "%s: line %d: replica line contains invalid "
1849 "uri definition - missing hostname.\n", fname, lineno, 0);
1853 replicahost = ch_malloc( strlen( cargv[ i ] ) );
1854 if ( replicahost == NULL ) {
1856 LDAP_LOG( CONFIG, ERR,
1857 "out of memory in read_config\n", 0, 0,0 );
1859 Debug( LDAP_DEBUG_ANY,
1860 "out of memory in read_config\n", 0, 0, 0 );
1862 ldap_free_urldesc( ludp );
1863 exit( EXIT_FAILURE );
1865 sprintf(replicahost, "%s:%d",
1866 ludp->lud_host, ludp->lud_port);
1867 nr = add_replica_info( be, replicahost );
1868 ldap_free_urldesc( ludp );
1869 ch_free(replicahost);
1875 LDAP_LOG( CONFIG, INFO,
1876 "%s: line %d: missing host or uri in \"replica\" line\n",
1877 fname, lineno , 0 );
1879 Debug( LDAP_DEBUG_ANY,
1880 "%s: line %d: missing host or uri in \"replica\" line\n",
1885 } else if ( nr == -1 ) {
1887 LDAP_LOG( CONFIG, INFO,
1888 "%s: line %d: unable to add"
1889 " replica \"%s\"\n",
1893 Debug( LDAP_DEBUG_ANY,
1894 "%s: line %d: unable to add replica \"%s\"\n",
1895 fname, lineno, cargv[i] + 5 );
1899 for ( i = 1; i < cargc; i++ ) {
1900 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1902 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1905 LDAP_LOG( CONFIG, INFO,
1906 "%s: line %d: suffix \"%s\" in \"replica\""
1907 " line is not valid for backend(ignored)\n",
1908 fname, lineno, cargv[i] + 7 );
1910 Debug( LDAP_DEBUG_ANY,
1911 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1912 fname, lineno, cargv[i] + 7 );
1918 LDAP_LOG( CONFIG, INFO,
1919 "%s: line %d: unable to normalize suffix"
1920 " in \"replica\" line (ignored)\n",
1921 fname, lineno , 0 );
1923 Debug( LDAP_DEBUG_ANY,
1924 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1930 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1932 char *arg = cargv[i] + 4;
1934 if ( arg[0] == '!' ) {
1939 if ( arg[0] != '=' ) {
1943 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1945 LDAP_LOG( CONFIG, INFO,
1946 "%s: line %d: attribute \"%s\" in "
1947 "\"replica\" line is unknown\n",
1948 fname, lineno, arg + 1 );
1950 Debug( LDAP_DEBUG_ANY,
1951 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1952 fname, lineno, arg + 1 );
1961 /* dn of slave entity allowed to write to replica */
1962 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1965 LDAP_LOG( CONFIG, CRIT,
1966 "%s: line %d: missing dn in \"updatedn <dn>\""
1967 " line.\n", fname, lineno , 0 );
1969 Debug( LDAP_DEBUG_ANY,
1970 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1978 LDAP_LOG( CONFIG, INFO,
1979 "%s: line %d: updatedn line must appear inside "
1980 "a database definition\n",
1981 fname, lineno , 0 );
1983 Debug( LDAP_DEBUG_ANY,
1984 "%s: line %d: updatedn line must appear inside a database definition\n",
1992 if ( load_ucdata( NULL ) < 0 ) return 1;
1994 dn.bv_val = cargv[1];
1995 dn.bv_len = strlen( cargv[1] );
1997 rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
1998 if( rc != LDAP_SUCCESS ) {
2000 LDAP_LOG( CONFIG, CRIT,
2001 "%s: line %d: updatedn DN is invalid.\n",
2002 fname, lineno , 0 );
2004 Debug( LDAP_DEBUG_ANY,
2005 "%s: line %d: updatedn DN is invalid\n",
2012 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
2015 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2016 "missing url in \"updateref <ldapurl>\" line.\n",
2017 fname, lineno , 0 );
2019 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2020 "missing url in \"updateref <ldapurl>\" line\n",
2028 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
2029 " line must appear inside a database definition\n",
2030 fname, lineno , 0 );
2032 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
2033 " line must appear inside a database definition\n",
2038 } else if ( !be->be_update_ndn.bv_len ) {
2040 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
2041 "updateref line must come after updatedn.\n",
2042 fname, lineno , 0 );
2044 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2045 "updateref line must after updatedn.\n",
2051 if( validate_global_referral( cargv[1] ) ) {
2053 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2054 "invalid URL (%s) in \"updateref\" line.\n",
2055 fname, lineno, cargv[1] );
2057 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2058 "invalid URL (%s) in \"updateref\" line.\n",
2059 fname, lineno, cargv[1] );
2064 vals[0].bv_val = cargv[1];
2065 vals[0].bv_len = strlen( vals[0].bv_val );
2066 if( value_add( &be->be_update_refs, vals ) )
2069 /* replication log file to which changes are appended */
2070 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
2073 LDAP_LOG( CONFIG, CRIT,
2074 "%s: line %d: missing filename in \"replogfile <filename>\""
2075 " line.\n", fname, lineno , 0 );
2077 Debug( LDAP_DEBUG_ANY,
2078 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2085 be->be_replogfile = ch_strdup( cargv[1] );
2087 replogfile = ch_strdup( cargv[1] );
2090 /* file from which to read additional rootdse attrs */
2091 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2094 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2095 "missing filename in \"rootDSE <filename>\" line.\n",
2096 fname, lineno , 0 );
2098 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2099 "missing filename in \"rootDSE <filename>\" line.\n",
2105 if( read_root_dse_file( cargv[1] ) ) {
2107 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2108 "could not read \"rootDSE <filename>\" line.\n",
2109 fname, lineno , 0 );
2111 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2112 "could not read \"rootDSE <filename>\" line\n",
2118 /* maintain lastmodified{by,time} attributes */
2119 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2122 LDAP_LOG( CONFIG, CRIT,
2123 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2124 " line.\n", fname, lineno , 0 );
2126 Debug( LDAP_DEBUG_ANY,
2127 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2133 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2135 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2141 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2148 /* turn on/off gentle SIGHUP handling */
2149 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2151 Debug( LDAP_DEBUG_ANY,
2152 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2156 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2157 global_gentlehup = 0;
2159 global_gentlehup = 1;
2163 /* set idle timeout value */
2164 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2168 LDAP_LOG( CONFIG, CRIT,
2169 "%s: line %d: missing timeout value in "
2170 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2172 Debug( LDAP_DEBUG_ANY,
2173 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2180 i = atoi( cargv[1] );
2184 LDAP_LOG( CONFIG, CRIT,
2185 "%s: line %d: timeout value (%d) invalid "
2186 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2188 Debug( LDAP_DEBUG_ANY,
2189 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2196 global_idletimeout = i;
2198 /* include another config file */
2199 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2202 LDAP_LOG( CONFIG, CRIT,
2203 "%s: line %d: missing filename in \"include "
2204 "<filename>\" line.\n", fname, lineno , 0 );
2206 Debug( LDAP_DEBUG_ANY,
2207 "%s: line %d: missing filename in \"include <filename>\" line\n",
2213 savefname = ch_strdup( cargv[1] );
2214 savelineno = lineno;
2216 if ( read_config( savefname, depth+1 ) != 0 ) {
2221 lineno = savelineno - 1;
2223 /* location of kerberos srvtab file */
2224 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2227 LDAP_LOG( CONFIG, CRIT,
2228 "%s: line %d: missing filename in \"srvtab "
2229 "<filename>\" line.\n", fname, lineno , 0 );
2231 Debug( LDAP_DEBUG_ANY,
2232 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2238 ldap_srvtab = ch_strdup( cargv[1] );
2240 #ifdef SLAPD_MODULES
2241 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2244 LDAP_LOG( CONFIG, INFO,
2245 "%s: line %d: missing filename in \"moduleload "
2246 "<filename>\" line.\n", fname, lineno , 0 );
2248 Debug( LDAP_DEBUG_ANY,
2249 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2253 exit( EXIT_FAILURE );
2255 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2257 LDAP_LOG( CONFIG, CRIT,
2258 "%s: line %d: failed to load or initialize module %s\n",
2259 fname, lineno, cargv[1] );
2261 Debug( LDAP_DEBUG_ANY,
2262 "%s: line %d: failed to load or initialize module %s\n",
2263 fname, lineno, cargv[1]);
2266 exit( EXIT_FAILURE );
2268 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2271 LDAP_LOG( CONFIG, INFO,
2272 "%s: line %d: missing path in \"modulepath <path>\""
2273 " line\n", fname, lineno , 0 );
2275 Debug( LDAP_DEBUG_ANY,
2276 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2280 exit( EXIT_FAILURE );
2282 if (module_path( cargv[1] )) {
2284 LDAP_LOG( CONFIG, CRIT,
2285 "%s: line %d: failed to set module search path to %s.\n",
2286 fname, lineno, cargv[1] );
2288 Debug( LDAP_DEBUG_ANY,
2289 "%s: line %d: failed to set module search path to %s\n",
2290 fname, lineno, cargv[1]);
2293 exit( EXIT_FAILURE );
2296 #endif /*SLAPD_MODULES*/
2299 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2300 rc = ldap_pvt_tls_set_option( NULL,
2301 LDAP_OPT_X_TLS_RANDOM_FILE,
2306 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2307 rc = ldap_pvt_tls_set_option( NULL,
2308 LDAP_OPT_X_TLS_CIPHER_SUITE,
2313 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2314 rc = ldap_pvt_tls_set_option( NULL,
2315 LDAP_OPT_X_TLS_CERTFILE,
2320 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2321 rc = ldap_pvt_tls_set_option( NULL,
2322 LDAP_OPT_X_TLS_KEYFILE,
2327 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2328 rc = ldap_pvt_tls_set_option( NULL,
2329 LDAP_OPT_X_TLS_CACERTDIR,
2334 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2335 rc = ldap_pvt_tls_set_option( NULL,
2336 LDAP_OPT_X_TLS_CACERTFILE,
2340 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2341 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2343 rc = ldap_pvt_tls_set_option( NULL,
2344 LDAP_OPT_X_TLS_REQUIRE_CERT,
2347 rc = ldap_int_tls_config( NULL,
2348 LDAP_OPT_X_TLS_REQUIRE_CERT,
2357 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2358 #ifdef SLAPD_RLOOKUPS
2361 LDAP_LOG( CONFIG, INFO,
2362 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2363 fname, lineno , 0 );
2365 Debug( LDAP_DEBUG_ANY,
2366 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2372 if ( !strcasecmp( cargv[1], "on" ) ) {
2373 use_reverse_lookup = 1;
2374 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2375 use_reverse_lookup = 0;
2378 LDAP_LOG( CONFIG, INFO,
2379 "%s: line %d: reverse-lookup: "
2380 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2382 Debug( LDAP_DEBUG_ANY,
2383 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2389 #else /* !SLAPD_RLOOKUPS */
2391 LDAP_LOG( CONFIG, INFO,
2392 "%s: line %d: reverse lookups "
2393 "are not configured (ignored).\n", fname, lineno , 0 );
2395 Debug( LDAP_DEBUG_ANY,
2396 "%s: line %d: reverse lookups are not configured (ignored).\n",
2399 #endif /* !SLAPD_RLOOKUPS */
2401 /* Netscape plugins */
2402 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2403 #if defined( LDAP_SLAPI )
2405 #ifdef notdef /* allow global plugins, too */
2407 * a "plugin" line must be inside a database
2408 * definition, since we implement pre-,post-
2409 * and extended operation plugins
2413 LDAP_LOG( CONFIG, INFO,
2414 "%s: line %d: plugin line must appear "
2415 "insid a database definition.\n",
2418 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2419 "line must appear inside a database "
2420 "definition\n", fname, lineno, 0 );
2426 if ( slapi_int_read_config( be, fname, lineno, cargc, cargv )
2430 slapi_plugins_used++;
2432 #else /* !defined( LDAP_SLAPI ) */
2434 LDAP_LOG( CONFIG, INFO,
2435 "%s: line %d: SLAPI not supported.\n",
2438 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2439 "not supported.\n", fname, lineno, 0 );
2443 #endif /* !defined( LDAP_SLAPI ) */
2445 /* Netscape plugins */
2446 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2447 #if defined( LDAP_SLAPI )
2450 LDAP_LOG( CONFIG, INFO,
2451 "%s: line %d: missing file name "
2452 "in pluginlog <filename> line.\n",
2455 Debug( LDAP_DEBUG_ANY,
2456 "%s: line %d: missing file name "
2457 "in pluginlog <filename> line.\n",
2463 if ( slapi_log_file != NULL ) {
2464 ch_free( slapi_log_file );
2467 slapi_log_file = ch_strdup( cargv[1] );
2468 #endif /* !defined( LDAP_SLAPI ) */
2470 /* pass anything else to the current backend info/db config routine */
2473 if ( bi->bi_config ) {
2474 rc = (*bi->bi_config)( bi, fname, lineno, cargc, cargv );
2480 case SLAP_CONF_UNKNOWN:
2482 LDAP_LOG( CONFIG, INFO,
2483 "%s: line %d: unknown directive \"%s\" inside "
2484 "backend info definition (ignored).\n",
2485 fname, lineno, cargv[0] );
2487 Debug( LDAP_DEBUG_ANY,
2488 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2489 fname, lineno, cargv[0] );
2498 } else if ( be != NULL ) {
2499 if ( be->be_config ) {
2500 rc = (*be->be_config)( be, fname, lineno, cargc, cargv );
2506 case SLAP_CONF_UNKNOWN:
2508 LDAP_LOG( CONFIG, INFO,
2509 "%s: line %d: unknown directive \"%s\" inside "
2510 "backend database definition (ignored).\n",
2511 fname, lineno, cargv[0] );
2513 Debug( LDAP_DEBUG_ANY,
2514 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2515 fname, lineno, cargv[0] );
2526 LDAP_LOG( CONFIG, INFO,
2527 "%s: line %d: unknown directive \"%s\" outside backend "
2528 "info and database definitions (ignored).\n",
2529 fname, lineno, cargv[0] );
2531 Debug( LDAP_DEBUG_ANY,
2532 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2533 fname, lineno, cargv[0] );
2542 if ( depth == 0 ) ch_free( cargv );
2544 if ( !global_schemadn.bv_val ) {
2545 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2547 dnNormalize( 0, NULL, NULL, &global_schemadn, &global_schemandn, NULL );
2550 if ( load_ucdata( NULL ) < 0 ) return 1;
2562 char logbuf[sizeof("pseudorootpw ***")];
2565 token = strtok_quote( line, " \t" );
2569 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2570 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2571 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2572 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2573 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2575 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2578 if ( strtok_quote_ptr ) {
2579 *strtok_quote_ptr = ' ';
2583 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2585 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2588 if ( strtok_quote_ptr ) {
2589 *strtok_quote_ptr = '\0';
2592 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2593 if ( cargc == cargv_size - 1 ) {
2595 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2597 if ( tmp == NULL ) {
2599 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2601 Debug( LDAP_DEBUG_ANY,
2602 "line %d: out of memory\n",
2608 cargv_size += ARGS_STEP;
2610 cargv[cargc++] = token;
2612 cargv[cargc] = NULL;
2617 strtok_quote( char *line, char *sep )
2623 strtok_quote_ptr = NULL;
2624 if ( line != NULL ) {
2627 while ( *next && strchr( sep, *next ) ) {
2631 if ( *next == '\0' ) {
2637 for ( inquote = 0; *next; ) {
2645 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2651 next + 1, strlen( next + 1 ) + 1 );
2652 next++; /* dont parse the escaped character */
2657 if ( strchr( sep, *next ) != NULL ) {
2658 strtok_quote_ptr = next;
2671 static char buf[BUFSIZ];
2673 static size_t lmax, lcur;
2675 #define CATLINE( buf ) \
2677 size_t len = strlen( buf ); \
2678 while ( lcur + len + 1 > lmax ) { \
2680 line = (char *) ch_realloc( line, lmax ); \
2682 strcpy( line + lcur, buf ); \
2687 fp_getline( FILE *fp, int *lineno )
2695 /* hack attack - keeps us from having to keep a stack of bufs... */
2696 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2701 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2702 /* trim off \r\n or \n */
2703 if ( (p = strchr( buf, '\n' )) != NULL ) {
2704 if( p > buf && p[-1] == '\r' ) --p;
2708 /* trim off trailing \ and append the next line */
2709 if ( line[ 0 ] != '\0'
2710 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2711 && p[ -1 ] != '\\' ) {
2716 if ( ! isspace( (unsigned char) buf[0] ) ) {
2720 /* change leading whitespace to a space */
2729 return( line[0] ? line : NULL );
2733 fp_getline_init( int *lineno )
2739 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2741 load_ucdata( char *path )
2743 static int loaded = 0;
2749 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2752 LDAP_LOG( CONFIG, CRIT,
2753 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2755 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2768 ucdata_unload( UCDATA_ALL );
2769 free( global_schemandn.bv_val );
2770 free( global_schemadn.bv_val );
2772 if ( slapd_args_file )
2773 free ( slapd_args_file );
2774 if ( slapd_pid_file )
2775 free ( slapd_pid_file );
2776 if ( default_passwd_hash )
2777 free( default_passwd_hash );
2778 acl_destroy( global_acl, NULL );
2789 syncinfo_t *si_entry;
2791 int duplicated_replica_id = 0;
2793 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2797 LDAP_LOG( CONFIG, ERR, "out of memory in add_syncrepl\n", 0, 0,0 );
2799 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2804 si->si_tls = SYNCINFO_TLS_OFF;
2805 if ( be->be_rootndn.bv_val ) {
2806 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
2808 si->si_bindmethod = LDAP_AUTH_SIMPLE;
2809 si->si_schemachecking = 0;
2810 ber_str2bv( "(objectclass=*)", sizeof("(objectclass=*)")-1, 0,
2811 &si->si_filterstr );
2812 si->si_base.bv_val = NULL;
2813 si->si_scope = LDAP_SCOPE_SUBTREE;
2814 si->si_attrsonly = 0;
2815 si->si_attrs = (char **) ch_calloc( 1, sizeof( char * ));
2816 si->si_attrs[0] = NULL;
2817 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2818 si->si_interval = 86400;
2819 si->si_syncCookie.ctxcsn = NULL;
2820 si->si_syncCookie.octet_str = NULL;
2821 si->si_syncCookie.sid = -1;
2822 si->si_manageDSAit = 0;
2825 si->si_syncUUID_ndn.bv_val = NULL;
2826 si->si_syncUUID_ndn.bv_len = 0;
2828 si->si_presentlist = NULL;
2829 LDAP_LIST_INIT( &si->si_nonpresentlist );
2831 rc = parse_syncrepl_line( cargv, cargc, si );
2833 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
2834 if ( si->si_rid == si_entry->si_rid ) {
2836 LDAP_LOG( CONFIG, ERR,
2837 "add_syncrepl: duplicated replica id\n", 0, 0,0 );
2839 Debug( LDAP_DEBUG_ANY,
2840 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
2842 duplicated_replica_id = 1;
2847 if ( rc < 0 || duplicated_replica_id ) {
2848 syncinfo_t *si_entry;
2849 /* Something bad happened - back out */
2851 LDAP_LOG( CONFIG, ERR, "failed to add syncinfo\n", 0, 0,0 );
2853 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2856 /* If error, remove all syncinfo */
2857 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
2858 if ( si_entry->si_updatedn.bv_val ) {
2859 ch_free( si->si_updatedn.bv_val );
2861 if ( si_entry->si_filterstr.bv_val ) {
2862 ch_free( si->si_filterstr.bv_val );
2864 if ( si_entry->si_attrs ) {
2866 while ( si_entry->si_attrs[i] != NULL ) {
2867 ch_free( si_entry->si_attrs[i] );
2870 ch_free( si_entry->si_attrs );
2874 while ( !LDAP_STAILQ_EMPTY( &be->be_syncinfo )) {
2875 si_entry = LDAP_STAILQ_FIRST( &be->be_syncinfo );
2876 LDAP_STAILQ_REMOVE_HEAD( &be->be_syncinfo, si_next );
2877 ch_free( si_entry );
2879 LDAP_STAILQ_INIT( &be->be_syncinfo );
2883 LDAP_LOG ( CONFIG, RESULTS,
2884 "add_syncrepl: Config: ** successfully added syncrepl \"%s\"\n",
2885 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2887 Debug( LDAP_DEBUG_CONFIG,
2888 "Config: ** successfully added syncrepl \"%s\"\n",
2889 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2891 if ( !si->si_schemachecking ) {
2892 be->be_flags |= SLAP_BFLAG_NO_SCHEMA_CHECK;
2895 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
2901 #define PROVIDERSTR "provider"
2902 #define SUFFIXSTR "suffix"
2903 #define UPDATEDNSTR "updatedn"
2904 #define BINDMETHSTR "bindmethod"
2905 #define SIMPLESTR "simple"
2906 #define SASLSTR "sasl"
2907 #define BINDDNSTR "binddn"
2908 #define CREDSTR "credentials"
2909 #define OLDAUTHCSTR "bindprincipal"
2910 #define AUTHCSTR "authcID"
2911 #define AUTHZSTR "authzID"
2912 #define SRVTABSTR "srvtab"
2913 #define SASLMECHSTR "saslmech"
2914 #define REALMSTR "realm"
2915 #define SECPROPSSTR "secprops"
2916 #define STARTTLSSTR "starttls"
2917 #define CRITICALSTR "critical"
2919 #define SCHEMASTR "schemachecking"
2920 #define FILTERSTR "filter"
2921 #define SEARCHBASESTR "searchbase"
2922 #define SCOPESTR "scope"
2923 #define ATTRSSTR "attrs"
2924 #define ATTRSONLYSTR "attrsonly"
2925 #define TYPESTR "type"
2926 #define INTERVALSTR "interval"
2927 #define LASTMODSTR "lastmod"
2928 #define LMREQSTR "req"
2929 #define LMGENSTR "gen"
2930 #define LMNOSTR "no"
2931 #define MANAGEDSAITSTR "manageDSAit"
2932 #define SLIMITSTR "sizelimit"
2933 #define TLIMITSTR "timelimit"
2935 #define GOT_ID 0x0001
2936 #define GOT_PROVIDER 0x0002
2937 #define GOT_METHOD 0x0004
2938 #define GOT_ALL 0x0007
2941 parse_syncrepl_line(
2952 for ( i = 1; i < cargc; i++ ) {
2953 if ( !strncasecmp( cargv[ i ], IDSTR, sizeof( IDSTR ) - 1 )) {
2955 /* '\0' string terminator accounts for '=' */
2956 val = cargv[ i ] + sizeof( IDSTR );
2958 if ( tmp >= 1000 || tmp < 0 ) {
2959 fprintf( stderr, "Error: parse_syncrepl_line: "
2960 "syncrepl id %d is out of range [0..999]\n", tmp );
2965 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR,
2966 sizeof( PROVIDERSTR ) - 1 )) {
2967 val = cargv[ i ] + sizeof( PROVIDERSTR );
2968 si->si_provideruri = ch_strdup( val );
2969 si->si_provideruri_bv = (BerVarray)
2970 ch_calloc( 2, sizeof( struct berval ));
2971 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
2972 0, &si->si_provideruri_bv[0] );
2973 si->si_provideruri_bv[1].bv_len = 0;
2974 si->si_provideruri_bv[1].bv_val = NULL;
2975 gots |= GOT_PROVIDER;
2976 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR,
2977 sizeof(STARTTLSSTR) - 1 ) )
2979 val = cargv[ i ] + sizeof( STARTTLSSTR );
2980 if( !strcasecmp( val, CRITICALSTR ) ) {
2981 si->si_tls = SYNCINFO_TLS_CRITICAL;
2983 si->si_tls = SYNCINFO_TLS_ON;
2985 } else if ( !strncasecmp( cargv[ i ],
2986 UPDATEDNSTR, sizeof( UPDATEDNSTR ) - 1 ) )
2988 struct berval updatedn = {0, NULL};
2989 val = cargv[ i ] + sizeof( UPDATEDNSTR );
2990 ber_str2bv( val, 0, 0, &updatedn );
2991 ch_free( si->si_updatedn.bv_val );
2992 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
2993 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR,
2994 sizeof( BINDMETHSTR ) - 1 ) )
2996 val = cargv[ i ] + sizeof( BINDMETHSTR );
2997 if ( !strcasecmp( val, SIMPLESTR )) {
2998 si->si_bindmethod = LDAP_AUTH_SIMPLE;
3000 } else if ( !strcasecmp( val, SASLSTR )) {
3001 #ifdef HAVE_CYRUS_SASL
3002 si->si_bindmethod = LDAP_AUTH_SASL;
3004 #else /* HAVE_CYRUS_SASL */
3005 fprintf( stderr, "Error: parse_syncrepl_line: "
3006 "not compiled with SASL support\n" );
3008 #endif /* HAVE_CYRUS_SASL */
3010 si->si_bindmethod = -1;
3012 } else if ( !strncasecmp( cargv[ i ],
3013 BINDDNSTR, sizeof( BINDDNSTR ) - 1 ) ) {
3014 val = cargv[ i ] + sizeof( BINDDNSTR );
3015 si->si_binddn = ch_strdup( val );
3016 } else if ( !strncasecmp( cargv[ i ],
3017 CREDSTR, sizeof( CREDSTR ) - 1 ) ) {
3018 val = cargv[ i ] + sizeof( CREDSTR );
3019 si->si_passwd = ch_strdup( val );
3020 } else if ( !strncasecmp( cargv[ i ],
3021 SASLMECHSTR, sizeof( SASLMECHSTR ) - 1 ) ) {
3022 val = cargv[ i ] + sizeof( SASLMECHSTR );
3023 si->si_saslmech = ch_strdup( val );
3024 } else if ( !strncasecmp( cargv[ i ],
3025 SECPROPSSTR, sizeof( SECPROPSSTR ) - 1 ) ) {
3026 val = cargv[ i ] + sizeof( SECPROPSSTR );
3027 si->si_secprops = ch_strdup( val );
3028 } else if ( !strncasecmp( cargv[ i ],
3029 REALMSTR, sizeof( REALMSTR ) - 1 ) ) {
3030 val = cargv[ i ] + sizeof( REALMSTR );
3031 si->si_realm = ch_strdup( val );
3032 } else if ( !strncasecmp( cargv[ i ],
3033 AUTHCSTR, sizeof( AUTHCSTR ) - 1 ) ) {
3034 val = cargv[ i ] + sizeof( AUTHCSTR );
3035 si->si_authcId = ch_strdup( val );
3036 } else if ( !strncasecmp( cargv[ i ],
3037 OLDAUTHCSTR, sizeof( OLDAUTHCSTR ) - 1 ) ) {
3038 /* Old authcID is provided for some backwards compatibility */
3039 val = cargv[ i ] + sizeof( OLDAUTHCSTR );
3040 si->si_authcId = ch_strdup( val );
3041 } else if ( !strncasecmp( cargv[ i ],
3042 AUTHZSTR, sizeof( AUTHZSTR ) - 1 ) ) {
3043 val = cargv[ i ] + sizeof( AUTHZSTR );
3044 si->si_authzId = ch_strdup( val );
3045 } else if ( !strncasecmp( cargv[ i ],
3046 SCHEMASTR, sizeof( SCHEMASTR ) - 1 ) )
3048 val = cargv[ i ] + sizeof( SCHEMASTR );
3049 if ( !strncasecmp( val, "on", sizeof( "on" ) - 1 )) {
3050 si->si_schemachecking = 1;
3051 } else if ( !strncasecmp( val, "off", sizeof( "off" ) - 1 ) ) {
3052 si->si_schemachecking = 0;
3054 si->si_schemachecking = 1;
3056 } else if ( !strncasecmp( cargv[ i ],
3057 FILTERSTR, sizeof( FILTERSTR ) - 1 ) )
3059 val = cargv[ i ] + sizeof( FILTERSTR );
3060 ber_str2bv( val, 0, 1, &si->si_filterstr );
3061 } else if ( !strncasecmp( cargv[ i ],
3062 SEARCHBASESTR, sizeof( SEARCHBASESTR ) - 1 ) )
3065 val = cargv[ i ] + sizeof( SEARCHBASESTR );
3066 if ( si->si_base.bv_val ) {
3067 ch_free( si->si_base.bv_val );
3069 ber_str2bv( val, 0, 0, &bv );
3070 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
3071 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
3074 } else if ( !strncasecmp( cargv[ i ],
3075 SCOPESTR, sizeof( SCOPESTR ) - 1 ) )
3077 val = cargv[ i ] + sizeof( SCOPESTR );
3078 if ( !strncasecmp( val, "base", sizeof( "base" ) - 1 )) {
3079 si->si_scope = LDAP_SCOPE_BASE;
3080 } else if ( !strncasecmp( val, "one", sizeof( "one" ) - 1 )) {
3081 si->si_scope = LDAP_SCOPE_ONELEVEL;
3082 } else if ( !strcasecmp( val, "subordinate" ) ||
3083 !strcasecmp( val, "children" ))
3085 si->si_scope = LDAP_SCOPE_SUBORDINATE;
3086 } else if ( !strncasecmp( val, "sub", sizeof( "sub" ) - 1 )) {
3087 si->si_scope = LDAP_SCOPE_SUBTREE;
3089 fprintf( stderr, "Error: parse_syncrepl_line: "
3090 "unknown scope \"%s\"\n", val);
3093 } else if ( !strncasecmp( cargv[ i ],
3094 ATTRSONLYSTR, sizeof( ATTRSONLYSTR ) - 1 ) )
3096 si->si_attrsonly = 1;
3097 } else if ( !strncasecmp( cargv[ i ],
3098 ATTRSSTR, sizeof( ATTRSSTR ) - 1 ) )
3100 val = cargv[ i ] + sizeof( ATTRSSTR );
3101 str2clist( &si->si_attrs, val, "," );
3102 } else if ( !strncasecmp( cargv[ i ],
3103 TYPESTR, sizeof( TYPESTR ) - 1 ) )
3105 val = cargv[ i ] + sizeof( TYPESTR );
3106 if ( !strncasecmp( val, "refreshOnly", sizeof("refreshOnly")-1 )) {
3107 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3108 } else if ( !strncasecmp( val, "refreshAndPersist",
3109 sizeof("refreshAndPersist")-1 ))
3111 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
3112 si->si_interval = 60;
3114 fprintf( stderr, "Error: parse_syncrepl_line: "
3115 "unknown sync type \"%s\"\n", val);
3118 } else if ( !strncasecmp( cargv[ i ],
3119 INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) )
3121 val = cargv[ i ] + sizeof( INTERVALSTR );
3122 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
3123 si->si_interval = 0;
3131 hstr = strchr( dstr, ':' );
3132 if ( hstr == NULL ) {
3133 fprintf( stderr, "Error: parse_syncrepl_line: "
3134 "invalid interval \"%s\"\n", val );
3138 mstr = strchr( hstr, ':' );
3139 if ( mstr == NULL ) {
3140 fprintf( stderr, "Error: parse_syncrepl_line: "
3141 "invalid interval \"%s\"\n", val );
3145 sstr = strchr( mstr, ':' );
3146 if ( sstr == NULL ) {
3147 fprintf( stderr, "Error: parse_syncrepl_line: "
3148 "invalid interval \"%s\"\n", val );
3157 if (( hh > 24 ) || ( hh < 0 ) ||
3158 ( mm > 60 ) || ( mm < 0 ) ||
3159 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
3160 fprintf( stderr, "Error: parse_syncrepl_line: "
3161 "invalid interval \"%s\"\n", val );
3164 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
3166 if ( si->si_interval < 0 ) {
3167 fprintf( stderr, "Error: parse_syncrepl_line: "
3168 "invalid interval \"%ld\"\n",
3169 (long) si->si_interval);
3172 } else if ( !strncasecmp( cargv[ i ],
3173 MANAGEDSAITSTR, sizeof( MANAGEDSAITSTR ) - 1 ) )
3175 val = cargv[ i ] + sizeof( MANAGEDSAITSTR );
3176 si->si_manageDSAit = atoi( val );
3177 } else if ( !strncasecmp( cargv[ i ],
3178 SLIMITSTR, sizeof( SLIMITSTR ) - 1 ) )
3180 val = cargv[ i ] + sizeof( SLIMITSTR );
3181 si->si_slimit = atoi( val );
3182 } else if ( !strncasecmp( cargv[ i ],
3183 TLIMITSTR, sizeof( TLIMITSTR ) - 1 ) )
3185 val = cargv[ i ] + sizeof( TLIMITSTR );
3186 si->si_tlimit = atoi( val );
3188 fprintf( stderr, "Error: parse_syncrepl_line: "
3189 "unknown keyword \"%s\"\n", cargv[ i ] );
3193 if ( gots != GOT_ALL ) {
3195 "Error: Malformed \"syncrepl\" line in slapd config file" );
3203 str2clist( char ***out, char *in, const char *brkstr )
3212 /* find last element in list */
3213 for (i = 0; *out && *out[i]; i++);
3215 /* protect the input string from strtok */
3216 str = ch_strdup( in );
3218 if ( *str == '\0' ) {
3223 /* Count words in string */
3225 for ( s = str; *s; s++ ) {
3226 if ( strchr( brkstr, *s ) != NULL ) {
3231 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
3233 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
3235 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
3237 *new = ch_strdup( s );