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 1553784 - Document how to prevent invalid selinux context for default home directories in SSSD-AD direct integration.
Summary: Document how to prevent invalid selinux context for default home directories ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: sssd
Version: 7.7
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Tomas Halman
QA Contact: sssd-qe
URL:
Whiteboard: sync-to-jira, review
Depends On:
Blocks: 1845987
TreeView+ depends on / blocked
 
Reported: 2018-03-09 14:33 UTC by German Parente
Modified: 2020-09-29 19:49 UTC (History)
16 users (show)

Fixed In Version: sssd-1.16.5-8.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1845987 (view as bug list)
Environment:
Last Closed: 2020-09-29 19:49:11 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github SSSD sssd issues 5155 0 None closed Document how to prevent invalid selinux context for default home directories in SSSD-AD direct integration. 2020-09-29 14:33:15 UTC
Red Hat Product Errata RHBA-2020:3904 0 None None None 2020-09-29 19:49:41 UTC

Description German Parente 2018-03-09 14:33:54 UTC
Description of problem:

not sure if this is an sssd bug or selinux-context one. I want to document the issue found in a customer case.

By default, sssd-ad sets the home directory path as /home/<AD domain>/<Unix username>

With existing SELinux contexts, this ends up having the following:

*/home* have the *home_root_t* context (which is OK)
*/home/<AD domain>* have the *user_home_dir_t* context (which seems to be wrong)
*/home/<AD domain>/<Unix username>* have the *user_home_t* context (which is also wrong)

The expected behavior should be:

- /home/<AD Domain> should have *user_root_t* context
- /home/<AD Domain>/<User> should have *user_home_dir_t*
- an equivalency context should be created for /home/<AD Domain> based on /home
- /home/<AD Domain> should exist prior to mkhomedir running, or mkhomedir should also have the *create* call in its allow list (allow oddjob_mkhomedir_t home_root_t : dir { ... } ;)



Version-Release number of selected component (if applicable): RHEL7.4

Comment 2 Jakub Hrozek 2018-03-11 19:49:47 UTC
Because SSSD only reports what the home directory is and what the UID and GID numbers of the user are, I think the file system contexts are more in the realm of SELinux policy or whoever is creating the home directories, I think it's fine to move the bugzilla to the selinux policy package.

Comment 3 Renaud Métrich 2018-03-13 13:18:48 UTC
Hi Jakub,

I understand that SSSD reports the home dir and uid/gid, but the home dir it reports is not the standard path (e.g. "/home/user"), but by default it is "/home/AD-domain/user", so I would expect some SELinux equivalency context between /home and /home/AD-domain to be set up by SSSD itself.

Will let Lukas decide of course.

REnaud.

Comment 4 Jakub Hrozek 2018-03-13 18:44:46 UTC
(In reply to Renaud Métrich from comment #3)
> Hi Jakub,
> 
> I understand that SSSD reports the home dir and uid/gid, but the home dir it
> reports is not the standard path (e.g. "/home/user"), but by default it is
> "/home/AD-domain/user",

The homedir is either read from the POSIX attributes or in their absence, SSSD uses local fallback mechanisms like override_homedir etc. If you want the homedir to be /home/$username, just set:
override_homedir = /home/%u

> so I would expect some SELinux equivalency context
> between /home and /home/AD-domain to be set up by SSSD itself.

SSSD doesn't do anything like that. It just provides the NSS API, see e.g. man getpwnam(3).

Comment 5 Renaud Métrich 2018-03-13 20:47:08 UTC
OK, let me rephrase.
In https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/windows_integration_guide/SSSD-AD#sssd-ad-proc, we can see the following text:

Optional: Configure User Home Directories and Shells

The pam_oddjob_mkhomedir.so library automatically creates home directories when users first log in to the Linux system. By default, SSSD retrieves the format of the home directory from the AD identity provider. To customize the directory format on Linux clients:

1. Open the /etc/sssd/sssd.conf file.

2. In the [domain] section, use one of these options:

* fallback_homedir sets a fallback home directory format, which is used only if a home directory is not defined in AD

* override_homedir sets a home directory template, which always overrides the home directory defined in AD

For example, to always use the format /home/domain_name/user_name:

[domain/EXAMPLE]
[... file truncated ...]
override_homedir = /home/%d/%u

For details, see the sssd.conf(5) man page.


It appears that this text (and the sssd.conf manpage) doesn't mention that when doing so, the SELinux contexts will be broken, as described in the Description of this BZ.
IMHO, this BZ is hence a Doc BZ, for both guide and manpage.

Comment 6 Lukas Vrabec 2018-06-13 10:28:04 UTC
I understand Renaud, and it make sense to me, but I if I don't know the name of AD-domain I'm not able to setup any SELinux file context equivalency. 
Maybe it should be mentioned in the sssd-ad manpage.

Comment 7 Renaud Métrich 2018-06-13 10:39:12 UTC
Yes this is an sssd-ad issue.

Comment 8 Lukas Vrabec 2018-06-13 10:52:10 UTC
Jakub, 
I can help with documentation, moving back to sssd

Comment 9 Jakub Hrozek 2019-03-28 20:28:21 UTC
Unfortunately the 7.7 development phase passed and we didn't have time to address this bug. Moving to 7.8

Comment 10 Steeve Goveas 2020-01-21 10:15:03 UTC
Moving it to 7.9

Comment 12 Alexander Bokovoy 2020-05-04 16:53:55 UTC
Note that this is not a bug in SSSD or oddjob. It is a limitation of a conceptual level that needs somehow to be solved separately.

oddjob, when responding to pam_mkhomedir_oddjob requests, correctly creates all required components of the home directory path. It also uses SELinux matchpathcon() function to find out what context should be set for the corresponding path component.

The problem here is that we have two different concepts for home directory paths:

 - traditional UNIX home directory, can be called single-level home directory, /home/<user>
 - multi-leveled home directories, /home/<domain>/<user>

There is no way for SELinux policy to differentiate between the two.

Comment 13 Tomas Halman 2020-05-13 07:43:38 UTC
Upstream ticket:
https://github.com/SSSD/sssd/issues/5155

Comment 14 Pavel Březina 2020-05-22 08:01:51 UTC
* `master`
    * d8d743870c459b5ff283c89d78b70d1684bd19a9 - man: Document invalid selinux context for homedirs
* `sssd-1-16`
    * adebc962af61b86f78ff3dfb6e33db27149c399d - man: Document invalid selinux context for homedirs

Comment 17 Dan Lavu 2020-06-16 00:12:07 UTC
Verified against sssd-1.16.5-10.el7.x86_64, text is in sssd-ad man file

"Note that the system typically expects a home directory in /home/%u folder. If you decide to use a different directory structure, some other parts of your system may need adjustments.

For example automated creation of home directories in combination with selinux requires selinux adjustment, otherwise the home directory will be created with wrong selinux context."

Comment 18 Dan Lavu 2020-06-16 17:16:45 UTC
Since this is a man page edit this will not have any automation.

Comment 20 errata-xmlrpc 2020-09-29 19:49:11 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-2020:3904


Note You need to log in before you can comment on or make changes to this bug.