DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T d

⟦9cf77326b⟧ TextFile

    Length: 4222 (0x107e)
    Types: TextFile
    Names: »ds_modifyrdn.c«

Derivation

└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
    └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« 
        └─⟦d3ac74d73⟧ 
            └─⟦this⟧ »isode-5.0/quipu/ds_modifyrdn.c« 

TextFile

/* ds_modifyrdn.c - */

#ifndef lint
static char *rcsid = "$Header: /f/osi/quipu/RCS/ds_modifyrdn.c,v 6.0 89/03/18 23:41:21 mrose Rel $";
#endif

/*
 * $Header: /f/osi/quipu/RCS/ds_modifyrdn.c,v 6.0 89/03/18 23:41:21 mrose Rel $
 *
 *
 * $Log:	ds_modifyrdn.c,v $
 * Revision 6.0  89/03/18  23:41:21  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/modifyrdn.h"

extern LLog * log_dsap;

#ifndef NO_STATS
extern LLog * log_stat;
extern int dn_print ();
#endif


do_ds_modifyrdn (arg, error, binddn,target)
    register struct ds_modifyrdn_arg     *arg;
    struct DSError              *error;
    DN                          binddn;
    DN                          target;
{
register Entry  entryptr;
register RDN rdn;
Attr_Sequence as;
AV_Sequence avs;
RDN modrdn;
char * new_version ();

	DLOG (log_dsap,LLOG_TRACE,("ds_modifyrdn"));

	if (target == NULLDN)
		target = arg->mra_object;

#ifndef NO_STATS
	dn_decode (target);
	pslog (log_stat,LLOG_NOTICE,"modifyrdn",dn_print,(caddr_t)target);
#endif

	/* stop aliases being dereferenced */
	arg->mra_common.ca_servicecontrol.svc_options |= SVC_OPT_DONTDEREFERENCEALIAS;

	if ((entryptr = find_master_entry (target,&arg->mra_common,error,binddn)) != NULLENTRY) {
 /* entry found, so alter it */

		if (( entryptr->e_parent != NULLENTRY) && (entryptr->e_parent->e_lock)) {
			error->dse_type = DSE_SERVICEERROR;
			error->ERR_SERVICE.DSE_sv_problem = DSE_SV_UNAVAILABLE;
			return (DS_ERROR_REMOTE);
		}

		if (check_acl (binddn,ACL_WRITE,entryptr->e_acl->ac_entry, target) == NOTOK) {
			error->dse_type = DSE_SECURITYERROR;
			error->ERR_SECURITY.DSE_sc_problem = DSE_SC_ACCESSRIGHTS;
			return (DS_ERROR_REMOTE);
		}
		if ( ! (entryptr->e_leaf)) {
			error->dse_type = DSE_UPDATEERROR;
			error->ERR_UPDATE.DSE_up_problem = DSE_UP_NOTONNONLEAF;
			return (DS_ERROR_REMOTE);
		}

		rdn_decode (arg->mra_newrdn);
		/* first check that it is an allowed type */
		if (check_schema_type (entryptr, arg->mra_newrdn->rdn_at, error) == NOTOK)
			return (DS_ERROR_REMOTE);

		if (arg->deleterdn)
			for (rdn=entryptr->e_name; rdn!=NULLRDN; rdn=rdn->rdn_next)
				if (remove_attribute (entryptr,rdn->rdn_at,error,binddn,target) != OK)
					return (DS_ERROR_REMOTE);


		/* must now add rdn as attribute */
		for (rdn=arg->mra_newrdn; rdn!=NULLRDN; rdn=rdn->rdn_next) {
			avs = avs_comp_new (AttrV_cpy(rdn->rdn_av));
			as = as_comp_new (AttrT_cpy(rdn->rdn_at),avs, NULLACL_INFO);
			if (addrdn_attribute (entryptr,as,error,binddn,target) != OK)
				return (DS_ERROR_REMOTE);

		}

		modrdn = entryptr->e_name;
		entryptr->e_name = rdn_cpy(arg->mra_newrdn);

		if (unravel_attribute (entryptr,error,TRUE) != OK) {
			/* I am sure this will never happen - but       */
			/* just incase ...                              */
			LLOG (log_dsap,LLOG_EXCEPTIONS,("modify rdn protocol error"));
			rdn_free (modrdn);
			return (DS_ERROR_REMOTE);
		} else {
			if (entryptr->e_parent != NULLENTRY)
				entryptr->e_parent->e_edbversion = new_version();

			if ((journal (entryptr)) != OK)
				fatal (-34,"mod rdn failed - check database");

			rdn_free (modrdn);
			return (DS_OK);
		}

	} else if (error->dse_type == DSE_REFERRAL)
		return (DS_ERROR_CONNECT);

	return (DS_ERROR_REMOTE);
}


addrdn_attribute (eptr,newas,error,requestor,dn)
Entry eptr;
Attr_Sequence newas;
struct DSError *error;
DN requestor,dn;
{
register Attr_Sequence as;
struct acl_info * acl;

	DLOG (log_dsap,LLOG_DEBUG,("add attribute"));

	if ( (as = as_find_type (eptr->e_attributes,newas->attr_type)) == NULLATTR)
		acl = eptr->e_acl->ac_default;
	else
		acl = as->attr_acl;

	if (check_acl(requestor,ACL_WRITE,acl,dn) == NOTOK) {
		error->dse_type = DSE_SECURITYERROR;
		error->ERR_SECURITY.DSE_sc_problem = DSE_SC_ACCESSRIGHTS;
		DLOG (log_dsap,LLOG_DEBUG,("add acl failed"));
		return (NOTOK);
	}

	eptr->e_attributes = as_merge (newas,eptr->e_attributes);
	return (OK);
}