Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1232425

Summary: D-Bus interface for InfoPipe.GetUserAttr returns base64 encoded values for octetString attributes
Product: Red Hat Enterprise Linux 7 Reporter: Petr Spacek <pspacek>
Component: sssdAssignee: SSSD Maintainers <sssd-maint>
Status: CLOSED UPSTREAM QA Contact: Namita Soman <nsoman>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: grajaiya, jgalipea, jhrozek, lslebodn, mkosek, mzidek, pbrezina
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-07 20:13:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Petr Spacek 2015-06-16 17:54:12 UTC
Description of problem:
Values obtained using D-Bus call org.freedesktop.sssd.infopipe.GetUserAttr() are base64 encoded if the attribute in LDAP has octetString syntax.

Version-Release number of selected component (if applicable):
sssd-dbus-1.12.2-58.el7_1.6.x86_64

How reproducible:
100 %

Steps to Reproduce:
0. Add LDAP schema with an octetString attribute:
E.g. ( 2.16.840.1.113730.3.8.11.31 NAME 'ipaSshPubKey' DESC 'SSH public key' EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 X-ORIGIN ( 'IPA v3' 'user defined' ) )


1. Configure IFP to return a attribute which has syntax octetString. /etc/sssd/sssd.conf:
[domain/redhat.com]
ldap_user_extra_attrs = mail, givenname, sn, ipaSshPubKey

[ifp]
allowed_uids = root
user_attributes = +mail, +givenname, +sn, +ipaSshPubKey

2. Populate the attributes with some data.

3. Request values of the attribute with octetString syntax over D-Bus:
#!/bin/python
import dbus

def get_keys_from_server(username):
    bus = dbus.SystemBus()
    infopipe_obj = bus.get_object("org.freedesktop.sssd.infopipe", "/org/freedesktop/sssd/infopipe")

    ifp = dbus.Interface(infopipe_obj, dbus_interface='org.freedesktop.sssd.infopipe')
    result = ifp.GetUserAttr(username, ["ipaSshPubKey"])
    ssh_keys = []
    if result:
        for sshpubkey in result["ipaSshPubKey"]:
            print(sshpubkey)

Actual results:
The returned value is base64 encoded.

Expected results:
Raw value is returned.

Comment 2 Jakub Hrozek 2015-06-19 15:56:23 UTC
The tentative plan is to keep returning everything as string, but mark clearly in the returned string representation that the value should be decoded.

Comment 3 Jakub Hrozek 2015-06-19 15:56:54 UTC
Upstream ticket:
https://fedorahosted.org/sssd/ticket/2684

Comment 4 Petr Spacek 2015-06-23 10:24:42 UTC
Jakub, could you be more specific? I'm not sure what you meant by 'mark clearly in the returned string representation that the value should be decoded'.

Comment 5 Jakub Hrozek 2015-06-23 10:41:00 UTC
Something like "values starting with two colons are encoded with base64 and the caller should decode them on their own".

Comment 6 Petr Spacek 2015-06-23 13:53:18 UTC
I feel that the proposal over-complicates a simple thing, i.e. an API which is supposed to return string stored in LDAP.

What if the actual string value starts with two colons? Will you base64 encode all IA5Strings starting with :: just to make sure that the right value can be obtained by decoding it?

Seriously?

What am I missing?

Why not fix it properly, e.g. to always return arbitrary blob (or always base64 encode it if arbitrary blob is not an option for some reason)?

I do not understand it, sorry.

Comment 7 Jakub Hrozek 2015-06-23 14:21:34 UTC
(In reply to Petr Spacek from comment #6)
> I feel that the proposal over-complicates a simple thing, i.e. an API which
> is supposed to return string stored in LDAP.
> 
> What if the actual string value starts with two colons? Will you base64
> encode all IA5Strings starting with :: just to make sure that the right
> value can be obtained by decoding it?
> 
> Seriously?
> 
> What am I missing?
> 
> Why not fix it properly, e.g. to always return arbitrary blob

Because D-Bus is typed. So the arbitrary blob would be 'array of bytes' with specified length, which is inconvenient.

>  (or always
> base64 encode it if arbitrary blob is not an option for some reason)?

That would work and would be similar to the 'arbitrary blob' you propose, but would complicate matters for 90% of attributes.

Comment 8 Petr Spacek 2015-06-23 14:31:40 UTC
Sorry, but I do not see the benefit of doing so. Even in your scheme users cannot rely on fact that the value will not be base64 encoded. Any code which depends on that check will blow up as soon as someone mistyped a value in LDAP and added space to the beginning of a string or did something similarly stupid.

I'm sorry to say that but that it is really a poor design for an API.

Comment 9 Petr Spacek 2015-06-23 14:32:46 UTC
I mean, 'any code which depends on that *property*', i.e. relying on fact that the value will certainly not be base64 encoded.

Comment 10 Jakub Hrozek 2016-11-23 13:55:23 UTC
Thank you for filing this bug report.

Since fixing this bug requires work in the upstream SSSD project which is not scheduled for the immediate future, I added a conditional development nack, pending upstream availability.

Comment 11 Jakub Hrozek 2017-08-07 20:13:44 UTC
Thank you for filing this bug report.

Since this bug is being tracked in the upstream issue tracker and the fix would only make its way to RHEL pending upstream availability, I'm closing this bugzilla with the resolution of UPSTREAM. Please reopen if you think this issue needs to be tracked here in the Red Hat Bugzilla.