Esempio n. 1
0
File: tls_g.c Progetto: 1ack/Impala
static int
tlsg_sb_remove( Sockbuf_IO_Desc *sbiod )
{
	struct tls_data		*p;
	
	assert( sbiod != NULL );
	assert( sbiod->sbiod_pvt != NULL );

	p = (struct tls_data *)sbiod->sbiod_pvt;
	gnutls_deinit ( p->session->session );
	LBER_FREE( p->session );
	LBER_FREE( sbiod->sbiod_pvt );
	sbiod->sbiod_pvt = NULL;
	return 0;
}
Esempio n. 2
0
int
ber_sockbuf_remove_io( Sockbuf *sb, Sockbuf_IO *sbio, int layer )
{
	Sockbuf_IO_Desc		*p, **q;

	assert( sb != NULL );
	assert( SOCKBUF_VALID( sb ) );
   
	if ( sb->sb_iod == NULL ) {
		return -1;
	}
   
	q = &sb->sb_iod;
	while ( *q != NULL ) {
		p = *q;
		if ( layer == p->sbiod_level && p->sbiod_io == sbio ) {
			if ( p->sbiod_io->sbi_remove != NULL &&
				p->sbiod_io->sbi_remove( p ) < 0 )
			{
				return -1;
			}
			*q = p->sbiod_next;
			LBER_FREE( p );
			break;
		}
		q = &p->sbiod_next;
	}

	return 0;
}
Esempio n. 3
0
static int
sb_debug_remove( Sockbuf_IO_Desc *sbiod )
{
	assert( sbiod != NULL );
	assert( sbiod->sbiod_pvt != NULL );

	LBER_FREE( sbiod->sbiod_pvt );
	sbiod->sbiod_pvt = NULL;
	return 0;
}
Esempio n. 4
0
void
ber_sockbuf_free( Sockbuf *sb )
{
	assert( sb != NULL );
	assert( SOCKBUF_VALID( sb ) );

	ber_int_sb_close( sb );
	ber_int_sb_destroy( sb );
	LBER_FREE( sb );
}
Esempio n. 5
0
void
ber_pvt_sb_buf_destroy( Sockbuf_Buf *buf )
{
	assert( buf != NULL);

	if (buf->buf_base) {
		LBER_FREE( buf->buf_base );
	}
	ber_pvt_sb_buf_init( buf );
}
Esempio n. 6
0
int
ldap_dnattr_result_rewrite(
	dncookie		*dc,
	BerVarray		a_vals
)
{
	struct berval	bv;
	int		i, last;

	assert( a_vals != NULL );

	for ( last = 0; !BER_BVISNULL( &a_vals[last] ); last++ )
		;
	last--;

	for ( i = 0; !BER_BVISNULL( &a_vals[i] ); i++ ) {
		switch ( ldap_back_dn_massage( dc, &a_vals[i], &bv ) ) {
		case LDAP_UNWILLING_TO_PERFORM:
			/*
			 * FIXME: need to check if it may be considered 
			 * legal to trim values when adding/modifying;
			 * it should be when searching (e.g. ACLs).
			 */
			LBER_FREE( a_vals[i].bv_val );
			if ( last > i ) {
				a_vals[i] = a_vals[last];
			}
			BER_BVZERO( &a_vals[last] );
			last--;
			break;

		default:
			/* leave attr untouched if massage failed */
			if ( !BER_BVISNULL( &bv ) && a_vals[i].bv_val != bv.bv_val ) {
				LBER_FREE( a_vals[i].bv_val );
				a_vals[i] = bv;
			}
			break;
		}
	}

	return 0;
}
Esempio n. 7
0
void
ldap_free_sort_keylist ( LDAPSortKey **keyList )
{
	int i;
	LDAPSortKey *nextKeyp;

	if (keyList == NULL) return;

	i=0;
	while ( 0 != (nextKeyp = keyList[i++]) ) {
		if (nextKeyp->attributeType) {
			LBER_FREE(nextKeyp->attributeType);
		}

		if (nextKeyp->orderingRule != NULL) {
			LBER_FREE(nextKeyp->orderingRule);
		}

		LBER_FREE(nextKeyp);
	}

	LBER_FREE(keyList);
}
Esempio n. 8
0
static int
sb_rdahead_remove( Sockbuf_IO_Desc *sbiod )
{
	Sockbuf_Buf		*p;

	assert( sbiod != NULL );

	p = (Sockbuf_Buf *)sbiod->sbiod_pvt;

	if ( p->buf_ptr != p->buf_end ) return -1;

	ber_pvt_sb_buf_destroy( (Sockbuf_Buf *)(sbiod->sbiod_pvt) );
	LBER_FREE( sbiod->sbiod_pvt );
	sbiod->sbiod_pvt = NULL;

	return 0;
}
Esempio n. 9
0
static int
sb_sasl_generic_remove( Sockbuf_IO_Desc *sbiod )
{
	struct sb_sasl_generic_data	*p;

	assert( sbiod != NULL );

	p = (struct sb_sasl_generic_data *)sbiod->sbiod_pvt;

	p->ops->fini(p);

	ber_pvt_sb_buf_destroy( &p->sec_buf_in );
	ber_pvt_sb_buf_destroy( &p->buf_in );
	ber_pvt_sb_buf_destroy( &p->buf_out );
	LBER_FREE( p );
	sbiod->sbiod_pvt = NULL;
	return 0;
}
Esempio n. 10
0
int
ldap_back_referral_result_rewrite(
	dncookie		*dc,
	BerVarray		a_vals,
	void			*memctx
)
{
	int		i, last;

	assert( dc != NULL );
	assert( a_vals != NULL );

	for ( last = 0; !BER_BVISNULL( &a_vals[ last ] ); last++ )
		;
	last--;

	for ( i = 0; !BER_BVISNULL( &a_vals[ i ] ); i++ ) {
		struct berval	dn,
				olddn = BER_BVNULL;
		int		rc;
		LDAPURLDesc	*ludp;

		rc = ldap_url_parse( a_vals[ i ].bv_val, &ludp );
		if ( rc != LDAP_URL_SUCCESS ) {
			/* leave attr untouched if massage failed */
			continue;
		}

		/* FIXME: URLs like "ldap:///dc=suffix" if passed
		 * thru ldap_url_parse() and ldap_url_desc2str()
		 * get rewritten as "ldap:///dc=suffix??base";
		 * we don't want this to occur... */
		if ( ludp->lud_scope == LDAP_SCOPE_BASE ) {
			ludp->lud_scope = LDAP_SCOPE_DEFAULT;
		}

		ber_str2bv( ludp->lud_dn, 0, 0, &olddn );
		
		rc = ldap_back_dn_massage( dc, &olddn, &dn );
		switch ( rc ) {
		case LDAP_UNWILLING_TO_PERFORM:
			/*
			 * FIXME: need to check if it may be considered 
			 * legal to trim values when adding/modifying;
			 * it should be when searching (e.g. ACLs).
			 */
			LBER_FREE( a_vals[ i ].bv_val );
			if ( last > i ) {
				a_vals[ i ] = a_vals[ last ];
			}
			BER_BVZERO( &a_vals[ last ] );
			last--;
			i--;
			break;

		default:
			/* leave attr untouched if massage failed */
			if ( !BER_BVISNULL( &dn ) && olddn.bv_val != dn.bv_val )
			{
				char	*newurl;

				ludp->lud_dn = dn.bv_val;
				newurl = ldap_url_desc2str( ludp );
				free( dn.bv_val );
				if ( newurl == NULL ) {
					/* FIXME: leave attr untouched
					 * even if ldap_url_desc2str failed...
					 */
					break;
				}

				ber_memfree_x( a_vals[ i ].bv_val, memctx );
				ber_str2bv_x( newurl, 0, 1, &a_vals[ i ], memctx );
				LDAP_FREE( newurl );
				ludp->lud_dn = olddn.bv_val;
			}
			break;
		}

		ldap_free_urldesc( ludp );
	}

	return 0;
}