Bug 973647 - missing error message when useradd cannot create user with homedir in location without default selinux context
missing error message when useradd cannot create user with homedir in locatio...
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: shadow-utils (Show other bugs)
7.0
All Linux
medium Severity low
: rc
: ---
Assigned To: Tomas Mraz
Michal Trunecka
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-12 08:32 EDT by Michal Trunecka
Modified: 2014-09-30 19:35 EDT (History)
4 users (show)

See Also:
Fixed In Version: shadow-utils-4.1.5.1-6.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-06-13 09:27:33 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Michal Trunecka 2013-06-12 08:32:15 EDT
Description of problem:
For example /mnt/qa/scratch has not a default selinux context:

# matchpathcon /mnt/qa/scratch
/mnt/qa/scratch	<<none>>

Creating user with homedir in there fails:

# useradd -m -d /mnt/qa/scratch/user19376 user19376
# echo $?
12

The returned 12 means the homedir couldn't be created. It works fine in permissive, no AVCs related to this issue. (even with disabled dontaudit rules)

In useradd.c, there is the following code in create_home function:

> 1762 if (set_selinux_file_context (user_home, NULL) != 0) {
> 1763     fail_exit (E_HOMEDIR);
> 1764 }

And because no orig.context is passed in the second argument and at the same time matchpathcon returns no default context, the set_selinux_file_context function failes.
From lib/selinux.c (in shadow-utils srcrpm):

> 53 int set_selinux_file_context (const char *dst_name, const char *orig_name)
...
> 62         if (selinux_enabled) {
> 63                 /* Get the default security context for this file */
> 64                 if (matchpathcon (dst_name, 0, &scontext) < 0) {
> 65                         /* We could not get the default, copy the original */
> 66                         if (orig_name == NULL)
> 67                                 goto error;



Version-Release number of selected component (if applicable):
shadow-utils-4.1.5.1-5.el7.x86_64
Comment 1 Tomas Mraz 2013-06-12 08:39:01 EDT
I don't think this is a bug. Just specify some default context adequate for the home directory parent with semanage fcontext -a ...

Or disable selinux if you do not want to work with it properly - but I strictly do not recommend that.
Comment 2 Michal Trunecka 2013-06-12 08:51:43 EDT
If not anything else, I definitely think that not logging any message about the reason of not creating home dir is a bug.
Comment 6 Ludek Smid 2014-06-13 09:27:33 EDT
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.

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