Commit 11ccf961 authored by Mark Valence's avatar Mark Valence
Browse files

Updated attribute routine to pass back bervals.

parent 664fabdf
......@@ -27,14 +27,14 @@ ldap_back_attribute(
Entry *target,
const char *e_ndn,
AttributeDescription *entry_at,
const char ***vals
struct berval ***vals
)
{
struct ldapinfo *li = (struct ldapinfo *) be->be_private;
int rc = 1, i, j;
int rc = 1, i, j, count;
Attribute *attr;
struct berval **abv;
char *s, **v;
struct berval **abv, **v;
char **vs;
LDAPMessage *result, *e;
char *gattr[2];
LDAP *ld;
......@@ -45,17 +45,14 @@ ldap_back_attribute(
if ((attr = attr_find(target->e_attrs, entry_at)) == NULL)
return(1);
for ( i = 0; attr->a_vals[i] != NULL; i++ ) { }
v = (char **) ch_calloc( (i + 1), sizeof(char *) );
for ( count = 0; attr->a_vals[count] != NULL; count++ ) { }
v = (struct berval **) ch_calloc( (count + 1), sizeof(struct berval *) );
if (v != NULL) {
for ( j = 0, abv = attr->a_vals; --i >= 0; abv++ ) {
for ( j = 0, abv = attr->a_vals; --count >= 0; abv++ ) {
if ( (*abv)->bv_len > 0 ) {
s = ch_malloc( (*abv)->bv_len + 1 );
if( s == NULL )
v[j] = ber_bvdup( *abv );
if( v[j] == NULL )
break;
memcpy(s, (*abv)->bv_val, (*abv)->bv_len);
s[(*abv)->bv_len] = 0;
v[j++] = s;
}
}
v[j] = NULL;
......@@ -76,9 +73,26 @@ ldap_back_attribute(
LDAP_NO_LIMIT, &result) == LDAP_SUCCESS)
{
if ((e = ldap_first_entry(ld, result)) != NULL) {
*vals = ldap_get_values(ld, e, entry_at->ad_cname->bv_val);
if (*vals != NULL)
rc = 0;
vs = ldap_get_values(ld, e, entry_at->ad_cname->bv_val);
if (vs != NULL) {
for ( count = 0; vs[count] != NULL; count++ ) { }
v = (struct berval **) ch_calloc( (count + 1), sizeof(struct berval *) );
if (v == NULL) {
ldap_value_free(vs);
} else {
for ( i = 0, j = 0; i < count; i++) {
v[j] = ber_bvstr( vs[i] );
if( v[j] == NULL )
ch_free(vs[i]);
else
j++;
}
v[j] = NULL;
*vals = v;
rc = 0;
ch_free(vs);
}
}
}
ldap_msgfree(result);
}
......
......@@ -67,7 +67,7 @@ extern int ldap_back_attribute LDAP_P(( BackendDB *bd,
Entry *target,
const char* e_ndn,
AttributeDescription* entry_at,
const char ***vals));
struct berval ***vals));
LDAP_END_DECL
......
......@@ -116,8 +116,10 @@ ldbm_back_attribute(
v = (struct berval **) ch_malloc( sizeof(struct berval *) * (i+1) );
for ( i=0, j=0; attr->a_vals[i] != NULL; i++ ) {
if( access_allowed(be, conn, op, e, entry_at,
attr->a_vals[i], ACL_READ) == 0)
if( conn != NULL
&& op != NULL
&& access_allowed(be, conn, op, e, entry_at,
attr->a_vals[i], ACL_READ) == 0)
{
continue;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment