Пример #1
0
int slapi_register_object_extension(
	const char *pluginname,
	const char *objectname,
	slapi_extension_constructor_fnptr constructor,
	slapi_extension_destructor_fnptr destructor,
	int *objecttype,
	int *extensionhandle)
{
	int rc;
	slapi_extension_t type;
	struct slapi_registered_extension *re;

	ldap_pvt_thread_mutex_lock( &registered_extensions.mutex );

	rc = map_extension_type( objectname, &type );
	if ( rc != 0 ) {
		ldap_pvt_thread_mutex_unlock( &registered_extensions.mutex );
		return rc;
	}

	*objecttype = (int)type;

	re = &registered_extensions.extensions[*objecttype];

	*extensionhandle = re->count;

	if ( re->active ) {
		/* can't add new extensions after objects have been created */
		ldap_pvt_thread_mutex_unlock( &registered_extensions.mutex );
		return -1;
	}

	re->count++;

	if ( re->constructors == NULL ) {
		re->constructors = (slapi_extension_constructor_fnptr *)slapi_ch_calloc( re->count,
			sizeof( slapi_extension_constructor_fnptr ) );
	} else {
		re->constructors = (slapi_extension_constructor_fnptr *)slapi_ch_realloc( (char *)re->constructors,
			re->count * sizeof( slapi_extension_constructor_fnptr ) );
	}
	re->constructors[*extensionhandle] = constructor;

	if ( re->destructors == NULL ) {
		re->destructors = (slapi_extension_destructor_fnptr *)slapi_ch_calloc( re->count,
			sizeof( slapi_extension_destructor_fnptr ) );
	} else {
		re->destructors = (slapi_extension_destructor_fnptr *)slapi_ch_realloc( (char *)re->destructors,
			re->count * sizeof( slapi_extension_destructor_fnptr ) );
	}
	re->destructors[*extensionhandle] = destructor;

	ldap_pvt_thread_mutex_unlock( &registered_extensions.mutex );

	return 0;
}
Пример #2
0
int slapi_int_create_object_extensions(int objecttype, void *object)
{
	int i;
	struct slapi_extension_block *eblock;
	void **peblock;
	void *parent;

	switch ((slapi_extension_t) objecttype) {
	case SLAPI_X_EXT_CONNECTION:
		peblock = &(((Connection *)object)->c_extensions);
		parent = NULL;
		break;	
	case SLAPI_X_EXT_OPERATION:
		peblock = &(((Operation *)object)->o_hdr->oh_extensions);
		parent = ((Operation *)object)->o_conn;
		break;
	default:
		return -1;
		break;
	}

	*peblock = NULL;

	ldap_pvt_thread_mutex_lock( &registered_extensions.mutex );
	if ( registered_extensions.extensions[objecttype].active == 0 ) {
		/*
		 * once we've created some extensions, no new extensions can
		 * be registered.
		 */
		registered_extensions.extensions[objecttype].active = 1;
	}
	ldap_pvt_thread_mutex_unlock( &registered_extensions.mutex );

	eblock = (struct slapi_extension_block *)slapi_ch_calloc( 1, sizeof(*eblock) );

	if ( registered_extensions.extensions[objecttype].count ) {
		eblock->extensions = (void **)slapi_ch_calloc( registered_extensions.extensions[objecttype].count, sizeof(void *) );
		for ( i = 0; i < registered_extensions.extensions[objecttype].count; i++ ) {
			new_extension( eblock, objecttype, object, parent, i );
		}
	} else {
		eblock->extensions = NULL;
	}

	*peblock = eblock;

	return 0;
}
Пример #3
0
Slapi_Backend *
slapi_be_new( const char *type, const char *name, int isprivate, int logchanges )
{
	Slapi_Backend *be;
	int i;

	/* should add some locking here to prevent concurrent access */
	if ( nbackends == maxbackends )
	{
		int oldsize = maxbackends;
		maxbackends += BACKEND_GRAB_SIZE;
		backends = (Slapi_Backend **) slapi_ch_realloc( (char *) backends, maxbackends * sizeof(Slapi_Backend *) );
		memset( &backends[oldsize], '\0', BACKEND_GRAB_SIZE * sizeof(Slapi_Backend *) );
	}

	for (i=0; ((i<maxbackends) && (backends[i])); i++)
		;

	PR_ASSERT(i<maxbackends);

	be = (Slapi_Backend *) slapi_ch_calloc(1, sizeof(Slapi_Backend));
	be->be_lock = slapi_new_rwlock();
	be_init( be, type, name, isprivate, logchanges, defsize, deftime );

	backends[i] = be;
	nbackends++;

	slapi_log_err(SLAPI_LOG_TRACE, "slapi_be_new",
					"Added new backend name [%s] type [%s] nbackends [%d]\n",
					name, type, nbackends);
	return( be );
}
Пример #4
0
int
sync_send_entry_from_changelog(Slapi_PBlock *pb,int chg_req, char *uniqueid)
{
	Slapi_Entry *db_entry = NULL;
	int chg_type = LDAP_SYNC_ADD;
	int rv;
	Slapi_PBlock *search_pb = NULL;
    	Slapi_Entry **entries = NULL;
	char *origbase;
	char *filter = slapi_ch_smprintf("(nsuniqueid=%s)",uniqueid);

	slapi_pblock_get( pb, SLAPI_ORIGINAL_TARGET_DN, &origbase );
	search_pb = slapi_pblock_new();
    	slapi_search_internal_set_pb(search_pb, origbase,
           				LDAP_SCOPE_SUBTREE, filter,
            				NULL, 0, NULL, NULL, plugin_get_default_component_id(), 0);
 	slapi_search_internal_pb(search_pb);
	slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &rv);
	if ( rv == LDAP_SUCCESS) {
		slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
    		if (entries)
			db_entry = *entries; /* there can only be one */
	}

	if (db_entry && sync_is_entry_in_scope(pb, db_entry)) {
		LDAPControl **ctrl = (LDAPControl **)slapi_ch_calloc(2, sizeof (LDAPControl *));
		sync_create_state_control(db_entry, &ctrl[0], chg_type, NULL);
		slapi_send_ldap_search_entry (pb, db_entry, ctrl, NULL, 0);
		ldap_controls_free(ctrl);
	}
	slapi_free_search_results_internal(search_pb);
	slapi_pblock_destroy(search_pb);
	slapi_ch_free((void **)&filter);
	return (0);
}
Пример #5
0
/*
 * Create a new protocol instance.
 */
