Skip to content
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

DBUS: Add ListByAttr(attr, filter, limit) #6367

Closed
wants to merge 1 commit into from
Closed

Conversation

aplopez
Copy link
Contributor

@aplopez aplopez commented Sep 27, 2022

Extended ListByName()'s mechanics to handle an attribute passed as parameters instead of forcing "name". ListByName() will pass "name."

Created a dbus function ListByAttr() passing the attribute requested by the user.

Resolves: #6020

:feature: Introduced the dbus function org.freedesktop.sssd.infopupe.Users.ListByAttr(attr, value, limit) listing users matching the filter attr=value.

Please have in mind these issues below also affect this implementation as they share the mechanics with ListByName(). They have to be addressed separate from this PR.
[D-Bus] ListByName() fails when not using wildcards
[D-Bus] ListByName() returns twice the same entry

@aplopez aplopez marked this pull request as ready for review September 28, 2022 12:01
@alexey-tikhonov alexey-tikhonov added the no-backport This should go to target branch only. label Sep 28, 2022
@justin-stephenson justin-stephenson self-assigned this Sep 28, 2022
Copy link
Contributor

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

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

The code looks good to me but I'm missing some type of automated test, either a unit-test or an integration test.

@justin-stephenson
Copy link
Contributor

As the original requestor of the feature, perhaps @flo-renaud may want to review this also.

@aplopez
Copy link
Contributor Author

aplopez commented Oct 3, 2022

The code looks good to me but I'm missing some type of automated test, either a unit-test or an integration test.

Added a test into the file you linked.

@justin-stephenson
Copy link
Contributor

Hi Alejandro,

Did I miss something in my configuration, or command I am using?

[root@master /]# dbus-send --system --print-reply --dest=org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe/Users/ipa_2etest/121000009 org.freedesktop.DBus.Properties.Get string:"org.freedesktop.sssd.infopipe.Users.User" string:"extraAttributes"
method return time=1664811583.329400 sender=:1.107 -> destination=:1.106 serial=6 reply_serial=2
   variant       array [
         dict entry(
            string "mail"
            array [
               string "testuser1@ipa.test"
            ]
         )
         dict entry(
            string "sn"
            array [
               string "user1"
            ]
         )
      ]

[root@master /]# dbus-send --system --print-reply --dest=org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe/Users org.freedesktop.sssd.infopipe.Users.ListByAttr "string:sn" "string:user1" "uint32:0"                            
method return time=1664811587.993677 sender=:1.107 -> destination=:1.108 serial=8 reply_serial=2
   array [
   ]

[root@master /]# dbus-send --system --print-reply --dest=org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe/Users org.freedesktop.sssd.infopipe.Users.ListByAttr "string:sn" "string:user*" "uint32:0"
method return time=1664811607.436829 sender=:1.112 -> destination=:1.111 serial=6 reply_serial=2
   array [
   ]

@aplopez
Copy link
Contributor Author

aplopez commented Oct 3, 2022

[root@master /]# dbus-send --system --print-reply --dest=org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe/Users org.freedesktop.sssd.infopipe.Users.ListByAttr "string:sn" "string:user1" "uint32:0"                            
method return time=1664811587.993677 sender=:1.107 -> destination=:1.108 serial=8 reply_serial=2
   array [
   ]

The problem here is that there are two pre-existing bugs that affect this new feature as it shares the code with ListByName(). I added the links in the description. So you should look for "user1*" to work around the issue.

[root@master /]# dbus-send --system --print-reply --dest=org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe/Users org.freedesktop.sssd.infopipe.Users.ListByAttr "string:sn" "string:user*" "uint32:0"
method return time=1664811607.436829 sender=:1.112 -> destination=:1.111 serial=6 reply_serial=2
   array [
   ]

I guess you need to add ldap_user_extra_attrs = sn to your domain's configuration for attribute sn to be included in the cache.

