Annotation of 43BSDReno/contrib/isode-beta/quipu/ds_modifyrdn.c, revision 1.1.1.1

1.1       root        1: /* ds_modifyrdn.c - */
                      2: 
                      3: #ifndef lint
                      4: static char *rcsid = "$Header: /f/osi/quipu/RCS/ds_modifyrdn.c,v 7.1 90/07/09 14:45:47 mrose Exp $";
                      5: #endif
                      6: 
                      7: /*
                      8:  * $Header: /f/osi/quipu/RCS/ds_modifyrdn.c,v 7.1 90/07/09 14:45:47 mrose Exp $
                      9:  *
                     10:  *
                     11:  * $Log:       ds_modifyrdn.c,v $
                     12:  * Revision 7.1  90/07/09  14:45:47  mrose
                     13:  * sync
                     14:  * 
                     15:  * Revision 7.0  89/11/23  22:17:12  mrose
                     16:  * Release 6.0
                     17:  * 
                     18:  */
                     19: 
                     20: /*
                     21:  *                                NOTICE
                     22:  *
                     23:  *    Acquisition, use, and distribution of this module and related
                     24:  *    materials are subject to the restrictions of a license agreement.
                     25:  *    Consult the Preface in the User's Manual for the full terms of
                     26:  *    this agreement.
                     27:  *
                     28:  */
                     29: 
                     30: 
                     31: #include "quipu/config.h"
                     32: #include "quipu/util.h"
                     33: #include "quipu/entry.h"
                     34: #include "quipu/modifyrdn.h"
                     35: #include "quipu/malloc.h"
                     36: 
                     37: extern LLog * log_dsap;
                     38: extern int encode_DAS_ModifyRDNArgumentData();
                     39: 
                     40: do_ds_modifyrdn (arg, error, binddn,target,di_p,dsp)
                     41:     register struct ds_modifyrdn_arg     *arg;
                     42:     struct DSError              *error;
                     43:     DN                          binddn;
                     44:     DN                          target;
                     45:     struct di_block            **di_p;
                     46:     char                       dsp;
                     47: {
                     48: Entry  entryptr;
                     49: register RDN rdn;
                     50: Attr_Sequence as;
                     51: AV_Sequence avs;
                     52: RDN modrdn;
                     53: char * new_version ();
                     54: int retval;
                     55: extern int read_only;
                     56: 
                     57:        DLOG (log_dsap,LLOG_TRACE,("ds_modifyrdn"));
                     58: 
                     59:        if (!dsp)
                     60:                target = arg->mra_object;
                     61: 
                     62:        /* stop aliases being dereferenced */
                     63:        arg->mra_common.ca_servicecontrol.svc_options |= SVC_OPT_DONTDEREFERENCEALIAS;
                     64: 
                     65:        if (target == NULLDN) {
                     66:                error->dse_type = DSE_NAMEERROR;
                     67:                error->ERR_NAME.DSE_na_problem = DSE_NA_NOSUCHOBJECT;
                     68:                error->ERR_NAME.DSE_na_matched = NULLDN;
                     69:                return (DS_ERROR_REMOTE);
                     70:        }
                     71: 
                     72:        switch(find_entry(target,&(arg->mra_common),binddn,NULLDNSEQ,TRUE,&(entryptr), error, di_p))
                     73:        {
                     74:        case DS_OK:
                     75:            /* Filled out entryptr - carry on */
                     76:            break;
                     77:        case DS_CONTINUE:
                     78:            /* Filled out di_p - what do we do with it ?? */
                     79:            return(DS_CONTINUE);
                     80: 
                     81:        case DS_X500_ERROR:
                     82:            /* Filled out error - what do we do with it ?? */
                     83:            return(DS_X500_ERROR);
                     84:        default:
                     85:            /* SCREAM */
                     86:            LLOG(log_dsap, LLOG_EXCEPTIONS, ("do_ds_modifyrdn() - find_entry failed"));
                     87:            return(DS_ERROR_LOCAL);
                     88:        }
                     89: 
                     90:        if (read_only || entryptr->e_parent->e_lock) {
                     91:                error->dse_type = DSE_SERVICEERROR;
                     92:                error->ERR_SERVICE.DSE_sv_problem = DSE_SV_UNAVAILABLE;
                     93:                return (DS_ERROR_REMOTE);
                     94:        }
                     95: 
                     96:        /* Strong authentication  */
                     97:        if ((retval = check_security_parms((caddr_t) arg,
                     98:                        encode_DAS_ModifyRDNArgumentData,
                     99:                        arg->mra_common.ca_security,
                    100:                        arg->mra_common.ca_sig, &binddn)) != 0)
                    101:        {
                    102:                error->dse_type = DSE_SECURITYERROR;
                    103:                error->ERR_SECURITY.DSE_sc_problem = retval;
                    104:                return (DS_ERROR_REMOTE);
                    105:        }
                    106: 
                    107:        /* not prepared to accept operation over DSP */
                    108:        if (dsp) {
                    109:                error->dse_type = DSE_SECURITYERROR;
                    110:                error->ERR_SECURITY.DSE_sc_problem = DSE_SC_AUTHENTICATION;
                    111:                return (DS_ERROR_REMOTE);
                    112:        }
                    113: 
                    114:        if ((check_acl (binddn,ACL_WRITE,entryptr->e_acl->ac_entry, target) == NOTOK)
                    115:            || ((entryptr->e_parent->e_data != E_TYPE_CONSTRUCTOR) && (check_acl (binddn,ACL_WRITE,entryptr->e_parent->e_acl->ac_entry, target) == NOTOK)) ) {
                    116:                error->dse_type = DSE_SECURITYERROR;
                    117:                error->ERR_SECURITY.DSE_sc_problem = DSE_SC_ACCESSRIGHTS;
                    118:                return (DS_ERROR_REMOTE);
                    119:        }
                    120:        if ( ! (entryptr->e_leaf)) {
                    121:                error->dse_type = DSE_UPDATEERROR;
                    122:                error->ERR_UPDATE.DSE_up_problem = DSE_UP_NOTONNONLEAF;
                    123:                return (DS_ERROR_REMOTE);
                    124:        }
                    125: 
                    126:        /* first check that it is an allowed type */
                    127:        for (rdn=arg->mra_newrdn; rdn!=NULLRDN; rdn=rdn->rdn_next)
                    128:                if (check_schema_type (entryptr, rdn->rdn_at, error) == NOTOK)
                    129:                        return (DS_ERROR_REMOTE);
                    130: 
                    131:        if (arg->deleterdn)
                    132:                for (rdn=entryptr->e_name; rdn!=NULLRDN; rdn=rdn->rdn_next)
                    133:                        if (remove_attribute (entryptr,rdn->rdn_at,error,binddn,target,entryptr) != OK)
                    134:                                return (DS_ERROR_REMOTE);
                    135: 
                    136: 
                    137:        /* must now add rdn as attribute */
                    138:        for (rdn=arg->mra_newrdn; rdn!=NULLRDN; rdn=rdn->rdn_next) {
                    139:                avs = avs_comp_new (AttrV_cpy(&rdn->rdn_av));
                    140:                as = as_comp_new (AttrT_cpy(rdn->rdn_at),avs, NULLACL_INFO);
                    141:                if (addrdn_attribute (entryptr,as,error,binddn,target) != OK)
                    142:                        return (DS_ERROR_REMOTE);
                    143: 
                    144:        }
                    145: 
                    146: #ifdef TURBO_DISK
                    147:        if (turbo_delete(entryptr) != OK)
                    148:                fatal (-34,"mod rdn delete failed - check database");
                    149: #endif
                    150: 
                    151:        modrdn = entryptr->e_name;
                    152:        DATABASE_HEAP;
                    153:        entryptr->e_name = rdn_cpy(arg->mra_newrdn);
                    154: 
                    155:        modify_attr (entryptr,binddn);
                    156:        if (unravel_attribute (entryptr,error) != OK) {
                    157:                GENERAL_HEAP;
                    158:                LLOG (log_dsap,LLOG_EXCEPTIONS,("modify rdn protocol error"));
                    159:                rdn_free (modrdn);
                    160:                return (DS_ERROR_REMOTE);
                    161:        } else {
                    162:                GENERAL_HEAP;
                    163:                if (entryptr->e_parent != NULLENTRY) {
                    164:                        if (entryptr->e_parent->e_edbversion)
                    165:                                free (entryptr->e_parent->e_edbversion);
                    166:                        entryptr->e_parent->e_edbversion = new_version();
                    167:                }
                    168: 
                    169: #ifdef TURBO_DISK
                    170:                if (turbo_write(entryptr) != OK)
                    171:                        fatal (-34,"mod rdn failed - check database");
                    172: #else
                    173:                if ((journal (entryptr)) != OK)
                    174:                        fatal (-34,"mod rdn failed - check database");
                    175: #endif
                    176: 
                    177:                rdn_free (modrdn);
                    178:                return (DS_OK);
                    179:        }
                    180: 
                    181: }
                    182: 
                    183: 
                    184: addrdn_attribute (eptr,newas,error,requestor,dn)
                    185: Entry eptr;
                    186: Attr_Sequence newas;
                    187: struct DSError *error;
                    188: DN requestor,dn;
                    189: {
                    190: register Attr_Sequence as;
                    191: struct acl_info * acl;
                    192: 
                    193:        DLOG (log_dsap,LLOG_DEBUG,("add attribute"));
                    194: 
                    195:        if ( (as = as_find_type (eptr->e_attributes,newas->attr_type)) == NULLATTR)
                    196:                acl = eptr->e_acl->ac_default;
                    197:        else
                    198:                acl = as->attr_acl;
                    199: 
                    200:        if (check_acl(requestor,ACL_WRITE,acl,dn) == NOTOK) {
                    201:                error->dse_type = DSE_SECURITYERROR;
                    202:                error->ERR_SECURITY.DSE_sc_problem = DSE_SC_ACCESSRIGHTS;
                    203:                DLOG (log_dsap,LLOG_DEBUG,("add acl failed"));
                    204:                return (NOTOK);
                    205:        }
                    206: 
                    207:        eptr->e_attributes = as_merge (newas,eptr->e_attributes);
                    208:        return (OK);
                    209: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.