Repl_Protocol *
prot_new(Repl_Agmt *agmt, int protocol_state)
{
	Slapi_DN *replarea_sdn = NULL;
	Repl_Protocol *rp = (Repl_Protocol *)slapi_ch_calloc(1, sizeof(Repl_Protocol));

	rp->prp_incremental = rp->prp_total = rp->prp_active_protocol = NULL;
	if (protocol_state == STATE_PERFORMING_TOTAL_UPDATE)
	{
		rp->state = STATE_PERFORMING_TOTAL_UPDATE;
	}
	else
	{
		rp->state = STATE_PERFORMING_INCREMENTAL_UPDATE;
	}
	rp->next_state = STATE_PERFORMING_INCREMENTAL_UPDATE; 
	if ((rp->lock = PR_NewLock()) == NULL)
	{
		goto loser;
	}
	rp->agmt = agmt;
	rp->conn = NULL;
	/* Acquire the local replica object */
	replarea_sdn = agmt_get_replarea(agmt);
	rp->replica_object = replica_get_replica_from_dn(replarea_sdn);
	if (NULL == rp->replica_object)
	{
		/* Whoa, no local replica!?!? */
		slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
			"prot_new - %s: Unable to locate replica object for local replica %s\n",
			agmt_get_long_name(agmt),
			slapi_sdn_get_dn(replarea_sdn));
		goto loser;
	}

	if (get_agmt_agreement_type(agmt) == REPLICA_TYPE_MULTIMASTER)
	{
		rp->prp_incremental = private_protocol_factory(rp, PROTOCOL_5_INCREMENTAL);
		rp->prp_total = private_protocol_factory(rp, PROTOCOL_5_TOTAL);
		rp->delete_conn = conn_delete;
	} 
	else if  (get_agmt_agreement_type(agmt) == REPLICA_TYPE_WINDOWS)
	{
		rp->prp_incremental = private_protocol_factory(rp, PROTOCOL_WINDOWS_INCREMENTAL);
		rp->prp_total = private_protocol_factory(rp, PROTOCOL_WINDOWS_TOTAL);
		rp->delete_conn = windows_conn_delete;
	}
	/* XXXggood register callback handlers for entries updated, and
		schedule window enter/leave. */
	
	goto done;

