1 /* config.c - configuration file handling routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2006 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>
37 #include <sys/types.h>
43 #include "slapi/slapi.h"
46 #include "lutil_ldap.h"
50 #include <openssl/ssl.h>
56 * defaults for various global variables
58 slap_mask_t global_allows = 0;
59 slap_mask_t global_disallows = 0;
60 int global_gentlehup = 0;
61 int global_idletimeout = 0;
62 char *global_host = NULL;
63 char *global_realm = NULL;
64 char *ldap_srvtab = "";
65 char **default_passwd_hash = NULL;
66 struct berval default_search_base = BER_BVNULL;
67 struct berval default_search_nbase = BER_BVNULL;
69 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
70 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
72 int slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
73 int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
75 char *slapd_pid_file = NULL;
76 char *slapd_args_file = NULL;
78 int use_reverse_lookup = 0;
81 int slapi_plugins_used = 0;
84 static int fp_getline(FILE *fp, ConfigArgs *c);
85 static void fp_getline_init(ConfigArgs *c);
86 static int fp_parse_line(ConfigArgs *c);
88 static char *strtok_quote(char *line, char *sep, char **quote_ptr);
89 static char *strtok_quote_ldif(char **line);
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 %d", fname, lineno );
107 init_config_argv( ConfigArgs *c )
109 c->argv = ch_calloc( ARGS_STEP + 1, sizeof( *c->argv ) );
110 c->argv_size = ARGS_STEP + 1;
113 ConfigTable *config_find_keyword(ConfigTable *Conf, ConfigArgs *c) {
116 for(i = 0; Conf[i].name; i++)
117 if( (Conf[i].length && (!strncasecmp(c->argv[0], Conf[i].name, Conf[i].length))) ||
118 (!strcasecmp(c->argv[0], Conf[i].name)) ) break;
119 if ( !Conf[i].name ) return NULL;
123 int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) {
124 int rc, arg_user, arg_type, arg_syn, iarg;
128 if(Conf->arg_type == ARG_IGNORED) {
129 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> ignored\n",
130 c->log, Conf->name, 0);
133 arg_type = Conf->arg_type & ARGS_TYPES;
134 arg_user = Conf->arg_type & ARGS_USERLAND;
135 arg_syn = Conf->arg_type & ARGS_SYNTAX;
137 if((arg_type == ARG_DN) && c->argc == 1) {
141 if(Conf->min_args && (c->argc < Conf->min_args)) {
142 snprintf( c->msg, sizeof( c->msg ), "<%s> missing <%s> argument",
143 c->argv[0], Conf->what );
144 Debug(LDAP_DEBUG_CONFIG, "%s: keyword %s\n", c->log, c->msg, 0 );
145 return(ARG_BAD_CONF);
147 if(Conf->max_args && (c->argc > Conf->max_args)) {
148 char *ignored = " ignored";
150 snprintf( c->msg, sizeof( c->msg ), "<%s> extra cruft after <%s>",
151 c->argv[0], Conf->what );
154 Debug(LDAP_DEBUG_CONFIG, "%s: %s%s.\n",
155 c->log, c->msg, ignored );
156 return(ARG_BAD_CONF);
158 if((arg_syn & ARG_DB) && !c->be) {
159 snprintf( c->msg, sizeof( c->msg ), "<%s> only allowed within database declaration",
161 Debug(LDAP_DEBUG_CONFIG, "%s: keyword %s\n",
163 return(ARG_BAD_CONF);
165 if((arg_syn & ARG_PRE_BI) && c->bi) {
166 snprintf( c->msg, sizeof( c->msg ), "<%s> must occur before any backend %sdeclaration",
167 c->argv[0], (arg_syn & ARG_PRE_DB) ? "or database " : "" );
168 Debug(LDAP_DEBUG_CONFIG, "%s: keyword %s\n",
170 return(ARG_BAD_CONF);
172 if((arg_syn & ARG_PRE_DB) && c->be && c->be != frontendDB) {
173 snprintf( c->msg, sizeof( c->msg ), "<%s> must occur before any database declaration",
175 Debug(LDAP_DEBUG_CONFIG, "%s: keyword %s\n",
177 return(ARG_BAD_CONF);
179 if((arg_syn & ARG_PAREN) && *c->argv[1] != '(' /*')'*/) {
180 snprintf( c->msg, sizeof( c->msg ), "<%s> old format not supported", c->argv[0] );
181 Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
183 return(ARG_BAD_CONF);
185 if(arg_type && !Conf->arg_item && !(arg_syn & ARG_OFFSET)) {
186 snprintf( c->msg, sizeof( c->msg ), "<%s> invalid config_table, arg_item is NULL",
188 Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
190 return(ARG_BAD_CONF);
193 memset(&c->values, 0, sizeof(c->values));
194 if(arg_type == ARG_STRING) {
196 c->value_string = ch_strdup(c->argv[1]);
197 } else if(arg_type == ARG_BERVAL) {
199 ber_str2bv( c->argv[1], 0, 1, &c->value_bv );
200 } else if(arg_type == ARG_DN) {
202 ber_str2bv( c->argv[1], 0, 0, &bv );
203 rc = dnPrettyNormal( NULL, &bv, &c->value_dn, &c->value_ndn, NULL );
204 if ( rc != LDAP_SUCCESS ) {
205 snprintf( c->msg, sizeof( c->msg ), "<%s> invalid DN %d (%s)",
206 c->argv[0], rc, ldap_err2string( rc ));
207 Debug(LDAP_DEBUG_CONFIG, "%s: %s\n" , c->log, c->msg, 0);
208 return(ARG_BAD_CONF);
211 ch_free( c->value_ndn.bv_val );
212 ch_free( c->value_dn.bv_val );
214 } else { /* all numeric */
216 iarg = 0; larg = 0; barg = 0;
219 if ( lutil_atoix( &iarg, c->argv[1], 0 ) != 0 ) {
220 snprintf( c->msg, sizeof( c->msg ),
221 "<%s> unable to parse \"%s\" as int",
222 c->argv[0], c->argv[1] );
223 Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
225 return(ARG_BAD_CONF);
229 if ( lutil_atolx( &larg, c->argv[1], 0 ) != 0 ) {
230 snprintf( c->msg, sizeof( c->msg ),
231 "<%s> unable to parse \"%s\" as long",
232 c->argv[0], c->argv[1] );
233 Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
235 return(ARG_BAD_CONF);
238 case ARG_BER_LEN_T: {
240 if ( lutil_atoulx( &l, c->argv[1], 0 ) != 0 ) {
241 snprintf( c->msg, sizeof( c->msg ),
242 "<%s> unable to parse \"%s\" as ber_len_t",
243 c->argv[0], c->argv[1] );
244 Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
246 return(ARG_BAD_CONF);
253 } else if ( !strcasecmp(c->argv[1], "on") ||
254 !strcasecmp(c->argv[1], "true") ||
255 !strcasecmp(c->argv[1], "yes") )
258 } else if ( !strcasecmp(c->argv[1], "off") ||
259 !strcasecmp(c->argv[1], "false") ||
260 !strcasecmp(c->argv[1], "no") )
264 snprintf( c->msg, sizeof( c->msg ), "<%s> invalid value",
266 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
268 return(ARG_BAD_CONF);
272 j = (arg_type & ARG_NONZERO) ? 1 : 0;
273 if(iarg < j && larg < j && barg < j ) {
274 larg = larg ? larg : (barg ? barg : iarg);
275 snprintf( c->msg, sizeof( c->msg ), "<%s> invalid value",
277 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
279 return(ARG_BAD_CONF);
283 case ARG_INT: c->value_int = iarg; break;
284 case ARG_LONG: c->value_long = larg; break;
285 case ARG_BER_LEN_T: c->value_ber_t = barg; break;
291 int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
295 arg_type = Conf->arg_type;
296 if(arg_type & ARG_MAGIC) {
297 if(!c->be) c->be = frontendDB;
299 rc = (*((ConfigDriver*)Conf->arg_item))(c);
301 if(c->be == frontendDB) c->be = NULL;
305 snprintf( c->msg, sizeof( c->msg ), "<%s> handler exited with %d",
307 Debug(LDAP_DEBUG_CONFIG, "%s: %s!\n",
310 return(ARG_BAD_CONF);
314 if(arg_type & ARG_OFFSET) {
315 if (c->be && (!overlay_is_over(c->be) ||
316 ((slap_overinfo *)c->be->bd_info)->oi_orig == c->bi))
317 ptr = c->be->be_private;
319 ptr = c->bi->bi_private;
321 snprintf( c->msg, sizeof( c->msg ), "<%s> offset is missing base pointer",
323 Debug(LDAP_DEBUG_CONFIG, "%s: %s!\n",
325 return(ARG_BAD_CONF);
327 ptr = (void *)((char *)ptr + (long)Conf->arg_item);
328 } else if (arg_type & ARGS_TYPES) {
329 ptr = Conf->arg_item;
331 if(arg_type & ARGS_TYPES)
332 switch(arg_type & ARGS_TYPES) {
334 case ARG_INT: *(int*)ptr = c->value_int; break;
335 case ARG_LONG: *(long*)ptr = c->value_long; break;
336 case ARG_BER_LEN_T: *(ber_len_t*)ptr = c->value_ber_t; break;
338 char *cc = *(char**)ptr;
340 if ((arg_type & ARG_UNIQUE) && c->op == SLAP_CONFIG_ADD ) {
341 Debug(LDAP_DEBUG_CONFIG, "%s: already set %s!\n",
342 c->log, Conf->name, 0 );
343 return(ARG_BAD_CONF);
347 *(char **)ptr = c->value_string;
351 *(struct berval *)ptr = c->value_bv;
357 int config_add_vals(ConfigTable *Conf, ConfigArgs *c) {
360 arg_type = Conf->arg_type;
361 if(arg_type == ARG_IGNORED) {
362 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> ignored\n",
363 c->log, Conf->name, 0);
366 rc = config_check_vals( Conf, c, 0 );
368 return config_set_vals( Conf, c );
372 config_del_vals(ConfigTable *cf, ConfigArgs *c)
376 /* If there is no handler, just ignore it */
377 if ( cf->arg_type & ARG_MAGIC ) {
378 c->op = LDAP_MOD_DELETE;
379 c->type = cf->arg_type & ARGS_USERLAND;
380 rc = (*((ConfigDriver*)cf->arg_item))(c);
386 config_get_vals(ConfigTable *cf, ConfigArgs *c)
392 if ( cf->arg_type & ARG_IGNORED ) {
396 memset(&c->values, 0, sizeof(c->values));
397 c->rvalue_vals = NULL;
398 c->rvalue_nvals = NULL;
399 c->op = SLAP_CONFIG_EMIT;
400 c->type = cf->arg_type & ARGS_USERLAND;
402 if ( cf->arg_type & ARG_MAGIC ) {
403 rc = (*((ConfigDriver*)cf->arg_item))(c);
406 if ( cf->arg_type & ARG_OFFSET ) {
407 if (c->be && (!overlay_is_over(c->be) ||
408 ((slap_overinfo *)c->be->bd_info)->oi_orig == c->bi))
409 ptr = c->be->be_private;
411 ptr = c->bi->bi_private;
414 ptr = (void *)((char *)ptr + (long)cf->arg_item);
419 switch(cf->arg_type & ARGS_TYPES) {
421 case ARG_INT: c->value_int = *(int *)ptr; break;
422 case ARG_LONG: c->value_long = *(long *)ptr; break;
423 case ARG_BER_LEN_T: c->value_ber_t = *(ber_len_t *)ptr; break;
426 c->value_string = ch_strdup(*(char **)ptr);
429 ber_dupbv( &c->value_bv, (struct berval *)ptr ); break;
432 if ( cf->arg_type & ARGS_TYPES) {
435 switch(cf->arg_type & ARGS_TYPES) {
436 case ARG_INT: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%d", c->value_int); break;
437 case ARG_LONG: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%ld", c->value_long); break;
438 case ARG_BER_LEN_T: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%ld", c->value_ber_t); break;
439 case ARG_ON_OFF: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%s",
440 c->value_int ? "TRUE" : "FALSE"); break;
442 if ( c->value_string && c->value_string[0]) {
443 ber_str2bv( c->value_string, 0, 0, &bv);
449 if ( !BER_BVISEMPTY( &c->value_bv )) {
459 if (bv.bv_val == c->log && bv.bv_len >= sizeof( c->log ) ) {
462 if (( cf->arg_type & ARGS_TYPES ) == ARG_STRING ) {
463 ber_bvarray_add(&c->rvalue_vals, &bv);
464 } else if ( !BER_BVISNULL( &bv ) ) {
465 value_add_one(&c->rvalue_vals, &bv);
467 /* else: maybe c->rvalue_vals already set? */
473 init_config_attrs(ConfigTable *ct) {
474 LDAPAttributeType *at;
478 for (i=0; ct[i].name; i++ ) {
481 if ( !ct[i].attribute ) continue;
482 at = ldap_str2attributetype( ct[i].attribute,
483 &code, &err, LDAP_SCHEMA_ALLOW_ALL );
485 fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s, %s\n",
486 ct[i].attribute, ldap_scherr2str(code), err );
490 code = at_add( at, 0, NULL, &err );
492 if ( code == SLAP_SCHERR_ATTR_DUP ) {
496 ldap_attributetype_free( at );
497 fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s, %s\n",
498 ct[i].attribute, scherr2str(code), err );
502 code = slap_str2ad( at->at_names[0], &ct[i].ad, &err );
503 if ( freeit || code ) {
504 ldap_attributetype_free( at );
509 fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s\n",
510 ct[i].attribute, err );
514 ct[i].ad->ad_type->sat_flags |= SLAP_AT_HIDE;
523 init_config_ocs( ConfigOCs *ocs ) {
526 for (i=0;ocs[i].co_def;i++) {
531 oc = ldap_str2objectclass( ocs[i].co_def, &code, &err,
532 LDAP_SCHEMA_ALLOW_ALL );
534 fprintf( stderr, "init_config_ocs: objectclass \"%s\": %s, %s\n",
535 ocs[i].co_def, ldap_scherr2str(code), err );
538 code = oc_add(oc,0,NULL,&err);
539 if ( code && code != SLAP_SCHERR_CLASS_DUP ) {
540 fprintf( stderr, "init_config_ocs: objectclass \"%s\": %s, %s\n",
541 ocs[i].co_def, scherr2str(code), err );
542 ldap_objectclass_free(oc);
545 ocs[i].co_oc = oc_find(oc->oc_names[0]);
547 ldap_objectclass_free(oc);
551 ocs[i].co_oc->soc_flags |= SLAP_OC_HIDE;
558 /* Split an LDIF line into space-separated tokens. Words may be grouped
559 * by quotes. A quoted string may begin in the middle of a word, but must
560 * end at the end of the word (be followed by whitespace or EOS). Any other
561 * quotes are passed through unchanged. All other characters are passed
565 strtok_quote_ldif( char **line )
567 char *beg, *ptr, *quote=NULL;
575 while( isspace( (unsigned char) *ptr )) ptr++;
586 if ( inquote && ( !ptr[1] || isspace((unsigned char) ptr[1]))) {
596 if ( isspace( (unsigned char) *ptr )) {
602 while ( quote < ptr ) {
610 while ( isspace( (unsigned char) *ptr )) ptr++;
617 config_parse_ldif( ConfigArgs *c )
620 c->tline = ch_strdup(c->line);
623 while ((c->argv[c->argc] = strtok_quote_ldif( &next )) != NULL) {
625 if ( c->argc >= c->argv_size ) {
626 char **tmp = ch_realloc( c->argv, (c->argv_size + ARGS_STEP) *
629 c->argv_size += ARGS_STEP;
632 c->argv[c->argc] = NULL;
636 config_parse_vals(ConfigTable *ct, ConfigArgs *c, int valx)
640 snprintf( c->log, sizeof( c->log ), "%s: value #%d",
641 ct->ad->ad_cname.bv_val, valx );
643 c->argv[0] = ct->ad->ad_cname.bv_val;
645 if ( ( ct->arg_type & ARG_QUOTE ) && c->line[ 0 ] != '"' ) {
646 c->argv[c->argc] = c->line;
648 c->argv[c->argc] = NULL;
651 config_parse_ldif( c );
653 rc = config_check_vals( ct, c, 1 );
658 rc = LDAP_CONSTRAINT_VIOLATION;
664 config_parse_add(ConfigTable *ct, ConfigArgs *c)
668 snprintf( c->log, sizeof( c->log ), "%s: value #%d",
669 ct->ad->ad_cname.bv_val, c->valx );
671 c->argv[0] = ct->ad->ad_cname.bv_val;
673 if ( ( ct->arg_type & ARG_QUOTE ) && c->line[ 0 ] != '"' ) {
674 c->argv[c->argc] = c->line;
676 c->argv[c->argc] = NULL;
679 config_parse_ldif( c );
681 c->op = LDAP_MOD_ADD;
682 rc = config_add_vals( ct, c );
689 read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft)
697 c = ch_calloc( 1, sizeof( ConfigArgs ) );
703 memcpy( c, cf, sizeof( ConfigArgs ) );
705 c->depth = depth; /* XXX */
712 init_config_argv( c );
714 if ( stat( fname, &s ) != 0 ) {
716 Debug(LDAP_DEBUG_ANY,
717 "could not stat config file \"%s\": %s (%d)\n",
718 fname, strerror(errno), errno);
723 if ( !S_ISREG( s.st_mode ) ) {
725 Debug(LDAP_DEBUG_ANY,
726 "regular file expected, got \"%s\"\n",
732 fp = fopen( fname, "r" );
735 Debug(LDAP_DEBUG_ANY,
736 "could not open config file \"%s\": %s (%d)\n",
737 fname, strerror(errno), errno);
742 Debug(LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0);
748 while ( fp_getline( fp, c ) ) {
749 /* skip comments and blank lines */
750 if ( c->line[0] == '#' || c->line[0] == '\0' ) {
754 snprintf( c->log, sizeof( c->log ), "%s: line %d",
755 c->fname, c->lineno );
759 if ( fp_parse_line( c ) ) {
765 Debug( LDAP_DEBUG_ANY, "%s: bad config line.\n",
771 c->op = SLAP_CONFIG_ADD;
773 ct = config_find_keyword( cft, c );
775 rc = config_add_vals( ct, c );
778 if ( rc & ARGS_USERLAND ) {
779 /* XXX a usertype would be opaque here */
780 Debug(LDAP_DEBUG_CONFIG, "%s: unknown user type <%s>\n",
781 c->log, c->argv[0], 0);
785 } else if ( rc == ARG_BAD_CONF ) {
790 } else if ( c->bi && !c->be ) {
791 rc = SLAP_CONF_UNKNOWN;
792 if ( c->bi->bi_cf_ocs ) {
793 ct = config_find_keyword( c->bi->bi_cf_ocs->co_table, c );
795 rc = config_add_vals( ct, c );
798 if ( c->bi->bi_config && rc == SLAP_CONF_UNKNOWN ) {
799 rc = (*c->bi->bi_config)(c->bi, c->fname, c->lineno,
804 case SLAP_CONF_UNKNOWN:
805 Debug( LDAP_DEBUG_ANY, "%s: unknown directive "
806 "<%s> inside backend info definition.\n",
807 c->log, *c->argv, 0);
814 } else if ( c->be && c->be != frontendDB ) {
815 rc = SLAP_CONF_UNKNOWN;
816 if ( c->be->be_cf_ocs ) {
817 ct = config_find_keyword( c->be->be_cf_ocs->co_table, c );
819 rc = config_add_vals( ct, c );
822 if ( c->be->be_config && rc == SLAP_CONF_UNKNOWN ) {
823 rc = (*c->be->be_config)(c->be, c->fname, c->lineno,
826 if ( rc == SLAP_CONF_UNKNOWN && SLAP_ISGLOBALOVERLAY( frontendDB ) )
828 /* global overlays may need
829 * definitions inside other databases...
831 rc = (*frontendDB->be_config)( frontendDB,
832 c->fname, (int)c->lineno, c->argc, c->argv );
839 case SLAP_CONF_UNKNOWN:
840 Debug( LDAP_DEBUG_ANY, "%s: unknown directive "
841 "<%s> inside backend database definition.\n",
842 c->log, *c->argv, 0);
849 } else if ( frontendDB->be_config ) {
850 rc = (*frontendDB->be_config)( frontendDB,
851 c->fname, (int)c->lineno, c->argc, c->argv);
854 case SLAP_CONF_UNKNOWN:
855 Debug( LDAP_DEBUG_ANY, "%s: unknown directive "
856 "<%s> inside global database definition.\n",
857 c->log, *c->argv, 0);
866 Debug( LDAP_DEBUG_ANY, "%s: unknown directive "
867 "<%s> outside backend info and database definitions.\n",
868 c->log, *c->argv, 0);
884 /* restrictops, allows, disallows, requires, loglevel */
887 bverb_to_mask(struct berval *bword, slap_verbmasks *v) {
889 for(i = 0; !BER_BVISNULL(&v[i].word); i++) {
890 if(!ber_bvstrcasecmp(bword, &v[i].word)) break;
896 verb_to_mask(const char *word, slap_verbmasks *v) {
898 ber_str2bv( word, 0, 0, &bword );
899 return bverb_to_mask( &bword, v );
903 verbs_to_mask(int argc, char *argv[], slap_verbmasks *v, slap_mask_t *m) {
905 for(i = 1; i < argc; i++) {
906 j = verb_to_mask(argv[i], v);
907 if(BER_BVISNULL(&v[j].word)) return i;
908 while (!v[j].mask) j--;
914 /* Mask keywords that represent multiple bits should occur before single
915 * bit keywords in the verbmasks array.
918 mask_to_verbs(slap_verbmasks *v, slap_mask_t m, BerVarray *bva) {
922 for (i=0; !BER_BVISNULL(&v[i].word); i++) {
923 if (!v[i].mask) continue;
924 if (( m & v[i].mask ) == v[i].mask ) {
925 value_add_one( bva, &v[i].word );
936 slap_verbmasks_init( slap_verbmasks **vp, slap_verbmasks *v )
940 assert( *vp == NULL );
942 for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ ) /* EMPTY */;
944 *vp = ch_calloc( i + 1, sizeof( slap_verbmasks ) );
946 for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ ) {
947 ber_dupbv( &(*vp)[ i ].word, &v[ i ].word );
948 *((slap_mask_t *)&(*vp)[ i ].mask) = v[ i ].mask;
951 BER_BVZERO( &(*vp)[ i ].word );
957 slap_verbmasks_destroy( slap_verbmasks *v )
963 for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ ) {
964 ch_free( v[ i ].word.bv_val );
973 slap_verbmasks_append(
977 slap_mask_t *ignore )
982 return LDAP_OPERATIONS_ERROR;
985 for ( i = 0; !BER_BVISNULL( &(*vp)[ i ].word ); i++ ) {
986 if ( !(*vp)[ i ].mask ) continue;
988 if ( ignore != NULL ) {
991 for ( j = 0; ignore[ j ] != 0; j++ ) {
992 if ( (*vp)[ i ].mask == ignore[ j ] ) {
998 if ( ( m & (*vp)[ i ].mask ) == (*vp)[ i ].mask ) {
999 if ( ber_bvstrcasecmp( v, &(*vp)[ i ].word ) == 0 ) {
1000 /* already set; ignore */
1001 return LDAP_SUCCESS;
1004 return LDAP_TYPE_OR_VALUE_EXISTS;
1007 if ( m & (*vp)[ i ].mask ) {
1009 return LDAP_CONSTRAINT_VIOLATION;
1014 *vp = ch_realloc( *vp, sizeof( slap_verbmasks ) * ( i + 2 ) );
1015 ber_dupbv( &(*vp)[ i ].word, v );
1016 *((slap_mask_t *)&(*vp)[ i ].mask) = m;
1017 BER_BVZERO( &(*vp)[ i + 1 ].word );
1019 return LDAP_SUCCESS;
1023 enum_to_verb(slap_verbmasks *v, slap_mask_t m, struct berval *bv) {
1026 for (i=0; !BER_BVISNULL(&v[i].word); i++) {
1027 if ( m == v[i].mask ) {
1038 static slap_verbmasks tlskey[] = {
1039 { BER_BVC("no"), SB_TLS_OFF },
1040 { BER_BVC("yes"), SB_TLS_ON },
1041 { BER_BVC("critical"), SB_TLS_CRITICAL },
1046 static slap_verbmasks methkey[] = {
1047 { BER_BVC("none"), LDAP_AUTH_NONE },
1048 { BER_BVC("simple"), LDAP_AUTH_SIMPLE },
1049 #ifdef HAVE_CYRUS_SASL
1050 { BER_BVC("sasl"), LDAP_AUTH_SASL },
1055 static slap_cf_aux_table bindkey[] = {
1056 { BER_BVC("uri="), offsetof(slap_bindconf, sb_uri), 'b', 1, NULL },
1057 { BER_BVC("bindmethod="), offsetof(slap_bindconf, sb_method), 'd', 0, methkey },
1058 { BER_BVC("binddn="), offsetof(slap_bindconf, sb_binddn), 'b', 1, NULL },
1059 { BER_BVC("credentials="), offsetof(slap_bindconf, sb_cred), 'b', 1, NULL },
1060 { BER_BVC("saslmech="), offsetof(slap_bindconf, sb_saslmech), 'b', 0, NULL },
1061 { BER_BVC("secprops="), offsetof(slap_bindconf, sb_secprops), 's', 0, NULL },
1062 { BER_BVC("realm="), offsetof(slap_bindconf, sb_realm), 'b', 0, NULL },
1063 { BER_BVC("authcID="), offsetof(slap_bindconf, sb_authcId), 'b', 0, NULL },
1064 { BER_BVC("authzID="), offsetof(slap_bindconf, sb_authzId), 'b', 1, NULL },
1066 { BER_BVC("starttls="), offsetof(slap_bindconf, sb_tls), 'd', 0, tlskey },
1068 #define aux_TLS (bindkey+10) /* beginning of TLS keywords */
1070 { BER_BVC("tls_cert="), offsetof(slap_bindconf, sb_tls_cert), 's', 1, NULL },
1071 { BER_BVC("tls_key="), offsetof(slap_bindconf, sb_tls_key), 's', 1, NULL },
1072 { BER_BVC("tls_cacert="), offsetof(slap_bindconf, sb_tls_cacert), 's', 1, NULL },
1073 { BER_BVC("tls_cacertdir="), offsetof(slap_bindconf, sb_tls_cacertdir), 's', 1, NULL },
1074 { BER_BVC("tls_reqcert="), offsetof(slap_bindconf, sb_tls_reqcert), 's', 1, NULL },
1075 { BER_BVC("tls_cipher_suite="), offsetof(slap_bindconf, sb_tls_cipher_suite), 's', 1, NULL },
1076 #ifdef HAVE_OPENSSL_CRL
1077 { BER_BVC("tls_crlcheck="), offsetof(slap_bindconf, sb_tls_crlcheck), 's', 1, NULL },
1080 { BER_BVNULL, 0, 0, 0, NULL }
1084 slap_cf_aux_table_parse( const char *word, void *dst, slap_cf_aux_table *tab0, LDAP_CONST char *tabmsg )
1086 int rc = SLAP_CONF_UNKNOWN;
1087 slap_cf_aux_table *tab;
1089 for (tab = tab0; !BER_BVISNULL(&tab->key); tab++ ) {
1090 if ( !strncasecmp( word, tab->key.bv_val, tab->key.bv_len )) {
1095 unsigned long *ulptr;
1096 struct berval *bptr;
1097 const char *val = word + tab->key.bv_len;
1099 switch ( tab->type ) {
1101 cptr = (char **)((char *)dst + tab->off);
1102 *cptr = ch_strdup( val );
1107 bptr = (struct berval *)((char *)dst + tab->off);
1108 ber_str2bv( val, 0, 1, bptr );
1113 assert( tab->aux != NULL );
1114 iptr = (int *)((char *)dst + tab->off);
1117 for ( j = 0; !BER_BVISNULL( &tab->aux[j].word ); j++ ) {
1118 if ( !strcasecmp( val, tab->aux[j].word.bv_val ) ) {
1119 *iptr = tab->aux[j].mask;
1126 iptr = (int *)((char *)dst + tab->off);
1128 rc = lutil_atoix( iptr, val, 0 );
1132 uptr = (unsigned *)((char *)dst + tab->off);
1134 rc = lutil_atoux( uptr, val, 0 );
1138 lptr = (long *)((char *)dst + tab->off);
1140 rc = lutil_atolx( lptr, val, 0 );
1144 ulptr = (unsigned long *)((char *)dst + tab->off);
1146 rc = lutil_atoulx( ulptr, val, 0 );
1151 Debug( LDAP_DEBUG_ANY, "invalid %s value %s\n",
1163 slap_cf_aux_table_unparse( void *src, struct berval *bv, slap_cf_aux_table *tab0 )
1165 char buf[AC_LINE_MAX], *ptr;
1166 slap_cf_aux_table *tab;
1170 for (tab = tab0; !BER_BVISNULL(&tab->key); tab++ ) {
1175 unsigned long *ulptr;
1176 struct berval *bptr;
1178 cptr = (char **)((char *)src + tab->off);
1180 switch ( tab->type ) {
1182 bptr = (struct berval *)((char *)src + tab->off);
1183 cptr = &bptr->bv_val;
1187 ptr = lutil_strcopy( ptr, tab->key.bv_val );
1188 if ( tab->quote ) *ptr++ = '"';
1189 ptr = lutil_strcopy( ptr, *cptr );
1190 if ( tab->quote ) *ptr++ = '"';
1195 assert( tab->aux != NULL );
1196 iptr = (int *)((char *)src + tab->off);
1198 for ( i = 0; !BER_BVISNULL( &tab->aux[i].word ); i++ ) {
1199 if ( *iptr == tab->aux[i].mask ) {
1201 ptr = lutil_strcopy( ptr, tab->key.bv_val );
1202 ptr = lutil_strcopy( ptr, tab->aux[i].word.bv_val );
1209 iptr = (int *)((char *)src + tab->off);
1211 ptr = lutil_strcopy( ptr, tab->key.bv_val );
1212 ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ), "%d", *iptr );
1216 uptr = (unsigned *)((char *)src + tab->off);
1218 ptr = lutil_strcopy( ptr, tab->key.bv_val );
1219 ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ), "%u", *uptr );
1223 lptr = (long *)((char *)src + tab->off);
1225 ptr = lutil_strcopy( ptr, tab->key.bv_val );
1226 ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ), "%ld", *lptr );
1230 ulptr = (unsigned long *)((char *)src + tab->off);
1232 ptr = lutil_strcopy( ptr, tab->key.bv_val );
1233 ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ), "%lu", *ulptr );
1241 tmp.bv_len = ptr - buf;
1242 ber_dupbv( bv, &tmp );
1247 bindconf_parse( const char *word, slap_bindconf *bc )
1250 /* Detect TLS config changes explicitly */
1251 if ( slap_cf_aux_table_parse( word, bc, aux_TLS, "tls config" ) == 0 ) {
1252 bc->sb_tls_do_init = 1;
1256 return slap_cf_aux_table_parse( word, bc, bindkey, "bind config" );
1260 bindconf_unparse( slap_bindconf *bc, struct berval *bv )
1262 return slap_cf_aux_table_unparse( bc, bv, bindkey );
1265 void bindconf_free( slap_bindconf *bc ) {
1266 if ( !BER_BVISNULL( &bc->sb_uri ) ) {
1267 ch_free( bc->sb_uri.bv_val );
1268 BER_BVZERO( &bc->sb_uri );
1270 if ( !BER_BVISNULL( &bc->sb_binddn ) ) {
1271 ch_free( bc->sb_binddn.bv_val );
1272 BER_BVZERO( &bc->sb_binddn );
1274 if ( !BER_BVISNULL( &bc->sb_cred ) ) {
1275 ch_free( bc->sb_cred.bv_val );
1276 BER_BVZERO( &bc->sb_cred );
1278 if ( !BER_BVISNULL( &bc->sb_saslmech ) ) {
1279 ch_free( bc->sb_saslmech.bv_val );
1280 BER_BVZERO( &bc->sb_saslmech );
1282 if ( bc->sb_secprops ) {
1283 ch_free( bc->sb_secprops );
1284 bc->sb_secprops = NULL;
1286 if ( !BER_BVISNULL( &bc->sb_realm ) ) {
1287 ch_free( bc->sb_realm.bv_val );
1288 BER_BVZERO( &bc->sb_realm );
1290 if ( !BER_BVISNULL( &bc->sb_authcId ) ) {
1291 ch_free( bc->sb_authcId.bv_val );
1292 BER_BVZERO( &bc->sb_authcId );
1294 if ( !BER_BVISNULL( &bc->sb_authzId ) ) {
1295 ch_free( bc->sb_authzId.bv_val );
1296 BER_BVZERO( &bc->sb_authzId );
1300 if ( bc->sb_tls_ctx ) {
1301 SSL_CTX_free( bc->sb_tls_ctx );
1302 bc->sb_tls_ctx = NULL;
1305 if ( bc->sb_tls_cert ) {
1306 ch_free( bc->sb_tls_cert );
1307 bc->sb_tls_cert = NULL;
1309 if ( bc->sb_tls_key ) {
1310 ch_free( bc->sb_tls_key );
1311 bc->sb_tls_key = NULL;
1313 if ( bc->sb_tls_cacert ) {
1314 ch_free( bc->sb_tls_cacert );
1315 bc->sb_tls_cacert = NULL;
1317 if ( bc->sb_tls_cacertdir ) {
1318 ch_free( bc->sb_tls_cacertdir );
1319 bc->sb_tls_cacertdir = NULL;
1321 if ( bc->sb_tls_reqcert ) {
1322 ch_free( bc->sb_tls_reqcert );
1323 bc->sb_tls_reqcert = NULL;
1325 if ( bc->sb_tls_cipher_suite ) {
1326 ch_free( bc->sb_tls_cipher_suite );
1327 bc->sb_tls_cipher_suite = NULL;
1329 #ifdef HAVE_OPENSSL_CRL
1330 if ( bc->sb_tls_crlcheck ) {
1331 ch_free( bc->sb_tls_crlcheck );
1332 bc->sb_tls_crlcheck = NULL;
1344 { "tls_cert", offsetof(slap_bindconf, sb_tls_cert), LDAP_OPT_X_TLS_CERTFILE },
1345 { "tls_key", offsetof(slap_bindconf, sb_tls_key), LDAP_OPT_X_TLS_KEYFILE },
1346 { "tls_cacert", offsetof(slap_bindconf, sb_tls_cacert), LDAP_OPT_X_TLS_CACERTFILE },
1347 { "tls_cacertdir", offsetof(slap_bindconf, sb_tls_cacertdir), LDAP_OPT_X_TLS_CACERTDIR },
1348 { "tls_cipher_suite", offsetof(slap_bindconf, sb_tls_cipher_suite), LDAP_OPT_X_TLS_CIPHER_SUITE },
1352 int bindconf_tls_set( slap_bindconf *bc, LDAP *ld )
1354 int i, rc, newctx = 0, res = 0;
1355 char *ptr = (char *)bc, **word;
1357 bc->sb_tls_do_init = 0;
1359 for (i=0; bindtlsopts[i].opt; i++) {
1360 word = (char **)(ptr + bindtlsopts[i].offset);
1362 rc = ldap_set_option( ld, bindtlsopts[i].opt, *word );
1364 Debug( LDAP_DEBUG_ANY,
1365 "bindconf_tls_set: failed to set %s to %s\n",
1366 bindtlsopts[i].key, *word, 0 );
1372 if ( bc->sb_tls_reqcert ) {
1373 rc = ldap_int_tls_config( ld, LDAP_OPT_X_TLS_REQUIRE_CERT,
1374 bc->sb_tls_reqcert );
1376 Debug( LDAP_DEBUG_ANY,
1377 "bindconf_tls_set: failed to set tls_reqcert to %s\n",
1378 bc->sb_tls_reqcert, 0, 0 );
1383 #ifdef HAVE_OPENSSL_CRL
1384 if ( bc->sb_tls_crlcheck ) {
1385 rc = ldap_int_tls_config( ld, LDAP_OPT_X_TLS_CRLCHECK,
1386 bc->sb_tls_crlcheck );
1388 Debug( LDAP_DEBUG_ANY,
1389 "bindconf_tls_set: failed to set tls_crlcheck to %s\n",
1390 bc->sb_tls_crlcheck, 0, 0 );
1399 if ( bc->sb_tls_ctx ) {
1400 SSL_CTX_free( bc->sb_tls_ctx );
1401 bc->sb_tls_ctx = NULL;
1403 rc = ldap_set_option( ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
1407 ldap_get_option( ld, LDAP_OPT_X_TLS_CTX, &bc->sb_tls_ctx );
1415 * connect to a client using the bindconf data
1416 * note: should move "version" into bindconf...
1419 slap_client_connect( LDAP **ldp, slap_bindconf *sb, int version )
1424 /* Init connection to master */
1425 rc = ldap_initialize( &ld, sb->sb_uri.bv_val );
1426 if ( rc != LDAP_SUCCESS ) {
1427 Debug( LDAP_DEBUG_ANY,
1428 "slap_client_connect: "
1429 "ldap_initialize(%s) failed (%d)\n",
1430 sb->sb_uri.bv_val, rc, 0 );
1434 if ( version != 0 ) {
1435 ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION,
1436 (const void *)&version );
1440 if ( sb->sb_tls_do_init ) {
1441 rc = bindconf_tls_set( sb, ld );
1443 } else if ( sb->sb_tls_ctx ) {
1444 rc = ldap_set_option( ld, LDAP_OPT_X_TLS_CTX,
1449 Debug( LDAP_DEBUG_ANY,
1450 "slap_client_connect: "
1451 "URI=%s TLS context initialization failed (%d)\n",
1452 sb->sb_uri.bv_val, rc, 0 );
1459 rc = ldap_start_tls_s( ld, NULL, NULL );
1460 if ( rc != LDAP_SUCCESS ) {
1461 Debug( LDAP_DEBUG_ANY,
1462 "slap_client_connect: URI=%s "
1463 "%s, ldap_start_tls failed (%d)\n",
1465 sb->sb_tls == SB_TLS_CRITICAL ?
1466 "Error" : "Warning",
1468 if ( sb->sb_tls == SB_TLS_CRITICAL ) {
1474 if ( sb->sb_method == LDAP_AUTH_SASL ) {
1475 #ifdef HAVE_CYRUS_SASL
1478 if ( sb->sb_secprops != NULL ) {
1479 rc = ldap_set_option( ld,
1480 LDAP_OPT_X_SASL_SECPROPS, sb->sb_secprops);
1482 if( rc != LDAP_OPT_SUCCESS ) {
1483 Debug( LDAP_DEBUG_ANY,
1484 "slap_client_connect: "
1485 "error, ldap_set_option "
1486 "(%s,SECPROPS,\"%s\") failed!\n",
1487 sb->sb_uri.bv_val, sb->sb_secprops, 0 );
1492 defaults = lutil_sasl_defaults( ld,
1493 sb->sb_saslmech.bv_val,
1494 sb->sb_realm.bv_val,
1495 sb->sb_authcId.bv_val,
1497 sb->sb_authzId.bv_val );
1499 rc = ldap_sasl_interactive_bind_s( ld,
1500 sb->sb_binddn.bv_val,
1501 sb->sb_saslmech.bv_val,
1504 lutil_sasl_interact,
1507 lutil_sasl_freedefs( defaults );
1509 /* FIXME: different error behaviors according to
1511 * 2) on err policy : exit, retry, backoff ...
1513 if ( rc != LDAP_SUCCESS ) {
1514 static struct berval bv_GSSAPI = BER_BVC( "GSSAPI" );
1516 Debug( LDAP_DEBUG_ANY, "slap_client_connect: URI=%s "
1517 "ldap_sasl_interactive_bind_s failed (%d)\n",
1518 sb->sb_uri.bv_val, rc, 0 );
1520 /* FIXME (see above comment) */
1521 /* if Kerberos credentials cache is not active, retry */
1522 if ( ber_bvcmp( &sb->sb_saslmech, &bv_GSSAPI ) == 0 &&
1523 rc == LDAP_LOCAL_ERROR )
1525 rc = LDAP_SERVER_DOWN;
1530 #else /* HAVE_CYRUS_SASL */
1531 /* Should never get here, we trapped this at config time */
1533 Debug( LDAP_DEBUG_SYNC, "not compiled with SASL support\n", 0, 0, 0 );
1538 } else if ( sb->sb_method == LDAP_AUTH_SIMPLE ) {
1539 rc = ldap_sasl_bind_s( ld,
1540 sb->sb_binddn.bv_val, LDAP_SASL_SIMPLE,
1541 &sb->sb_cred, NULL, NULL, NULL );
1542 if ( rc != LDAP_SUCCESS ) {
1543 Debug( LDAP_DEBUG_ANY, "slap_client_connect: "
1545 "ldap_sasl_bind_s failed (%d)\n",
1546 sb->sb_uri.bv_val, sb->sb_binddn.bv_val, rc );
1554 ldap_unbind_ext( ld, NULL, NULL );
1565 /* -------------------------------------- */
1569 strtok_quote( char *line, char *sep, char **quote_ptr )
1576 if ( line != NULL ) {
1579 while ( *next && strchr( sep, *next ) ) {
1583 if ( *next == '\0' ) {
1589 for ( inquote = 0; *next; ) {
1597 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1603 next + 1, strlen( next + 1 ) + 1 );
1604 next++; /* dont parse the escaped character */
1609 if ( strchr( sep, *next ) != NULL ) {
1623 static char buf[AC_LINE_MAX];
1625 static size_t lmax, lcur;
1627 #define CATLINE( buf ) \
1629 size_t len = strlen( buf ); \
1630 while ( lcur + len + 1 > lmax ) { \
1631 lmax += AC_LINE_MAX; \
1632 line = (char *) ch_realloc( line, lmax ); \
1634 strcpy( line + lcur, buf ); \
1639 fp_getline_init(ConfigArgs *c) {
1645 fp_getline( FILE *fp, ConfigArgs *c )
1653 /* avoid stack of bufs */
1654 if ( strncasecmp( line, "include", STRLENOF( "include" ) ) == 0 ) {
1660 while ( fgets( buf, sizeof( buf ), fp ) ) {
1661 p = strchr( buf, '\n' );
1663 if ( p > buf && p[-1] == '\r' ) {
1671 && ( p = line + strlen( line ) - 1 )[0] == '\\'
1678 if ( !isspace( (unsigned char)buf[0] ) ) {
1689 return(line[0] ? 1 : 0);
1693 fp_parse_line(ConfigArgs *c)
1696 static char *const hide[] = {
1697 "rootpw", "replica", "syncrepl", /* in slapd */
1698 "acl-bind", "acl-method", "idassert-bind", /* in back-ldap */
1699 "acl-passwd", "bindpw", /* in back-<ldap/meta> */
1700 "pseudorootpw", /* in back-meta */
1701 "dbpasswd", /* in back-sql */
1705 int i = (int)(sizeof(hide)/sizeof(hide[0])) - 1;
1707 c->tline = ch_strdup(c->line);
1708 token = strtok_quote(c->tline, " \t", "e_ptr);
1710 if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break;
1711 if(quote_ptr) *quote_ptr = ' ';
1712 Debug(LDAP_DEBUG_CONFIG, "line %d (%s%s)\n", c->lineno,
1713 hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
1714 if(quote_ptr) *quote_ptr = '\0';
1716 for(;; token = strtok_quote(NULL, " \t", "e_ptr)) {
1717 if(c->argc >= c->argv_size) {
1719 tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv));
1721 Debug(LDAP_DEBUG_ANY, "line %d: out of memory\n", c->lineno, 0, 0);
1725 c->argv_size += ARGS_STEP;
1729 c->argv[c->argc++] = token;
1731 c->argv[c->argc] = NULL;
1738 ucdata_unload( UCDATA_ALL );
1740 /* NOTE: in case of early exit, frontendDB can be NULL */
1741 if ( frontendDB->be_schemandn.bv_val )
1742 free( frontendDB->be_schemandn.bv_val );
1743 if ( frontendDB->be_schemadn.bv_val )
1744 free( frontendDB->be_schemadn.bv_val );
1745 if ( frontendDB->be_acl )
1746 acl_destroy( frontendDB->be_acl, NULL );
1749 if ( slapd_args_file )
1750 free ( slapd_args_file );
1751 if ( slapd_pid_file )
1752 free ( slapd_pid_file );
1753 if ( default_passwd_hash )
1754 ldap_charray_free( default_passwd_hash );
1758 slap_str2clist( char ***out, char *in, const char *brkstr )
1766 /* find last element in list */
1767 for (i = 0; *out && (*out)[i]; i++);
1769 /* protect the input string from strtok */
1770 str = ch_strdup( in );
1772 if ( *str == '\0' ) {
1777 /* Count words in string */
1779 for ( s = str; *s; s++ ) {
1780 if ( strchr( brkstr, *s ) != NULL ) {
1785 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
1787 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
1789 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
1791 *new = ch_strdup( s );
1800 int config_generic_wrapper( Backend *be, const char *fname, int lineno,
1801 int argc, char **argv )
1803 ConfigArgs c = { 0 };
1814 c.op = SLAP_CONFIG_ADD;
1815 snprintf( c.log, sizeof( c.log ), "%s: line %d", fname, lineno );
1817 rc = SLAP_CONF_UNKNOWN;
1818 ct = config_find_keyword( be->be_cf_ocs->co_table, &c );
1820 rc = config_add_vals( ct, &c );