]> git.sur5r.net Git - openldap/blob - servers/slapd/config.c
update for new backend types
[openldap] / servers / slapd / config.c
1 /* config.c - configuration file handling routines */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2005 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
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>.
15  */
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17  * All rights reserved.
18  *
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.
25  */
26
27 #include "portable.h"
28
29 #include <stdio.h>
30
31 #include <ac/string.h>
32 #include <ac/ctype.h>
33 #include <ac/signal.h>
34 #include <ac/socket.h>
35 #include <ac/errno.h>
36
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <unistd.h>
40
41 #include "slap.h"
42 #ifdef LDAP_SLAPI
43 #include "slapi/slapi.h"
44 #endif
45 #include "lutil.h"
46 #include "config.h"
47
48 #define ARGS_STEP       512
49
50 /*
51  * defaults for various global variables
52  */
53 slap_mask_t             global_allows = 0;
54 slap_mask_t             global_disallows = 0;
55 int             global_gentlehup = 0;
56 int             global_idletimeout = 0;
57 char    *global_host = NULL;
58 char    *global_realm = NULL;
59 char            *ldap_srvtab = "";
60 char            **default_passwd_hash = NULL;
61 struct berval default_search_base = BER_BVNULL;
62 struct berval default_search_nbase = BER_BVNULL;
63
64 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
65 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
66
67 int     slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
68 int     slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
69
70 char   *slapd_pid_file  = NULL;
71 char   *slapd_args_file = NULL;
72
73 int use_reverse_lookup = 0;
74
75 #ifdef LDAP_SLAPI
76 int slapi_plugins_used = 0;
77 #endif
78
79 static int fp_getline(FILE *fp, ConfigArgs *c);
80 static void fp_getline_init(ConfigArgs *c);
81 static int fp_parse_line(ConfigArgs *c);
82
83 static char     *strtok_quote(char *line, char *sep, char **quote_ptr);
84
85 ConfigArgs *
86 new_config_args( BackendDB *be, const char *fname, int lineno, int argc, char **argv )
87 {
88         ConfigArgs *c;
89         c = ch_calloc( 1, sizeof( ConfigArgs ) );
90         if ( c == NULL ) return(NULL);
91         c->be     = be; 
92         c->fname  = fname;
93         c->argc   = argc;
94         c->argv   = argv; 
95         c->lineno = lineno;
96         snprintf( c->log, sizeof( c->log ), "%s: line %d", fname, lineno );
97         return(c);
98 }
99
100 void
101 init_config_argv( ConfigArgs *c )
102 {
103         c->argv = ch_calloc( ARGS_STEP + 1, sizeof( *c->argv ) );
104         c->argv_size = ARGS_STEP + 1;
105 }
106
107 ConfigTable *config_find_keyword(ConfigTable *Conf, ConfigArgs *c) {
108         int i;
109
110         for(i = 0; Conf[i].name; i++)
111                 if( (Conf[i].length && (!strncasecmp(c->argv[0], Conf[i].name, Conf[i].length))) ||
112                         (!strcasecmp(c->argv[0], Conf[i].name)) ) break;
113         if ( !Conf[i].name ) return NULL;
114         return Conf+i;
115 }
116
117 int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) {
118         int rc, arg_user, arg_type, iarg;
119         long larg;
120         ber_len_t barg;
121         
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);
126                 return(0);
127         }
128         if((arg_type & ARG_DN) && c->argc == 1) {
129                 c->argc = 2;
130                 c->argv[1] = "";
131         }
132         if(Conf->min_args && (c->argc < Conf->min_args)) {
133                 sprintf( c->msg, "<%s> missing <%s> argument",
134                         c->argv[0], Conf->what );
135                 Debug(LDAP_DEBUG_CONFIG, "%s: keyword %s\n", c->log, c->msg, 0 );
136                 return(ARG_BAD_CONF);
137         }
138         if(Conf->max_args && (c->argc > Conf->max_args)) {
139                 sprintf( c->msg, "<%s> extra cruft after <%s> ignored",
140                         c->argv[0], Conf->what );
141                 Debug(LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 );
142         }
143         if((arg_type & ARG_DB) && !c->be) {
144                 sprintf( c->msg, "<%s> only allowed within database declaration",
145                         c->argv[0] );
146                 Debug(LDAP_DEBUG_CONFIG, "%s: keyword %s\n",
147                         c->log, c->msg, 0);
148                 return(ARG_BAD_CONF);
149         }
150         if((arg_type & ARG_PRE_BI) && c->bi) {
151                 sprintf( c->msg, "<%s> must occur before any backend %sdeclaration",
152                         c->argv[0], (arg_type & ARG_PRE_DB) ? "or database " : "" );
153                 Debug(LDAP_DEBUG_CONFIG, "%s: keyword %s\n",
154                         c->log, c->msg, 0 );
155                 return(ARG_BAD_CONF);
156         }
157         if((arg_type & ARG_PRE_DB) && c->be && c->be != frontendDB) {
158                 sprintf( c->msg, "<%s> must occur before any database declaration",
159                         c->argv[0] );
160                 Debug(LDAP_DEBUG_CONFIG, "%s: keyword %s\n",
161                         c->log, c->msg, 0);
162                 return(ARG_BAD_CONF);
163         }
164         if((arg_type & ARG_PAREN) && *c->argv[1] != '(' /*')'*/) {
165                 sprintf( c->msg, "<%s> old format not supported", c->argv[0] );
166                 Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
167                         c->log, c->msg, 0);
168                 return(ARG_BAD_CONF);
169         }
170         if((arg_type & ARGS_POINTER) && !Conf->arg_item && !(arg_type & ARG_OFFSET)) {
171                 sprintf( c->msg, "<%s> invalid config_table, arg_item is NULL",
172                         c->argv[0] );
173                 Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
174                         c->log, c->msg, 0);
175                 return(ARG_BAD_CONF);
176         }
177         c->type = arg_user = (arg_type & ARGS_USERLAND);
178         memset(&c->values, 0, sizeof(c->values));
179         if(arg_type & ARGS_NUMERIC) {
180                 int j;
181                 iarg = 0; larg = 0; barg = 0;
182                 switch(arg_type & ARGS_NUMERIC) {
183                         case ARG_INT:           iarg = atoi(c->argv[1]);                break;
184                         case ARG_LONG:          larg = strtol(c->argv[1], NULL, 0);     break;
185                         case ARG_BER_LEN_T:     barg = (ber_len_t)atol(c->argv[1]);     break;
186                         case ARG_ON_OFF:
187                                 if(c->argc == 1) {
188                                         iarg = 1;
189                                 } else if(!strcasecmp(c->argv[1], "on") ||
190                                         !strcasecmp(c->argv[1], "true")) {
191                                         iarg = 1;
192                                 } else if(!strcasecmp(c->argv[1], "off") ||
193                                         !strcasecmp(c->argv[1], "false")) {
194                                         iarg = 0;
195                                 } else {
196                                         sprintf( c->msg, "<%s> invalid value, ignored",
197                                                 c->argv[0] );
198                                         Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
199                                                 c->log, c->msg, 0 );
200                                         return(0);
201                                 }
202                                 break;
203                 }
204                 j = (arg_type & ARG_NONZERO) ? 1 : 0;
205                 if(iarg < j && larg < j && barg < j ) {
206                         larg = larg ? larg : (barg ? barg : iarg);
207                         sprintf( c->msg, "<%s> invalid value, ignored",
208                                 c->argv[0] );
209                         Debug(LDAP_DEBUG_CONFIG, "%s: %s\n",
210                                 c->log, c->msg, 0 );
211                         return(ARG_BAD_CONF);
212                 }
213                 switch(arg_type & ARGS_NUMERIC) {
214                         case ARG_ON_OFF:
215                         case ARG_INT:           c->value_int = iarg;            break;
216                         case ARG_LONG:          c->value_long = larg;           break;
217                         case ARG_BER_LEN_T:     c->value_ber_t = barg;          break;
218                 }
219         } else if(arg_type & ARG_STRING) {
220                 if ( !check_only )
221                         c->value_string = ch_strdup(c->argv[1]);
222         } else if(arg_type & ARG_BERVAL) {
223                 if ( !check_only )
224                         ber_str2bv( c->argv[1], 0, 1, &c->value_bv );
225         } else if(arg_type & ARG_DN) {
226                 struct berval bv;
227                 ber_str2bv( c->argv[1], 0, 0, &bv );
228                 rc = dnPrettyNormal( NULL, &bv, &c->value_dn, &c->value_ndn, NULL );
229                 if ( rc != LDAP_SUCCESS ) {
230                         sprintf( c->msg, "<%s> invalid DN %d (%s)",
231                                 c->argv[0], rc, ldap_err2string( rc ));
232                         Debug(LDAP_DEBUG_CONFIG, "%s: %s\n" , c->log, c->msg, 0);
233                         return(ARG_BAD_CONF);
234                 }
235                 if ( check_only ) {
236                         ch_free( c->value_ndn.bv_val );
237                         ch_free( c->value_dn.bv_val );
238                 }
239         }
240         return 0;
241 }
242
243 int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
244         int rc, arg_type;
245         void *ptr = NULL;
246
247         arg_type = Conf->arg_type;
248         if(arg_type & ARG_MAGIC) {
249                 if(!c->be) c->be = frontendDB;
250                 c->msg[0] = '\0';
251                 rc = (*((ConfigDriver*)Conf->arg_item))(c);
252 #if 0
253                 if(c->be == frontendDB) c->be = NULL;
254 #endif
255                 if(rc) {
256                         if ( !c->msg[0] ) {
257                                 sprintf( c->msg, "<%s> handler exited with %d",
258                                         c->argv[0], rc );
259                                 Debug(LDAP_DEBUG_CONFIG, "%s: %s!\n",
260                                         c->log, c->msg, 0 );
261                         }
262                         return(ARG_BAD_CONF);
263                 }
264                 return(0);
265         }
266         if(arg_type & ARG_OFFSET) {
267                 if (c->be)
268                         ptr = c->be->be_private;
269                 else if (c->bi)
270                         ptr = c->bi->bi_private;
271                 else {
272                         sprintf( c->msg, "<%s> offset is missing base pointer",
273                                 c->argv[0] );
274                         Debug(LDAP_DEBUG_CONFIG, "%s: %s!\n",
275                                 c->log, c->msg, 0);
276                         return(ARG_BAD_CONF);
277                 }
278                 ptr = (void *)((char *)ptr + (int)Conf->arg_item);
279         } else if (arg_type & ARGS_POINTER) {
280                 ptr = Conf->arg_item;
281         }
282         if(arg_type & ARGS_POINTER)
283                 switch(arg_type & ARGS_POINTER) {
284                         case ARG_ON_OFF:
285                         case ARG_INT:           *(int*)ptr = c->value_int;                      break;
286                         case ARG_LONG:          *(long*)ptr = c->value_long;                    break;
287                         case ARG_BER_LEN_T:     *(ber_len_t*)ptr = c->value_ber_t;                      break;
288                         case ARG_STRING: {
289                                 char *cc = *(char**)ptr;
290                                 if(cc) {
291                                         if ((arg_type & ARG_UNIQUE) && c->op == SLAP_CONFIG_ADD ) {
292                                                 Debug(LDAP_DEBUG_CONFIG, "%s: already set %s!\n",
293                                                         c->log, Conf->name, 0 );
294                                                 return(ARG_BAD_CONF);
295                                         }
296                                         ch_free(cc);
297                                 }
298                                 *(char **)ptr = c->value_string;
299                                 break;
300                                 }
301                         case ARG_BERVAL:
302                                 *(struct berval *)ptr = c->value_bv;
303                                 break;
304                 }
305         return(0);
306 }
307
308 int config_add_vals(ConfigTable *Conf, ConfigArgs *c) {
309         int rc, arg_type;
310
311         arg_type = Conf->arg_type;
312         if(arg_type == ARG_IGNORED) {
313                 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> ignored\n",
314                         c->log, Conf->name, 0);
315                 return(0);
316         }
317         rc = config_check_vals( Conf, c, 0 );
318         if ( rc ) return rc;
319         return config_set_vals( Conf, c );
320 }
321
322 int
323 config_del_vals(ConfigTable *cf, ConfigArgs *c)
324 {
325         int rc = 0;
326
327         /* If there is no handler, just ignore it */
328         if ( cf->arg_type & ARG_MAGIC ) {
329                 c->op = LDAP_MOD_DELETE;
330                 c->type = cf->arg_type & ARGS_USERLAND;
331                 rc = (*((ConfigDriver*)cf->arg_item))(c);
332         }
333         return rc;
334 }
335
336 int
337 config_get_vals(ConfigTable *cf, ConfigArgs *c)
338 {
339         int rc = 0;
340         struct berval bv;
341         void *ptr;
342
343         if ( cf->arg_type & ARG_IGNORED ) {
344                 return 1;
345         }
346
347         memset(&c->values, 0, sizeof(c->values));
348         c->rvalue_vals = NULL;
349         c->rvalue_nvals = NULL;
350         c->op = SLAP_CONFIG_EMIT;
351         c->type = cf->arg_type & ARGS_USERLAND;
352
353         if ( cf->arg_type & ARG_MAGIC ) {
354                 rc = (*((ConfigDriver*)cf->arg_item))(c);
355                 if ( rc ) return rc;
356         } else {
357                 if ( cf->arg_type & ARG_OFFSET ) {
358                         if ( c->be )
359                                 ptr = c->be->be_private;
360                         else if ( c->bi )
361                                 ptr = c->bi->bi_private;
362                         else
363                                 return 1;
364                         ptr = (void *)((char *)ptr + (int)cf->arg_item);
365                 } else {
366                         ptr = cf->arg_item;
367                 }
368                 
369                 switch(cf->arg_type & ARGS_POINTER) {
370                 case ARG_ON_OFF:
371                 case ARG_INT:   c->value_int = *(int *)ptr; break;
372                 case ARG_LONG:  c->value_long = *(long *)ptr; break;
373                 case ARG_BER_LEN_T:     c->value_ber_t = *(ber_len_t *)ptr; break;
374                 case ARG_STRING:
375                         if ( *(char **)ptr )
376                                 c->value_string = ch_strdup(*(char **)ptr);
377                         break;
378                 case ARG_BERVAL:
379                         ber_dupbv( &c->value_bv, (struct berval *)ptr ); break;
380                 }
381         }
382         if ( cf->arg_type & ARGS_POINTER) {
383                 bv.bv_val = c->log;
384                 switch(cf->arg_type & ARGS_POINTER) {
385                 case ARG_INT: bv.bv_len = sprintf(bv.bv_val, "%d", c->value_int); break;
386                 case ARG_LONG: bv.bv_len = sprintf(bv.bv_val, "%ld", c->value_long); break;
387                 case ARG_BER_LEN_T: bv.bv_len = sprintf(bv.bv_val, "%ld", c->value_ber_t); break;
388                 case ARG_ON_OFF: bv.bv_len = sprintf(bv.bv_val, "%s",
389                         c->value_int ? "TRUE" : "FALSE"); break;
390                 case ARG_STRING:
391                         if ( c->value_string && c->value_string[0]) {
392                                 ber_str2bv( c->value_string, 0, 0, &bv);
393                         } else {
394                                 return 1;
395                         }
396                         break;
397                 case ARG_BERVAL:
398                         if ( !BER_BVISEMPTY( &c->value_bv )) {
399                                 bv = c->value_bv;
400                         } else {
401                                 return 1;
402                         }
403                         break;
404                 }
405                 if (( cf->arg_type & ARGS_POINTER ) == ARG_STRING )
406                         ber_bvarray_add(&c->rvalue_vals, &bv);
407                 else
408                         value_add_one(&c->rvalue_vals, &bv);
409         }
410         return rc;
411 }
412
413 int
414 init_config_attrs(ConfigTable *ct) {
415         LDAPAttributeType *at;
416         int i, code;
417         const char *err;
418
419         for (i=0; ct[i].name; i++ ) {
420                 int             freeit = 0;
421
422                 if ( !ct[i].attribute ) continue;
423                 at = ldap_str2attributetype( ct[i].attribute,
424                         &code, &err, LDAP_SCHEMA_ALLOW_ALL );
425                 if ( !at ) {
426                         fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s, %s\n",
427                                 ct[i].attribute, ldap_scherr2str(code), err );
428                         return code;
429                 }
430
431                 code = at_add( at, 0, NULL, &err );
432                 if ( code ) {
433                         if ( code == SLAP_SCHERR_ATTR_DUP ) {
434                                 freeit = 1;
435
436                         } else {
437                                 fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s, %s\n",
438                                         ct[i].attribute, scherr2str(code), err );
439                                 return code;
440                         }
441                 }
442                 code = slap_str2ad( at->at_names[0], &ct[i].ad, &err );
443                 if ( freeit ) {
444                         ldap_attributetype_free( at );
445                 } else {
446                         ldap_memfree( at );
447                 }
448                 if ( code ) {
449                         fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s\n",
450                                 ct[i].attribute, err );
451                         return code;
452                 }
453         }
454
455         return 0;
456 }
457
458 int
459 init_config_ocs( ConfigOCs *ocs ) {
460         int i;
461
462         for (i=0;ocs[i].co_def;i++) {
463                 LDAPObjectClass *oc;
464                 int code;
465                 const char *err;
466
467                 oc = ldap_str2objectclass( ocs[i].co_def, &code, &err,
468                         LDAP_SCHEMA_ALLOW_ALL );
469                 if ( !oc ) {
470                         fprintf( stderr, "init_config_ocs: objectclass \"%s\": %s, %s\n",
471                                 ocs[i].co_def, ldap_scherr2str(code), err );
472                         return code;
473                 }
474                 code = oc_add(oc,0,NULL,&err);
475                 if ( code && code != SLAP_SCHERR_CLASS_DUP ) {
476                         fprintf( stderr, "init_config_ocs: objectclass \"%s\": %s, %s\n",
477                                 ocs[i].co_def, scherr2str(code), err );
478                         return code;
479                 }
480                 ocs[i].co_oc = oc_find(oc->oc_names[0]);
481                 ldap_memfree(oc);
482         }
483         return 0;
484 }
485
486 int
487 config_parse_vals(ConfigTable *ct, ConfigArgs *c, int valx)
488 {
489         int     rc = 0;
490         char    *saveline = NULL;
491
492         snprintf( c->log, sizeof( c->log ), "%s: value #%d",
493                 ct->ad->ad_cname.bv_val, valx );
494         c->argc = 1;
495         c->argv[0] = ct->ad->ad_cname.bv_val;
496
497         if ( ( ct->arg_type & ARG_QUOTE ) && c->line[ 0 ] != '"' ) {
498                 ber_len_t       len;
499
500                 saveline = c->line;
501                 len = strlen( c->line );
502                 c->line = ch_malloc( len + STRLENOF( "\"\"" ) + 1 );
503                 sprintf( c->line, "\"%s\"", saveline );
504         }
505
506         if ( fp_parse_line( c ) ) {
507                 rc = 1;
508         } else {
509                 rc = config_check_vals( ct, c, 1 );
510         }
511
512         if ( saveline ) {
513                 ch_free( c->line );
514                 c->line = saveline;
515         }
516
517         if ( rc )
518                 rc = LDAP_CONSTRAINT_VIOLATION;
519
520         ch_free( c->tline );
521         return rc;
522 }
523
524 int
525 config_parse_add(ConfigTable *ct, ConfigArgs *c)
526 {
527         int     rc = 0;
528         char    *saveline = NULL;
529
530         snprintf( c->log, sizeof( c->log ), "%s: value #%d",
531                 ct->ad->ad_cname.bv_val, c->valx );
532         c->argc = 1;
533         c->argv[0] = ct->ad->ad_cname.bv_val;
534
535         if ( ( ct->arg_type & ARG_QUOTE ) && c->line[ 0 ] != '"' ) {
536                 ber_len_t       len;
537
538                 saveline = c->line;
539                 len = strlen( c->line );
540                         
541                 c->line = ch_malloc( len + STRLENOF( "\"\"" ) + 1 );
542                 sprintf( c->line, "\"%s\"", saveline );
543         }
544
545         if ( fp_parse_line( c ) ) {
546                 rc = 1;
547         } else {
548                 c->op = LDAP_MOD_ADD;
549                 rc = config_add_vals( ct, c );
550         }
551
552         if ( saveline ) {
553                 ch_free( c->line );
554                 c->line = saveline;
555         }
556
557         ch_free( c->tline );
558         return rc;
559 }
560
561 int
562 read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft)
563 {
564         FILE *fp;
565         ConfigTable *ct;
566         ConfigArgs *c;
567         int rc;
568         struct stat s;
569
570         c = ch_calloc( 1, sizeof( ConfigArgs ) );
571         if ( c == NULL ) {
572                 return 1;
573         }
574
575         if ( depth ) {
576                 memcpy( c, cf, sizeof( ConfigArgs ) );
577         } else {
578                 c->depth = depth; /* XXX */
579                 c->bi = NULL;
580                 c->be = NULL;
581         }
582
583         c->valx = -1;
584         c->fname = fname;
585         init_config_argv( c );
586
587         if ( stat( fname, &s ) != 0 ) {
588                 ldap_syslog = 1;
589                 Debug(LDAP_DEBUG_ANY,
590                     "could not stat config file \"%s\": %s (%d)\n",
591                     fname, strerror(errno), errno);
592                 return(1);
593         }
594
595         if ( !S_ISREG( s.st_mode ) ) {
596                 ldap_syslog = 1;
597                 Debug(LDAP_DEBUG_ANY,
598                     "regular file expected, got \"%s\"\n",
599                     fname, 0, 0 );
600                 return(1);
601         }
602
603         fp = fopen( fname, "r" );
604         if ( fp == NULL ) {
605                 ldap_syslog = 1;
606                 Debug(LDAP_DEBUG_ANY,
607                     "could not open config file \"%s\": %s (%d)\n",
608                     fname, strerror(errno), errno);
609                 return(1);
610         }
611
612         Debug(LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0);
613
614         fp_getline_init(c);
615
616         c->tline = NULL;
617
618         while ( fp_getline( fp, c ) ) {
619                 /* skip comments and blank lines */
620                 if ( c->line[0] == '#' || c->line[0] == '\0' ) {
621                         continue;
622                 }
623
624                 snprintf( c->log, sizeof( c->log ), "%s: line %d",
625                                 c->fname, c->lineno );
626
627                 c->argc = 0;
628                 ch_free( c->tline );
629                 if ( fp_parse_line( c ) ) {
630                         rc = 1;
631                         goto leave;
632                 }
633
634                 if ( c->argc < 1 ) {
635                         Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: bad config line" 
636                                 SLAPD_CONF_UNKNOWN_IGNORED ".\n",
637                                 c->log, 0, 0);
638 #ifdef SLAPD_CONF_UNKNOWN_BAILOUT
639                         rc = 1;
640                         goto leave;
641 #else /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
642                         continue;
643 #endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
644                 }
645
646                 c->op = SLAP_CONFIG_ADD;
647
648                 ct = config_find_keyword( cft, c );
649                 if ( ct ) {
650                         rc = config_add_vals( ct, c );
651                         if ( !rc ) continue;
652
653                         if ( rc & ARGS_USERLAND ) {
654                                 /* XXX a usertype would be opaque here */
655                                 Debug(LDAP_DEBUG_CONFIG, "%s: unknown user type <%s>\n",
656                                         c->log, c->argv[0], 0);
657                                 rc = 1;
658                                 goto leave;
659
660                         } else if ( rc == ARG_BAD_CONF ) {
661                                 rc = 1;
662                                 goto leave;
663                         }
664                         
665                 } else if ( c->bi && !c->be ) {
666                         rc = SLAP_CONF_UNKNOWN;
667                         if ( c->bi->bi_cf_ocs ) {
668                                 ct = config_find_keyword( c->bi->bi_cf_ocs->co_table, c );
669                                 if ( ct ) {
670                                         rc = config_add_vals( ct, c );
671                                 }
672                         }
673                         if ( c->bi->bi_config && rc == SLAP_CONF_UNKNOWN ) {
674                                 rc = (*c->bi->bi_config)(c->bi, c->fname, c->lineno,
675                                         c->argc, c->argv);
676                         }
677                         if ( rc ) {
678                                 switch(rc) {
679                                 case SLAP_CONF_UNKNOWN:
680                                         Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: "
681                                                 "unknown directive <%s> inside backend info definition"
682                                                 SLAPD_CONF_UNKNOWN_IGNORED ".\n",
683                                                 c->log, *c->argv, 0);
684 #ifndef SLAPD_CONF_UNKNOWN_BAILOUT
685                                         continue;
686 #endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
687                                 default:
688                                         rc = 1;
689                                         goto leave;
690                                 }
691                         }
692
693                 } else if ( c->be ) {
694                         rc = SLAP_CONF_UNKNOWN;
695                         if ( c->be->be_cf_ocs ) {
696                                 ct = config_find_keyword( c->be->be_cf_ocs->co_table, c );
697                                 if ( ct ) {
698                                         rc = config_add_vals( ct, c );
699                                 }
700                         }
701                         if ( c->be->be_config && rc == SLAP_CONF_UNKNOWN ) {
702                                 rc = (*c->be->be_config)(c->be, c->fname, c->lineno,
703                                         c->argc, c->argv);
704                         }
705                         if ( rc ) {
706                                 switch(rc) {
707                                 case SLAP_CONF_UNKNOWN:
708                                         Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: "
709                                                 "unknown directive <%s> inside backend database "
710                                                 "definition" SLAPD_CONF_UNKNOWN_IGNORED ".\n",
711                                                 c->log, *c->argv, 0);
712 #ifndef SLAPD_CONF_UNKNOWN_BAILOUT
713                                         continue;
714 #endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
715                                 default:
716                                         rc = 1;
717                                         goto leave;
718                                 }
719                         }
720
721                 } else if ( frontendDB->be_config ) {
722                         rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv);
723                         if ( rc ) {
724                                 switch(rc) {
725                                 case SLAP_CONF_UNKNOWN:
726                                         Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: "
727                                                 "unknown directive <%s> inside global database definition"
728                                                 SLAPD_CONF_UNKNOWN_IGNORED ".\n",
729                                                 c->log, *c->argv, 0);
730 #ifndef SLAPD_CONF_UNKNOWN_BAILOUT
731                                         continue;
732 #endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
733                                 default:
734                                         rc = 1;
735                                         goto leave;
736                                 }
737                         }
738                         
739                 } else {
740                         Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: "
741                                 "unknown directive <%s> outside backend info and database definitions"
742                                 SLAPD_CONF_UNKNOWN_IGNORED ".\n",
743                                 c->log, *c->argv, 0);
744 #ifdef SLAPD_CONF_UNKNOWN_BAILOUT
745                         rc = 1;
746                         goto leave;
747 #else /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
748                         continue;
749 #endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
750                 }
751         }
752
753         rc = 0;
754
755 leave:
756         ch_free(c->tline);
757         fclose(fp);
758         ch_free(c->argv);
759         ch_free(c);
760         return(rc);
761 }
762
763 /* restrictops, allows, disallows, requires, loglevel */
764
765 int
766 verb_to_mask(const char *word, slap_verbmasks *v) {
767         int i;
768         for(i = 0; !BER_BVISNULL(&v[i].word); i++)
769                 if(!strcasecmp(word, v[i].word.bv_val))
770                         break;
771         return(i);
772 }
773
774 int
775 verbs_to_mask(int argc, char *argv[], slap_verbmasks *v, slap_mask_t *m) {
776         int i, j;
777         for(i = 1; i < argc; i++) {
778                 j = verb_to_mask(argv[i], v);
779                 if(BER_BVISNULL(&v[j].word)) return(1);
780                 while (!v[j].mask) j--;
781                 *m |= v[j].mask;
782         }
783         return(0);
784 }
785
786 /* Mask keywords that represent multiple bits should occur before single
787  * bit keywords in the verbmasks array.
788  */
789 int
790 mask_to_verbs(slap_verbmasks *v, slap_mask_t m, BerVarray *bva) {
791         int i;
792
793         if (!m) return 1;
794         for (i=0; !BER_BVISNULL(&v[i].word); i++) {
795                 if (!v[i].mask) continue;
796                 if (( m & v[i].mask ) == v[i].mask ) {
797                         value_add_one( bva, &v[i].word );
798                         m ^= v[i].mask;
799                         if ( !m ) break;
800                 }
801         }
802         return 0;
803 }
804
805 int
806 slap_verbmasks_init( slap_verbmasks **vp, slap_verbmasks *v )
807 {
808         int             i;
809
810         assert( *vp == NULL );
811
812         for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ )
813                 ;
814
815         *vp = ch_calloc( i + 1, sizeof( slap_verbmasks ) );
816
817         for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ ) {
818                 ber_dupbv( &(*vp)[ i ].word, &v[ i ].word );
819                 *((slap_mask_t *)&(*vp)[ i ].mask) = v[ i ].mask;
820         }
821
822         BER_BVZERO( &(*vp)[ i ].word );
823
824         return 0;               
825 }
826
827 int
828 slap_verbmasks_destroy( slap_verbmasks *v )
829 {
830         int             i;
831
832         assert( v != NULL );
833
834         for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ ) {
835                 ch_free( v[ i ].word.bv_val );
836         }
837
838         ch_free( v );
839
840         return 0;
841 }
842
843 int
844 slap_verbmasks_append(
845         slap_verbmasks  **vp,
846         slap_mask_t     m,
847         struct berval   *v,
848         slap_mask_t     *ignore )
849 {
850         int     i;
851
852         if ( !m ) {
853                 return 1;
854         }
855
856         for ( i = 0; !BER_BVISNULL( &(*vp)[ i ].word ); i++ ) {
857                 if ( !(*vp)[ i ].mask ) continue;
858
859                 if ( ignore != NULL ) {
860                         int     j;
861
862                         for ( j = 0; ignore[ j ] != 0; j++ ) {
863                                 if ( (*vp)[ i ].mask == ignore[ j ] ) {
864                                         goto check_next;
865                                 }
866                         }
867                 }
868
869                 if ( ( m & (*vp)[ i ].mask ) == (*vp)[ i ].mask ) {
870                         if ( ber_bvstrcasecmp( v, &(*vp)[ i ].word ) == 0 ) {
871                                 /* already set; ignore */
872                                 return 0;
873                         }
874                         /* conflicts */
875                         return 1;
876                 }
877
878                 if ( m & (*vp)[ i ].mask ) {
879                         /* conflicts */
880                         return 1;
881                 }
882 check_next:;
883         }
884
885         *vp = ch_realloc( *vp, sizeof( slap_verbmasks ) * ( i + 2 ) );
886         ber_dupbv( &(*vp)[ i ].word, v );
887         *((slap_mask_t *)&(*vp)[ i ].mask) = m;
888         BER_BVZERO( &(*vp)[ i + 1 ].word );
889
890         return 0;
891 }
892
893 int
894 enum_to_verb(slap_verbmasks *v, slap_mask_t m, struct berval *bv) {
895         int i;
896
897         for (i=0; !BER_BVISNULL(&v[i].word); i++) {
898                 if ( m == v[i].mask ) {
899                         if ( bv != NULL ) {
900                                 *bv = v[i].word;
901                         }
902                         return i;
903                 }
904         }
905         return -1;
906 }
907
908 static slap_verbmasks tlskey[] = {
909         { BER_BVC("no"),        SB_TLS_OFF },
910         { BER_BVC("yes"),       SB_TLS_ON },
911         { BER_BVC("critical"),  SB_TLS_CRITICAL },
912         { BER_BVNULL, 0 }
913 };
914
915 static slap_verbmasks methkey[] = {
916         { BER_BVC("none"),      LDAP_AUTH_NONE },
917         { BER_BVC("simple"),    LDAP_AUTH_SIMPLE },
918 #ifdef HAVE_CYRUS_SASL
919         { BER_BVC("sasl"),      LDAP_AUTH_SASL },
920 #endif
921         { BER_BVNULL, 0 }
922 };
923
924 typedef struct cf_aux_table {
925         struct berval key;
926         int off;
927         char type;
928         char quote;
929         slap_verbmasks *aux;
930 } cf_aux_table;
931
932 static cf_aux_table bindkey[] = {
933         { BER_BVC("starttls="), offsetof(slap_bindconf, sb_tls), 'd', 0, tlskey },
934         { BER_BVC("bindmethod="), offsetof(slap_bindconf, sb_method), 'd', 0, methkey },
935         { BER_BVC("binddn="), offsetof(slap_bindconf, sb_binddn), 'b', 1, NULL },
936         { BER_BVC("credentials="), offsetof(slap_bindconf, sb_cred), 'b', 1, NULL },
937         { BER_BVC("saslmech="), offsetof(slap_bindconf, sb_saslmech), 'b', 0, NULL },
938         { BER_BVC("secprops="), offsetof(slap_bindconf, sb_secprops), 's', 0, NULL },
939         { BER_BVC("realm="), offsetof(slap_bindconf, sb_realm), 'b', 0, NULL },
940         { BER_BVC("authcID="), offsetof(slap_bindconf, sb_authcId), 'b', 0, NULL },
941         { BER_BVC("authzID="), offsetof(slap_bindconf, sb_authzId), 'b', 1, NULL },
942         { BER_BVNULL, 0, 0, 0, NULL }
943 };
944
945 int bindconf_parse( const char *word, slap_bindconf *bc ) {
946         int rc = 0;
947         cf_aux_table *tab;
948
949         for (tab = bindkey; !BER_BVISNULL(&tab->key); tab++) {
950                 if ( !strncasecmp( word, tab->key.bv_val, tab->key.bv_len )) {
951                         char **cptr;
952                         int *iptr, j;
953                         struct berval *bptr;
954                         const char *val = word + tab->key.bv_len;
955
956                         switch ( tab->type ) {
957                         case 's':
958                                 cptr = (char **)((char *)bc + tab->off);
959                                 *cptr = ch_strdup( val );
960                                 break;
961
962                         case 'b':
963                                 bptr = (struct berval *)((char *)bc + tab->off);
964                                 ber_str2bv( val, 0, 1, bptr );
965                                 break;
966
967                         case 'd':
968                                 assert( tab->aux != NULL );
969                                 iptr = (int *)((char *)bc + tab->off);
970
971                                 rc = 1;
972                                 for ( j = 0; !BER_BVISNULL( &tab->aux[j].word ); j++ ) {
973                                         if ( !strcasecmp( val, tab->aux[j].word.bv_val ) ) {
974                                                 *iptr = tab->aux[j].mask;
975                                                 rc = 0;
976                                         }
977                                 }
978                                 break;
979                         }
980
981                         if ( rc ) {
982                                 Debug( LDAP_DEBUG_ANY, "invalid bind config value %s\n",
983                                         word, 0, 0 );
984                         }
985                         
986                         return rc;
987                 }
988         }
989
990         return rc;
991 }
992
993 int bindconf_unparse( slap_bindconf *bc, struct berval *bv ) {
994         char buf[BUFSIZ], *ptr;
995         cf_aux_table *tab;
996         struct berval tmp;
997
998         ptr = buf;
999         for (tab = bindkey; !BER_BVISNULL(&tab->key); tab++) {
1000                 char **cptr;
1001                 int *iptr, i;
1002                 struct berval *bptr;
1003
1004                 cptr = (char **)((char *)bc + tab->off);
1005
1006                 switch ( tab->type ) {
1007                 case 'b':
1008                         bptr = (struct berval *)((char *)bc + tab->off);
1009                         cptr = &bptr->bv_val;
1010                 case 's':
1011                         if ( *cptr ) {
1012                                 *ptr++ = ' ';
1013                                 ptr = lutil_strcopy( ptr, tab->key.bv_val );
1014                                 if ( tab->quote ) *ptr++ = '"';
1015                                 ptr = lutil_strcopy( ptr, *cptr );
1016                                 if ( tab->quote ) *ptr++ = '"';
1017                         }
1018                         break;
1019
1020                 case 'd':
1021                         assert( tab->aux != NULL );
1022                         iptr = (int *)((char *)bc + tab->off);
1023                 
1024                         for ( i = 0; !BER_BVISNULL( &tab->aux[i].word ); i++ ) {
1025                                 if ( *iptr == tab->aux[i].mask ) {
1026                                         *ptr++ = ' ';
1027                                         ptr = lutil_strcopy( ptr, tab->key.bv_val );
1028                                         ptr = lutil_strcopy( ptr, tab->aux[i].word.bv_val );
1029                                         break;
1030                                 }
1031                         }
1032                         break;
1033                 }
1034         }
1035         tmp.bv_val = buf;
1036         tmp.bv_len = ptr - buf;
1037         ber_dupbv( bv, &tmp );
1038         return 0;
1039 }
1040
1041 void bindconf_free( slap_bindconf *bc ) {
1042         if ( !BER_BVISNULL( &bc->sb_binddn ) ) {
1043                 ch_free( bc->sb_binddn.bv_val );
1044                 BER_BVZERO( &bc->sb_binddn );
1045         }
1046         if ( !BER_BVISNULL( &bc->sb_cred ) ) {
1047                 ch_free( bc->sb_cred.bv_val );
1048                 BER_BVZERO( &bc->sb_cred );
1049         }
1050         if ( !BER_BVISNULL( &bc->sb_saslmech ) ) {
1051                 ch_free( bc->sb_saslmech.bv_val );
1052                 BER_BVZERO( &bc->sb_saslmech );
1053         }
1054         if ( bc->sb_secprops ) {
1055                 ch_free( bc->sb_secprops );
1056                 bc->sb_secprops = NULL;
1057         }
1058         if ( !BER_BVISNULL( &bc->sb_realm ) ) {
1059                 ch_free( bc->sb_realm.bv_val );
1060                 BER_BVZERO( &bc->sb_realm );
1061         }
1062         if ( !BER_BVISNULL( &bc->sb_authcId ) ) {
1063                 ch_free( bc->sb_authcId.bv_val );
1064                 BER_BVZERO( &bc->sb_authcId );
1065         }
1066         if ( !BER_BVISNULL( &bc->sb_authzId ) ) {
1067                 ch_free( bc->sb_authzId.bv_val );
1068                 BER_BVZERO( &bc->sb_authzId );
1069         }
1070 }
1071
1072
1073 /* -------------------------------------- */
1074
1075
1076 static char *
1077 strtok_quote( char *line, char *sep, char **quote_ptr )
1078 {
1079         int             inquote;
1080         char            *tmp;
1081         static char     *next;
1082
1083         *quote_ptr = NULL;
1084         if ( line != NULL ) {
1085                 next = line;
1086         }
1087         while ( *next && strchr( sep, *next ) ) {
1088                 next++;
1089         }
1090
1091         if ( *next == '\0' ) {
1092                 next = NULL;
1093                 return( NULL );
1094         }
1095         tmp = next;
1096
1097         for ( inquote = 0; *next; ) {
1098                 switch ( *next ) {
1099                 case '"':
1100                         if ( inquote ) {
1101                                 inquote = 0;
1102                         } else {
1103                                 inquote = 1;
1104                         }
1105                         AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1106                         break;
1107
1108                 case '\\':
1109                         if ( next[1] )
1110                                 AC_MEMCPY( next,
1111                                             next + 1, strlen( next + 1 ) + 1 );
1112                         next++;         /* dont parse the escaped character */
1113                         break;
1114
1115                 default:
1116                         if ( ! inquote ) {
1117                                 if ( strchr( sep, *next ) != NULL ) {
1118                                         *quote_ptr = next;
1119                                         *next++ = '\0';
1120                                         return( tmp );
1121                                 }
1122                         }
1123                         next++;
1124                         break;
1125                 }
1126         }
1127
1128         return( tmp );
1129 }
1130
1131 static char     buf[BUFSIZ];
1132 static char     *line;
1133 static size_t lmax, lcur;
1134
1135 #define CATLINE( buf ) \
1136         do { \
1137                 size_t len = strlen( buf ); \
1138                 while ( lcur + len + 1 > lmax ) { \
1139                         lmax += BUFSIZ; \
1140                         line = (char *) ch_realloc( line, lmax ); \
1141                 } \
1142                 strcpy( line + lcur, buf ); \
1143                 lcur += len; \
1144         } while( 0 )
1145
1146 static void
1147 fp_getline_init(ConfigArgs *c) {
1148         c->lineno = -1;
1149         buf[0] = '\0';
1150 }
1151
1152 static int
1153 fp_getline( FILE *fp, ConfigArgs *c )
1154 {
1155         char    *p;
1156
1157         lcur = 0;
1158         CATLINE(buf);
1159         c->lineno++;
1160
1161         /* avoid stack of bufs */
1162         if ( strncasecmp( line, "include", STRLENOF( "include" ) ) == 0 ) {
1163                 buf[0] = '\0';
1164                 c->line = line;
1165                 return(1);
1166         }
1167
1168         while ( fgets( buf, sizeof( buf ), fp ) ) {
1169                 p = strchr( buf, '\n' );
1170                 if ( p ) {
1171                         if ( p > buf && p[-1] == '\r' ) {
1172                                 --p;
1173                         }
1174                         *p = '\0';
1175                 }
1176                 /* XXX ugly */
1177                 c->line = line;
1178                 if ( line[0]
1179                                 && ( p = line + strlen( line ) - 1 )[0] == '\\'
1180                                 && p[-1] != '\\' )
1181                 {
1182                         p[0] = '\0';
1183                         lcur--;
1184                         
1185                 } else {
1186                         if ( !isspace( (unsigned char)buf[0] ) ) {
1187                                 return(1);
1188                         }
1189                         buf[0] = ' ';
1190                 }
1191                 CATLINE(buf);
1192                 c->lineno++;
1193         }
1194
1195         buf[0] = '\0';
1196         c->line = line;
1197         return(line[0] ? 1 : 0);
1198 }
1199
1200 static int
1201 fp_parse_line(ConfigArgs *c)
1202 {
1203         char *token;
1204         static char *const hide[] = {
1205                 "rootpw", "replica", "syncrepl",  /* in slapd */
1206                 "acl-bind", "acl-method", "idassert-bind",  /* in back-ldap */
1207                 "acl-passwd", "bindpw",  /* in back-<ldap/meta> */
1208                 "pseudorootpw",  /* in back-meta */
1209                 "dbpasswd",  /* in back-sql */
1210                 NULL
1211         };
1212         char *quote_ptr;
1213         int i = (int)(sizeof(hide)/sizeof(hide[0])) - 1;
1214
1215         c->tline = ch_strdup(c->line);
1216         token = strtok_quote(c->tline, " \t", &quote_ptr);
1217
1218         if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break;
1219         if(quote_ptr) *quote_ptr = ' ';
1220         Debug(LDAP_DEBUG_CONFIG, "line %d (%s%s)\n", c->lineno,
1221                 hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
1222         if(quote_ptr) *quote_ptr = '\0';
1223
1224         for(;; token = strtok_quote(NULL, " \t", &quote_ptr)) {
1225                 if(c->argc >= c->argv_size) {
1226                         char **tmp;
1227                         tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv));
1228                         if(!tmp) {
1229                                 Debug(LDAP_DEBUG_ANY, "line %d: out of memory\n", c->lineno, 0, 0);
1230                                 return -1;
1231                         }
1232                         c->argv = tmp;
1233                         c->argv_size += ARGS_STEP;
1234                 }
1235                 if(token == NULL)
1236                         break;
1237                 c->argv[c->argc++] = token;
1238         }
1239         c->argv[c->argc] = NULL;
1240         return(0);
1241 }
1242
1243 void
1244 config_destroy( )
1245 {
1246         ucdata_unload( UCDATA_ALL );
1247         if ( frontendDB ) {
1248                 /* NOTE: in case of early exit, frontendDB can be NULL */
1249                 if ( frontendDB->be_schemandn.bv_val )
1250                         free( frontendDB->be_schemandn.bv_val );
1251                 if ( frontendDB->be_schemadn.bv_val )
1252                         free( frontendDB->be_schemadn.bv_val );
1253                 if ( frontendDB->be_acl )
1254                         acl_destroy( frontendDB->be_acl, NULL );
1255         }
1256         free( line );
1257         if ( slapd_args_file )
1258                 free ( slapd_args_file );
1259         if ( slapd_pid_file )
1260                 free ( slapd_pid_file );
1261         if ( default_passwd_hash )
1262                 ldap_charray_free( default_passwd_hash );
1263 }
1264
1265 char **
1266 slap_str2clist( char ***out, char *in, const char *brkstr )
1267 {
1268         char    *str;
1269         char    *s;
1270         char    *lasts;
1271         int     i, j;
1272         char    **new;
1273
1274         /* find last element in list */
1275         for (i = 0; *out && (*out)[i]; i++);
1276
1277         /* protect the input string from strtok */
1278         str = ch_strdup( in );
1279
1280         if ( *str == '\0' ) {
1281                 free( str );
1282                 return( *out );
1283         }
1284
1285         /* Count words in string */
1286         j=1;
1287         for ( s = str; *s; s++ ) {
1288                 if ( strchr( brkstr, *s ) != NULL ) {
1289                         j++;
1290                 }
1291         }
1292
1293         *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
1294         new = *out + i;
1295         for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
1296                 s != NULL;
1297                 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
1298         {
1299                 *new = ch_strdup( s );
1300                 new++;
1301         }
1302
1303         *new = NULL;
1304         free( str );
1305         return( *out );
1306 }
1307
1308 int config_generic_wrapper( Backend *be, const char *fname, int lineno,
1309         int argc, char **argv )
1310 {
1311         ConfigArgs c = { 0 };
1312         ConfigTable *ct;
1313         int rc;
1314
1315         c.be = be;
1316         c.fname = fname;
1317         c.lineno = lineno;
1318         c.argc = argc;
1319         c.argv = argv;
1320         c.valx = -1;
1321         sprintf( c.log, "%s: line %d", fname, lineno );
1322
1323         rc = SLAP_CONF_UNKNOWN;
1324         ct = config_find_keyword( be->be_cf_ocs->co_table, &c );
1325         if ( ct )
1326                 rc = config_add_vals( ct, &c );
1327         return rc;
1328 }