loser:
	prot_delete(&rp);

done:
	slapi_sdn_free(&replarea_sdn);

	return rp;
}
Пример #6
0
int sync_srch_refresh_post_search(Slapi_PBlock *pb)
{
	int rc = 0;
	SyncOpInfo *info = sync_get_operation_extension(pb);

	if (!info) {
		return (0); /* nothing to do */
	}
	if (info->send_flag & SYNC_FLAG_SEND_INTERMEDIATE) {
		rc = sync_intermediate_msg(pb, LDAP_TAG_SYNC_REFRESH_DELETE, info->cookie, NULL);
		/* the refresh phase is over, now the post op
		 * plugins will create the state control 
		 * depending on the operation type, reset flag
		 */
		info->send_flag &= ~SYNC_FLAG_ADD_STATE_CTRL;
		/* activate the persistent phase thread*/
		sync_persist_startup(info->tid, info->cookie);
	}
	if (info->send_flag & SYNC_FLAG_ADD_DONE_CTRL) {
		LDAPControl **ctrl = (LDAPControl **)slapi_ch_calloc(2, sizeof (LDAPControl *));
		char *cookiestr = sync_cookie2str(info->cookie);
		sync_create_sync_done_control( &ctrl[0], 0, cookiestr);
		slapi_pblock_set(pb, SLAPI_RESCONTROLS, ctrl);
		slapi_ch_free((void **)&cookiestr);
	}
	return(rc);
}
Пример #7
0
static struct berval*
ss_filter_key (indexer_t* ix, struct berval* val)
{
    struct berval* key = (struct berval*) slapi_ch_calloc (1, sizeof(struct berval));
    if (val->bv_len > 0) {
	struct berval** keys = NULL;
	auto struct berval* vals[2];
	vals[0] = val;
	vals[1] = NULL;
	keys = ix->ix_index (ix, vals, NULL);
	if (keys && keys[0]) {
	    /* why +1 in the len?  you need the +1 to old the trailing NULL,
	       to guard against someone accidentally doing a strcmp or
	       other str function, but a bvcmp is going to use the bv_len
	       which includes the trailing NULL which the value being
	       compared against might not have - not only are bervals
	       not guaranteed to be properly NULL terminated, but they
	       also contain binary data - see slapi_ber_bvcpy() */
	    key->bv_len = keys[0]->bv_len + 1;
	    key->bv_val = slapi_ch_malloc (key->bv_len);
	    memcpy (key->bv_val, keys[0]->bv_val, keys[0]->bv_len);
	    key->bv_val[key->bv_len-1] = '\0';
	}
    }
    return key;
}
Пример #8
0
void
ReplGenericListAddObject(ReplGenericList *list,
			 void *newObject)
{
    if(list) {
	ReplGenericList *new_struct = (ReplGenericList *)
	    slapi_ch_calloc(1, sizeof(ReplGenericList));

	if (!new_struct)
	    return;
	/* set back pointer of old first element */
	if(list->next) {
	    list->next->prev = new_struct;
	}

	/* we might have a next but since we are the first we WONT have
	   a previous */
	new_struct->object = newObject;
	new_struct->next = list->next;
	new_struct->prev = NULL;

	/* the new element is the first one */
	list->next = new_struct;

	/* if this is the only element it is the end too */
	if(NULL == list->prev)
	    list->prev = new_struct;
	
    }
    return;
}
Пример #9
0
/*
 * mempool_init creates NSPR thread private index, 
 * then allocates per-thread-private.
 * mempool is initialized at the first mempool_return
 */
