]> git.sur5r.net Git - openldap/blob - servers/slapd/schema.c
use auth sockbuf max
[openldap] / servers / slapd / schema.c
1 /* schema.c - routines to manage schema definitions */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11
12 #include <ac/ctype.h>
13 #include <ac/string.h>
14 #include <ac/socket.h>
15
16 #include "slap.h"
17 #include "ldap_pvt.h"
18
19
20 #if defined( SLAPD_SCHEMA_DN )
21
22 int
23 schema_info( Entry **entry, const char **text )
24 {
25         AttributeDescription *ad_structuralObjectClass
26                 = slap_schema.si_ad_structuralObjectClass;
27         AttributeDescription *ad_objectClass
28                 = slap_schema.si_ad_objectClass;
29
30         Entry           *e;
31         struct berval   vals[2];
32
33         vals[1].bv_val = NULL;
34
35         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
36
37         e->e_attrs = NULL;
38         /* backend-specific schema info should be created by the
39          * backend itself
40          */
41         ber_dupbv( &e->e_name, &global_schemadn );
42         ber_dupbv( &e->e_nname, &global_schemandn );
43         e->e_private = NULL;
44
45         vals[0].bv_val = "subentry";
46         vals[0].bv_len = sizeof("subentry")-1;
47         attr_merge( e, ad_structuralObjectClass, vals );
48
49         vals[0].bv_val = "top";
50         vals[0].bv_len = sizeof("top")-1;
51         attr_merge( e, ad_objectClass, vals );
52
53         vals[0].bv_val = "subentry";
54         vals[0].bv_len = sizeof("subentry")-1;
55         attr_merge( e, ad_objectClass, vals );
56
57         vals[0].bv_val = "subschema";
58         vals[0].bv_len = sizeof("subschema")-1;
59         attr_merge( e, ad_objectClass, vals );
60
61         vals[0].bv_val = "extensibleObject";
62         vals[0].bv_len = sizeof("extensibleObject")-1;
63         attr_merge( e, ad_objectClass, vals );
64
65         {
66                 int rc;
67                 AttributeDescription *desc = NULL;
68                 struct berval rdn = global_schemadn;
69                 vals[0].bv_val = strchr( rdn.bv_val, '=' );
70
71                 if( vals[0].bv_val == NULL ) {
72                         *text = "improperly configured subschema subentry";
73                         return LDAP_OTHER;
74                 }
75
76                 vals[0].bv_val++;
77                 vals[0].bv_len = rdn.bv_len - (vals[0].bv_val - rdn.bv_val);
78                 rdn.bv_len -= vals[0].bv_len + 1;
79
80                 rc = slap_bv2ad( &rdn, &desc, text );
81
82                 if( rc != LDAP_SUCCESS ) {
83                         entry_free( e );
84                         *text = "improperly configured subschema subentry";
85                         return LDAP_OTHER;
86                 }
87
88                 attr_merge( e, desc, vals );
89         }
90
91         if ( syn_schema_info( e ) 
92                 || mr_schema_info( e )
93                 || mru_schema_info( e )
94                 || at_schema_info( e )
95                 || oc_schema_info( e ) )
96         {
97                 /* Out of memory, do something about it */
98                 entry_free( e );
99                 *text = "out of memory";
100                 return LDAP_OTHER;
101         }
102         
103         *entry = e;
104         return LDAP_SUCCESS;
105 }
106 #endif