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

1.1       root        1: /* ds_list.c - */
                      2: 
                      3: #ifndef lint
                      4: static char *rcsid = "$Header: /f/osi/quipu/RCS/ds_list.c,v 7.1 90/07/09 14:45:43 mrose Exp $";
                      5: #endif
                      6: 
                      7: /*
                      8:  * $Header: /f/osi/quipu/RCS/ds_list.c,v 7.1 90/07/09 14:45:43 mrose Exp $
                      9:  *
                     10:  *
                     11:  * $Log:       ds_list.c,v $
                     12:  * Revision 7.1  90/07/09  14:45:43  mrose
                     13:  * sync
                     14:  * 
                     15:  * Revision 7.0  89/11/23  22:17:09  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/util.h"
                     32: #include "quipu/connection.h"
                     33: #include "quipu/list.h"
                     34: 
                     35: extern LLog * log_dsap;
                     36: extern Entry database_root;
                     37: extern int encode_DAS_ListArgumentData();
                     38: static int build_result();
                     39: 
                     40: do_ds_list (arg, error, result, binddn, target, di_p, dsp)
                     41:     register struct ds_list_arg          *arg;
                     42:     register struct ds_list_result       *result;
                     43:     struct DSError                      *error;
                     44:     DN                                  binddn;
                     45:     DN                                  target;
                     46:     struct di_block                    **di_p;
                     47:     char                               dsp;
                     48: {
                     49: Entry  entryptr;
                     50: int retval;
                     51: DN realtarget;
                     52: 
                     53:        DLOG (log_dsap,LLOG_TRACE,("ds_list"));
                     54: 
                     55:        if (!dsp)
                     56:                target = arg->lsa_object;
                     57: 
                     58:        switch(find_child_entry(target,&(arg->lsa_common),binddn,NULLDNSEQ,FALSE,&(entryptr),error,di_p))
                     59:        {
                     60:        case DS_OK:
                     61:            /* Filled out entryptr - carry on */
                     62:            break;
                     63:        case DS_CONTINUE:
                     64:            /* Filled out di_p - what do we do with it ?? */
                     65:            return(DS_CONTINUE);
                     66: 
                     67:        case DS_X500_ERROR:
                     68:            /* Filled out error - what do we do with it ?? */
                     69:            return(DS_X500_ERROR);
                     70:        default:
                     71:            /* SCREAM */
                     72:            LLOG(log_dsap, LLOG_EXCEPTIONS, ("do_ds_list() - find_child_entry failed"));
                     73:            return(DS_ERROR_LOCAL);
                     74:        }
                     75: 
                     76:        /* Strong authentication  */
                     77:        if ((retval = check_security_parms((caddr_t) arg,
                     78:                        encode_DAS_ListArgumentData,
                     79:                        arg->lsa_common.ca_security,
                     80:                        arg->lsa_common.ca_sig, &binddn)) != 0)
                     81:        {
                     82:                error->dse_type = DSE_SECURITYERROR;
                     83:                error->ERR_SECURITY.DSE_sc_problem = retval;
                     84:                return (DS_ERROR_REMOTE);
                     85:        }
                     86: 
                     87:        realtarget = get_copy_dn(entryptr);
                     88: 
                     89:        if (entryptr->e_leaf) {
                     90:                if ((entryptr->e_master != NULLAV) || (entryptr->e_slave != NULLAV)) {
                     91:                        int res;
                     92:                        /* PROBLEM: Might not list everything if user is entitled to more... */
                     93:                        if (try_cache (arg,result,realtarget) == OK) {
                     94:                                dn_free (realtarget);
                     95:                                return (DS_OK);
                     96:                        }
                     97:                        res = constructor_dsa_info(realtarget,NULLDNSEQ,FALSE,entryptr,error,di_p);
                     98:                        dn_free (realtarget);
                     99:                        return res;
                    100:                }
                    101: 
                    102:                dn_free (realtarget);
                    103: 
                    104:                result->lsr_subordinates = NULLSUBORD;
                    105:                result->lsr_age  =  (time_t) 0 ;
                    106:                result->lsr_common.cr_requestor = NULLDN;
                    107:                if ( error->dse_type == DSE_NOERROR ) {
                    108:                        result->lsr_object = NULLDN;
                    109:                        result->lsr_common.cr_aliasdereferenced = FALSE;
                    110:                } else {
                    111:                        result->lsr_common.cr_aliasdereferenced = TRUE;
                    112:                        result->lsr_object = get_copy_dn (entryptr->e_parent);
                    113:                }
                    114:                result->lsr_cr = NULLCONTINUATIONREF;
                    115:                result->lsr_limitproblem = LSR_NOLIMITPROBLEM;
                    116:                return (DS_OK);
                    117:        }
                    118: 
                    119:        /* check parent will allow listing */
                    120:        if (check_acl (dsp ? NULLDN : binddn,ACL_READ, entryptr->e_acl->ac_child, realtarget) != OK) {
                    121:                if (dsp && (check_acl (binddn,ACL_READ, entryptr->e_acl->ac_child, realtarget) == OK)) {
                    122:                        error->dse_type = DSE_SECURITYERROR;
                    123:                        error->ERR_SECURITY.DSE_sc_problem = DSE_SC_AUTHENTICATION;
                    124:                        dn_free (realtarget);
                    125:                        return (DS_ERROR_REMOTE);
                    126:                }
                    127:                error->dse_type = DSE_SECURITYERROR;
                    128:                error->ERR_SECURITY.DSE_sc_problem = DSE_SC_ACCESSRIGHTS;
                    129:                dn_free (realtarget);
                    130:                return (DS_ERROR_REMOTE);
                    131:        }
                    132: 
                    133:        if (entryptr->e_child == NULLENTRY) {
                    134:                int res;
                    135:                if (try_cache (arg,result,realtarget) == OK) {
                    136:                        dn_free (realtarget);
                    137:                        return (DS_OK);
                    138:                }
                    139:                res = constructor_dsa_info(realtarget,NULLDNSEQ,FALSE,entryptr,error,di_p);
                    140:                dn_free (realtarget);
                    141:                return res;             
                    142:        }
                    143: 
                    144:        dn_free (realtarget);
                    145: 
                    146:        build_result (arg,entryptr->e_child,result,error,dsp ? NULLDN : binddn, dsp);
                    147:        return (DS_OK);
                    148: }
                    149: 
                    150: static int build_result (arg,ptr,result,error,binddn,dsp)
                    151: register Entry ptr;
                    152: struct ds_list_arg    *arg;
                    153: struct ds_list_result *result;
                    154: struct DSError * error;
                    155: DN binddn;
                    156: char dsp;
                    157: {
                    158: register struct subordinate *sub;
                    159: register struct subordinate *trail = NULLSUBORD;
                    160: DN dn;
                    161: DN dnend;
                    162: RDN dnrdn;
                    163: int size;
                    164: register int cnt;
                    165: extern int admin_size;
                    166: char adminlimit = FALSE;
                    167: 
                    168:        DLOG (log_dsap,LLOG_DEBUG,("building list results"));
                    169: 
                    170:        result->lsr_subordinates = NULLSUBORD;
                    171:        if (!dsp && manager (binddn))
                    172:            size = arg->lsa_common.ca_servicecontrol.svc_sizelimit;
                    173:        else 
                    174:            if ((size = MIN(admin_size,arg->lsa_common.ca_servicecontrol.svc_sizelimit)) == SVC_NOSIZELIMIT) {
                    175:                size = admin_size;
                    176:                adminlimit = TRUE;
                    177:            }
                    178: 
                    179:        result->lsr_age  =  (time_t) 0 ;
                    180:        result->lsr_common.cr_requestor = NULLDN;
                    181:        /* if no error and NOT SVC_OPT_DONTDEREFERENCEALIASES then */
                    182:        /* the alias will have been derefeferenced -signified by   */
                    183:        /* NO_ERROR !!! */
                    184:        if ( error->dse_type == DSE_NOERROR ) {
                    185:                result->lsr_object = NULLDN;
                    186:                result->lsr_common.cr_aliasdereferenced = FALSE;
                    187:        } else {
                    188:                result->lsr_common.cr_aliasdereferenced = TRUE;
                    189:                result->lsr_object = get_copy_dn (ptr->e_parent);
                    190:        }
                    191:        result->lsr_cr = NULLCONTINUATIONREF;
                    192: 
                    193:        dn = get_copy_dn (ptr);
                    194:        for (dnend = dn; dnend->dn_parent != NULLDN; dnend=dnend->dn_parent)
                    195:                ;  /* NO-OP */
                    196:        dnrdn = dnend->dn_rdn;
                    197: 
                    198:        for (cnt =0; (ptr!=NULLENTRY) && (size == SVC_NOSIZELIMIT || cnt < size) ; ptr=ptr->e_sibling) {
                    199:                dnend->dn_rdn = ptr->e_name;
                    200:                if (check_acl (binddn,ACL_READ,ptr->e_acl->ac_entry,dn) == OK) {
                    201:                        sub = (struct subordinate *) smalloc (sizeof(struct subordinate));
                    202:                        sub->sub_copy = ptr->e_data;
                    203:                        sub->sub_rdn = rdn_cpy(ptr->e_name);
                    204:                        sub->sub_aliasentry = (ptr->e_alias == NULLDN ? FALSE : TRUE);
                    205:                        if (trail != NULLSUBORD)
                    206:                                trail->sub_next = sub;
                    207:                        else
                    208:                                result->lsr_subordinates = sub;
                    209:                        trail = sub;
                    210:                        cnt++;
                    211:                }
                    212:        }
                    213:        sub->sub_next = NULLSUBORD;
                    214: 
                    215:        if ( (size != SVC_NOSIZELIMIT && cnt >= size) && (ptr!=NULLENTRY) )
                    216:                /* stopped look up due to size limit */
                    217:                /* need to send continuation reference */
                    218:                result->lsr_limitproblem = adminlimit ? 
                    219:                        LSR_ADMINSIZEEXCEEDED : LSR_SIZELIMITEXCEEDED;
                    220:        else
                    221:                result->lsr_limitproblem = LSR_NOLIMITPROBLEM;
                    222: 
                    223:        dnend->dn_rdn = NULLRDN;
                    224:        dn_free (dn);
                    225:        rdn_free (dnrdn);
                    226: }
                    227: 
                    228: 
                    229: try_cache (arg,result,target)
                    230:     register struct ds_list_arg          *arg;
                    231:     register struct ds_list_result       *result;
                    232:     DN                                          target;
                    233: {
                    234: struct list_cache *ptr;
                    235: struct subordinate * subord_cpy();
                    236: 
                    237:        if ((arg->lsa_common.ca_servicecontrol.svc_options & SVC_OPT_DONTUSECOPY) == 0) {
                    238:                if ((ptr = find_list_cache (target,arg->lsa_common.ca_servicecontrol.svc_sizelimit)) != NULLCACHE) {
                    239:                        DLOG (log_dsap,LLOG_DEBUG,("building list results using cache"));
                    240:                        result->lsr_subordinates = subord_cpy(ptr->list_subs);
                    241:                        result->lsr_age  =  (time_t) 0 ;
                    242:                        result->lsr_common.cr_aliasdereferenced = FALSE;
                    243:                        result->lsr_common.cr_requestor = NULLDN;
                    244:                        result->lsr_object = NULLDN;
                    245:                        result->lsr_cr = NULLCONTINUATIONREF;
                    246:                        result->lsr_limitproblem = ptr->list_problem;
                    247:                        return (OK);
                    248:                }
                    249:        }
                    250: 
                    251:        return (NOTOK);
                    252: }
                    253: 

unix.superglobalmegacorp.com

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