static void
mempool_init(struct mempool **my_mempool)
{
	int i;
	if (NULL == my_mempool) {
		return;
	} 
#ifdef SHARED_MEMPOOL
	for (i = 0; MEMPOOL_END != mempool[i].mempool_name; i++) {
		mempool[i].mempool_mutex = PR_NewLock();
		if (NULL == mempool[i].mempool_mutex) {
			PRErrorCode ec = PR_GetError();
			slapi_log_err(SLAPI_LOG_ERR, "mempool", "mempool_init: "
				"failed to create mutex - (%d - %s); mempool(%s) is disabled",
				ec, slapd_pr_strerror(ec), mempool[i].mempool_name);
			rc = LDAP_OPERATIONS_ERROR;
		}
	}
#else
	PR_NewThreadPrivateIndex (&mempool_index, mempool_destroy);
	*my_mempool = (struct mempool *)slapi_ch_calloc(MAX_MEMPOOL, sizeof(struct mempool));
	for (i = 0; i < MAX_MEMPOOL; i++) {
		(*my_mempool)[i].mempool_name = mempool_names[i];
	}
#endif
}
Пример #10
0
/*
  Converts generalized time to UNIX GMT time.  For example:
  "20060807211257Z" -> 1154981577
*/
time_t
gentimeToEpochtime( char *gentimestr ) {
    time_t epochtime, cur_local_epochtime, cur_gm_epochtime, zone_offset;
    struct tm t, *cur_gm_time;

    /* Find the local offset from GMT */
    cur_gm_time = (struct tm*)slapi_ch_calloc( 1, sizeof( struct tm ) );
    cur_local_epochtime = time( (time_t *)0 );
    gmtime_r( &cur_local_epochtime, cur_gm_time );
    cur_gm_epochtime = mktime( cur_gm_time );
    free( cur_gm_time );
    zone_offset = cur_gm_epochtime - cur_local_epochtime;

    /* Parse generalizedtime string into a tm struct */
    t.tm_year = antoi( gentimestr, 0, 4 ) - 1900;
    t.tm_mon = antoi( gentimestr, 4, 2 ) - 1;
    t.tm_mday = antoi( gentimestr, 6, 2 );
    t.tm_hour = antoi( gentimestr, 8, 2 );
    t.tm_min = antoi( gentimestr, 10, 2 );
    t.tm_sec = antoi( gentimestr, 12, 2 );
    t.tm_isdst = 0; /* DST does not apply to UTC */

    /* Turn tm object into local epoch time */
    epochtime = mktime( &t );

    /* Turn local epoch time into GMT epoch time */
    epochtime -= zone_offset;

    return( epochtime );
}
Пример #11
0
static SyncOpInfo*
new_SyncOpInfo(int flag, PRThread *tid, Sync_Cookie *cookie) {
    SyncOpInfo *spec = (SyncOpInfo *)slapi_ch_calloc(1, sizeof(SyncOpInfo));
    spec->send_flag = flag;
    spec->cookie = cookie;
    spec->tid = tid;

    return spec;
}
Пример #12
0
/*
 * **************************************************************************
 * API
 * **************************************************************************
 */
