Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nadezhda Ivanova
OpenLDAP
Commits
f0560292
Commit
f0560292
authored
Apr 19, 2012
by
Ondrej Kuznik
Committed by
Howard Chu
Jul 08, 2014
Browse files
ITS#7256 mplement bi_tool_entry_delete for back-ldif
parent
c048b7ca
Changes
1
Show whitespace changes
Inline
Side-by-side
servers/slapd/back-ldif/ldif.c
View file @
f0560292
...
...
@@ -1891,6 +1891,63 @@ ldif_tool_entry_modify( BackendDB *be, Entry *e, struct berval *text )
return
NOID
;
}
static
int
ldif_tool_entry_delete
(
BackendDB
*
be
,
ID
id
,
struct
berval
*
text
)
{
struct
ldif_tool
*
tl
=
&
((
struct
ldif_info
*
)
be
->
be_private
)
->
li_tool
;
int
rc
=
LDAP_SUCCESS
;
const
char
*
errmsg
=
NULL
;
struct
berval
path
;
Entry
*
e
;
Operation
op
=
{
0
};
id
--
;
if
(
id
>=
tl
->
ecount
||
tl
->
entries
[
id
]
==
NULL
)
return
LDAP_OTHER
;
e
=
tl
->
entries
[
id
];
op
.
o_bd
=
be
;
ndn2path
(
&
op
,
&
e
->
e_nname
,
&
path
,
0
);
ldif2dir_len
(
path
);
ldif2dir_name
(
path
);
if
(
rmdir
(
path
.
bv_val
)
<
0
)
{
switch
(
errno
)
{
case
ENOTEMPTY
:
rc
=
LDAP_NOT_ALLOWED_ON_NONLEAF
;
break
;
case
ENOENT
:
/* is leaf, go on */
break
;
default:
rc
=
LDAP_OTHER
;
errmsg
=
"internal error (cannot delete subtree directory)"
;
break
;
}
}
if
(
rc
==
LDAP_SUCCESS
)
{
dir2ldif_name
(
path
);
if
(
unlink
(
path
.
bv_val
)
<
0
)
{
rc
=
LDAP_NO_SUCH_OBJECT
;
if
(
errno
!=
ENOENT
)
{
rc
=
LDAP_OTHER
;
errmsg
=
"internal error (cannot delete entry file)"
;
}
}
}
SLAP_FREE
(
path
.
bv_val
);
entry_free
(
e
);
tl
->
entries
[
id
]
=
NULL
;
if
(
errmsg
==
NULL
&&
rc
!=
LDAP_OTHER
)
errmsg
=
ldap_err2string
(
rc
);
if
(
errmsg
!=
NULL
)
snprintf
(
text
->
bv_val
,
text
->
bv_len
,
"%s"
,
errmsg
);
return
rc
;
}
/* Setup */
...
...
@@ -1990,6 +2047,7 @@ ldif_back_initialize( BackendInfo *bi )
bi
->
bi_tool_entry_get
=
ldif_tool_entry_get
;
bi
->
bi_tool_entry_put
=
ldif_tool_entry_put
;
bi
->
bi_tool_entry_modify
=
ldif_tool_entry_modify
;
bi
->
bi_tool_entry_delete
=
ldif_tool_entry_delete
;
bi
->
bi_tool_entry_reindex
=
0
;
bi
->
bi_tool_sync
=
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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