|
|
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: 9727 (0x25ff)
Types: TextFile
Names: »attribute.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z«
└─⟦de7628f85⟧
└─⟦this⟧ »isode-6.0/quipu/attribute.c«
/* attribute.c - */
#ifndef lint
static char *rcsid = "$Header: /f/osi/quipu/RCS/attribute.c,v 7.2 90/01/11 23:55:49 mrose Exp $";
#endif
/*
* $Header: /f/osi/quipu/RCS/attribute.c,v 7.2 90/01/11 23:55:49 mrose Exp $
*
*
* $Log: attribute.c,v $
* Revision 7.2 90/01/11 23:55:49 mrose
* lint
*
* Revision 7.1 90/01/11 18:37:17 mrose
* real-sync
*
* Revision 7.0 89/11/23 22:16:38 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"
#include "quipu/oid.h"
#include "quipu/malloc.h"
AttributeType at_p_password;
AttributeType at_password;
AttributeType at_acl;
AttributeType at_control;
AttributeType at_schema;
AttributeType at_applctx;
oid_table_attr * tab_applctx;
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_version;
OID alias_oc;
OID quipu_dsa_oid;
extern oid_table_attr * tab_objectclass;
extern oid_table_attr * tab_alias;
extern LLog * log_dsap;
check_dsa_known_oids ()
{
/* for efficiency yacc has knowledge of certain oid built in
check these are in current table */
check_known_oids ();
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;
at_applctx = AttrT_new (APPLCTX_OID);
if ( at_applctx == NULLAttrT)
fatal (-23,"supported application context attribute type missing - check oidtables");
at_schema = AttrT_new (SCHEMA_OID);
if ( at_schema == NULLAttrT)
fatal (-24,"treeStructure attribute type missing - check oidtables");
tab_schema = at_schema->at_table;
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");
if ( (tab_version = name2attr (VERSION_OID)) == NULLTABLE_ATTR)
fatal (-31,"version attribute type missing - check oidtables");
if ( ( alias_oc = str2oid (ALIAS_OC)) == NULLOID)
fatal (-32, "alias objectclass missing");
alias_oc = oid_cpy (alias_oc);
quipu_dsa_oid = oid_cpy (str2oid(QUIPU_DSA));
if ( (at_p_password = AttrT_new(PROTECTED_OID)) == NULLAttrT)
fatal (-33, "protectedPassword attribute type missing - check oidtables");
}
real_unravel_attribute (eptr,error,decode)
Entry eptr;
struct DSError * error;
char decode;
{
register Attr_Sequence as;
RDN new_rdn;
AttributeType at;
AV_Sequence avs;
struct acl * acl = (struct acl *) NULL;
extern oid_cmp ();
char * dsa_version = NULLCP;
char oc_found = FALSE;
int rdn_print();
DLOG (log_dsap,LLOG_TRACE,("unravel_attributes"));
if (decode) {
(void) as_decode (eptr->e_attributes); /* may not be needed - safety first tho' */
(void) rdn_decode (eptr->e_name);
}
/* take rdn's and make sure an attribute, if not add it in */
for (new_rdn = eptr->e_name; new_rdn != NULLRDN; new_rdn = new_rdn->rdn_next) {
if (new_rdn->rdn_at.at_table != NULLTABLE_ATTR)
new_rdn->rdn_av.av_syntax = new_rdn->rdn_at.at_table->oa_syntax;
if ((as = as_find_type (eptr->e_attributes,&new_rdn->rdn_at)) == NULLATTR) {
SET_HEAP (&new_rdn->rdn_at);
at = AttrT_cpy (&new_rdn->rdn_at);
avs = avs_comp_new (AttrV_cpy(&new_rdn->rdn_av));
as = as_comp_new (at, avs, NULLACL_INFO);
eptr->e_attributes = as_merge (eptr->e_attributes,as);
RESTORE_HEAP;
} else {
for (avs=as->attr_value; avs!=NULLAV; avs=avs->avseq_next)
if (AttrV_cmp (&new_rdn->rdn_av,&avs->avseq_av) == 0)
break;
if (avs == NULLAV) {
SET_HEAP (&new_rdn->rdn_at);
avs = avs_comp_new (AttrV_cpy(&new_rdn->rdn_av));
as->attr_value = avs_merge (as->attr_value,avs);
RESTORE_HEAP;
}
}
}
/* now get special attributes into structure */
/* first reset pointerss - incase deleted. */
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.at_table == NULLTABLE_ATTR) {
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 (avs_decode (&as->attr_type,as->attr_value) == NOTOK) {
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_INVALIDATTRIBUTESYNTAX;
error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_type = AttrT_cpy(&as->attr_type);
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 == tab_acl) {
eptr->e_acl = (struct acl *) as->attr_value->avseq_av.av_struct;
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_edbinfo) {
if (eptr->e_dsainfo == NULLDSA) {
eptr->e_dsainfo = (struct dsa_info *) smalloc (sizeof (struct dsa_info));
bzero ((char *)eptr->e_dsainfo,sizeof (struct dsa_info));
}
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));
bzero ((char *)eptr->e_dsainfo,sizeof (struct dsa_info));
}
eptr->e_dsainfo->dsa_addr = (struct PSAPaddr *) as->attr_value->avseq_av.av_struct;
}
else if (as->attr_type.at_table == tab_alias)
eptr->e_alias = (DN) as->attr_value->avseq_av.av_struct;
else if (as->attr_type.at_table == tab_version)
dsa_version = (char *) as->attr_value->avseq_av.av_struct;
else if (as->attr_type.at_table == tab_objectclass)
oc_found = TRUE;
}
if (eptr->e_dsainfo != NULLDSA) /* set version number */
eptr->e_dsainfo->dsa_version = dsa_version;
if (oc_found != TRUE) {
/* obscure error - violates schema 'cos of top !!! */
error->dse_type = DSE_UPDATEERROR;
error->ERR_UPDATE.DSE_up_problem = DSE_UP_NAMINGVIOLATION;
return (NOTOK);
}
/* Make sure acl attribute exists */
if (eptr->e_acl == (struct acl *) NULL) {
Attr_Sequence as1;
AV_Sequence avs1;
AttributeValue av;
SET_HEAP (at_acl);
acl = acl_alloc();
eptr->e_acl = acl;
acl->ac_child = acl_default ();
acl->ac_entry = acl_default ();
acl->ac_default = acl_default ();
acl->ac_attributes = NULLACL_ATTR;
av = AttrV_alloc();
av->av_syntax = str2syntax ("acl");
av->av_struct = (caddr_t) 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);
RESTORE_HEAP;
}
/* 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 */
for ( as = eptr->e_attributes; as != NULLATTR; as = as->attr_link)
as->attr_acl = acl->ac_default;
} else {
register struct acl_attr * aa;
struct acl_attr * found_aa;
register struct oid_seq * oidptr;
char once;
/* 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_aa = NULLACL_ATTR;
once = FALSE;
for ( aa = acl->ac_attributes; aa!=NULLACL_ATTR; aa=aa->aa_next) {
for ( oidptr=aa->aa_types;oidptr != NULLOIDSEQ; oidptr=oidptr->oid_next) {
if (oid_cmp (oidptr->oid_oid,grab_oid(&as->attr_type)) == 0) {
if (once == TRUE)
pslog (log_dsap,LLOG_EXCEPTIONS,
"WARNING Inconsistent ACL in entry",
rdn_print,
(caddr_t)eptr->e_name);
else
once = TRUE;
found_aa = aa;
}
}
}
if (found_aa != NULLACL_ATTR)
/* found the apprioriate acl - add oid to it */
as->attr_acl = found_aa->aa_acl;
else
as->attr_acl = acl->ac_default;
}
}
return (OK);
}