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 2135793 - mkhomedir does not set the permissions of the home directory according to HOME_MODE
Summary: mkhomedir does not set the permissions of the home directory according to HOM...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: oddjob
Version: 8.6
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Alexander Bokovoy
QA Contact: ipa-qe
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-10-18 12:49 UTC by Carlos Santos
Modified: 2023-05-16 09:59 UTC (History)
2 users (show)

Fixed In Version: oddjob-0.34.7-3.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-16 08:38:16 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Fedora Pagure oddjob issue 17 0 None None None 2022-10-18 13:14:22 UTC
Red Hat Issue Tracker FREEIPA-8941 0 None None None 2022-10-18 12:52:57 UTC
Red Hat Issue Tracker RHELPLAN-136888 0 None None None 2022-10-18 12:53:04 UTC
Red Hat Product Errata RHBA-2023:2853 0 None None None 2023-05-16 08:38:17 UTC

Description Carlos Santos 2022-10-18 12:49:54 UTC
Description of problem:

Currently the home directory permissions are set by taking the /etc/skel 
mode and masking it with HOME_MODE:

    override_umask = 0777 & ~get_umask(&configured_umask, "HOME_MODE");
    stat(skel, &sb); /* performed by nftw() */
    oddjob_selinux_mkdir(newpath, sb->st_mode & ~override_umask, uid, gid);

The problem is that when HOME_MODE is more permissive than /etc/skel,
the masking will not produce the desired result, e.g.

    skel_mode = 0755
    HOME_MODE = 0775
    override_umask = 0777 & ~HOME_MODE /* 0002 */
    mode = skel_mode & ~override_umask /* 0755 & 0775 = 0755 */

In order to fix the problem, mkhomedir should use 0777 & ~override_umask
for the top home directory.

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

- oddjob-0.34.7-1.el8.x86_64
- oddjob-mkhomedir-0.34.7-1.el8.x86_64

How reproducible:

Always

Steps to Reproduce:

1. Ensure that HOME_MODE has the required values in /etc/login.defs:

   HOME_MODE  0775

2. Ensure that /etc/skel has the default permissions

   # ls -ld /etc/skel
   drwxr-xr-x. 2 root root 76 Oct  4 09:38 /etc/skel

3. Create an test user, without creating the home directory

   # useradd --no-create-home test14

   If the user already exists, just remove the home directory

   # rm -rf ~test14

4. Simulate what oddjobd would do the first time the user logs in

   # echo test14 | /usr/libexec/oddjob/mkhomedir

   The permissions of the test14 home directory should be rwxrwxr-x but
   are rwxr-xr-x

   # ls -ld ~test14
   drwxr-xr-x. 2 test14 test14 76 Oct 18 09:35 /home/test14

5. Remove the user home directory

   # rm -rf ~test14

6. Ensure that PAM will use mkhomedir

   # authselect select sssd --force
   # authselect enable-feature with-mkhomedir
   # authselect enable-feature with-sudo
   # systemctl enable --now oddjobd.service

7. Log in as test14. The permissions of the test14 home directory should
   be rwxrwxr-x but are rwxr-xr-x

   # su -l test14 -c 'ls -ld $HOME'
   drwxr-xr-x. 2 test14 test14 76 Oct 18 09:43 /home/test14

Actual results:

The permissions of the home directory depend on the /etc/skel permissions.

Expected results:

The permissions of the home directory should be what is set in HOME_MODE.

Comment 1 Alexander Bokovoy 2022-12-09 14:12:28 UTC
Fix was provided upstream in https://pagure.io/oddjob/pull-request/18 and merged.

Comment 6 Mohammad Rizwan 2022-12-21 09:46:51 UTC
version:
oddjob-0.34.7-3.el8.x86_64

