]> git.sur5r.net Git - openldap/blob - servers/slapd/schemaparse.c
Add reference to slapd.conf(5) and recommendation to avoid cleartext passwords.
[openldap] / servers / slapd / schemaparse.c
1 /* schemaparse.c - routines to parse config file objectclass definitions */
2
3 #include "portable.h"
4
5 #include <stdio.h>
6
7 #include <ac/string.h>
8 #include <ac/socket.h>
9
10 #include "slap.h"
11
12 struct objclass         *global_oc;
13 int                     global_schemacheck;
14
15 static void             oc_usage(void);
16
17 void
18 parse_oc(
19     Backend     *be,
20     char        *fname,
21     int         lineno,
22     int         argc,
23     char        **argv
24 )
25 {
26         int             i;
27         char            last;
28         struct objclass *oc;
29         struct objclass **ocp;
30
31         oc = (struct objclass *) ch_calloc( 1, sizeof(struct objclass) );
32         oc->oc_name = ch_strdup( argv[1] );
33         for ( i = 2; i < argc; i++ ) {
34                 /* required attributes */
35                 if ( strcasecmp( argv[i], "requires" ) == 0 ) {
36                         do {
37                                 i++;
38                                 if ( i < argc ) {
39                                         char **s = str2charray( argv[i], "," );
40                                         last = argv[i][strlen( argv[i] ) - 1];
41                                         charray_merge( &oc->oc_required, s );
42                                         charray_free( s );
43                                 }
44                         } while ( i < argc && last == ',' );
45
46                 /* optional attributes */
47                 } else if ( strcasecmp( argv[i], "allows" ) == 0 ) {
48                         do {
49                                 i++;
50                                 if ( i < argc ) {
51                                         char **s = str2charray( argv[i], "," );
52                                         last = argv[i][strlen( argv[i] ) - 1];
53                                         
54                                         charray_merge( &oc->oc_allowed, s );
55                                         charray_free( s );
56                                 }
57                         } while ( i < argc && last == ',' );
58
59                 } else {
60                         fprintf( stderr,
61             "%s: line %d: expecting \"requires\" or \"allows\" got \"%s\"\n",
62                             fname, lineno, argv[i] );
63                         oc_usage();
64                 }
65         }
66
67         ocp = &global_oc;
68         while ( *ocp != NULL ) {
69                 ocp = &(*ocp)->oc_next;
70         }
71         *ocp = oc;
72 }
73
74 static void
75 oc_usage( void )
76 {
77         fprintf( stderr, "<oc clause> ::= objectclass <ocname>\n" );
78         fprintf( stderr, "                [ requires <attrlist> ]\n" );
79         fprintf( stderr, "                [ allows <attrlist> ]\n" );
80         exit( 1 );
81 }
82