Bug 785902

Summary: Errors with empty loginShell and proxy provider
Product: Red Hat Enterprise Linux 6 Reporter: Stephen Gallagher <sgallagh>
Component: sssdAssignee: Stephen Gallagher <sgallagh>
Status: CLOSED ERRATA QA Contact: IDM QE LIST <seceng-idm-qe-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3CC: apeetham, grajaiya, jgalipea, jzeleny, prc
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sssd-1.8.0-2.el6.beta2 Doc Type: Bug Fix
Doc Text:
Cause: The function which was storing user entities to SSSD cache didn't check for empty strings in loginShell attribute. Therefore if it encountered such attribute, the storing procedure would fail completely. Consequence: When using proxy provider and utilized nss module returned empty loginShell, updating user record in cache failed. Therefore invalid data could have been returned to client. Fix: Make sure that proxy provider doesn't pass empty string to the function. Result: when proxy provider gets result with empty loginShell attribute, it doesn't fail and user is stored correctly. Therefore valid entry is returned to the client.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 11:54:35 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Stephen Gallagher 2012-01-30 21:01:04 UTC
This bug is created as a clone of upstream ticket:
https://fedorahosted.org/sssd/ticket/892

This issue was found by Kaushik while testing the proxy provider.

The loginShell attribute is a MAY attribute according to rfc 2307 and 2307bis and neither rfc give a hint what to do if loginShell is missing.

If loginShell is missing or empty for a LDAP user the corresponding attribute is not written to the cache, because sysdb_add_basic_user() drops it in this case. When using the proxy provider in both cases (missing or empty) an empty string is returned by the external getpwnam_r() call and an update of the cached entry will fail. The reason is that sysdb_store_user() only checks if shell==NULL but not if shell is an empty string and now tries to update a non-existent attribute in the cache which is not allowed.

As a side effect it is also not possible to update other attributes, e.g, a change in the gecos field, because all updates and done in a single operation.

To fix this I would like to suggest to introduce a configurable default login shell with a default value of '/dev/null'.

To reproduce this issue configure a domain as

{{{
[domain/proxy]
id_provider = proxy
proxy_lib_name = ldap
proxy_pam_target = sss_ldap
}}}

start with an empty cache and call 'id ldap_user_with_missing_loginShell'. The following error messages can be found:

{{{
(Wed Jun 15 12:23:39 2011) [sssd[be[proxy]]] [sysdb_set_entry_attr] (6): Error: 14 (Bad address)
(Wed Jun 15 12:23:39 2011) [sssd[be[proxy]]] [ldb] (9): cancel ldb transaction (nesting: 1)
(Wed Jun 15 12:23:39 2011) [sssd[be[proxy]]] [sysdb_store_user] (6): Error: 14 (Bad address)
(Wed Jun 15 12:23:39 2011) [sssd[be[proxy]]] [ldb] (9): cancel ldb transaction (nesting: 0)
(Wed Jun 15 12:23:39 2011) [sssd[be[proxy]]] [acctinfo_callback] (4): Request processed. Returned 3,14,Internal Error (Cannot make/remove an entry for the specified session)
}}}

Comment 4 Jan Zeleny 2012-04-04 10:39:13 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause: The function which was storing user entities to SSSD cache didn't check for empty strings in loginShell attribute. Therefore if it encountered such attribute, the storing procedure would fail completely.
Consequence: When using proxy provider and utilized nss module returned empty loginShell, updating user record in cache failed. Therefore invalid data could have been returned to client.
Fix: Make sure that proxy provider doesn't pass empty string to the function.
Result: when proxy provider gets result with empty loginShell attribute, it doesn't fail and user is stored correctly. Therefore valid entry is returned to the client.

Comment 5 Amith 2012-04-11 09:24:42 UTC
Verified on sssd-1.8.0-22.el6.x86_64. 

The beaker output for the associated automation script is given below:

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Verify BZ release ticket #342 :- Errors with empty loginShell and proxy provider
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Running '/usr/bin/ldapadd -x -D cn=Manager,dc=example,dc=com -w Secret123 -H ldap://hubcap.lab.eng.pnq.redhat.com -f /tmp/tempuser.ldif > /dev/null 2>&1'
:: [   PASS   ] :: Running '/sbin/service sssd stop'
:: [   PASS   ] :: Running 'rm -f /var/lib/sss/db/*'
:: [   PASS   ] :: Running '/sbin/service sssd start'
:: [   PASS   ] :: Running '/bin/sleep 5s'
:: [   PASS   ] :: Running '/usr/bin/id tempuser'
:: [   PASS   ] :: File '/var/log/sssd/sssd_PROXY.log' should not contain '\[sysdb_set_entry_attr\] (6): Error: 14 (Bad address)'
:: [   PASS   ] :: File '/var/log/sssd/sssd_PROXY.log' should not contain '\[sysdb_store_user\] (6): Error: 14 (Bad address)'
:: [   PASS   ] :: File '/var/log/sssd/sssd_PROXY.log' should not contain 'Internal Error (Cannot make/remove an entry for the specified session)'
:: [   PASS   ] :: Running '/usr/bin/ldapmodify -x -D cn=Manager,dc=example,dc=com -w Secret123 -H ldap://hubcap.lab.eng.pnq.redhat.com -f /tmp/deluser.ldif > /dev/null 2>&1'
:: [   PASS   ] :: Running 'rm -f /tmp/tempuser.ldif'
:: [   PASS   ] :: Running 'rm -f /tmp/deluser.ldif'
:: [   LOG    ] :: Duration: 34s
:: [   LOG    ] :: Assertions: 12 good, 0 bad
:: [   PASS   ] :: RESULT: Verify BZ release ticket #342 :- Errors with empty loginShell and proxy provider

Comment 7 errata-xmlrpc 2012-06-20 11:54:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0747.html