|
|
1.1 root 1: /* schema.c - */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/quipu/RCS/schema.c,v 7.2 90/07/09 14:46:34 mrose Exp $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/quipu/RCS/schema.c,v 7.2 90/07/09 14:46:34 mrose Exp $
9: *
10: *
11: * $Log: schema.c,v $
12: * Revision 7.2 90/07/09 14:46:34 mrose
13: * sync
14: *
15: * Revision 7.1 90/03/15 11:19:09 mrose
16: * quipu-sync
17: *
18: * Revision 7.0 89/11/23 22:18:03 mrose
19: * Release 6.0
20: *
21: */
22:
23: /*
24: * NOTICE
25: *
26: * Acquisition, use, and distribution of this module and related
27: * materials are subject to the restrictions of a license agreement.
28: * Consult the Preface in the User's Manual for the full terms of
29: * this agreement.
30: *
31: */
32:
33:
34: #include "quipu/util.h"
35: #include "quipu/entry.h"
36: #include "quipu/ds_error.h"
37:
38: extern int oidformat;
39: extern LLog * log_dsap;
40:
41: extern AttributeType at_objectclass;
42: extern AttributeType at_schema;
43: extern OID alias_oc;
44:
45: AV_Sequence oc_avs (as)
46: Attr_Sequence as;
47: {
48: Attr_Sequence at;
49:
50: if ((at = as_find_type (as,at_objectclass)) == NULLATTR)
51: return (NULLAV);
52:
53: return( at->attr_value);
54: }
55:
56: real_check_schema (eptr,as,error)
57: Entry eptr;
58: Attr_Sequence as;
59: struct DSError * error;
60: {
61: register Attr_Sequence at;
62: AV_Sequence avs;
63: AV_Sequence avs_oc;
64: table_seq optr;
65: AV_Sequence tavs = NULLAV;
66: objectclass * oc;
67: extern OID alias_oc;
68:
69: DLOG (log_dsap,LLOG_TRACE,("check schema")) ;
70:
71: if (eptr->e_parent == NULLENTRY)
72: return (OK); /* no schema for root */
73:
74: if (eptr->e_data != E_DATA_MASTER)
75: return (OK); /* only check schema of MASTERed entries */
76:
77: avs_oc = avs = oc_avs (eptr->e_attributes);
78:
79: if ((at = as_find_type (eptr->e_parent->e_attributes,at_schema)) != NULLATTR) {
80: /* what should default be !!! */
81:
82: tavs = at->attr_value;
83: /* make sure object class is allowed */
84: if (test_schema (tavs,avs) != OK) {
85: LLOG (log_dsap,LLOG_EXCEPTIONS,("Specified object class is not in the tree structure (schema) list"));
86: error->dse_type = DSE_UPDATEERROR;
87: error->ERR_UPDATE.DSE_up_problem = DSE_UP_NAMINGVIOLATION;
88: return (NOTOK);
89: }
90: }
91:
92: /* now check 'must contain' attributes */
93: for (; avs != NULLAV; avs = avs->avseq_next) {
94: oc = (objectclass *) avs->avseq_av.av_struct;
95: for (optr=oc->oc_must; optr!=NULLTABLE_SEQ; optr=optr->ts_next) {
96: at = (as == NULLATTR) ? eptr->e_attributes : as;
97: for (; at!=NULLATTR; at=at->attr_link)
98: if (at->attr_type == optr->ts_oa)
99: break;
100:
101: if (at == NULLATTR) {
102: LLOG (log_dsap,LLOG_EXCEPTIONS,("'Must' attribute missing '%s'",attr2name(optr->ts_oa,OIDPART)));
103: error->dse_type = DSE_UPDATEERROR;
104: error->ERR_UPDATE.DSE_up_problem = DSE_UP_OBJECTCLASSVIOLATION;
105: return (NOTOK);
106: }
107: }
108: }
109:
110:
111: /* Now try the 'may' contain bits */
112: /* BUT not if "alias" */
113:
114: if ( check_in_oc (alias_oc, avs_oc) )
115: return (OK);
116:
117: at = (as == NULLATTR) ? eptr->e_attributes : as;
118: for (; at!=NULLATTR; at=at->attr_link) {
119: optr = NULLTABLE_SEQ;
120: for (avs = avs_oc; avs != NULLAV; avs = avs->avseq_next) {
121: oc = (objectclass *) avs->avseq_av.av_struct;
122: optr=oc->oc_must;
123: if ((optr == NULLTABLE_SEQ) && (oc->oc_may == NULLTABLE_SEQ) && (oc->oc_hierachy == NULLOIDSEQ))
124: return OK; /* unknown object class */
125: for (; optr!=NULLTABLE_SEQ; optr=optr->ts_next)
126: if (at->attr_type == optr->ts_oa)
127: break;
128: if (optr != NULLTABLE_SEQ)
129: break;
130:
131: for (optr=oc->oc_may; optr!=NULLTABLE_SEQ; optr=optr->ts_next)
132: if (at->attr_type == optr->ts_oa)
133: break;
134: if (optr != NULLTABLE_SEQ)
135: break;
136: }
137: if (optr == NULLTABLE_SEQ) {
138: LLOG (log_dsap,LLOG_EXCEPTIONS,("attribute '%s' not allowed in the specified objectclass",attr2name(at->attr_type,OIDPART)));
139: error->dse_type = DSE_UPDATEERROR;
140: error->ERR_UPDATE.DSE_up_problem = DSE_UP_OBJECTCLASSVIOLATION;
141: return (NOTOK);
142: }
143: }
144: return (OK);
145:
146: }
147:
148: check_schema_type (eptr,attr,error)
149: Entry eptr;
150: AttributeType attr;
151: struct DSError * error;
152: {
153: Attr_Sequence at;
154: register table_seq optr;
155: AV_Sequence avs;
156: AV_Sequence tavs = NULLAV;
157: objectclass * oc;
158:
159: DLOG (log_dsap,LLOG_TRACE,("check schema type"));
160:
161: if (eptr->e_parent == NULLENTRY)
162: return (OK); /* no schema for root */
163:
164: avs = oc_avs (eptr->e_attributes);
165:
166: if ((at = as_find_type (eptr->e_parent->e_attributes,at_schema)) != NULLATTR) {
167: tavs = at->attr_value;
168: if (test_schema (tavs,avs) != OK) {
169: LLOG (log_dsap,LLOG_EXCEPTIONS,("given objectclass not in schema (tree structure) list"));
170: error->dse_type = DSE_UPDATEERROR;
171: error->ERR_UPDATE.DSE_up_problem = DSE_UP_NAMINGVIOLATION;
172: return (NOTOK);
173: }
174: }
175:
176: /* Now try the 'may' contain bits */
177: /* BUT not if "alias" */
178:
179: if ( check_in_oc (alias_oc, avs) )
180: return (OK);
181:
182: for (; avs != NULLAV; avs = avs->avseq_next) {
183: oc = (objectclass *) avs->avseq_av.av_struct;
184: optr=oc->oc_must;
185: if ((optr == NULLTABLE_SEQ) && (oc->oc_may == NULLTABLE_SEQ) && (oc->oc_hierachy == NULLOIDSEQ))
186: return (OK); /* unknown object class */
187: for (; optr!=NULLTABLE_SEQ; optr=optr->ts_next)
188: if (attr == optr->ts_oa)
189: break;
190: if (optr != NULLTABLE_SEQ)
191: break;
192:
193: for (optr=oc->oc_may; optr!=NULLTABLE_SEQ; optr=optr->ts_next)
194: if (attr == optr->ts_oa)
195: break;
196: if (optr != NULLTABLE_SEQ)
197: break;
198: }
199:
200: if (optr == NULLTABLE_SEQ) {
201: LLOG (log_dsap,LLOG_EXCEPTIONS,("Attribute '%s' not allowed for specified objectclass",attr2name(attr,OIDPART)));
202: error->dse_type = DSE_UPDATEERROR;
203: error->ERR_UPDATE.DSE_up_problem = DSE_UP_OBJECTCLASSVIOLATION;
204: return (NOTOK);
205: }
206: return (OK);
207:
208: }
209:
210:
211: test_schema (tree,oc)
212: AV_Sequence tree;
213: AV_Sequence oc;
214: {
215: AV_Sequence aptr, tavs;
216: struct tree_struct *tptr;
217: char found;
218: objectclass * oc1;
219:
220: if (oc == NULLAV)
221: return (NOTOK);
222:
223: for (aptr=oc; aptr!= NULLAV; aptr=aptr->avseq_next) {
224: found = FALSE;
225: for (tavs=tree; tavs!=NULLAV ;tavs=tavs->avseq_next) {
226: tptr = (struct tree_struct *) tavs->avseq_av.av_struct;
227: if (tptr->tree_object == NULLOBJECTCLASS) {
228: /* is this correct behaviour ? */
229: found = TRUE;
230: break;
231: }
232: oc1 = (objectclass *) aptr->avseq_av.av_struct;
233: if (test_hierarchy (tptr->tree_object->oc_ot.ot_oid, oc1->oc_ot.ot_oid) == 0) {
234: found = TRUE;
235: break;
236: }
237: }
238: if (found == FALSE) {
239: return (NOTOK);
240: }
241: }
242: return (OK);
243: }
244:
245: test_hierarchy (a,b) /* see if b in oc a */
246: OID a,b;
247: {
248: struct oid_seq * oidseq;
249: objectclass *oc;
250:
251: if (oid_cmp (a,b) == 0)
252: return (OK);
253:
254: if ((oc = oid2oc(a)) == NULLOBJECTCLASS) {
255: LLOG (log_dsap,LLOG_EXCEPTIONS,("got an illeagl object class!!!"));
256: return (NOTOK);
257: }
258:
259: for (oidseq = oc->oc_hierachy; oidseq != NULLOIDSEQ; oidseq = oidseq->oid_next)
260: if (test_hierarchy (oidseq->oid_oid,b) == OK)
261: return (OK);
262:
263: return (NOTOK);
264: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.