1 /* config.c - configuration file handling routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2005 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>
39 #include "slapi/slapi.h"
44 #endif /* HAVE_LIMITS_H */
47 #endif /* ! PATH_MAX */
53 * defaults for various global variables
55 slap_mask_t global_allows = 0;
56 slap_mask_t global_disallows = 0;
57 int global_gentlehup = 0;
58 int global_idletimeout = 0;
59 char *global_host = NULL;
60 char *global_realm = NULL;
61 char *ldap_srvtab = "";
62 char **default_passwd_hash = NULL;
63 struct berval default_search_base = BER_BVNULL;
64 struct berval default_search_nbase = BER_BVNULL;
66 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
67 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
69 int slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
70 int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
72 char *slapd_pid_file = NULL;
73 char *slapd_args_file = NULL;
75 char *strtok_quote_ptr;
77 int use_reverse_lookup = 0;
80 int slapi_plugins_used = 0;
83 static int fp_getline(FILE *fp, ConfigArgs *c);
84 static void fp_getline_init(ConfigArgs *c);
85 static int fp_parse_line(ConfigArgs *c);
87 static char *strtok_quote(char *line, char *sep);
89 int read_config_file(const char *fname, int depth, ConfigArgs *cf);
92 new_config_args( BackendDB *be, const char *fname, int lineno, int argc, char **argv )
95 c = ch_calloc( 1, sizeof( ConfigArgs ) );
96 if ( c == NULL ) return(NULL);
102 snprintf( c->log, sizeof( c->log ), "%s: line %lu", fname, lineno );
106 int parse_config_table(ConfigTable *Conf, ConfigArgs *c) {
107 int i, rc, arg_user, arg_type, iarg;
112 for(i = 0; Conf[i].name; i++)
113 if( (Conf[i].length && (!strncasecmp(c->argv[0], Conf[i].name, Conf[i].length))) ||
114 (!strcasecmp(c->argv[0], Conf[i].name)) ) break;
115 if(!Conf[i].name) return(ARG_UNKNOWN);
116 arg_type = Conf[i].arg_type;
117 if(arg_type == ARG_IGNORED) {
118 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> ignored\n",
119 c->log, Conf[i].name, 0);
122 if(Conf[i].min_args && (c->argc < Conf[i].min_args)) {
123 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> missing <%s> argument\n",
124 c->log, Conf[i].name, Conf[i].what);
125 return(ARG_BAD_CONF);
127 if(Conf[i].max_args && (c->argc > Conf[i].max_args)) {
128 Debug(LDAP_DEBUG_CONFIG, "%s: extra cruft after <%s> in <%s> line (ignored)\n",
129 c->log, Conf[i].what, Conf[i].name);
131 if((arg_type & ARG_DB) && !c->be) {
132 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> allowed only within database declaration\n",
133 c->log, Conf[i].name, 0);
134 return(ARG_BAD_CONF);
136 if((arg_type & ARG_PRE_BI) && c->bi) {
137 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> must appear before any backend %sdeclaration\n",
138 c->log, Conf[i].name, ((arg_type & ARG_PRE_DB)
139 ? "or database " : "") );
140 return(ARG_BAD_CONF);
142 if((arg_type & ARG_PRE_DB) && c->be && c->be != frontendDB) {
143 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> must appear before any database declaration\n",
144 c->log, Conf[i].name, 0);
145 return(ARG_BAD_CONF);
147 if((arg_type & ARG_PAREN) && *c->argv[1] != '(' /*')'*/) {
148 Debug(LDAP_DEBUG_CONFIG, "%s: old <%s> format not supported\n",
149 c->log, Conf[i].name, 0);
150 return(ARG_BAD_CONF);
152 if((arg_type & ARGS_POINTER) && !Conf[i].arg_item) {
153 Debug(LDAP_DEBUG_CONFIG, "%s: null arg_item for <%s>\n",
154 c->log, Conf[i].name, 0);
155 return(ARG_BAD_CONF);
157 c->type = arg_user = (arg_type & ARGS_USERLAND);
158 memset(&c->values, 0, sizeof(c->values));
159 if(arg_type & ARGS_NUMERIC) {
161 iarg = 0; larg = 0; barg = 0;
162 switch(arg_type & ARGS_NUMERIC) {
163 case ARG_INT: iarg = atoi(c->argv[1]); break;
164 case ARG_LONG: larg = strtol(c->argv[1], NULL, 0); break;
165 case ARG_BER_LEN_T: barg = (ber_len_t)atol(c->argv[1]); break;
169 } else if(!strcasecmp(c->argv[1], "on") ||
170 !strcasecmp(c->argv[1], "true")) {
172 } else if(!strcasecmp(c->argv[1], "off") ||
173 !strcasecmp(c->argv[1], "false")) {
176 Debug(LDAP_DEBUG_CONFIG, "%s: ignoring ", c->log, 0, 0);
177 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%s) in <%s> line\n",
178 Conf[i].what, c->argv[1], Conf[i].name);
183 j = (arg_type & ARG_NONZERO) ? 1 : 0;
184 if(iarg < j || larg < j || barg < j ) {
185 larg = larg ? larg : (barg ? barg : iarg);
186 Debug(LDAP_DEBUG_CONFIG, "%s: " , c->log, 0, 0);
187 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%ld) in <%s> line\n", Conf[i].what, larg, Conf[i].name);
188 return(ARG_BAD_CONF);
190 switch(arg_type & ARGS_NUMERIC) {
192 case ARG_INT: c->value_int = iarg; break;
193 case ARG_LONG: c->value_long = larg; break;
194 case ARG_BER_LEN_T: c->value_ber_t = barg; break;
196 } else if(arg_type & ARG_STRING) {
197 c->value_string = ch_strdup(c->argv[1]);
198 } else if(arg_type & ARG_DN) {
200 ber_str2bv( c->argv[1], 0, 0, &bv );
201 rc = dnPrettyNormal( NULL, &bv, &c->value_dn, &c->value_ndn, NULL );
202 if ( rc != LDAP_SUCCESS ) {
203 Debug(LDAP_DEBUG_CONFIG, "%s: " , c->log, 0, 0);
204 Debug(LDAP_DEBUG_CONFIG, "%s DN is invalid %d (%s)\n",
205 Conf[i].name, rc, ldap_err2string( rc ));
206 return(ARG_BAD_CONF);
209 if(arg_type & ARG_MAGIC) {
210 if(!c->be) c->be = frontendDB;
211 rc = (*((ConfigDriver*)Conf[i].arg_item))(c);
212 if(c->be == frontendDB) c->be = NULL;
214 Debug(LDAP_DEBUG_CONFIG, "%s: handler for <%s> exited with %d!",
215 c->log, Conf[i].name, rc);
216 return(ARG_BAD_CONF);
220 if(arg_type & ARG_OFFSET) {
222 ptr = c->be->be_private;
224 ptr = c->bi->bi_private;
226 Debug(LDAP_DEBUG_CONFIG, "%s: offset for <%s> missing base pointer!",
227 c->log, Conf[i].name, 0);
228 return(ARG_BAD_CONF);
230 ptr = (void *)((char *)ptr + (int)Conf[i].arg_item);
231 } else if (arg_type & ARGS_POINTER) {
232 ptr = Conf[i].arg_item;
234 if(arg_type & ARGS_POINTER) switch(arg_type & ARGS_POINTER) {
236 case ARG_INT: *(int*)ptr = iarg; break;
237 case ARG_LONG: *(long*)ptr = larg; break;
238 case ARG_BER_LEN_T: *(ber_len_t*)ptr = barg; break;
240 char *cc = *(char**)ptr;
242 if (arg_type & ARG_UNIQUE) {
243 Debug(LDAP_DEBUG_CONFIG, "%s: already set %s!\n",
244 c->log, Conf[i].name, 0 );
245 return(ARG_BAD_CONF);
247 ch_free(cc); /* potential memory leak */
249 *(char **)ptr = c->value_string;
257 config_get_vals(ConfigTable *cf, ConfigArgs *c)
263 if ( cf->arg_type & ARG_IGNORED ) {
267 memset(&c->values, 0, sizeof(c->values));
268 c->rvalue_vals = NULL;
269 c->rvalue_nvals = NULL;
271 c->type = cf->arg_type & ARGS_USERLAND;
273 if ( cf->arg_type & ARG_MAGIC ) {
274 rc = (*((ConfigDriver*)cf->arg_item))(c);
277 if ( cf->arg_type & ARG_OFFSET ) {
279 ptr = c->be->be_private;
281 ptr = c->bi->bi_private;
284 ptr = (void *)((char *)ptr + (int)cf->arg_item);
289 switch(cf->arg_type & ARGS_POINTER) {
291 case ARG_INT: c->value_int = *(int *)ptr; break;
292 case ARG_LONG: c->value_long = *(long *)ptr; break;
293 case ARG_BER_LEN_T: c->value_ber_t = *(ber_len_t *)ptr; break;
296 c->value_string = ch_strdup(*(char **)ptr);
300 if ( cf->arg_type & ARGS_POINTER) {
302 switch(cf->arg_type & ARGS_POINTER) {
303 case ARG_INT: bv.bv_len = sprintf(bv.bv_val, "%d", c->value_int); break;
304 case ARG_LONG: bv.bv_len = sprintf(bv.bv_val, "%l", c->value_long); break;
305 case ARG_BER_LEN_T: bv.bv_len =sprintf(bv.bv_val, "%l",c->value_ber_t); break;
306 case ARG_ON_OFF: bv.bv_len = sprintf(bv.bv_val, "%s",
307 c->value_int ? "TRUE" : "FALSE"); break;
309 if ( c->value_string && c->value_string[0]) {
310 ber_str2bv( c->value_string, 0, 0, &bv);
316 if (( cf->arg_type & ARGS_POINTER ) == ARG_STRING )
317 ber_bvarray_add(&c->rvalue_vals, &bv);
319 value_add_one(&c->rvalue_vals, &bv);
325 init_config_attrs(ConfigTable *ct) {
326 LDAPAttributeType *at;
330 for (i=0; ct[i].name; i++ ) {
331 if ( !ct[i].attribute ) continue;
332 at = ldap_str2attributetype( ct[i].attribute,
333 &code, &err, LDAP_SCHEMA_ALLOW_ALL );
335 fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s, %s\n",
336 ct[i].attribute, ldap_scherr2str(code), err );
339 code = at_add( at, &err );
340 if ( code && code != SLAP_SCHERR_ATTR_DUP ) {
341 fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s, %s\n",
342 ct[i].attribute, scherr2str(code), err );
345 code = slap_str2ad( at->at_names[0], &ct[i].ad, &err );
347 fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s\n",
348 ct[i].attribute, err );
358 init_config_ocs( ConfigOCs *ocs ) {
361 for (i=0;ocs[i].def;i++) {
366 oc = ldap_str2objectclass( ocs[i].def, &code, &err,
367 LDAP_SCHEMA_ALLOW_ALL );
369 fprintf( stderr, "init_config_ocs: objectclass \"%s\": %s, %s\n",
370 ocs[i].def, ldap_scherr2str(code), err );
373 code = oc_add(oc,0,&err);
374 if ( code && code != SLAP_SCHERR_CLASS_DUP ) {
375 fprintf( stderr, "init_config_ocs: objectclass \"%s\": %s, %s\n",
376 ocs[i].def, scherr2str(code), err );
380 *ocs[i].oc = oc_find(oc->oc_names[0]);
388 read_config(const char *fname, int depth) {
390 if ( !backend_db_init( "config" ))
392 return read_config_file(fname, depth, NULL);
396 read_config_file(const char *fname, int depth, ConfigArgs *cf)
402 c = ch_calloc( 1, sizeof( ConfigArgs ) );
408 memcpy( c, cf, sizeof( ConfigArgs ) );
410 c->depth = depth; /* XXX */
416 c->argv = ch_calloc( ARGS_STEP + 1, sizeof( *c->argv ) );
417 c->argv_size = ARGS_STEP + 1;
419 fp = fopen( fname, "r" );
422 Debug(LDAP_DEBUG_ANY,
423 "could not open config file \"%s\": %s (%d)\n",
424 fname, strerror(errno), errno);
428 Debug(LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0);
432 while ( fp_getline( fp, c ) ) {
433 /* skip comments and blank lines */
434 if ( c->line[0] == '#' || c->line[0] == '\0' ) {
438 snprintf( c->log, sizeof( c->log ), "%s: line %lu",
439 c->fname, c->lineno );
441 if ( fp_parse_line( c ) ) {
446 Debug(LDAP_DEBUG_CONFIG, "%s: bad config line (ignored)\n", c->log, 0, 0);
450 rc = parse_config_table( config_back_cf_table, c );
454 if ( rc & ARGS_USERLAND ) {
455 switch(rc) { /* XXX a usertype would be opaque here */
457 Debug(LDAP_DEBUG_CONFIG, "%s: unknown user type <%d>\n",
458 c->log, *c->argv, 0);
462 } else if ( rc == ARG_BAD_CONF || rc != ARG_UNKNOWN ) {
465 } else if ( c->bi && c->bi->bi_config ) { /* XXX to check: could both be/bi_config? oops */
466 rc = (*c->bi->bi_config)(c->bi, c->fname, c->lineno, c->argc, c->argv);
469 case SLAP_CONF_UNKNOWN:
470 Debug(LDAP_DEBUG_CONFIG, "%s: "
471 "unknown directive <%s> inside backend info definition (ignored)\n",
472 c->log, *c->argv, 0);
479 } else if ( c->be && c->be->be_cf_table ) {
480 rc = parse_config_table( c->be->be_cf_table, c );
484 case SLAP_CONF_UNKNOWN:
485 Debug( LDAP_DEBUG_CONFIG, "%s: "
486 "unknown directive <%s> inside backend database definition (ignored)\n",
487 c->log, *c->argv, 0);
494 } else if ( c->be && c->be->be_config ) {
495 rc = (*c->be->be_config)(c->be, c->fname, c->lineno, c->argc, c->argv);
498 case SLAP_CONF_UNKNOWN:
499 Debug( LDAP_DEBUG_CONFIG, "%s: "
500 "unknown directive <%s> inside backend database definition (ignored)\n",
501 c->log, *c->argv, 0);
508 } else if ( frontendDB->be_config ) {
509 rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv);
512 case SLAP_CONF_UNKNOWN:
513 Debug( LDAP_DEBUG_CONFIG, "%s: "
514 "unknown directive <%s> inside global database definition (ignored)\n",
515 c->log, *c->argv, 0);
523 Debug(LDAP_DEBUG_CONFIG, "%s: "
524 "unknown directive <%s> outside backend info and database definitions (ignored)\n",
525 c->log, *c->argv, 0);
533 if ( BER_BVISNULL( &frontendDB->be_schemadn ) ) {
534 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
535 &frontendDB->be_schemadn );
536 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
537 if ( rc != LDAP_SUCCESS ) {
538 Debug(LDAP_DEBUG_ANY, "%s: "
539 "unable to normalize default schema DN \"%s\"\n",
540 c->log, frontendDB->be_schemadn.bv_val, 0 );
541 /* must not happen */
557 /* restrictops, allows, disallows, requires, loglevel */
560 verb_to_mask(ConfigArgs *c, struct verb_mask_list *v, int word) {
562 for(j = 0; v[j].word; j++)
563 if(!strcasecmp(c->argv[word], v[j].word))
569 verbs_to_mask(ConfigArgs *c, struct verb_mask_list *v, slap_mask_t *m) {
571 for(i = 1; i < c->argc; i++) {
572 j = verb_to_mask(c, v, i);
573 if(!v[j].word) return(1);
574 while (!v[j].mask) j--;
581 mask_to_verbs(ConfigArgs *c, struct verb_mask_list *v, slap_mask_t m) {
586 for (i=0; v[i].word; i++) {
587 if (!v[i].mask) continue;
588 if (( m & v[i].mask ) == v[i].mask ) {
589 ber_str2bv( v[i].word, 0, 0, &bv );
590 value_add_one( &c->rvalue_vals, &bv );
596 static struct verb_mask_list tlskey[] = {
597 { "no", SB_TLS_OFF },
598 { "yes", SB_TLS_ON },
599 { "critical", SB_TLS_CRITICAL }
602 static struct verb_mask_list methkey[] = {
603 { "simple", LDAP_AUTH_SIMPLE },
604 #ifdef HAVE_CYRUS_SASL
605 { "sasl", LDAP_AUTH_SASL },
610 typedef struct cf_aux_table {
614 struct verb_mask_list *aux;
617 static cf_aux_table bindkey[] = {
618 { BER_BVC("starttls="), offsetof(slap_bindconf, sb_tls), 0, tlskey },
619 { BER_BVC("bindmethod="), offsetof(slap_bindconf, sb_method), 0, methkey },
620 { BER_BVC("binddn="), offsetof(slap_bindconf, sb_binddn), 1, NULL },
621 { BER_BVC("credentials="), offsetof(slap_bindconf, sb_cred), 1, NULL },
622 { BER_BVC("saslmech="), offsetof(slap_bindconf, sb_saslmech), 0, NULL },
623 { BER_BVC("secprops="), offsetof(slap_bindconf, sb_secprops), 0, NULL },
624 { BER_BVC("realm="), offsetof(slap_bindconf, sb_realm), 0, NULL },
625 { BER_BVC("authcID="), offsetof(slap_bindconf, sb_authcId), 0, NULL },
626 { BER_BVC("authzID="), offsetof(slap_bindconf, sb_authzId), 1, NULL },
627 { BER_BVNULL, 0, 0, NULL }
630 int bindconf_parse( char *word, slap_bindconf *bc ) {
635 for (tab = bindkey; !BER_BVISNULL(&tab->key); tab++) {
636 if ( !strncasecmp( word, tab->key.bv_val, tab->key.bv_len )) {
637 cptr = (char **)((char *)bc + tab->off);
641 for (j=0; tab->aux[j].word; j++) {
642 if (!strcasecmp(word+tab->key.bv_len, tab->aux[j].word)) {
643 int *ptr = (int *)cptr;
644 *ptr = tab->aux[j].mask;
649 Debug(LDAP_DEBUG_ANY, "invalid bind config value %s\n",
654 *cptr = ch_strdup(word+tab->key.bv_len);
661 int bindconf_unparse( slap_bindconf *bc, struct berval *bv ) {
662 char buf[BUFSIZ], *ptr;
668 for (tab = bindkey; !BER_BVISNULL(&tab->key); tab++) {
669 cptr = (char **)((char *)bc + tab->off);
671 int *ip = (int *)cptr, i;
672 for ( i=0; tab->aux[i].word; i++ ) {
673 if ( *ip == tab->aux[i].mask ) {
675 ptr = lutil_strcopy( ptr, tab->key.bv_val );
676 ptr = lutil_strcopy( ptr, tab->aux[i].word );
680 } else if ( *cptr ) {
682 ptr = lutil_strcopy( ptr, tab->key.bv_val );
683 if ( tab->quote ) *ptr++ = '"';
684 ptr = lutil_strcopy( ptr, *cptr );
685 if ( tab->quote ) *ptr++ = '"';
689 tmp.bv_len = ptr - buf;
690 ber_dupbv( bv, &tmp );
694 void bindconf_free( slap_bindconf *bc ) {
695 if ( bc->sb_binddn ) {
696 ch_free( bc->sb_binddn );
699 ch_free( bc->sb_cred );
701 if ( bc->sb_saslmech ) {
702 ch_free( bc->sb_saslmech );
704 if ( bc->sb_secprops ) {
705 ch_free( bc->sb_secprops );
707 if ( bc->sb_realm ) {
708 ch_free( bc->sb_realm );
710 if ( bc->sb_authcId ) {
711 ch_free( bc->sb_authcId );
713 if ( bc->sb_authzId ) {
714 ch_free( bc->sb_authzId );
719 /* -------------------------------------- */
723 strtok_quote( char *line, char *sep )
729 strtok_quote_ptr = NULL;
730 if ( line != NULL ) {
733 while ( *next && strchr( sep, *next ) ) {
737 if ( *next == '\0' ) {
743 for ( inquote = 0; *next; ) {
751 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
757 next + 1, strlen( next + 1 ) + 1 );
758 next++; /* dont parse the escaped character */
763 if ( strchr( sep, *next ) != NULL ) {
764 strtok_quote_ptr = next;
777 static char buf[BUFSIZ];
779 static size_t lmax, lcur;
781 #define CATLINE( buf ) \
783 size_t len = strlen( buf ); \
784 while ( lcur + len + 1 > lmax ) { \
786 line = (char *) ch_realloc( line, lmax ); \
788 strcpy( line + lcur, buf ); \
793 fp_getline_init(ConfigArgs *c) {
799 fp_getline( FILE *fp, ConfigArgs *c )
807 /* avoid stack of bufs */
808 if ( strncasecmp( line, "include", STRLENOF( "include" ) ) == 0 ) {
814 while ( fgets( buf, sizeof( buf ), fp ) ) {
815 p = strchr( buf, '\n' );
817 if ( p > buf && p[-1] == '\r' ) {
825 && ( p = line + strlen( line ) - 1 )[0] == '\\'
832 if ( !isspace( (unsigned char)buf[0] ) ) {
843 return(line[0] ? 1 : 0);
847 fp_parse_line(ConfigArgs *c)
850 char *tline = ch_strdup(c->line);
851 char *hide[] = { "rootpw", "replica", "bindpw", "pseudorootpw", "dbpasswd", '\0' };
855 token = strtok_quote(tline, " \t");
857 if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break;
858 if(strtok_quote_ptr) *strtok_quote_ptr = ' ';
859 Debug(LDAP_DEBUG_CONFIG, "line %lu (%s%s)\n", c->lineno, hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
860 if(strtok_quote_ptr) *strtok_quote_ptr = '\0';
862 for(; token; token = strtok_quote(NULL, " \t")) {
863 if(c->argc == c->argv_size - 1) {
865 tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv));
867 Debug(LDAP_DEBUG_ANY, "line %lu: out of memory\n", c->lineno, 0, 0);
871 c->argv_size += ARGS_STEP;
873 c->argv[c->argc++] = token;
875 c->argv[c->argc] = NULL;
882 ucdata_unload( UCDATA_ALL );
884 /* NOTE: in case of early exit, frontendDB can be NULL */
885 if ( frontendDB->be_schemandn.bv_val )
886 free( frontendDB->be_schemandn.bv_val );
887 if ( frontendDB->be_schemadn.bv_val )
888 free( frontendDB->be_schemadn.bv_val );
889 if ( frontendDB->be_acl )
890 acl_destroy( frontendDB->be_acl, NULL );
893 if ( slapd_args_file )
894 free ( slapd_args_file );
895 if ( slapd_pid_file )
896 free ( slapd_pid_file );
897 if ( default_passwd_hash )
898 ldap_charray_free( default_passwd_hash );
902 slap_str2clist( char ***out, char *in, const char *brkstr )
910 /* find last element in list */
911 for (i = 0; *out && (*out)[i]; i++);
913 /* protect the input string from strtok */
914 str = ch_strdup( in );
916 if ( *str == '\0' ) {
921 /* Count words in string */
923 for ( s = str; *s; s++ ) {
924 if ( strchr( brkstr, *s ) != NULL ) {
929 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
931 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
933 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
935 *new = ch_strdup( s );