Bug 1919942

Summary: sss_override does not take precedence over override_homedir directive
Product: Red Hat Enterprise Linux 8 Reporter: ttuffin
Component: sssdAssignee: Sumit Bose <sbose>
Status: CLOSED ERRATA QA Contact: Anuj Borah <aborah>
Severity: low Docs Contact:
Priority: medium    
Version: 8.4CC: aborah, atikhono, dlavu, grajaiya, jhrozek, lslebodn, mzidek, pbrezina, sbose, tmihinto, tscherf
Target Milestone: betaKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: sync-to-jira
Fixed In Version: sssd-2.5.0-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-09 19:47:00 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 ttuffin 2021-01-25 12:25:20 UTC
Description of problem:
When using `sss_override` to override a user's home directory, it fails to take precedence over the `override_homedir` directive in /etc/sssd/sssd.conf. That is, if `override_homedir` is set in sssd.conf, this will always override the home directory specified by the `sss_override` command. Is this by design?


Version-Release number of selected component (if applicable):
sssd-client-1.16.5-10.el7_9.6.x86_64
sssd-tools-1.16.5-10.el7_9.6.x86_64


How reproducible:
Always


Steps to Reproduce:
1. Install sssd and sssd-tools
2. Join to domain (I joined to AD with adcli, i.e. `realm join domain.local --membership-software=adcli -U <DOMAIN_ADMIN>`
3. Edit sssd.conf and set homedir, i.e. `override_homedir = /home/%u1`
4. Restart sssd and check homedir: # getent passwd joe
(home set to /home/joe1)
5. Use `sss_override` to set a different home directory: # sss_override user-add joe -h /home/joe2
6. Restart sssd and use getent command to check home directory, which is still set to /home/joe1.

Actual results:
In this example the home directory for user joe will be set to /home/joe1, which means the `override_homedir` directive takes precedence over over the home directory set by `sss_override`.


Expected results:
I would expect `sss_override` to take precedence over `override_homedir`. Since `override_homedir` is on a per-domain level and `sss_override` is per user/group on the local client, `sss_override` allows overriding down to a lower level and therefore should take precedence over `override_homedir`. So the order should be:
1. sss_override
2. override_homedir
3. fallback_homedir

That's just my opinion, but maybe I am missing something.


Additional info:
`sss_override` does successfully override the `fallback_homedir` directive.

Comment 2 ttuffin 2021-01-27 10:16:23 UTC
I have confirmed the same behaviour in RHEL 8.3 (4.18.0-240.el8.x86_64).

[root@test-vm-4 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.3 (Ootpa)
[root@test-vm-4 ~]# uname -r 
4.18.0-240.el8.x86_64
[root@test-vm-4 ~]# grep override /etc/sssd/sssd.conf 
[root@test-vm-4 ~]# 
[root@test-vm-4 ~]# sss_override user-show rick
[root@test-vm-4 ~]# getent passwd rick
rick:*:549001000:549000513:rick:/home/myhome1:/bin/bash
[root@test-vm-4 ~]# sss_override user-add rick -h /home/myhome3
[root@test-vm-4 ~]# sss_override user-show rick
rick:::::/home/myhome3::
[root@test-vm-4 ~]# systemctl restart sssd
[root@test-vm-4 ~]# getent passwd rick
rick:*:549001000:549000513:rick:/home/myhome3:/bin/bash
[root@test-vm-4 ~]# echo 'override_homedir = /home/myhome2' >> /etc/sssd/sssd.conf 
[root@test-vm-4 ~]# systemctl restart sssd
[root@test-vm-4 ~]# getent passwd rick
rick:*:549001000:549000513:rick:/home/myhome2:/bin/bash

Removing sss_override and re-applying does not help.

[root@test-vm-4 ~]# sss_override user-del rick
[root@test-vm-4 ~]# systemctl restart sssd
[root@test-vm-4 ~]# sss_override user-add rick -h /home/myhome3
[root@test-vm-4 ~]# systemctl restart sssd
[root@test-vm-4 ~]# getent passwd rick
rick:*:549001000:549000513:rick:/home/myhome2:/bin/bash

I have also confirmed the same behaviour occurs when trying to override the loginShell attribute.

Comment 4 Sumit Bose 2021-02-01 12:13:18 UTC
Hi,

the question is how the different ways to override the home directory should be ordered. We have the direct overrides, override_homedir and fallback_homedir options. At least the current order should be documented. So far override_homedir is treated as a general override to have a unified assignment of the home directories.

It would be good to know why the customer wants to use override_homedir instead of fallback_homedir?

bye,
Sumit

Comment 5 ttuffin 2021-02-08 10:09:45 UTC
Hi Sumit,

fallback_homedir will only work when the unixHomeDirectory attribute in Active Directory is undefined. In this particular case, all user accounts in AD have this attribute defined and therefore fallback_homedir will work. The customer did try removing this attribute which then allowed them to use fallback_homedir, but this workaround caused other issues with 3rd party authentication platforms.
Therefore, the customer (and I) expect it work as follows:

- unixHomeDirectory attribute in AD is defined.
- On a particular subset of RHEL servers, override_homedir will be used to set a new home directory.
- On a single server from that subset, the home directory for a single user account needs to be changed, and therefore sss_override is used for this purpose.

I agree the question is around how the overrides should be ordered. Since sss_override provides more granular overriding capabilities, I propose that it should be taking precedence over the override_homedir directive, which today, it does not.

Cheers,
Thomas

Comment 6 ttuffin 2021-02-09 09:09:46 UTC
Correction in typo in comment #5 (can't edit?) - "all user accounts in AD have this attribute defined and therefore fallback_homedir will NOT work"

Comment 7 Sumit Bose 2021-02-12 11:33:24 UTC
Hi,

thanks for the explanation, makes sense. So we should make sure individual overrides are preferred over override_homedir and document the new order in the man page.

bye,
Sumit

Comment 8 Sumit Bose 2021-02-12 13:01:23 UTC
Hi,

I've push an initial version of patch to https://github.com/sumit-bose/sssd/commit/65c301b78ebd8f96f34d20e23750b4ded5587d60, tests, man page update etc are still missing.

bye,
Sumit

Comment 13 Sumit Bose 2021-04-15 11:14:20 UTC
Upstream ticket:
https://github.com/SSSD/sssd/issues/5589

Comment 14 Pavel Březina 2021-04-21 10:01:55 UTC
Pushed PR: https://github.com/SSSD/sssd/pull/5590

* `master`
    * 691fe4944a606e1d56d2f6bb77f5a6045317d4e9 - nss: prefer homedir overrides over override_homedir option

Comment 25 errata-xmlrpc 2021-11-09 19:47:00 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 (sssd bug fix and enhancement update), and where to find the updated
files, follow the link below.

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

https://access.redhat.com/errata/RHBA-2021:4435