@justin-stephenson
Copy link
Contributor

I guess you need to add ldap_user_extra_attrs = sn to your domain's configuration for attribute sn to be included in the cache.

I do have this and user_attributes in my sssd configuration.

Attached log of the failed ListByAttr lookup with "string:sn" "string:user1" "uint32:0"

@justin-stephenson
Copy link
Contributor

@justin-stephenson
Copy link
Contributor

flake8 check is failing to post the result to the PR, but manually running it shows:

# flake8 src/tests/intg/test_infopipe.py 
src/tests/intg/test_infopipe.py:806:1: E302 expected 2 blank lines, found 1
src/tests/intg/test_infopipe.py:822:1: W391 blank line at end of file

@aplopez
Copy link
Contributor Author

aplopez commented Oct 4, 2022

flake8 check is failing to post the result to the PR, but manually running it shows:

# flake8 src/tests/intg/test_infopipe.py 
src/tests/intg/test_infopipe.py:806:1: E302 expected 2 blank lines, found 1
src/tests/intg/test_infopipe.py:822:1: W391 blank line at end of file

Thanks. I was looking for this information. (Good to know I can run it manually)

@ikerexxe
Copy link
Contributor

ikerexxe commented Oct 4, 2022

Added a test into the file you linked.

Thanks!

Once the flake8 issues are fixed it would be good for me.

Extended ListByName()'s mechanics to handle an attribute passed
as parameters instead of forcing "name." ListByName() will pass "name."

Created a dbus function ListByAttr() using ListByName()'s mechanics
but passing the attribute requested by the user.

Resolves: SSSD#6020

:feature: Introduced the dbus function
          org.freedesktop.sssd.infopipe.Users.ListByAttr(attr, value, limit)
          listing upto limit users matching the filter attr=value.
@aplopez
Copy link
Contributor Author

aplopez commented Oct 4, 2022

I guess you need to add ldap_user_extra_attrs = sn to your domain's configuration for attribute sn to be included in the cache.

I do have this and user_attributes in my sssd configuration.

Attached log of the failed ListByAttr lookup with "string:sn" "string:user1" "uint32:0"

Should be fixed now. Let me know if it is not the case.

@aplopez
Copy link
Contributor Author

aplopez commented Oct 4, 2022

@ikerexxe In addition to the flake8 fix, I made some changes related to the problem found by @justin-stephenson . You may want to review them.

@alexey-tikhonov
Copy link
Member

Covscan failed due to infra failure.

@ikerexxe
Copy link
Contributor

ikerexxe commented Oct 5, 2022

LGTM. Thanks for the patches.

@justin-stephenson
Copy link
Contributor

Should be fixed now. Let me know if it is not the case.

Hi, this works now but output is repeated twice. If this is acceptable and will be addressed separately then ack from my side.

dbus-send --system --print-reply --dest=org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe/Users org.freedesktop.sssd.infopipe.Users.ListByAttr "string:sn" "string:user*" "uint32:0"
method return time=1664973962.592147 sender=:1.191 -> destination=:1.205 serial=32 reply_serial=2
   array [
      object path "/org/freedesktop/sssd/infopipe/Users/ipa_2etest/121000009"
      object path "/org/freedesktop/sssd/infopipe/Users/ipa_2etest/121000009"
   ]

@aplopez
Copy link
Contributor Author

aplopez commented Oct 5, 2022

Hi, this works now but output is repeated twice. If this is acceptable and will be addressed separately then ack from my side.

Hi. It is one of the preexisting bugs mentioned in the description.
#6360

It will be fixed at some time in the future.

@pbrezina
Copy link
Member

pbrezina commented Oct 7, 2022

Pushed PR: #6367

  • master
    • acfe3b2 - DBUS: Add ListByAttr(attr, filter, limit)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugzilla no-backport This should go to target branch only. Pushed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFE] provide dbus method to find users by attr
5 participants