CSNGen* 
csngen_new (ReplicaId rid, Slapi_Attr *state)
{
	int rc = CSN_SUCCESS;
   	CSNGen *gen = NULL;

	gen = (CSNGen*)slapi_ch_calloc (1, sizeof (CSNGen));
	if (gen == NULL)
	{
		slapi_log_err(SLAPI_LOG_ERR, "csngen_new", "Memory allocation failed\n");
		return NULL;
	}

	/* create lock to control the access to the state information */
	gen->lock = slapi_new_rwlock();	
	if (gen->lock == NULL)
	{
		slapi_log_err(SLAPI_LOG_ERR, "csngen_new", "Failed to create lock\n");
		rc = CSN_NSPR_ERROR;
		goto done;
	}

	/* initialize callback list */
	_csngen_init_callbacks (gen);

	gen->state.rid  = rid;

	if (state)
	{
		rc = _csngen_parse_state (gen, state);
		if (rc != CSN_SUCCESS)
		{
			goto done;
		}
	}
	else
	{
		/* new generator */
		gen->state.sampled_time = current_time ();
		gen->state.local_offset = 0;
		gen->state.remote_offset = 0;
		gen->state.seq_num = 0;
	}

done:
	if (rc != CSN_SUCCESS)
	{
		if (gen)
		{
			csngen_free (&gen);	
		}

		return NULL;
	}

    return gen;
}
Пример #13
0
/*
  The type and val pointers are assumed to have sufficient lifetime -
  we don't have to copy them - they are usually just pointers into
  the SLAPI_PLUGIN_MR_TYPE and SLAPI_PLUGIN_MR_VALUE fields of the
  operation pblock, whose lifetime should encompass the creation
  and destruction of the bitwise_match_cb object.
*/
static struct bitwise_match_cb *
new_bitwise_match_cb(char *type, struct berval *val)
{
    struct bitwise_match_cb *bmc = (struct bitwise_match_cb *)slapi_ch_calloc(1, sizeof(struct bitwise_match_cb));
    bmc->type = slapi_ch_strdup(type);
    bmc->val = val;

    return bmc;
}
Пример #14
0
Slapi_ValueSet *
slapi_valueset_new()
{
	Slapi_ValueSet *vs = (Slapi_ValueSet *)slapi_ch_calloc(1,sizeof(Slapi_ValueSet));

	if(vs)
		slapi_valueset_init(vs);

	return vs;
}
Пример #15
0
Slapi_ValueSet *
valueset_dup(const Slapi_ValueSet *dupee)
{
	Slapi_ValueSet *duped= (Slapi_ValueSet *)slapi_ch_calloc(1,sizeof(Slapi_ValueSet));
	if (NULL!=duped)
	{
		valueset_add_valuearray( duped, dupee->va );
	}
	return duped;
}
Пример #16
0
int 
aclgroup_init ()
{

	aclUserGroups = ( aclGroupCache * ) slapi_ch_calloc (1, sizeof ( aclGroupCache ) );
	if ( NULL ==  (aclUserGroups->aclg_rwlock = slapi_new_rwlock())) {
		slapi_log_error(SLAPI_LOG_FATAL, plugin_name, "Unable to allocate RWLOCK for group cache\n");
		return 1;
	}
	return 0;
}
Пример #17
0
/*
 * This is the conversation function passed into pam_start().  This is what sets the password
 * that PAM uses to authenticate.  This function is sort of stupid - it assumes all echo off
 * or binary prompts are for the password, and other prompts are for the username.  Time will
 * tell if this is actually the case.
 */
static int
pam_conv_func(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *mydata)
{
	int ii;
	struct berval *creds;
	struct my_pam_conv_str *my_data = (struct my_pam_conv_str *)mydata;
    struct pam_response *reply;
	int ret = PAM_SUCCESS;

    if (num_msg <= 0) {
		return PAM_CONV_ERR;
	}

	/* empty reply structure */
    reply = (struct pam_response *)slapi_ch_calloc(num_msg,
										  sizeof(struct pam_response));
	slapi_pblock_get( my_data->pb, SLAPI_BIND_CREDENTIALS, &creds ); /* the password */
	for (ii = 0; ii < num_msg; ++ii) {
		slapi_log_error(SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
						"pam msg [%d] = %d %s\n", ii, msg[ii]->msg_style,
						msg[ii]->msg);
		/* hard to tell what prompt is for . . . */
		/* assume prompts for password are either BINARY or ECHO_OFF */
		if (msg[ii]->msg_style == PAM_PROMPT_ECHO_OFF) {
			reply[ii].resp = strdupbv(creds);
#ifdef LINUX
		} else if (msg[ii]->msg_style == PAM_BINARY_PROMPT) {
			reply[ii].resp = strdupbv(creds);
#endif
		} else if (msg[ii]->msg_style == PAM_PROMPT_ECHO_ON) { /* assume username */
			reply[ii].resp = slapi_ch_strdup(my_data->pam_identity);
		} else if (msg[ii]->msg_style == PAM_ERROR_MSG) {
			slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
							"pam msg [%d] error [%s]\n", ii, msg[ii]->msg);
		} else if (msg[ii]->msg_style == PAM_TEXT_INFO) {
			slapi_log_error(SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
							"pam msg [%d] text info [%s]\n", ii, msg[ii]->msg);
		} else {
			slapi_log_error(SLAPI_LOG_FATAL, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
							"Error: unknown pam message type (%d: %s)\n",
							msg[ii]->msg_style, msg[ii]->msg);
			ret = PAM_CONV_ERR;
		}
	}

	if (ret == PAM_CONV_ERR) {
		free_pam_response(num_msg, reply);
		reply = NULL;
	}

	*resp = reply;

	return ret;
}
Пример #18
0
static struct factory_type*
new_factory_type(const char *name, size_t offset)
{
    struct factory_type* ft= (struct factory_type*)slapi_ch_calloc(1, sizeof(struct factory_type));
	ft->name= slapi_ch_strdup(name);
    ft->extension_lock = PR_NewLock();
	ft->extension_count= 0;
	ft->extension_offset= offset;
	ft->existence_count= 0;
	return ft;
}
Пример #19
0
static void
ldbm_instance_attrcrypt_enable(struct attrinfo *ai, int cipher)
{
	attrcrypt_private *priv = NULL;
	if (NULL == ai->ai_attrcrypt) {
		/* No existing private structure, allocate one */
		ai->ai_attrcrypt = (attrcrypt_private*) slapi_ch_calloc(1, sizeof(attrcrypt_private));
	}
	priv = ai->ai_attrcrypt;
	priv->attrcrypt_cipher = cipher;
}
Пример #20
0
static 
sasl_map_private *sasl_map_new_private(void)
{
	Slapi_RWLock *new_lock =  slapi_new_rwlock();
	sasl_map_private *new_priv = NULL;
	if (NULL == new_lock) {
		return NULL;
	}
	new_priv = (sasl_map_private *)slapi_ch_calloc(1,sizeof(sasl_map_private));
	new_priv->lock = new_lock;
	return new_priv;
}
Пример #21
0
Файл: csn.c Проект: leto/389-ds
CSN *csn_new()
{
#ifdef DEBUG
	if(!counters_created)
	{
		csn_create_counters();
	}
	slapi_counter_increment(slapi_csn_counter_created);
	slapi_counter_increment(slapi_csn_counter_exist);
#endif
	return (CSN*)slapi_ch_calloc(sizeof(CSN),1);
}
Пример #22
0
/* create per-domain config object */
void *
ipa_winsync_config_new_domain(
    const Slapi_DN *ds_subtree,
    const Slapi_DN *ad_subtree
)
{
    IPA_WinSync_Domain_Config *iwdc =
        (IPA_WinSync_Domain_Config *)
        slapi_ch_calloc(1, sizeof(IPA_WinSync_Domain_Config));

    return (void *)iwdc;
}
Пример #23
0
/* This function does a shallow copy on the payload data supplied, so the caller should not free it, and it needs to be allocated using slapi_ch_malloc() */
static 
sasl_map_data *sasl_map_new_data(char *name, char *regex, char *dntemplate, char *filtertemplate, int priority)
{
	sasl_map_data *new_dp = (sasl_map_data *) slapi_ch_calloc(1,sizeof(sasl_map_data));
	new_dp->name = name;
	new_dp->regular_expression = regex;
	new_dp->template_base_dn = dntemplate;
	new_dp->template_search_filter = filtertemplate;
	new_dp->priority = priority;
	new_dp->next = NULL;
	new_dp->prev = NULL;
	return new_dp;
}
Пример #24
0
ReplGenericList *
ReplGenericListNew(void)
{
    ReplGenericList *list=NULL;
    if(NULL == (list = (ReplGenericList *)
		slapi_ch_calloc(1,sizeof(ReplGenericList)))) {
	return(NULL);
    }
    list->object = NULL;
    list->next = NULL;
    list->prev = NULL;
    return(list);
}
Пример #25
0
Файл: dl.c Проект: Firstyear/ds
void dl_init (DataList *dl, int init_alloc)
{
    PR_ASSERT (dl);

    memset (dl, 0, sizeof (*dl));

    if (init_alloc <= 0)
        dl->alloc_count = INIT_ALLOC;
    else
        dl->alloc_count = init_alloc;

    dl->elements = (void**)slapi_ch_calloc (dl->alloc_count, sizeof (void*));
}
Пример #26
0
/*
 * Construct a new ec structure
 */
