Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nadezhda Ivanova
OpenLDAP
Commits
eed02aea
Commit
eed02aea
authored
Apr 07, 2003
by
Pierangelo Masarati
Browse files
need a second function because of different free() routines
parent
243311d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
servers/slapd/back-ldap/back-ldap.h
View file @
eed02aea
...
...
@@ -192,6 +192,7 @@ extern int suffix_massage_config( struct rewrite_info *info,
struct
berval
*
prnc
,
struct
berval
*
nrnc
);
#endif
/* ENABLE_REWRITE */
extern
int
ldap_dnattr_rewrite
(
dncookie
*
dc
,
BerVarray
a_vals
);
extern
int
ldap_dnattr_result_rewrite
(
dncookie
*
dc
,
BerVarray
a_vals
);
LDAP_END_DECL
...
...
servers/slapd/back-ldap/map.c
View file @
eed02aea
...
...
@@ -44,6 +44,9 @@
#include
"slap.h"
#include
"back-ldap.h"
#undef ldap_debug
/* silence a warning in ldap-int.h */
#include
"../../../libraries/libldap/ldap-int.h"
int
mapping_cmp
(
const
void
*
c1
,
const
void
*
c2
)
{
...
...
@@ -468,6 +471,13 @@ ldap_back_filter_map_rewrite(
return
0
;
}
/*
* I don't like this much, but we need two different
* functions because different heap managers may be
* in use in back-ldap/meta to reduce the amount of
* calls to malloc routines, and some of the free()
* routines may be macros with args
*/
int
ldap_dnattr_rewrite
(
dncookie
*
dc
,
...
...
@@ -482,33 +492,73 @@ ldap_dnattr_rewrite(
for
(
i
=
0
;
a_vals
[
i
].
bv_val
!=
NULL
;
i
++
)
{
switch
(
ldap_back_dn_massage
(
dc
,
&
a_vals
[
i
],
&
bv
)
)
{
case
LDAP_SUCCESS
:
case
LDAP_OTHER
:
/* ? */
default:
/* ??? */
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).
*/
ch_free
(
a_vals
[
i
].
bv_val
);
if
(
last
>
i
)
{
a_vals
[
i
]
=
a_vals
[
last
];
}
a_vals
[
last
].
bv_len
=
0
;
a_vals
[
last
].
bv_val
=
NULL
;
last
--
;
break
;
default:
/* leave attr untouched if massage failed */
if
(
bv
.
bv_val
&&
bv
.
bv_val
!=
a_vals
[
i
].
bv_val
)
{
ch_free
(
a_vals
[
i
].
bv_val
);
a_vals
[
i
]
=
bv
;
}
break
;
}
}
return
0
;
}
int
ldap_dnattr_result_rewrite
(
dncookie
*
dc
,
BerVarray
a_vals
)
{
struct
berval
bv
;
int
i
,
last
;
for
(
last
=
0
;
a_vals
[
last
].
bv_val
;
last
++
);
last
--
;
for
(
i
=
0
;
a_vals
[
i
].
bv_val
;
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 (
see
ACLs).
* it should be when searching (
e.g.
ACLs).
*/
ch_free
(
a_vals
[
i
].
bv_val
);
if
(
last
>
i
)
{
LBER_FREE
(
&
a_vals
[
i
].
bv_val
);
if
(
last
>
i
)
{
a_vals
[
i
]
=
a_vals
[
last
];
}
a_vals
[
last
].
bv_len
=
0
;
a_vals
[
last
].
bv_val
=
NULL
;
a_vals
[
last
].
bv_len
=
0
;
last
--
;
break
;
default:
/* leave attr untouched if massage failed */
if
(
bv
.
bv_val
&&
a_vals
[
i
].
bv_val
!=
bv
.
bv_val
)
{
LBER_FREE
(
a_vals
[
i
].
bv_val
);
a_vals
[
i
]
=
bv
;
}
break
;
}
}
return
0
;
}
servers/slapd/back-ldap/search.c
View file @
eed02aea
...
...
@@ -519,37 +519,8 @@ ldap_build_entry(
*/
}
else
if
(
attr
->
a_desc
->
ad_type
->
sat_syntax
==
slap_schema
.
si_syn_distinguishedName
)
{
int
last
,
i
;
ldap_dnattr_result_rewrite
(
&
dc
,
attr
->
a_vals
)
;
/*
* FIXME: should use ldap_dnattr_rewrite(),
* but need a different free() callback ...
*/
for
(
last
=
0
;
attr
->
a_vals
[
last
].
bv_val
;
last
++
);
for
(
i
=
0
;
attr
->
a_vals
[
i
].
bv_val
;
i
++
)
{
struct
berval
newval
=
{
0
,
NULL
};
bv
=
&
attr
->
a_vals
[
i
];
switch
(
ldap_back_dn_massage
(
&
dc
,
bv
,
&
newval
)
)
{
case
LDAP_UNWILLING_TO_PERFORM
:
LBER_FREE
(
bv
->
bv_val
);
if
(
last
>
i
)
{
*
bv
=
attr
->
a_vals
[
last
];
}
attr
->
a_vals
[
last
].
bv_val
=
NULL
;
last
--
;
break
;
default:
if
(
newval
.
bv_val
&&
bv
->
bv_val
!=
newval
.
bv_val
)
{
LBER_FREE
(
bv
->
bv_val
);
*
bv
=
newval
;
}
break
;
}
}
}
if
(
normalize
&&
last
&&
attr
->
a_desc
->
ad_type
->
sat_equality
&&
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment