Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joe Martin
OpenLDAP
Commits
b0e1f1e2
Commit
b0e1f1e2
authored
Jan 21, 2009
by
Quanah Gibson-Mount
Browse files
ITS#5756 addpartial improvements
parent
8f4621a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
contrib/slapd-modules/addpartial/addpartial-overlay.c
View file @
b0e1f1e2
...
...
@@ -33,7 +33,6 @@
#include
"portable.h"
#include
"slap.h"
static
int
addpartial_search_cb
(
Operation
*
op
,
SlapReply
*
rs
);
static
int
collect_error_msg_cb
(
Operation
*
op
,
SlapReply
*
rs
);
static
slap_overinst
addpartial
;
...
...
@@ -46,10 +45,8 @@ static int addpartial_add( Operation *op, SlapReply *rs)
{
Operation
nop
=
*
op
;
SlapReply
nrs
=
{
REP_RESULT
};
Filter
*
filter
=
NULL
;
Entry
*
toAdd
=
NULL
;
struct
berval
fstr
=
BER_BVNULL
;
slap_callback
cb
=
{
NULL
,
addpartial_search_cb
,
NULL
,
NULL
};
Entry
*
found
=
NULL
;
slap_overinst
*
on
=
(
slap_overinst
*
)
op
->
o_bd
->
bd_info
;
int
rc
;
...
...
@@ -64,61 +61,20 @@ static int addpartial_add( Operation *op, SlapReply *rs)
{
return
SLAP_CB_CONTINUE
;
}
rs
->
sr_text
=
NULL
;
nop
.
o_callback
=
&
cb
;
op
->
o_bd
->
bd_info
=
(
BackendInfo
*
)
on
->
on_info
;
nop
.
o_tag
=
LDAP_REQ_SEARCH
;
nop
.
o_ctrls
=
NULL
;
filter
=
str2filter
(
"(objectclass=*)"
);
filter2bv
(
filter
,
&
fstr
);
nop
.
ors_scope
=
LDAP_SCOPE_BASE
;
nop
.
ors_deref
=
LDAP_DEREF_NEVER
;
nop
.
ors_slimit
=
-
1
;
//SLAP_NO_LIMIT;
nop
.
ors_tlimit
=
-
1
;
//SLAP_NO_LIMIT;
nop
.
ors_attrsonly
=
0
;
nop
.
ors_attrs
=
slap_anlist_no_attrs
;
nop
.
ors_filter
=
filter
;
nop
.
ors_filterstr
=
fstr
;
memset
(
&
nrs
,
0
,
sizeof
(
nrs
));
nrs
.
sr_type
=
REP_RESULT
;
nrs
.
sr_err
=
LDAP_SUCCESS
;
nrs
.
sr_entry
=
NULL
;
nrs
.
sr_flags
|=
REP_ENTRY_MUSTBEFREED
;
nrs
.
sr_text
=
NULL
;
Debug
(
LDAP_DEBUG_TRACE
,
"%s: performing search
\n
"
,
addpartial
.
on_bi
.
bi_type
,
0
,
0
);
if
(
nop
.
o_bd
->
be_search
)
{
rc
=
nop
.
o_bd
->
be_search
(
&
nop
,
&
nrs
);
Debug
(
LDAP_DEBUG_TRACE
,
"%s: search performed
\n
"
,
addpartial
.
on_bi
.
bi_type
,
0
,
0
);
}
else
{
Debug
(
LDAP_DEBUG_TRACE
,
"%s: backend missing search function
\n
"
,
addpartial
.
on_bi
.
bi_type
,
0
,
0
);
}
if
(
filter
)
filter_free
(
filter
);
if
(
fstr
.
bv_val
)
ch_free
(
fstr
.
bv_val
);
rc
=
overlay_entry_get_ov
(
&
nop
,
&
nop
.
o_req_ndn
,
NULL
,
NULL
,
0
,
&
found
,
on
);
if
(
rc
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"%s: no entry found, falling through to normal add
\n
"
,
addpartial
.
on_bi
.
bi_type
,
0
,
0
);
return
SLAP_CB_CONTINUE
;
}
else
{
Entry
*
found
=
NULL
;
Debug
(
LDAP_DEBUG_TRACE
,
"%s: found the dn
\n
"
,
addpartial
.
on_bi
.
bi_type
,
0
,
0
);
found
=
(
Entry
*
)
cb
.
sc_private
;
if
(
found
)
{
...
...
@@ -150,8 +106,7 @@ static int addpartial_add( Operation *op, SlapReply *rs)
mod
->
sml_op
&=
LDAP_MOD_OP
;
mod
->
sml_next
=
NULL
;
mod
->
sml_desc
=
attr
->
a_desc
;
mod
->
sml_type
.
bv_val
=
attr
->
a_desc
->
ad_cname
.
bv_val
;
mod
->
sml_type
.
bv_len
=
strlen
(
mod
->
sml_type
.
bv_val
);
mod
->
sml_type
=
attr
->
a_desc
->
ad_cname
;
mod
->
sml_values
=
attr
->
a_vals
;
mod
->
sml_nvalues
=
attr
->
a_nvals
;
mod
->
sml_numvals
=
attr
->
a_numvals
;
...
...
@@ -190,8 +145,7 @@ static int addpartial_add( Operation *op, SlapReply *rs)
mod
->
sml_op
&=
LDAP_MOD_OP
;
mod
->
sml_next
=
NULL
;
mod
->
sml_desc
=
attr
->
a_desc
;
mod
->
sml_type
.
bv_val
=
attr
->
a_desc
->
ad_cname
.
bv_val
;
mod
->
sml_type
.
bv_len
=
strlen
(
mod
->
sml_type
.
bv_val
);
mod
->
sml_type
=
attr
->
a_desc
->
ad_cname
;
mod
->
sml_values
=
attr
->
a_vals
;
mod
->
sml_nvalues
=
attr
->
a_nvals
;
mod
->
sml_numvals
=
attr
->
a_numvals
;
...
...
@@ -245,9 +199,7 @@ static int addpartial_add( Operation *op, SlapReply *rs)
mod
->
sml_op
&=
LDAP_MOD_OP
;
mod
->
sml_next
=
NULL
;
mod
->
sml_desc
=
attr
->
a_desc
;
mod
->
sml_type
.
bv_val
=
attr
->
a_desc
->
ad_cname
.
bv_val
;
mod
->
sml_type
.
bv_len
=
strlen
(
mod
->
sml_type
.
bv_val
);
mod
->
sml_type
=
attr
->
a_desc
->
ad_cname
;
mod
->
sml_values
=
attr
->
a_vals
;
mod
->
sml_nvalues
=
attr
->
a_nvals
;
mod
->
sml_numvals
=
attr
->
a_numvals
;
...
...
@@ -278,9 +230,7 @@ static int addpartial_add( Operation *op, SlapReply *rs)
mod
->
sml_op
=
LDAP_MOD_REPLACE
;
mod
->
sml_next
=
NULL
;
mod
->
sml_desc
=
attr
->
a_desc
;
mod
->
sml_type
.
bv_val
=
attr
->
a_desc
->
ad_cname
.
bv_val
;
mod
->
sml_type
.
bv_len
=
strlen
(
mod
->
sml_type
.
bv_val
);
mod
->
sml_type
=
attr
->
a_desc
->
ad_cname
;
mod
->
sml_values
=
NULL
;
mod
->
sml_nvalues
=
NULL
;
mod
->
sml_numvals
=
0
;
...
...
@@ -296,71 +246,69 @@ static int addpartial_add( Operation *op, SlapReply *rs)
}
}
overlay_entry_release_ov
(
&
nop
,
found
,
0
,
on
);
if
(
mods
)
{
Modifications
*
m
=
NULL
;
Modifications
*
toDel
;
int
modcount
;
slap_callback
nullcb
=
{
NULL
,
collect_error_msg_cb
,
NULL
,
NULL
};
Debug
(
LDAP_DEBUG_TRACE
,
"%s: mods to do...
\n
"
,
addpartial
.
on_bi
.
bi_type
,
0
,
0
);
if
(
nop
.
o_bd
->
be_modify
)
memset
(
&
nrs
,
0
,
sizeof
(
nrs
));
nrs
.
sr_type
=
REP_RESULT
;
nrs
.
sr_err
=
LDAP_SUCCESS
;
nrs
.
sr_entry
=
NULL
;
nrs
.
sr_text
=
NULL
;
nop
.
o_tag
=
LDAP_REQ_MODIFY
;
nop
.
orm_modlist
=
mods
;
nop
.
orm_no_opattrs
=
0
;
nop
.
o_callback
=
&
nullcb
;
nop
.
o_bd
->
bd_info
=
(
BackendInfo
*
)
on
->
on_info
;
for
(
m
=
mods
,
modcount
=
0
;
m
;
m
=
m
->
sml_next
,
modcount
++
)
{
Modifications
*
m
=
NULL
;
int
modcount
;
slap_callback
nullcb
=
{
NULL
,
collect_error_msg_cb
,
NULL
,
NULL
};
char
textbuf
[
SLAP_TEXT_BUFLEN
];
size_t
textlen
=
sizeof
textbuf
;
memset
(
&
nrs
,
0
,
sizeof
(
nrs
));
nrs
.
sr_type
=
REP_RESULT
;
nrs
.
sr_err
=
LDAP_SUCCESS
;
nrs
.
sr_entry
=
NULL
;
nrs
.
sr_text
=
NULL
;
nop
.
o_tag
=
LDAP_REQ_MODIFY
;
nop
.
orm_modlist
=
mods
;
nop
.
o_callback
=
&
nullcb
;
nop
.
o_bd
->
bd_info
=
(
BackendInfo
*
)
on
->
on_info
;
for
(
m
=
mods
,
modcount
=
0
;
m
;
m
=
m
->
sml_next
,
modcount
++
)
{
/* count number of mods */
}
/* count number of mods */
}
Debug
(
LDAP_DEBUG_TRACE
,
"%s: number of mods: %d
\n
"
,
addpartial
.
on_bi
.
bi_type
,
modcount
,
0
);
Debug
(
LDAP_DEBUG_TRACE
,
"%s: number of mods: %d
\n
"
,
addpartial
.
on_bi
.
bi_type
,
modcount
,
0
);
if
(
nop
.
o_bd
->
be_modify
)
{
rc
=
(
nop
.
o_bd
->
be_modify
)(
&
nop
,
&
nrs
);
}
if
(
rc
==
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"%s: modify successful
\n
"
,
addpartial
.
on_bi
.
bi_type
,
0
,
0
);
}
else
if
(
rc
==
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"%s: modify successful
\n
"
,
addpartial
.
on_bi
.
bi_type
,
0
,
0
);
}
else
{
Debug
(
LDAP_DEBUG_TRACE
,
"%s: modify unsuccessful: %d
\n
"
,
addpartial
.
on_bi
.
bi_type
,
rc
,
0
);
rs
->
sr_err
=
rc
;
if
(
nullcb
.
sc_private
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"%s: modify unsuccessful: %d
\n
"
,
addpartial
.
on_bi
.
bi_type
,
rc
,
0
);
rs
->
sr_err
=
rc
;
if
(
nrs
.
sr_text
)
{
rs
->
sr_text
=
nullcb
.
sc_private
;
}
rs
->
sr_text
=
nullcb
.
sc_private
;
}
}
Debug
(
LDAP_DEBUG_TRACE
,
"%s: freeing mods...
\n
"
,
addpartial
.
on_bi
.
bi_type
,
0
,
0
);
if
(
mods
!=
NULL
)
{
Modifications
*
toDel
;
Debug
(
LDAP_DEBUG_TRACE
,
"%s: freeing mods...
\n
"
,
addpartial
.
on_bi
.
bi_type
,
0
,
0
);
for
(
toDel
=
mods
;
toDel
;
toDel
=
mods
)
{
mods
=
mods
->
sml_next
;
ch_free
(
toDel
);
}
}
for
(
toDel
=
mods
;
toDel
;
toDel
=
mods
)
{
mods
=
mods
->
sml_next
;
ch_free
(
toDel
);
}
}
else
...
...
@@ -368,9 +316,6 @@ static int addpartial_add( Operation *op, SlapReply *rs)
Debug
(
LDAP_DEBUG_TRACE
,
"%s: no mods to process
\n
"
,
addpartial
.
on_bi
.
bi_type
,
0
,
0
);
}
if
(
found
!=
NULL
)
entry_free
(
found
);
}
else
{
...
...
@@ -387,26 +332,6 @@ static int addpartial_add( Operation *op, SlapReply *rs)
}
}
static
int
addpartial_search_cb
(
Operation
*
op
,
SlapReply
*
rs
)
{
Entry
*
entry
=
NULL
;
if
(
rs
->
sr_type
!=
REP_SEARCH
)
return
0
;
Debug
(
LDAP_DEBUG_TRACE
,
"%s: addpartial_search_cb
\n
"
,
addpartial
.
on_bi
.
bi_type
,
0
,
0
);
if
(
rs
->
sr_entry
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"%s: dn found: %s
\n
"
,
addpartial
.
on_bi
.
bi_type
,
rs
->
sr_entry
->
e_nname
.
bv_val
,
0
);
entry
=
rs
->
sr_entry
;
op
->
o_callback
->
sc_private
=
(
void
*
)
entry_dup
(
entry
);
}
return
0
;
}
static
int
collect_error_msg_cb
(
Operation
*
op
,
SlapReply
*
rs
)
{
if
(
rs
->
sr_text
)
...
...
@@ -427,5 +352,5 @@ int addpartial_init()
int
init_module
(
int
argc
,
char
*
argv
[])
{
return
addpartial_init
();
return
addpartial_init
();
}
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