Skip to content

Issue 6256 - nsslapd-numlisteners limit is not enforced #6257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 30, 2024
Merged

Conversation

jchapma
Copy link
Contributor

@jchapma jchapma commented Jul 9, 2024

Description: When a invalid value for the attribute nsslapd-numlisteners is used, config normalises the value but the invalid value is written to dse.ldif.

Fix description: Modify config to return operations error if an invalid value is used. Modify configdse to handle an operations error if an invalid value is used.

Fixes: #6256

Reviewed by:

@@ -287,7 +287,8 @@ load_config_dse(Slapi_PBlock *pb __attribute__((unused)),
if (attr_name) {
retval = config_set(attr_name, values, returntext, 1 /* force apply */);
if ((strcasecmp(attr_name, CONFIG_MAXDESCRIPTORS_ATTRIBUTE) == 0) ||
(strcasecmp(attr_name, CONFIG_RESERVEDESCRIPTORS_ATTRIBUTE) == 0)) {
(strcasecmp(attr_name, CONFIG_RESERVEDESCRIPTORS_ATTRIBUTE) == 0) ||
(strcasecmp(attr_name, CONFIG_NUM_LISTENERS_ATTRIBUTE) == 0)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why to put the attribute to this check if we don't benefit from that?

We should either remove it from here or we should add this (or something like this with LDAP_UNWILLING_TO_PERFORM) to ldap/servers/slapd/libglobs.c::config_set_num_listeners:

        if (nValue > maxVal) {
            nValue = maxVal;
            retVal = LDAP_UNWILLING_TO_PERFORM;
        } else {
            retVal = LDAP_OPERATIONS_ERROR;
        }

Or do I miss something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check is here to cover the corner case where a user has changed version, if we don't add the check and the "nsslapd-numlisteners" attr is present in dse.ldif the instance will fail to start.

IIUC we need to return LDAP_OPERATIONS_ERROR when an invalid value has been used for this attr, otherwise the invalid value gets written to dse.ldif.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a look over this again and yes, it is best to return LDAP_UNWILLING_TO_PERFORM when an invalid value for the nsslapd-numlisteners is used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, IIUC, you changed the behaviour now to reject the value instead of normalizing it (as it was before).
Could you please elaborate on why you think it's the current thing to do for nsslapd-numlisteners?

You probably need to change the commit message and test the docstring with the explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the dse backend callback is called there are two passes done for each mod, the first pass validates the value and the second pass apply's the change. With the existing behaviour, when an invalid value is input the config code normalises the value during the first pass, then during the second pass the invalid value is written to dse.ldif, which is why this issue was created.

To avoid this we need to reject an invalid value so the second pass doesn't apply the change. To reject the invalid value we need to return either LDAP_OPERATIONS_ERROR like almost all of the other config_set functions or LDAP_UNWILLING_TO_PERFORM.

Yes the plan was to update the commit message during merge, I need to update the CI test so I will update the doc string also.

@droideck
Copy link
Member

droideck commented Jul 26, 2024

Sorry, I was waiting for GitHub CI to be working again, but maybe we had some fix recently? Could you please rebase onto main?

It will also give us the test you and @ssidhaye added.

jchapma added 4 commits July 26, 2024 15:16
Description: When a invalid value for the attribute nsslapd-numlisteners
is used, config normalises the value but the invalid value is written to
dse.ldif.

Fix description: Modify config to return operations error if an invalid
value is used. Modify configdse to handle an operations error if an
invalid value is used.

Fixes: #6256

Reviewed by:
@jchapma
Copy link
Contributor Author

jchapma commented Jul 29, 2024

Sorry, I was waiting for GitHub CI to be working again, but maybe we had some fix recently? Could you please rebase onto main?

It will also give us the test you and @ssidhaye added.

Rebased with main branch, the CI test I added wasn't used, I just added the with statement to @ssidhaye test.

Copy link
Member

@droideck droideck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jchapma jchapma merged commit 9753fb9 into main Jul 30, 2024
388 of 390 checks passed
@jchapma jchapma deleted the numlisteners branch July 30, 2024 02:56
vashirov pushed a commit that referenced this pull request Jul 30, 2024
Description: When a invalid value for the attribute nsslapd-numlisteners
is used, config normalises the value but the invalid value is written to
dse.ldif.

Fix description: Modify config to reject an invalid value is used.

Fixes: #6256

Reviewed by: @droideck (Thank you)
vashirov pushed a commit that referenced this pull request Jul 30, 2024
Description: When a invalid value for the attribute nsslapd-numlisteners
is used, config normalises the value but the invalid value is written to
dse.ldif.

Fix description: Modify config to reject an invalid value is used.

Fixes: #6256

Reviewed by: @droideck (Thank you)
vashirov pushed a commit that referenced this pull request Jul 30, 2024
Description: When a invalid value for the attribute nsslapd-numlisteners
is used, config normalises the value but the invalid value is written to
dse.ldif.

Fix description: Modify config to reject an invalid value is used.

Fixes: #6256

Reviewed by: @droideck (Thank you)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nsslapd-numlisteners limit is not enforced
2 participants