|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T s
Length: 6306 (0x18a2) Types: TextFile Names: »schema.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z« └─⟦de7628f85⟧ └─⟦this⟧ »isode-6.0/quipu/schema.c«
/* schema.c - */ #ifndef lint static char *rcsid = "$Header: /f/osi/quipu/RCS/schema.c,v 7.0 89/11/23 22:18:03 mrose Rel $"; #endif /* * $Header: /f/osi/quipu/RCS/schema.c,v 7.0 89/11/23 22:18:03 mrose Rel $ * * * $Log: schema.c,v $ * Revision 7.0 89/11/23 22:18:03 mrose * Release 6.0 * */ /* * NOTICE * * Acquisition, use, and distribution of this module and related * materials are subject to the restrictions of a license agreement. * Consult the Preface in the User's Manual for the full terms of * this agreement. * */ #include "quipu/util.h" #include "quipu/entry.h" #include "quipu/ds_error.h" extern int oidformat; extern LLog * log_dsap; extern AttributeType at_objectclass; extern AttributeType at_schema; extern OID alias_oc; AV_Sequence oc_avs (as) Attr_Sequence as; { Attr_Sequence at; if ((at = as_find_type (as,at_objectclass)) == NULLATTR) return (NULLAV); return( at->attr_value); } real_check_schema (eptr,as,error,decode) Entry eptr; Attr_Sequence as; struct DSError * error; char decode; { register Attr_Sequence at; AV_Sequence avs; AV_Sequence avs_oc; table_seq optr; AV_Sequence tavs = NULLAV; objectclass * oc; extern OID alias_oc; DLOG (log_dsap,LLOG_TRACE,("check schema")) ; if (decode) (void) as_decode (as); if (eptr->e_parent == NULLENTRY) return (OK); /* no schema for root */ avs_oc = avs = oc_avs (eptr->e_attributes); if ((at = as_find_type (eptr->e_parent->e_attributes,at_schema)) != NULLATTR) { /* what should default be !!! */ tavs = at->attr_value; /* make sure object class is allowed */ if (test_schema (tavs,avs) != OK) { LLOG (log_dsap,LLOG_EXCEPTIONS,("Specified object class is not in the tree structure (schema) list")); error->dse_type = DSE_UPDATEERROR; error->ERR_UPDATE.DSE_up_problem = DSE_UP_NAMINGVIOLATION; return (NOTOK); } } /* now check 'must contain' attributes */ for (; avs != NULLAV; avs = avs->avseq_next) { oc = (objectclass *) avs->avseq_av.av_struct; for (optr=oc->oc_must; optr!=NULLTABLE_SEQ; optr=optr->ts_next) { at = (as == NULLATTR) ? eptr->e_attributes : as; for (; at!=NULLATTR; at=at->attr_link) if (at->attr_type.at_table == optr->ts_oa) break; if (at == NULLATTR) { LLOG (log_dsap,LLOG_EXCEPTIONS,("'Must' attribute missing '%s'",attr2name(optr->ts_oa,OIDPART))); error->dse_type = DSE_UPDATEERROR; error->ERR_UPDATE.DSE_up_problem = DSE_UP_OBJECTCLASSVIOLATION; return (NOTOK); } } } /* Now try the 'may' contain bits */ /* BUT not if "alias" */ if ( check_in_oc (alias_oc, avs_oc) ) return (OK); at = (as == NULLATTR) ? eptr->e_attributes : as; for (; at!=NULLATTR; at=at->attr_link) { optr = NULLTABLE_SEQ; for (avs = avs_oc; avs != NULLAV; avs = avs->avseq_next) { oc = (objectclass *) avs->avseq_av.av_struct; for (optr=oc->oc_must; optr!=NULLTABLE_SEQ; optr=optr->ts_next) if (at->attr_type.at_table == optr->ts_oa) break; if (optr != NULLTABLE_SEQ) break; for (optr=oc->oc_may; optr!=NULLTABLE_SEQ; optr=optr->ts_next) if (at->attr_type.at_table == optr->ts_oa) break; if (optr != NULLTABLE_SEQ) break; } if (optr == NULLTABLE_SEQ) { LLOG (log_dsap,LLOG_EXCEPTIONS,("attribute '%s' not allowed in the specified objectclass",attr2name(at->attr_type.at_table,OIDPART))); error->dse_type = DSE_UPDATEERROR; error->ERR_UPDATE.DSE_up_problem = DSE_UP_OBJECTCLASSVIOLATION; return (NOTOK); } } return (OK); } check_schema_type (eptr,attr,error) Entry eptr; AttributeType attr; struct DSError * error; { Attr_Sequence at; register table_seq optr; AV_Sequence avs; AV_Sequence tavs = NULLAV; objectclass * oc; DLOG (log_dsap,LLOG_TRACE,("check schema type")); if (eptr->e_parent == NULLENTRY) return (OK); /* no schema for root */ avs = oc_avs (eptr->e_attributes); if ((at = as_find_type (eptr->e_parent->e_attributes,at_schema)) != NULLATTR) { tavs = at->attr_value; if (test_schema (tavs,avs) != OK) { LLOG (log_dsap,LLOG_EXCEPTIONS,("given objectclass not in schema (tree structure) list")); error->dse_type = DSE_UPDATEERROR; error->ERR_UPDATE.DSE_up_problem = DSE_UP_NAMINGVIOLATION; return (NOTOK); } } /* Now try the 'may' contain bits */ /* BUT not if "alias" */ if ( check_in_oc (alias_oc, avs) ) return (OK); for (; avs != NULLAV; avs = avs->avseq_next) { oc = (objectclass *) avs->avseq_av.av_struct; for (optr=oc->oc_must; optr!=NULLTABLE_SEQ; optr=optr->ts_next) if (attr->at_table == optr->ts_oa) break; if (optr != NULLTABLE_SEQ) break; for (optr=oc->oc_may; optr!=NULLTABLE_SEQ; optr=optr->ts_next) if (attr->at_table == optr->ts_oa) break; if (optr != NULLTABLE_SEQ) break; } if (optr == NULLTABLE_SEQ) { LLOG (log_dsap,LLOG_EXCEPTIONS,("Attribute '%s' not allowed for specified objectclass",attr2name(attr->at_table,OIDPART))); error->dse_type = DSE_UPDATEERROR; error->ERR_UPDATE.DSE_up_problem = DSE_UP_OBJECTCLASSVIOLATION; return (NOTOK); } return (OK); } test_schema (tree,oc) AV_Sequence tree; AV_Sequence oc; { AV_Sequence aptr, tavs; struct tree_struct *tptr; char found; objectclass * oc1; if (oc == NULLAV) return (NOTOK); for (aptr=oc; aptr!= NULLAV; aptr=aptr->avseq_next) { found = FALSE; for (tavs=tree; tavs!=NULLAV ;tavs=tavs->avseq_next) { tptr = (struct tree_struct *) tavs->avseq_av.av_struct; if (tptr->tree_object == NULLOBJECTCLASS) { /* is this correct behaviour ? */ found = TRUE; break; } oc1 = (objectclass *) aptr->avseq_av.av_struct; if (test_hierarchy (tptr->tree_object->oc_ot.ot_oid, oc1->oc_ot.ot_oid) == 0) { found = TRUE; break; } } if (found == FALSE) { return (NOTOK); } } return (OK); } test_hierarchy (a,b) /* see if b in oc a */ OID a,b; { struct oid_seq * oidseq; objectclass *oc; if (oid_cmp (a,b) == 0) return (OK); if ((oc = oid2oc(a)) == NULLOBJECTCLASS) { LLOG (log_dsap,LLOG_EXCEPTIONS,("got an illeagl object class!!!")); return (NOTOK); } for (oidseq = oc->oc_hierachy; oidseq != NULLOIDSEQ; oidseq = oidseq->oid_next) if (test_hierarchy (oidseq->oid_oid,b) == OK) return (OK); return (NOTOK); }