|
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 a
Length: 9886 (0x269e) Types: TextFile Names: »attribute.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« └─⟦d3ac74d73⟧ └─⟦this⟧ »isode-5.0/quipu/attribute.c«
/* attribute.c - */ #ifndef lint static char *rcsid = "$Header: /f/osi/quipu/RCS/attribute.c,v 6.0 89/03/18 23:41:03 mrose Rel $"; #endif /* * $Header: /f/osi/quipu/RCS/attribute.c,v 6.0 89/03/18 23:41:03 mrose Rel $ * * * $Log: attribute.c,v $ * Revision 6.0 89/03/18 23:41:03 mrose * Release 5.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" #include "quipu/oid.h" AttributeType at_password; AttributeType at_objectclass; AttributeType at_acl; AttributeType at_control; oid_table_attr * tab_password; oid_table_attr * tab_acl; oid_table_attr * tab_schema; oid_table_attr * tab_edbinfo; oid_table_attr * tab_masterdsa; oid_table_attr * tab_slavedsa; oid_table_attr * tab_dsaaddress; oid_table_attr * tab_objectclass; oid_table_attr * tab_alias; oid_table_attr * tab_version; extern LLog * log_dsap; check_known_oids () { /* for efficiency yacc has knowledge of certain oid built in check these are in current table */ at_password = AttrT_new (PASSWORD_OID); if (at_password == NULLAttrT) fatal (-21,"userPassword attribute type missing - check oidtables"); tab_password = at_password->at_table; at_control = AttrT_new (CONTROL_OID); if (at_control == NULLAttrT) fatal (-22,"control attribute type missing - check oidtables"); at_acl = AttrT_new (ACL_OID); if ( at_acl == NULLAttrT) fatal (-23,"acl attribute type missing - check oidtables"); tab_acl = at_acl->at_table; if ( (tab_schema = name2attr (SCHEMA_OID)) == NULLTABLE_ATTR) fatal (-24,"treeStructure attribute type missing - check oidtables"); if ( (tab_edbinfo = name2attr (EDBINFO_OID)) == NULLTABLE_ATTR) fatal (-25,"edbinfo attribute type missing - check oidtables"); if ( (tab_masterdsa = name2attr (MASTERDSA_OID)) == NULLTABLE_ATTR) fatal (-26,"masterDSA attribute type missing - check oidtables"); if ( (tab_slavedsa = name2attr (SLAVEDSA_OID)) == NULLTABLE_ATTR) fatal (-27,"slaveDSA attribute type missing - check oidtables"); if ( (tab_dsaaddress = name2attr (DSAADDRESS_OID)) == NULLTABLE_ATTR) fatal (-28,"dsaAddress attribute type missing - check oidtables"); at_objectclass = AttrT_new (OBJECTCLASS_OID); if (at_objectclass == NULLAttrT) fatal (-29,"objectClass attribute type missing - check oidtables"); tab_objectclass = at_objectclass->at_table; if ( (tab_alias = name2attr (ALIAS_OID)) == NULLTABLE_ATTR) fatal (-30,"alias attribute type missing - check oidtables"); if ( (tab_version = name2attr (VERSION_OID)) == NULLTABLE_ATTR) fatal (-31,"version attribute type missing - check oidtables"); } unravel_attribute (eptr,error,decode) Entry eptr; struct DSError * error; char decode; { register Attr_Sequence as; AttributeType at; AV_Sequence avs; struct oid_seq *oidseq; struct acl * acl = (struct acl *) NULL; extern oid_cmp (); char * dsa_version = NULLCP; DLOG (log_dsap,LLOG_TRACE,("unravel_attributes")); if (decode) { as_decode (eptr->e_attributes); /* may not be needed - safety first tho' */ rdn_decode (eptr->e_name); } /* take rdn and make sure an attribute, if not add it in */ /* with careful freeing could remove copy here !!! */ if (eptr->e_name->rdn_at->at_table != NULLTABLE_ATTR) eptr->e_name->rdn_av->av_syntax = eptr->e_name->rdn_at->at_table->oa_syntax; at = AttrT_cpy (eptr->e_name->rdn_at); avs = avs_comp_new (AttrV_cpy(eptr->e_name->rdn_av)); as = as_comp_new (at, avs, NULLACL_INFO); eptr->e_attributes = as_merge (as,eptr->e_attributes); /* Above line produces a 'harmless' matching error if we are not the root dsa. Ignore it. */ /* now get special attributes into structure */ /* first reset pointerss - incase deleted. */ eptr->e_oc_avseq = NULLAV; eptr->e_passwd = NULLCP; eptr->e_struct = NULLAV; eptr->e_alias = NULLDN; eptr->e_dsainfo = NULLDSA; eptr->e_master = NULLAV; eptr->e_slave = NULLAV; for ( as = eptr->e_attributes; as != NULLATTR; as = as->attr_link) { if (as->attr_type == NULLAttrT) { error->dse_type = DSE_ATTRIBUTEERROR; error->ERR_ATTRIBUTE.DSE_at_name = get_copy_dn (eptr); error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_what = DSE_AT_UNDEFINEDATTRIBUTETYPE; error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_type = NULLAttrT; error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_value = NULLAttrV; error->ERR_ATTRIBUTE.DSE_at_plist.dse_at_next = DSE_AT_NOPROBLEM; return (NOTOK); } if (as->attr_type->at_table == NULLTABLE_ATTR) continue; if (as->attr_type->at_table == tab_password) eptr->e_passwd = as->attr_value->avseq_av->av_un.av_str; else if (as->attr_type->at_table == tab_acl) { eptr->e_acl = as->attr_value->avseq_av->av_un.av_acl; acl = eptr->e_acl; if (acl->ac_child == NULLACL_INFO) acl->ac_child = acl_default (); if (acl->ac_entry == NULLACL_INFO) acl->ac_entry = acl_default (); if (acl->ac_default == NULLACL_INFO) acl->ac_default = acl_default (); } else if (as->attr_type->at_table == tab_schema) eptr->e_struct = as->attr_value; else if (as->attr_type->at_table == tab_edbinfo) { if (eptr->e_dsainfo == NULLDSA) { eptr->e_dsainfo = (struct dsa_info *) smalloc (sizeof (struct dsa_info)); eptr->e_dsainfo->dsa_addr = NULLPA; } eptr->e_dsainfo->dsa_attr = as->attr_value; } else if (as->attr_type->at_table == tab_masterdsa) { eptr->e_master = as->attr_value; eptr->e_leaf = FALSE; } else if (as->attr_type->at_table == tab_slavedsa) { eptr->e_slave = as->attr_value; eptr->e_leaf = FALSE; } else if (as->attr_type->at_table == tab_dsaaddress) { if (eptr->e_dsainfo == NULLDSA) { eptr->e_dsainfo = (struct dsa_info *) smalloc (sizeof (struct dsa_info)); eptr->e_dsainfo->dsa_attr = NULLAV; } eptr->e_dsainfo->dsa_addr = as->attr_value->avseq_av->av_un.av_psap; } else if (as->attr_type->at_table == tab_alias) eptr->e_alias = as->attr_value->avseq_av->av_un.av_dn; else if (as->attr_type->at_table == tab_version) dsa_version = as->attr_value->avseq_av->av_un.av_str; else if (as->attr_type->at_table == tab_objectclass) eptr->e_oc_avseq = as->attr_value; else /* not a special attribute, so make soundex keys */ avs_soundex_key (as->attr_value); } if (eptr->e_dsainfo != NULLDSA) /* set version number */ eptr->e_dsainfo->dsa_version = dsa_version; /* make sure objectclass exists */ if (eptr->e_oc_avseq == NULLAV) { error->dse_type = DSE_ATTRIBUTEERROR; error->ERR_ATTRIBUTE.DSE_at_name = get_copy_dn (eptr); error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_what = DSE_AT_NOSUCHATTRIBUTE; error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_type = AttrT_cpy (at_objectclass); error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_value = NULLAttrV; error->ERR_ATTRIBUTE.DSE_at_plist.dse_at_next = DSE_AT_NOPROBLEM; return (NOTOK); } /* Make sure acl attribute exists */ if (acl == (struct acl *) NULL) { Attr_Sequence as1; AV_Sequence avs1; AttributeValue av; acl = eptr->e_acl; acl->ac_child = acl_default (); acl->ac_entry = acl_default (); acl->ac_default = acl_default (); av = AttrV_alloc(); av->av_pe = NULLPE; av->av_syntax = AV_ACL; av->av_un.av_acl = acl; avs1 = avs_comp_new (av); as1 = as_comp_new (AttrT_cpy(at_acl),avs1,NULLACL_INFO); eptr->e_attributes = as_merge(eptr->e_attributes,as1); } /* now do the attribute acl */ /* first of all create and oid_seq of all attribute, and point them to */ /* the default. */ if (acl->ac_attributes == NULLACL_ATTR) { /* the easy case !!! - set every attribute to ac_default */ acl->ac_attributes = acl_attr_alloc (); acl->ac_attributes->aa_next = NULLACL_ATTR; acl->ac_attributes->aa_types = NULLOIDSEQ; acl->ac_attributes->aa_acl = acl->ac_default; for ( as = eptr->e_attributes; as != NULLATTR; as = as->attr_link) { as->attr_acl = acl->ac_default; oidseq = oid_seq_alloc (); oidseq->oid_oid = oid_cpy (grab_oid(as->attr_type)); oidseq->oid_next = NULLOIDSEQ; acl->ac_attributes->aa_types = oid_seq_merge (acl->ac_attributes->aa_types,oidseq); } } else { register struct acl_attr * aa; register struct oid_seq * oidptr; char found; struct acl_attr * dflt = NULLACL_ATTR; /* The following is probably in efficient */ /* There must be a better way of setting these pointers */ for ( as = eptr->e_attributes; as != NULLATTR; as = as->attr_link) { found = FALSE; for ( aa = acl->ac_attributes; aa!=NULLACL_ATTR; aa=aa->aa_next) { if (aa->aa_acl == acl->ac_default ) dflt = aa; for ( oidptr=aa->aa_types;oidptr != NULLOIDSEQ; oidptr=oidptr->oid_next) { if (quipu_oid_cmp (oidptr->oid_oid,grab_oid(as->attr_type)) == 0) { found = TRUE; break; } } if (found == TRUE) break ; } if (found == TRUE) { /* found the apprioriate acl - add oid to it */ as->attr_acl = aa->aa_acl; } else { /* add it to the default list */ if ( dflt == NULLACL_ATTR ) { /* is no default - make one */ struct acl_attr * newacl; newacl = acl_attr_alloc(); newacl->aa_next = acl->ac_attributes; acl->ac_attributes = newacl; newacl->aa_acl = acl->ac_default; as->attr_acl = acl->ac_default; newacl->aa_types = oid_seq_alloc(); newacl->aa_types->oid_oid = oid_cpy(grab_oid(as->attr_type)); newacl->aa_types->oid_next = NULLOIDSEQ; dflt = newacl; } else { as->attr_acl = acl->ac_default; oidseq = oid_seq_alloc (); oidseq->oid_oid = oid_cpy (grab_oid(as->attr_type)); oidseq->oid_next = NULLOIDSEQ; dflt->aa_types = oid_seq_merge (dflt->aa_types,oidseq); } } } } return (OK); }