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 ConfigTable *config_find_keyword(ConfigTable *Conf, ConfigArgs *c) {
109 for(i = 0; Conf[i].name; i++)
110 if( (Conf[i].length && (!strncasecmp(c->argv[0], Conf[i].name, Conf[i].length))) ||
111 (!strcasecmp(c->argv[0], Conf[i].name)) ) break;
112 if ( !Conf[i].name ) return NULL;
116 int config_add_vals(ConfigTable *Conf, ConfigArgs *c) {
117 int i, rc, arg_user, arg_type, iarg;
122 arg_type = Conf->arg_type;
123 if(arg_type == ARG_IGNORED) {
124 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> ignored\n",
125 c->log, Conf->name, 0);
128 if(Conf->min_args && (c->argc < Conf->min_args)) {
129 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> missing <%s> argument\n",
130 c->log, Conf->name, Conf->what);
131 return(ARG_BAD_CONF);
133 if(Conf->max_args && (c->argc > Conf->max_args)) {
134 Debug(LDAP_DEBUG_CONFIG, "%s: extra cruft after <%s> in <%s> line (ignored)\n",
135 c->log, Conf->what, Conf->name);
137 if((arg_type & ARG_DB) && !c->be) {
138 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> allowed only within database declaration\n",
139 c->log, Conf->name, 0);
140 return(ARG_BAD_CONF);
142 if((arg_type & ARG_PRE_BI) && c->bi) {
143 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> must appear before any backend %sdeclaration\n",
144 c->log, Conf->name, ((arg_type & ARG_PRE_DB)
145 ? "or database " : "") );
146 return(ARG_BAD_CONF);
148 if((arg_type & ARG_PRE_DB) && c->be && c->be != frontendDB) {
149 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> must appear before any database declaration\n",
150 c->log, Conf->name, 0);
151 return(ARG_BAD_CONF);
153 if((arg_type & ARG_PAREN) && *c->argv[1] != '(' /*')'*/) {
154 Debug(LDAP_DEBUG_CONFIG, "%s: old <%s> format not supported\n",
155 c->log, Conf->name, 0);
156 return(ARG_BAD_CONF);
158 if((arg_type & ARGS_POINTER) && !Conf->arg_item && !(arg_type & ARG_OFFSET)) {
159 Debug(LDAP_DEBUG_CONFIG, "%s: null arg_item for <%s>\n",
160 c->log, Conf->name, 0);
161 return(ARG_BAD_CONF);
163 c->type = arg_user = (arg_type & ARGS_USERLAND);
164 memset(&c->values, 0, sizeof(c->values));
165 if(arg_type & ARGS_NUMERIC) {
167 iarg = 0; larg = 0; barg = 0;
168 switch(arg_type & ARGS_NUMERIC) {
169 case ARG_INT: iarg = atoi(c->argv[1]); break;
170 case ARG_LONG: larg = strtol(c->argv[1], NULL, 0); break;
171 case ARG_BER_LEN_T: barg = (ber_len_t)atol(c->argv[1]); break;
175 } else if(!strcasecmp(c->argv[1], "on") ||
176 !strcasecmp(c->argv[1], "true")) {
178 } else if(!strcasecmp(c->argv[1], "off") ||
179 !strcasecmp(c->argv[1], "false")) {
182 Debug(LDAP_DEBUG_CONFIG, "%s: ignoring ", c->log, 0, 0);
183 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%s) in <%s> line\n",
184 Conf->what, c->argv[1], Conf->name);
189 j = (arg_type & ARG_NONZERO) ? 1 : 0;
190 if(iarg < j || larg < j || barg < j ) {
191 larg = larg ? larg : (barg ? barg : iarg);
192 Debug(LDAP_DEBUG_CONFIG, "%s: " , c->log, 0, 0);
193 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%ld) in <%s> line\n", Conf->what, larg, Conf->name);
194 return(ARG_BAD_CONF);
196 switch(arg_type & ARGS_NUMERIC) {
198 case ARG_INT: c->value_int = iarg; break;
199 case ARG_LONG: c->value_long = larg; break;
200 case ARG_BER_LEN_T: c->value_ber_t = barg; break;
202 } else if(arg_type & ARG_STRING) {
203 c->value_string = ch_strdup(c->argv[1]);
204 } else if(arg_type & ARG_BERVAL) {
205 ber_str2bv( c->argv[1], 0, 1, &c->value_bv );
206 } else if(arg_type & ARG_DN) {
208 ber_str2bv( c->argv[1], 0, 0, &bv );
209 rc = dnPrettyNormal( NULL, &bv, &c->value_dn, &c->value_ndn, NULL );
210 if ( rc != LDAP_SUCCESS ) {
211 Debug(LDAP_DEBUG_CONFIG, "%s: " , c->log, 0, 0);
212 Debug(LDAP_DEBUG_CONFIG, "%s DN is invalid %d (%s)\n",
213 Conf->name, rc, ldap_err2string( rc ));
214 return(ARG_BAD_CONF);
217 if(arg_type & ARG_MAGIC) {
218 if(!c->be) c->be = frontendDB;
219 rc = (*((ConfigDriver*)Conf->arg_item))(c);
220 if(c->be == frontendDB) c->be = NULL;
222 Debug(LDAP_DEBUG_CONFIG, "%s: handler for <%s> exited with %d!\n",
223 c->log, Conf->name, rc);
224 return(ARG_BAD_CONF);
228 if(arg_type & ARG_OFFSET) {
230 ptr = c->be->be_private;
232 ptr = c->bi->bi_private;
234 Debug(LDAP_DEBUG_CONFIG, "%s: offset for <%s> missing base pointer!\n",
235 c->log, Conf->name, 0);
236 return(ARG_BAD_CONF);
238 ptr = (void *)((char *)ptr + (int)Conf->arg_item);
239 } else if (arg_type & ARGS_POINTER) {
240 ptr = Conf->arg_item;
242 if(arg_type & ARGS_POINTER)
243 switch(arg_type & ARGS_POINTER) {
245 case ARG_INT: *(int*)ptr = iarg; break;
246 case ARG_LONG: *(long*)ptr = larg; break;
247 case ARG_BER_LEN_T: *(ber_len_t*)ptr = barg; break;
249 char *cc = *(char**)ptr;
251 if (arg_type & ARG_UNIQUE) {
252 Debug(LDAP_DEBUG_CONFIG, "%s: already set %s!\n",
253 c->log, Conf->name, 0 );
254 return(ARG_BAD_CONF);
256 ch_free(cc); /* potential memory leak */
258 *(char **)ptr = c->value_string;
262 *(struct berval *)ptr = c->value_bv;
269 config_del_vals(ConfigTable *cf, ConfigArgs *c)
275 config_get_vals(ConfigTable *cf, ConfigArgs *c)
281 if ( cf->arg_type & ARG_IGNORED ) {
285 memset(&c->values, 0, sizeof(c->values));
286 c->rvalue_vals = NULL;
287 c->rvalue_nvals = NULL;
288 c->op = SLAP_CONFIG_EMIT;
289 c->type = cf->arg_type & ARGS_USERLAND;
291 if ( cf->arg_type & ARG_MAGIC ) {
292 rc = (*((ConfigDriver*)cf->arg_item))(c);
295 if ( cf->arg_type & ARG_OFFSET ) {
297 ptr = c->be->be_private;
299 ptr = c->bi->bi_private;
302 ptr = (void *)((char *)ptr + (int)cf->arg_item);
307 switch(cf->arg_type & ARGS_POINTER) {
309 case ARG_INT: c->value_int = *(int *)ptr; break;
310 case ARG_LONG: c->value_long = *(long *)ptr; break;
311 case ARG_BER_LEN_T: c->value_ber_t = *(ber_len_t *)ptr; break;
314 c->value_string = ch_strdup(*(char **)ptr);
317 ber_dupbv( &c->value_bv, (struct berval *)ptr ); break;
320 if ( cf->arg_type & ARGS_POINTER) {
322 switch(cf->arg_type & ARGS_POINTER) {
323 case ARG_INT: bv.bv_len = sprintf(bv.bv_val, "%d", c->value_int); break;
324 case ARG_LONG: bv.bv_len = sprintf(bv.bv_val, "%ld", c->value_long); break;
325 case ARG_BER_LEN_T: bv.bv_len = sprintf(bv.bv_val, "%ld", c->value_ber_t); break;
326 case ARG_ON_OFF: bv.bv_len = sprintf(bv.bv_val, "%s",
327 c->value_int ? "TRUE" : "FALSE"); break;
329 if ( c->value_string && c->value_string[0]) {
330 ber_str2bv( c->value_string, 0, 0, &bv);
336 if ( !BER_BVISEMPTY( &c->value_bv )) {
343 if (( cf->arg_type & ARGS_POINTER ) == ARG_STRING )
344 ber_bvarray_add(&c->rvalue_vals, &bv);
346 value_add_one(&c->rvalue_vals, &bv);
352 init_config_attrs(ConfigTable *ct) {
353 LDAPAttributeType *at;
357 for (i=0; ct[i].name; i++ ) {
358 if ( !ct[i].attribute ) continue;
359 at = ldap_str2attributetype( ct[i].attribute,
360 &code, &err, LDAP_SCHEMA_ALLOW_ALL );
362 fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s, %s\n",
363 ct[i].attribute, ldap_scherr2str(code), err );
366 code = at_add( at, &err );
367 if ( code && code != SLAP_SCHERR_ATTR_DUP ) {
368 fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s, %s\n",
369 ct[i].attribute, scherr2str(code), err );
372 code = slap_str2ad( at->at_names[0], &ct[i].ad, &err );
374 fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s\n",
375 ct[i].attribute, err );
385 init_config_ocs( ConfigOCs *ocs ) {
388 for (i=0;ocs[i].def;i++) {
393 oc = ldap_str2objectclass( ocs[i].def, &code, &err,
394 LDAP_SCHEMA_ALLOW_ALL );
396 fprintf( stderr, "init_config_ocs: objectclass \"%s\": %s, %s\n",
397 ocs[i].def, ldap_scherr2str(code), err );
400 code = oc_add(oc,0,&err);
401 if ( code && code != SLAP_SCHERR_CLASS_DUP ) {
402 fprintf( stderr, "init_config_ocs: objectclass \"%s\": %s, %s\n",
403 ocs[i].def, scherr2str(code), err );
407 *ocs[i].oc = oc_find(oc->oc_names[0]);
415 read_config_file(const char *fname, int depth, ConfigArgs *cf)
422 c = ch_calloc( 1, sizeof( ConfigArgs ) );
428 memcpy( c, cf, sizeof( ConfigArgs ) );
430 c->depth = depth; /* XXX */
436 c->argv = ch_calloc( ARGS_STEP + 1, sizeof( *c->argv ) );
437 c->argv_size = ARGS_STEP + 1;
439 fp = fopen( fname, "r" );
442 Debug(LDAP_DEBUG_ANY,
443 "could not open config file \"%s\": %s (%d)\n",
444 fname, strerror(errno), errno);
448 Debug(LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0);
452 while ( fp_getline( fp, c ) ) {
453 /* skip comments and blank lines */
454 if ( c->line[0] == '#' || c->line[0] == '\0' ) {
458 snprintf( c->log, sizeof( c->log ), "%s: line %lu",
459 c->fname, c->lineno );
461 if ( fp_parse_line( c ) ) {
466 Debug(LDAP_DEBUG_CONFIG, "%s: bad config line (ignored)\n", c->log, 0, 0);
470 c->op = LDAP_MOD_ADD;
472 ct = config_find_keyword( config_back_cf_table, c );
474 rc = config_add_vals( ct, c );
477 if ( rc & ARGS_USERLAND ) {
478 /* XXX a usertype would be opaque here */
479 Debug(LDAP_DEBUG_CONFIG, "%s: unknown user type <%s>\n",
480 c->log, c->argv[0], 0);
483 } else if ( rc == ARG_BAD_CONF ) {
487 } else if ( c->bi ) {
488 rc = SLAP_CONF_UNKNOWN;
489 if ( c->bi->bi_cf_table ) {
490 ct = config_find_keyword( c->bi->bi_cf_table, c );
492 rc = config_add_vals( ct, c );
495 if ( c->bi->bi_config && rc == SLAP_CONF_UNKNOWN ) {
496 rc = (*c->bi->bi_config)(c->bi, c->fname, c->lineno,
501 case SLAP_CONF_UNKNOWN:
502 Debug(LDAP_DEBUG_CONFIG, "%s: "
503 "unknown directive <%s> inside backend info definition (ignored)\n",
504 c->log, *c->argv, 0);
511 } else if ( c->be ) {
512 rc = SLAP_CONF_UNKNOWN;
513 if ( c->be->be_cf_table ) {
514 ct = config_find_keyword( c->be->be_cf_table, c );
516 rc = config_add_vals( ct, c );
519 if ( c->be->be_config && rc == SLAP_CONF_UNKNOWN ) {
520 rc = (*c->be->be_config)(c->be, c->fname, c->lineno,
525 case SLAP_CONF_UNKNOWN:
526 Debug( LDAP_DEBUG_CONFIG, "%s: "
527 "unknown directive <%s> inside backend database "
528 "definition (ignored)\n",
529 c->log, *c->argv, 0);
536 } else if ( frontendDB->be_config ) {
537 rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv);
540 case SLAP_CONF_UNKNOWN:
541 Debug( LDAP_DEBUG_CONFIG, "%s: "
542 "unknown directive <%s> inside global database definition (ignored)\n",
543 c->log, *c->argv, 0);
551 Debug(LDAP_DEBUG_CONFIG, "%s: "
552 "unknown directive <%s> outside backend info and database definitions (ignored)\n",
553 c->log, *c->argv, 0);
561 if ( BER_BVISNULL( &frontendDB->be_schemadn ) ) {
562 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
563 &frontendDB->be_schemadn );
564 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
565 if ( rc != LDAP_SUCCESS ) {
566 Debug(LDAP_DEBUG_ANY, "%s: "
567 "unable to normalize default schema DN \"%s\"\n",
568 c->log, frontendDB->be_schemadn.bv_val, 0 );
569 /* must not happen */
585 /* restrictops, allows, disallows, requires, loglevel */
588 verb_to_mask(const char *word, slap_verbmasks *v) {
590 for(i = 0; !BER_BVISNULL(&v[i].word); i++)
591 if(!strcasecmp(word, v[i].word.bv_val))
597 verbs_to_mask(int argc, char *argv[], slap_verbmasks *v, slap_mask_t *m) {
599 for(i = 1; i < argc; i++) {
600 j = verb_to_mask(argv[i], v);
601 if(BER_BVISNULL(&v[j].word)) return(1);
602 while (!v[j].mask) j--;
609 mask_to_verbs(slap_verbmasks *v, slap_mask_t m, BerVarray *bva) {
614 for (i=0; !BER_BVISNULL(&v[i].word); i++) {
615 if (!v[i].mask) continue;
616 if (( m & v[i].mask ) == v[i].mask ) {
617 value_add_one( bva, &v[i].word );
623 static slap_verbmasks tlskey[] = {
624 { BER_BVC("no"), SB_TLS_OFF },
625 { BER_BVC("yes"), SB_TLS_ON },
626 { BER_BVC("critical"), SB_TLS_CRITICAL },
630 static slap_verbmasks methkey[] = {
631 { BER_BVC("simple"), LDAP_AUTH_SIMPLE },
632 #ifdef HAVE_CYRUS_SASL
633 { BER_BVC("sasl"), LDAP_AUTH_SASL },
638 typedef struct cf_aux_table {
645 static cf_aux_table bindkey[] = {
646 { BER_BVC("starttls="), offsetof(slap_bindconf, sb_tls), 0, tlskey },
647 { BER_BVC("bindmethod="), offsetof(slap_bindconf, sb_method), 0, methkey },
648 { BER_BVC("binddn="), offsetof(slap_bindconf, sb_binddn), 1, NULL },
649 { BER_BVC("credentials="), offsetof(slap_bindconf, sb_cred), 1, NULL },
650 { BER_BVC("saslmech="), offsetof(slap_bindconf, sb_saslmech), 0, NULL },
651 { BER_BVC("secprops="), offsetof(slap_bindconf, sb_secprops), 0, NULL },
652 { BER_BVC("realm="), offsetof(slap_bindconf, sb_realm), 0, NULL },
653 { BER_BVC("authcID="), offsetof(slap_bindconf, sb_authcId), 0, NULL },
654 { BER_BVC("authzID="), offsetof(slap_bindconf, sb_authzId), 1, NULL },
655 { BER_BVNULL, 0, 0, NULL }
658 int bindconf_parse( const char *word, slap_bindconf *bc ) {
663 for (tab = bindkey; !BER_BVISNULL(&tab->key); tab++) {
664 if ( !strncasecmp( word, tab->key.bv_val, tab->key.bv_len )) {
665 cptr = (char **)((char *)bc + tab->off);
669 for (j=0; !BER_BVISNULL(&tab->aux[j].word); j++) {
670 if (!strcasecmp(word+tab->key.bv_len, tab->aux[j].word.bv_val)) {
671 int *ptr = (int *)cptr;
672 *ptr = tab->aux[j].mask;
677 Debug(LDAP_DEBUG_ANY, "invalid bind config value %s\n",
682 *cptr = ch_strdup(word+tab->key.bv_len);
689 int bindconf_unparse( slap_bindconf *bc, struct berval *bv ) {
690 char buf[BUFSIZ], *ptr;
696 for (tab = bindkey; !BER_BVISNULL(&tab->key); tab++) {
697 cptr = (char **)((char *)bc + tab->off);
699 int *ip = (int *)cptr, i;
700 for ( i=0; !BER_BVISNULL(&tab->aux[i].word); i++ ) {
701 if ( *ip == tab->aux[i].mask ) {
703 ptr = lutil_strcopy( ptr, tab->key.bv_val );
704 ptr = lutil_strcopy( ptr, tab->aux[i].word.bv_val );
708 } else if ( *cptr ) {
710 ptr = lutil_strcopy( ptr, tab->key.bv_val );
711 if ( tab->quote ) *ptr++ = '"';
712 ptr = lutil_strcopy( ptr, *cptr );
713 if ( tab->quote ) *ptr++ = '"';
717 tmp.bv_len = ptr - buf;
718 ber_dupbv( bv, &tmp );
722 void bindconf_free( slap_bindconf *bc ) {
723 if ( bc->sb_binddn ) {
724 ch_free( bc->sb_binddn );
727 ch_free( bc->sb_cred );
729 if ( bc->sb_saslmech ) {
730 ch_free( bc->sb_saslmech );
732 if ( bc->sb_secprops ) {
733 ch_free( bc->sb_secprops );
735 if ( bc->sb_realm ) {
736 ch_free( bc->sb_realm );
738 if ( bc->sb_authcId ) {
739 ch_free( bc->sb_authcId );
741 if ( bc->sb_authzId ) {
742 ch_free( bc->sb_authzId );
747 /* -------------------------------------- */
751 strtok_quote( char *line, char *sep )
757 strtok_quote_ptr = NULL;
758 if ( line != NULL ) {
761 while ( *next && strchr( sep, *next ) ) {
765 if ( *next == '\0' ) {
771 for ( inquote = 0; *next; ) {
779 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
785 next + 1, strlen( next + 1 ) + 1 );
786 next++; /* dont parse the escaped character */
791 if ( strchr( sep, *next ) != NULL ) {
792 strtok_quote_ptr = next;
805 static char buf[BUFSIZ];
807 static size_t lmax, lcur;
809 #define CATLINE( buf ) \
811 size_t len = strlen( buf ); \
812 while ( lcur + len + 1 > lmax ) { \
814 line = (char *) ch_realloc( line, lmax ); \
816 strcpy( line + lcur, buf ); \
821 fp_getline_init(ConfigArgs *c) {
827 fp_getline( FILE *fp, ConfigArgs *c )
835 /* avoid stack of bufs */
836 if ( strncasecmp( line, "include", STRLENOF( "include" ) ) == 0 ) {
842 while ( fgets( buf, sizeof( buf ), fp ) ) {
843 p = strchr( buf, '\n' );
845 if ( p > buf && p[-1] == '\r' ) {
853 && ( p = line + strlen( line ) - 1 )[0] == '\\'
860 if ( !isspace( (unsigned char)buf[0] ) ) {
871 return(line[0] ? 1 : 0);
875 fp_parse_line(ConfigArgs *c)
878 char *tline = ch_strdup(c->line);
879 char *hide[] = { "rootpw", "replica", "bindpw", "pseudorootpw", "dbpasswd", '\0' };
883 token = strtok_quote(tline, " \t");
885 if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break;
886 if(strtok_quote_ptr) *strtok_quote_ptr = ' ';
887 Debug(LDAP_DEBUG_CONFIG, "line %lu (%s%s)\n", c->lineno, hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
888 if(strtok_quote_ptr) *strtok_quote_ptr = '\0';
890 for(; token; token = strtok_quote(NULL, " \t")) {
891 if(c->argc == c->argv_size - 1) {
893 tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv));
895 Debug(LDAP_DEBUG_ANY, "line %lu: out of memory\n", c->lineno, 0, 0);
899 c->argv_size += ARGS_STEP;
901 c->argv[c->argc++] = token;
903 c->argv[c->argc] = NULL;
910 ucdata_unload( UCDATA_ALL );
912 /* NOTE: in case of early exit, frontendDB can be NULL */
913 if ( frontendDB->be_schemandn.bv_val )
914 free( frontendDB->be_schemandn.bv_val );
915 if ( frontendDB->be_schemadn.bv_val )
916 free( frontendDB->be_schemadn.bv_val );
917 if ( frontendDB->be_acl )
918 acl_destroy( frontendDB->be_acl, NULL );
921 if ( slapd_args_file )
922 free ( slapd_args_file );
923 if ( slapd_pid_file )
924 free ( slapd_pid_file );
925 if ( default_passwd_hash )
926 ldap_charray_free( default_passwd_hash );
930 slap_str2clist( char ***out, char *in, const char *brkstr )
938 /* find last element in list */
939 for (i = 0; *out && (*out)[i]; i++);
941 /* protect the input string from strtok */
942 str = ch_strdup( in );
944 if ( *str == '\0' ) {
949 /* Count words in string */
951 for ( s = str; *s; s++ ) {
952 if ( strchr( brkstr, *s ) != NULL ) {
957 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
959 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
961 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
963 *new = ch_strdup( s );
972 int config_generic_wrapper( Backend *be, const char *fname, int lineno,
973 int argc, char **argv )
975 ConfigArgs c = { 0 };
984 sprintf( c.log, "%s: line %lu", fname, lineno );
986 rc = SLAP_CONF_UNKNOWN;
987 ct = config_find_keyword( be->be_cf_table, &c );
989 rc = config_add_vals( ct, &c );