Issue 8434 - Config entry cleanup on Add should be run unconditionally
Summary: Config entry cleanup on Add should be run unconditionally
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: 2.5.0
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-04 19:58 UTC by Ondřej Kuzník
Modified: 2020-10-14 21:08 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ondřej Kuzník 2016-06-04 19:58:56 UTC
Full_Name: Ondrej Kuznik
Version: master
OS: 
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (2a02:c7f:221f:c00:a3e:8eff:fe52:dac5)


With cn=config the ConfigLDAPadd function might have to allocate resources that
are needed by the time the attributes/config directives are being processed
since there is no indication which directives there are and what order they come
in.

If any of the config values fail validation, the configuration code has to react
and clean up - which is possible using ca->cleanup.

While Modify handling (config_modify_internal) already calls ca->cleanup in each
case, this is not true for config_add_internal, there it is only run on success.
Comment 1 Howard Chu 2016-06-08 22:15:06 UTC
okuznik@symas.com wrote:
> Full_Name: Ondrej Kuznik
> Version: master
> OS:
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (2a02:c7f:221f:c00:a3e:8eff:fe52:dac5)
>
>
> With cn=config the ConfigLDAPadd function might have to allocate resources that
> are needed by the time the attributes/config directives are being processed
> since there is no indication which directives there are and what order they come
> in.

When using LDAPAdd, attributes are processed in the order of their schema 
definitions.

> If any of the config values fail validation, the configuration code has to react
> and clean up - which is possible using ca->cleanup.

No, that's not its purpose. If anything fails, the entire config entry must be 
wiped out. LDAPAdd is all-or-nothing.

> While Modify handling (config_modify_internal) already calls ca->cleanup in each
> case, this is not true for config_add_internal, there it is only run on success.

-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

Comment 2 Ondřej Kuzník 2016-06-18 20:33:52 UTC
On Wed, Jun 08, 2016 at 10:15:13PM +0000, hyc@symas.com wrote:
> okuznik@symas.com wrote:
>> With cn=config the ConfigLDAPadd function might have to allocate resources that
>> are needed by the time the attributes/config directives are being processed
>> since there is no indication which directives there are and what order they come
>> in.
> 
> When using LDAPAdd, attributes are processed in the order of their schema 
> definitions.
> 
>> If any of the config values fail validation, the configuration code has to react
>> and clean up - which is possible using ca->cleanup.
> 
> No, that's not its purpose. If anything fails, the entire config entry must be 
> wiped out. LDAPAdd is all-or-nothing.

Yes, but the resource usually has to be allocated before the any of the
attributes are processed. In case of failure, the overlay does not have
a chance to react and free it since it has no idea when the reversal of
all of the attributes has finished.

Comment 3 Ondřej Kuzník 2020-06-10 12:07:42 UTC
Code to implement this is in a merge request here:
https://git.openldap.org/openldap/openldap/-/merge_requests/79
Comment 4 Quanah Gibson-Mount 2020-06-22 17:30:14 UTC
  • 57b0ed90 
by Ondřej Kuzník at 2020-06-21T18:55:09+00:00 
ITS#8434 Allow cleanup at the end of a failed back-config add