oddjob_mkhomedir or mkhomedir
It appears that there has been a conscious decision made within Red Hat to move away from pam_mkhomedir in favour of pam_oddjob_mkhomedir, but I haven't yet been able to find a written reference to this.
I came to this by identifying a bug in a configuration with pam_mkhomedir SELinux types being incorrectly set on newly created home directories (home_root_t not user_home_dir_t). It would appear several others have found this bug, and it has been filed (in one instance) at the following URL.
https://bugzilla.redhat.com/show_bug.cgi?id=903880
I was quite surprised by the response "Please use oddjob_mkhomedir" and the closure status "CLOSED NOTABUG" to what appears to be a valid bug report. Is there a reason the SELinux policy for pam_mkhomedir isn't being fixed? pam_mkhomedir is shipped as part of the PAM package, so I would assume it is supported by Red Hat and should be fixed? Is there another issue that would lead to pam_mkhomedir being deprecated that someone from Red Hat can explain?
Interestingly the same bug was raised here, and apparently resolved and closed as Errata:
https://bugzilla.redhat.com/show_bug.cgi?id=863132
Unfortunately, to provide the oddjob_mkhomedir capability you need two additional services running
oddjobd - to execute the jobs
messagebus - to message the oddjob service
So am I right in thinking that this requires two extra services running and three extra packages installed to work around an SELinux bug in a module that ships with the default PAM configuration?
Responses
Good question.
I have had issues with the "oddjob" approach and had to fall back to using pam module instead. Unfortunately we were not terribly diligent identifying exactly what the issue was, we instead just "fixed" the issue and moved on...
from /etc/pam.d/system-auth-ac
session optional pam_mkhomedir.so
The problem I see, however, is if you run
authconfig --enablemkhomedir --update
I believe it will attempt to update your configuration to utilize the "oddjob" way.
If I had to provide a single reason why it doesn't work as expected in our environment, I would have to declare it is because we try to embrace a bit of the new method while clinging to some legacy methods and they collide.
The reason we have pam_oddjob_mkhomedir is to separate out the ability to create a homedir and all of the content from the login programs.
With pam_mkhomedir login programs have to be allowed to create Your homedir, but if you setup /etc/skel then it also needs to be able to create any content in your home dir.
We in the SELinux world want to control what login programs can do. So we want to separate this abiltity to create home directory content into a separate priv daemon on the hosts, which the login programs can request to create the content. This means that from an SELinux point of view we can stop login programs like sshd from reading random content in your homedir. Why is this important? Over the years it has been shown that login programs have had bugs that led to information leakage without the users every being able to login to a system.
We probably should document this better then we do inside of the pam_mkhomedir documentation. I would suggest we open a bug about this.
BTW I blogged on this yesterday.
https://danwalsh.livejournal.com/69837.html
oddjob is used by a couple of other tools including OpenShift, but for the most part, DBUS has sort of usurped alot of its functionality. I guess pam_oddjob_mkhomedir could be rewritten as a standard dbus service that talks to systemd and starts the mkhomedir process on demand.
I don't really know what the plans are for the packagers of pam.
We created a workaround that we are testing now as we have the STIG applied(V1R9) which means no oddjob service
Added the following below pam_mkhomedir.so in /etc/pam.d/password-auth
session optional pam_exec.so debug log=/var/log/pam_exec_rconhomedir.log /usr/local/bin/restoreconhome.sh
Created /usr/local/bin/restoreconhome.sh
#!/bin/bash
#
# Script that will be run by pam_exec to ensure that
# homedirs have correct selinux context
# This script uses getent as the home dir may be provided via winbind or other
# external mechanism
cmd="/sbin/restorecon -R $(getent passwd ${PAM_USER} | awk -F':' '{print $6}')"
echo $cmd
$cmd
Seems like -R might not be wanted as this will run every login, but it works for us now. I'm not sure how /etc/skel gets copied, but if the files are copied in the same way then -R is needed as the files would have the wrong context as well(right?)
The STIG says that oddjobd should not be running. It does not say anything about whether or not it should be installed/removed. Where I am working, RHEL 6 servers have
session optional pam_oddjob_mkhomedir.so umask=0077
in multiple /etc/pam.d files, with oddjobd installed but disabled and not running. STIG scans show no findings for oddjobd
CORRECTION !! No STIG findings, but no home directory will be created UNLESS oddjobd is running.
And running "authconfig --updateall" restarts/reenables it as well !
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
