Skip to content

Conversation

@sumit-bose
Copy link
Contributor

To make sure any overrides are applied to the user even when searched by
UPN or email address sysdb_search_user_by_upn_with_view_res() is now used
in the cache request code.

@sumit-bose sumit-bose marked this pull request as draft June 13, 2025 07:46
@alexey-tikhonov
Copy link
Member

alexey-tikhonov commented Jun 13, 2025

Is this related to #7996?
UPD: looks like not.

@sumit-bose
Copy link
Contributor Author

Is this related to #7996? UPD: looks like not.

No, https://issues.redhat.com/browse/RHEL-72935

@alexey-tikhonov
Copy link
Member

Do you know if it's applicable to sssd-2-9-4?

@sumit-bose
Copy link
Contributor Author

Do you know if it's applicable to sssd-2-9-4?

Yes, looks like the issue is present since a long time.

@alexey-tikhonov
Copy link
Member

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors user lookup by UPN to use a new function sysdb_search_user_by_upn_with_view_res that correctly applies overrides from views. The changes involve removing the old sysdb_getpwupn function, implementing the new one, and updating the cache request plugin and tests. The overall change is good and includes a relevant system test. I found one potential logic bug in the new function where an ENOENT error code might be incorrectly overwritten, which I've commented on with a suggested fix.

Comment on lines +734 to +737
/* If there are views we have to check if override values must be added to
* the original object. */

Choose a reason for hiding this comment

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

high

There is a potential logic error in this function. If sysdb_search_user_by_upn_res returns ENOENT, ret is set to ENOENT. The code then proceeds to line 759, where ret is unconditionally overwritten to EOK. This causes the function to return EOK with an empty result set, instead of ENOENT, which was the original error code indicating the entry was not found. This changes the semantics of the function's return value.

To preserve the ENOENT error code, you should handle this case before ret is overwritten. I suggest adding a check after the initial search and before attempting to process overrides.

    if (ret == ENOENT) {
        goto done;
    }

    /* If there are views we have to check if override values must be added to
     * the original object. */

Copy link
Member

Choose a reason for hiding this comment

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

This is valid. The original code returns the empty object but keeps ENOENT return code.

Copy link
Member

Choose a reason for hiding this comment

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

'empty object' == NULL?

Copy link
Member

Choose a reason for hiding this comment

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

I mean, what's the point, why not simply if (ret != EOK) return ret;?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi,

I fixed this as Pavel suggested, the function will return ENOENT with an empty (not NULL) struct ldb_result as sysdb_search_user_by_upn_res(). The caller in the cache_req code is quite robust and could handle the original version as well, but being consistent with sysdb_search_user_by_upn_res() makes sense imo.

bye,
Sumit

Copy link
Member

@alexey-tikhonov alexey-tikhonov Dec 5, 2025

Choose a reason for hiding this comment

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

Ok, perhaps empty object is expected by the caller of 'cache_req_plugin::lookup_fn' (I didn't check).

But current patch returns NULL in case sysdb_search_user_by_upn_res() == ENOENT, not empty struct...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, perhaps empty object is expected by the caller of 'cache_req_plugin::lookup_fn' (I didn't check).

No, it isn't expected if ENOENT is returned.

But current patch returns NULL in case sysdb_search_user_by_upn_res() == ENOENT, not empty struct...

I think unfortunately both cases are possible. But in either case sysdb_search_user_by_upn_with_view_res() would return the same combination as sysdb_search_user_by_upn_res().

Copy link
Member

Choose a reason for hiding this comment

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

Ok, perhaps empty object is expected by the caller of 'cache_req_plugin::lookup_fn' (I didn't check).

No, it isn't expected if ENOENT is returned.

I'm confused: what is the point then to orig_obj = talloc_zero(mem_ctx, struct ldb_result); if sysdb_add_overrides_to_object() == ENOENT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi,

in the latest version I simplified sysdb_search_user_by_upn_with_view_res() wit hthe result that it might behaver differently than other lookup_fn methods of cache_req plugins but not cause issues in the single caller.

bye,
Sumit

Copy link
Member

Choose a reason for hiding this comment

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

Thank you.

@pbrezina, are you fine with the latest version?

Copy link
Member

@pbrezina pbrezina left a comment

Choose a reason for hiding this comment

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

Otherwise ack.

Comment on lines +734 to +737
/* If there are views we have to check if override values must be added to
* the original object. */
Copy link
Member

Choose a reason for hiding this comment

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

This is valid. The original code returns the empty object but keeps ENOENT return code.

@alexey-tikhonov alexey-tikhonov added the coverity Trigger a coverity scan label Dec 19, 2025
@alexey-tikhonov
Copy link
Member

Note: Covscan is green.

@alexey-tikhonov alexey-tikhonov removed the coverity Trigger a coverity scan label Dec 19, 2025
@alexey-tikhonov
Copy link
Member

alexey-tikhonov commented Dec 20, 2025

f-44 system test fails aren't due to this PR.
At least some of them are related to https://bugzilla.redhat.com/show_bug.cgi?id=2423900

sumit-bose and others added 5 commits January 2, 2026 11:38
The new call will apply overrides to a user object which was searched by
UPN or email address before returning it.

Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
To make sure any overrides are applied to the user even when searched by
UPN or email address sysdb_search_user_by_upn_with_view_res() is now
used in the cache request code.

Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Add a system test to verify that IPA ID view overrides are correctly
applied when looking up a user by email address.

The test creates a user with an email, applies ID view overrides
(login, uid, gid, home), and verifies that the overridden values are
returned when looking up the user by:
- original name
- overridden name
- email address

Signed-off-by: Madhuri Upadhye <mupadhye@redhat.com>
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
@sssd-bot
Copy link

sssd-bot commented Jan 2, 2026

The pull request was accepted by @alexey-tikhonov with the following PR CI status:


🟢 CodeFactor (success)
🟢 CodeQL (success)
🟢 osh-diff-scan:fedora-rawhide-x86_64:upstream (success)
🟢 rpm-build:centos-stream-10-x86_64:upstream (success)
🟢 rpm-build:fedora-42-x86_64:upstream (success)
🟢 rpm-build:fedora-43-x86_64:upstream (success)
🟢 rpm-build:fedora-rawhide-x86_64:upstream (success)
🟢 Analyze (target) / cppcheck (success)
🟢 Build / freebsd (success)
🟢 Build / make-distcheck (success)
🟢 ci / intgcheck (centos-10) (success)
🟢 ci / intgcheck (fedora-42) (success)
🟢 ci / intgcheck (fedora-43) (success)
🟢 ci / intgcheck (fedora-44) (success)
🟢 ci / prepare (success)
🟢 ci / system (centos-10) (success)
🟢 ci / system (fedora-42) (success)
🟢 ci / system (fedora-43) (success)
🔴 ci / system (fedora-44) (failure)
➖ Coverity scan / coverity (skipped)
🟢 Static code analysis / codeql (success)
🟢 Static code analysis / pre-commit (success)
🟢 Static code analysis / python-system-tests (success)


There are unsuccessful or unfinished checks. Make sure that the failures are not related to this pull request before merging.

@alexey-tikhonov alexey-tikhonov merged commit 6413f60 into SSSD:master Jan 2, 2026
13 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants