|
|
1.1 ! root 1: /* attribute.c - */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/quipu/RCS/attribute.c,v 7.3 90/04/18 08:49:44 mrose Exp $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/quipu/RCS/attribute.c,v 7.3 90/04/18 08:49:44 mrose Exp $ ! 9: * ! 10: * ! 11: * $Log: attribute.c,v $ ! 12: * Revision 7.3 90/04/18 08:49:44 mrose ! 13: * 6.2 ! 14: * ! 15: * Revision 7.2 90/01/11 23:55:49 mrose ! 16: * lint ! 17: * ! 18: * Revision 7.1 90/01/11 18:37:17 mrose ! 19: * real-sync ! 20: * ! 21: * Revision 7.0 89/11/23 22:16:38 mrose ! 22: * Release 6.0 ! 23: * ! 24: */ ! 25: ! 26: /* ! 27: * NOTICE ! 28: * ! 29: * Acquisition, use, and distribution of this module and related ! 30: * materials are subject to the restrictions of a license agreement. ! 31: * Consult the Preface in the User's Manual for the full terms of ! 32: * this agreement. ! 33: * ! 34: */ ! 35: ! 36: ! 37: #include "quipu/util.h" ! 38: #include "quipu/entry.h" ! 39: #include "quipu/ds_error.h" ! 40: #include "quipu/oid.h" ! 41: #include "quipu/malloc.h" ! 42: ! 43: AttributeType at_certificate; ! 44: AttributeType at_p_password; ! 45: AttributeType at_password; ! 46: AttributeType at_acl; ! 47: AttributeType at_control; ! 48: AttributeType at_schema; ! 49: AttributeType at_applctx; ! 50: oid_table_attr * tab_applctx; ! 51: oid_table_attr * tab_password; ! 52: oid_table_attr * tab_acl; ! 53: oid_table_attr * tab_schema; ! 54: oid_table_attr * tab_edbinfo; ! 55: oid_table_attr * tab_masterdsa; ! 56: oid_table_attr * tab_slavedsa; ! 57: oid_table_attr * tab_dsaaddress; ! 58: oid_table_attr * tab_version; ! 59: OID alias_oc; ! 60: OID quipu_dsa_oid; ! 61: ! 62: extern oid_table_attr * tab_objectclass; ! 63: extern oid_table_attr * tab_alias; ! 64: extern LLog * log_dsap; ! 65: ! 66: check_dsa_known_oids () ! 67: { ! 68: /* for efficiency yacc has knowledge of certain oid built in ! 69: check these are in current table */ ! 70: ! 71: check_known_oids (); ! 72: ! 73: at_password = AttrT_new (PASSWORD_OID); ! 74: if (at_password == NULLAttrT) ! 75: fatal (-21,"userPassword attribute type missing - check oidtables"); ! 76: tab_password = at_password; ! 77: ! 78: at_control = AttrT_new (CONTROL_OID); ! 79: if (at_control == NULLAttrT) ! 80: fatal (-22,"control attribute type missing - check oidtables"); ! 81: ! 82: at_acl = AttrT_new (ACL_OID); ! 83: if ( at_acl == NULLAttrT) ! 84: fatal (-23,"acl attribute type missing - check oidtables"); ! 85: tab_acl = at_acl; ! 86: ! 87: at_applctx = AttrT_new (APPLCTX_OID); ! 88: if ( at_applctx == NULLAttrT) ! 89: fatal (-23,"supported application context attribute type missing - check oidtables"); ! 90: ! 91: at_schema = AttrT_new (SCHEMA_OID); ! 92: if ( at_schema == NULLAttrT) ! 93: fatal (-24,"treeStructure attribute type missing - check oidtables"); ! 94: tab_schema = at_schema; ! 95: ! 96: if ( (tab_edbinfo = name2attr (EDBINFO_OID)) == NULLTABLE_ATTR) ! 97: fatal (-25,"edbinfo attribute type missing - check oidtables"); ! 98: ! 99: if ( (tab_masterdsa = name2attr (MASTERDSA_OID)) == NULLTABLE_ATTR) ! 100: fatal (-26,"masterDSA attribute type missing - check oidtables"); ! 101: ! 102: if ( (tab_slavedsa = name2attr (SLAVEDSA_OID)) == NULLTABLE_ATTR) ! 103: fatal (-27,"slaveDSA attribute type missing - check oidtables"); ! 104: ! 105: if ( (tab_dsaaddress = name2attr (DSAADDRESS_OID)) == NULLTABLE_ATTR) ! 106: fatal (-28,"dsaAddress attribute type missing - check oidtables"); ! 107: ! 108: if ( (tab_version = name2attr (VERSION_OID)) == NULLTABLE_ATTR) ! 109: fatal (-31,"version attribute type missing - check oidtables"); ! 110: ! 111: if ( ( alias_oc = str2oid (ALIAS_OC)) == NULLOID) ! 112: fatal (-32, "alias objectclass missing"); ! 113: ! 114: alias_oc = oid_cpy (alias_oc); ! 115: quipu_dsa_oid = oid_cpy (str2oid(QUIPU_DSA)); ! 116: ! 117: if ( (at_p_password = AttrT_new(PROTECTED_OID)) == NULLAttrT) ! 118: fatal (-33, "protectedPassword attribute type missing - check oidtables"); ! 119: ! 120: if ( (at_certificate = AttrT_new(CERTIFICATE_OID)) == NULLAttrT) ! 121: fatal (-34, "userCertificate attribute type missing - check oidtables"); ! 122: } ! 123: ! 124: real_unravel_attribute (eptr,error) ! 125: Entry eptr; ! 126: struct DSError * error; ! 127: { ! 128: register Attr_Sequence as; ! 129: RDN new_rdn, rdn_test; ! 130: AttributeType at; ! 131: AV_Sequence avs; ! 132: struct acl * acl = (struct acl *) NULL; ! 133: extern oid_cmp (); ! 134: char * dsa_version = NULLCP; ! 135: char oc_found = FALSE; ! 136: int rdn_print(); ! 137: ! 138: DLOG (log_dsap,LLOG_TRACE,("unravel_attributes")); ! 139: ! 140: /* take rdn's and make sure an attribute, if not add it in */ ! 141: for (new_rdn = eptr->e_name; new_rdn != NULLRDN; new_rdn = new_rdn->rdn_next) { ! 142: if (new_rdn->rdn_at != NULLTABLE_ATTR) ! 143: new_rdn->rdn_av.av_syntax = new_rdn->rdn_at->oa_syntax; ! 144: ! 145: if (new_rdn->rdn_av.av_syntax == 0) { ! 146: /* Check we know about local RDNs syntax */ ! 147: if (eptr->e_data == E_DATA_MASTER) { ! 148: LLOG (log_dsap, LLOG_EXCEPTIONS, ("RDN of unknown attribute type")); ! 149: error->dse_type = DSE_UPDATEERROR; ! 150: error->ERR_UPDATE.DSE_up_problem = DSE_UP_NAMINGVIOLATION; ! 151: return NOTOK; ! 152: } ! 153: } ! 154: ! 155: for (rdn_test = eptr->e_name; rdn_test != new_rdn; rdn_test = rdn_test->rdn_next) ! 156: /* check for repeated attribute in RDN */ ! 157: if (AttrT_cmp (new_rdn->rdn_at, rdn_test->rdn_at) == 0) { ! 158: LLOG (log_dsap, LLOG_EXCEPTIONS, ("RDN with two AVAs of same attribute type")); ! 159: error->dse_type = DSE_UPDATEERROR; ! 160: error->ERR_UPDATE.DSE_up_problem = DSE_UP_NAMINGVIOLATION; ! 161: return NOTOK; ! 162: } ! 163: ! 164: if ((as = as_find_type (eptr->e_attributes,new_rdn->rdn_at)) == NULLATTR) { ! 165: SET_HEAP (new_rdn->rdn_at); ! 166: at = AttrT_cpy (new_rdn->rdn_at); ! 167: avs = avs_comp_new (AttrV_cpy(&new_rdn->rdn_av)); ! 168: as = as_comp_new (at, avs, NULLACL_INFO); ! 169: eptr->e_attributes = as_merge (eptr->e_attributes,as); ! 170: RESTORE_HEAP; ! 171: } else { ! 172: for (avs=as->attr_value; avs!=NULLAV; avs=avs->avseq_next) ! 173: if (AttrV_cmp (&new_rdn->rdn_av,&avs->avseq_av) == 0) ! 174: break; ! 175: if (avs == NULLAV) { ! 176: SET_HEAP (new_rdn->rdn_at); ! 177: avs = avs_comp_new (AttrV_cpy(&new_rdn->rdn_av)); ! 178: as->attr_value = avs_merge (as->attr_value,avs); ! 179: RESTORE_HEAP; ! 180: } ! 181: } ! 182: } ! 183: ! 184: /* now get special attributes into structure */ ! 185: /* first reset pointerss - incase deleted. */ ! 186: ! 187: eptr->e_alias = NULLDN; ! 188: eptr->e_dsainfo = NULLDSA; ! 189: eptr->e_master = NULLAV; ! 190: eptr->e_slave = NULLAV; ! 191: ! 192: for ( as = eptr->e_attributes; as != NULLATTR; as = as->attr_link) { ! 193: if (as->attr_type == NULLTABLE_ATTR) { ! 194: error->dse_type = DSE_ATTRIBUTEERROR; ! 195: error->ERR_ATTRIBUTE.DSE_at_name = get_copy_dn (eptr); ! 196: error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_what = DSE_AT_UNDEFINEDATTRIBUTETYPE; ! 197: error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_type = NULLAttrT; ! 198: error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_value = NULLAttrV; ! 199: error->ERR_ATTRIBUTE.DSE_at_plist.dse_at_next = DSE_AT_NOPROBLEM; ! 200: return (NOTOK); ! 201: } ! 202: ! 203: if (as->attr_type == tab_acl) { ! 204: eptr->e_acl = (struct acl *) as->attr_value->avseq_av.av_struct; ! 205: acl = eptr->e_acl; ! 206: if (acl->ac_child == NULLACL_INFO) ! 207: acl->ac_child = acl_default (); ! 208: if (acl->ac_entry == NULLACL_INFO) ! 209: acl->ac_entry = acl_default (); ! 210: if (acl->ac_default == NULLACL_INFO) ! 211: acl->ac_default = acl_default (); ! 212: } ! 213: ! 214: else if (as->attr_type == tab_edbinfo) { ! 215: if (eptr->e_dsainfo == NULLDSA) { ! 216: eptr->e_dsainfo = (struct dsa_info *) smalloc (sizeof (struct dsa_info)); ! 217: bzero ((char *)eptr->e_dsainfo,sizeof (struct dsa_info)); ! 218: } ! 219: eptr->e_dsainfo->dsa_attr = as->attr_value; ! 220: } ! 221: ! 222: else if (as->attr_type == tab_masterdsa) { ! 223: eptr->e_master = as->attr_value; ! 224: eptr->e_leaf = FALSE; ! 225: } ! 226: ! 227: else if (as->attr_type == tab_slavedsa) { ! 228: eptr->e_slave = as->attr_value; ! 229: eptr->e_leaf = FALSE; ! 230: } ! 231: ! 232: else if (as->attr_type == tab_dsaaddress) { ! 233: if (eptr->e_dsainfo == NULLDSA) { ! 234: eptr->e_dsainfo = (struct dsa_info *) smalloc (sizeof (struct dsa_info)); ! 235: bzero ((char *)eptr->e_dsainfo,sizeof (struct dsa_info)); ! 236: } ! 237: eptr->e_dsainfo->dsa_addr = (struct PSAPaddr *) as->attr_value->avseq_av.av_struct; ! 238: } ! 239: ! 240: else if (as->attr_type == tab_alias) ! 241: eptr->e_alias = (DN) as->attr_value->avseq_av.av_struct; ! 242: ! 243: else if (as->attr_type == tab_version) ! 244: dsa_version = (char *) as->attr_value->avseq_av.av_struct; ! 245: ! 246: else if (as->attr_type == tab_objectclass) ! 247: oc_found = TRUE; ! 248: ! 249: } ! 250: ! 251: if ((eptr->e_master == NULLAV) && (eptr->e_slave == NULLAV)) ! 252: /* May need a stronger test here */ ! 253: eptr->e_leaf = TRUE; ! 254: ! 255: if (eptr->e_dsainfo != NULLDSA) /* set version number */ ! 256: eptr->e_dsainfo->dsa_version = dsa_version; ! 257: ! 258: if (oc_found != TRUE) { ! 259: LLOG (log_dsap, LLOG_EXCEPTIONS, ("Object class attribute missing")); ! 260: error->dse_type = DSE_UPDATEERROR; ! 261: error->ERR_UPDATE.DSE_up_problem = DSE_UP_OBJECTCLASSVIOLATION; ! 262: return (NOTOK); ! 263: } ! 264: /* Make sure acl attribute exists */ ! 265: if (eptr->e_acl == (struct acl *) NULL) { ! 266: Attr_Sequence as1; ! 267: AV_Sequence avs1; ! 268: AttributeValue av; ! 269: ! 270: SET_HEAP (at_acl); ! 271: ! 272: acl = acl_alloc(); ! 273: eptr->e_acl = acl; ! 274: acl->ac_child = acl_default (); ! 275: acl->ac_entry = acl_default (); ! 276: acl->ac_default = acl_default (); ! 277: acl->ac_attributes = NULLACL_ATTR; ! 278: av = AttrV_alloc(); ! 279: av->av_syntax = str2syntax ("acl"); ! 280: av->av_struct = (caddr_t) acl; ! 281: avs1 = avs_comp_new (av); ! 282: as1 = as_comp_new (AttrT_cpy(at_acl),avs1,NULLACL_INFO); ! 283: eptr->e_attributes = as_merge(eptr->e_attributes,as1); ! 284: ! 285: RESTORE_HEAP; ! 286: } ! 287: ! 288: /* now do the attribute acl */ ! 289: /* first of all create and oid_seq of all attribute, and point them to */ ! 290: /* the default. */ ! 291: if (acl->ac_attributes == NULLACL_ATTR) { ! 292: /* the easy case !!! - set every attribute to ac_default */ ! 293: for ( as = eptr->e_attributes; as != NULLATTR; as = as->attr_link) ! 294: as->attr_acl = acl->ac_default; ! 295: } else { ! 296: register struct acl_attr * aa; ! 297: struct acl_attr * found_aa; ! 298: register struct oid_seq * oidptr; ! 299: char once; ! 300: ! 301: /* The following is probably in efficient */ ! 302: /* There must be a better way of setting these pointers */ ! 303: for ( as = eptr->e_attributes; as != NULLATTR; as = as->attr_link) { ! 304: found_aa = NULLACL_ATTR; ! 305: once = FALSE; ! 306: ! 307: for ( aa = acl->ac_attributes; aa!=NULLACL_ATTR; aa=aa->aa_next) { ! 308: for ( oidptr=aa->aa_types;oidptr != NULLOIDSEQ; oidptr=oidptr->oid_next) { ! 309: if (oid_cmp (oidptr->oid_oid,grab_oid(as->attr_type)) == 0) { ! 310: if (once == TRUE) ! 311: pslog (log_dsap,LLOG_EXCEPTIONS, ! 312: "WARNING Inconsistent ACL in entry", ! 313: rdn_print, ! 314: (caddr_t)eptr->e_name); ! 315: else ! 316: once = TRUE; ! 317: found_aa = aa; ! 318: } ! 319: } ! 320: } ! 321: ! 322: if (found_aa != NULLACL_ATTR) ! 323: /* found the apprioriate acl - add oid to it */ ! 324: as->attr_acl = found_aa->aa_acl; ! 325: else ! 326: as->attr_acl = acl->ac_default; ! 327: } ! 328: } ! 329: return (OK); ! 330: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.