============================= test session starts ==============================
platform linux -- Python 3.6.8, pytest-3.10.1, py-1.11.0, pluggy-1.0.0 -- /usr/libexec/platform-python
cachedir: /home/cloud-user/.pytest_cache
metadata: {'Python': '3.6.8', 'Platform': 'Linux-4.18.0-445.el8.x86_64-x86_64-with-redhat-8.8-Ootpa', 'Packages': {'pytest': '3.10.1', 'py': '1.11.0', 'pluggy': '1.0.0'}, 'Plugins': {'metadata': '1.11.0', 'html': '1.22.1', 'multihost': '3.0', 'sourceorder': '0.6.0'}}
rootdir: /usr/lib/python3.6/site-packages/ipatests, inifile:
plugins: metadata-1.11.0, html-1.22.1, multihost-3.0, sourceorder-0.6.0
collecting ... collected 11 items

test_integration/test_authselect.py::TestClientInstallation::test_install_client_no_preconfigured_profile PASSED [  9%]
test_integration/test_authselect.py::TestClientInstallation::test_uninstall_client_no_preconfigured_profile PASSED [ 18%]
test_integration/test_authselect.py::TestClientInstallation::test_install_client_preconfigured_profile PASSED [ 27%]
test_integration/test_authselect.py::TestClientInstallation::test_uninstall_client_preconfigured_profile PASSED [ 36%]
test_integration/test_authselect.py::TestClientInstallation::test_install_client_no_sudo PASSED [ 45%]
test_integration/test_authselect.py::TestClientInstallation::test_uninstall_wrong_sysrestore PASSED [ 54%]
test_integration/test_authselect.py::TestClientInstallation::test_install_client_subid PASSED [ 63%]
test_integration/test_authselect.py::TestServerInstallation::test_install PASSED [ 72%]
test_integration/test_authselect.py::TestServerInstallation::test_uninstall PASSED [ 81%]
test_integration/test_authselect.py::TestServerInstallation::test_install_with_subid PASSED [ 90%]
test_integration/test_authselect.py::TestServerInstallation::test_uninstall_with_subid PASSED [100%]

---------------- generated xml file: /home/cloud-user/junit.xml ----------------
----------- generated html file: file:///home/cloud-user/report.html -----------
========================= 11 passed in 4093.19 seconds =========================


============================= test session starts ==============================
platform linux -- Python 3.6.8, pytest-3.10.1, py-1.11.0, pluggy-1.0.0 -- /usr/libexec/platform-python
cachedir: /home/cloud-user/.pytest_cache
metadata: {'Python': '3.6.8', 'Platform': 'Linux-4.18.0-445.el8.x86_64-x86_64-with-redhat-8.8-Ootpa', 'Packages': {'pytest': '3.10.1', 'py': '1.11.0', 'pluggy': '1.0.0'}, 'Plugins': {'metadata': '1.11.0', 'html': '1.22.1', 'multihost': '3.0', 'sourceorder': '0.6.0'}}
rootdir: /usr/lib/python3.6/site-packages/ipatests, inifile:
plugins: metadata-1.11.0, html-1.22.1, multihost-3.0, sourceorder-0.6.0
collecting ... collected 4 items

test_integration/test_installation_client.py::TestInstallClient::test_dns_lookup_kdc_is_true_with_default_enrollment_options PASSED [ 25%]
test_integration/test_installation_client.py::TestInstallClient::test_dns_lookup_kdc_is_true_with_ipa_server_on_cli PASSED [ 50%]
test_integration/test_installation_client.py::TestInstallClient::test_client_install_with_ssh_trust_dns PASSED [ 75%]
test_integration/test_installation_client.py::TestClientInstallBind::test_client_nsupdate PASSED [100%]

---------------- generated xml file: /home/cloud-user/junit.xml ----------------
----------- generated html file: file:///home/cloud-user/report.html -----------
========================= 4 passed in 1214.58 seconds ==========================


Automation passed (sanity check), hence marking the bug verified.

Comment 10 errata-xmlrpc 2023-05-16 08:38:16 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 (oddjob 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-2023:2853


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