static slapi_eq_context *
eq_new(slapi_eq_fn_t fn, void *arg, time_t when, unsigned long interval)
{
	slapi_eq_context *retptr = (slapi_eq_context *)slapi_ch_calloc(1, sizeof(slapi_eq_context));
	time_t now;

	retptr->ec_fn = fn;
	retptr->ec_arg = arg;
	now = current_time();
	retptr->ec_when = when < now ? now : when;
	retptr->ec_interval = interval == 0UL ? 0UL : (interval + 999) / 1000;
	retptr->ec_id = (Slapi_Eq_Context)retptr;
	return retptr;
}
Пример #27
0
/*
 * aclanom_init ();
 *	Generate a profile for the anonymous user.  We can use this profile
 *	later to determine what resources the client is allowed to.
 *
 * Dependency:
 * 		Before calling this, it is assumed that all the ACLs have been read
 *		and parsed. 
 *
 *		We will go thru all the ACL and pick the ANYONE ACL and generate the anom 
 *		profile.
 *
 */
int
aclanom_init ()
{

	acl_anom_profile = (struct anom_profile * )
                slapi_ch_calloc (1, sizeof ( struct anom_profile ) );

	if (( anom_rwlock = slapi_new_rwlock()) == NULL ) {
		slapi_log_err(SLAPI_LOG_ERR, plugin_name,
				"aclanom_init - Failed in getting the ANOM rwlock\n" );
		return 1;
	}
	return 0;
}
Пример #28
0
static struct factory_extension*
new_factory_extension(
    const char *pluginname,
    slapi_extension_constructor_fnptr constructor, 
    slapi_extension_destructor_fnptr destructor)
{
	struct factory_extension* fe = (struct factory_extension*)slapi_ch_calloc(1, sizeof(struct factory_extension));

	fe->pluginname= slapi_ch_strdup(pluginname);
	fe->constructor= constructor;
	fe->destructor= destructor;

	return fe;
}
Пример #29
0
int sync_srch_refresh_pre_entry(Slapi_PBlock *pb)
{
	int rc = 0;
	SyncOpInfo *info = sync_get_operation_extension(pb);

	if (!info) {
		rc = 0; /* nothing to do */
	} else if (info->send_flag & SYNC_FLAG_ADD_STATE_CTRL) {
		Slapi_Entry *e;
		slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_ENTRY, &e);
		LDAPControl **ctrl = (LDAPControl **)slapi_ch_calloc(2, sizeof (LDAPControl *));
		sync_create_state_control(e, &ctrl[0], LDAP_SYNC_ADD, NULL);
		slapi_pblock_set(pb, SLAPI_SEARCH_CTRLS, ctrl);
	}
	return(rc);
}
Пример #30
0
static int
convert_to_string(Slapi_DN *dn, void *arg)
{
	struct list_to_string_data *data = (struct list_to_string_data *)arg;
	int newlen = slapi_sdn_get_ndn_len(dn) + strlen(data->delimiter) + 1;
	if (data->string) {
		newlen += strlen(data->string);
		data->string = slapi_ch_realloc(data->string, newlen);
	} else {
		data->string = slapi_ch_calloc(1, newlen);
	}
	strcat(data->string, slapi_sdn_get_dn(dn));
	strcat(data->string, data->delimiter);

	return 1;
}