Bug 767579

Summary: selinux prevents quota from setting quota on homedirs
Product: Red Hat Enterprise Linux 6 Reporter: Karel Volný <kvolny>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: high Docs Contact:
Priority: high    
Version: 6.2CC: dwalsh, mmalik, ppisar
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.7.19-136.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 12:29:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Karel Volný 2011-12-14 12:28:26 UTC
Description of problem:
Trying to set up quota on a filesystem which is mounted as an user home directory fails due to selinux denial for the command "quotacheck -c /user/home/directory"

Version-Release number of selected component (if applicable):
selinux-policy-targeted-3.7.19-126.el6.noarch

How reproducible:
always

Steps to Reproduce:
1. run the test /CoreOS/quota/Regression/bz77871-grace-period-not-shown
  
Actual results:
see https://beaker.engineering.redhat.com/tasks/executed?task=/CoreOS/quota/Regression/bz77871-grace-period-not-shown&job_id=170480

ls -dlZ /tmp/tmp.QCHj5nec7c/bz77871:
drwxr-xr-x. bz77871 bz77871 unconfined_u:object_r:user_home_dir_t:s0 /tmp/tmp.QCHj5nec7c/bz77871
quotacheck: Cannot create new quotafile /tmp/tmp.QCHj5nec7c/bz77871/aquota.user.new: Permission denied
quotacheck: Cannot initialize IO on new quotafile: Permission denied

type=SYSCALL msg=audit(1323811395.282:1089019): arch=c000003e syscall=2 success=no exit=-13 a0=7fff2d5d2030 a1=c2 a2=180 a3=7fff2d5d1da0 items=0 ppid=30595 pid=30889 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="quotacheck" exe="/sbin/quotacheck" subj=unconfined_u:unconfined_r:quota_t:s0-s0:c0.c1023 key=(null)
type=AVC msg=audit(1323811395.282:1089019): avc:  denied  { write } for  pid=30889 comm="quotacheck" name="/" dev=loop0 ino=2 scontext=unconfined_u:unconfined_r:quota_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_dir_t:s0 tclass=dir


Expected results:
no errors/denials, aquota.user created properly

Additional info:
Note that "unconfined_u:object_r:user_home_dir_t:s0" corresponds to the contexts of normal user directories in /home

Comment 1 Miroslav Grepl 2011-12-14 13:33:34 UTC
Karel,
you will need to use "home_root_t" label, which is used for /home directory.

Comment 2 Karel Volný 2011-12-16 15:07:34 UTC
(In reply to comment #1)
> Karel,
> you will need to use "home_root_t" label, which is used for /home directory.

okay, changing 
unconfined_u:object_r:user_home_dir_t:s0 to unconfined_u:object_r:home_root_t:s0 seems to enable quota to do its job

however, this creates quite unpleasant inconsistency, as for example restorecon tends to change home_root_t to user_home_dir_t

could we have this at least as RFE to enable quota to operate both on home_root_t AND user_home_dir_t ?

Comment 3 Daniel Walsh 2011-12-17 12:42:30 UTC
Sure,  But Karel would an admin actually setup a users homedir with a quota.group file actually  in the users homedir? Or is this just a test issue?

Comment 4 Miroslav Grepl 2011-12-19 07:33:05 UTC
Yes, this is a good question. I would say this is more a test issue.

Comment 5 Karel Volný 2011-12-19 11:43:48 UTC
(In reply to comment #3)
> Sure,  But Karel would an admin actually setup a users homedir with a
> quota.group file actually  in the users homedir? Or is this just a test issue?

well, I don't have the statistical data ...

the problem is that quota works by default per filesystem, and it puts its data (i.e. quota.user/quota.group) into fileystem's root

while the typical usage is to have /home mounted on one filesystem and users' directories as subdirectories on that filesystem, I think having users' directories as separate mounts makes sense too (and using quota on them, as quota provides better control than just "I won't write the file as you are out of free blocks on this harddrive")

CCing ppisar, the quota maintainer, if he can correct me/add some info ...?

Comment 6 Petr Pisar 2011-12-19 12:27:00 UTC
I have not so much to add. quota tools control quotas that are maintained per file system. Thus administrator expects the tools can work on any (real) mount point. Not only on /home. Otherwise you tell administrator that quotas are supported on /home only which is hard constraint. I think SELinux should allow quota tools to write into file_t.

Comment 7 Miroslav Grepl 2011-12-20 13:45:51 UTC
I added a fix to Fedora16.

Comment 8 Miroslav Grepl 2012-01-26 10:20:06 UTC
Fixed in selinux-policy-3.7.19-136.el6

Comment 11 errata-xmlrpc 2012-06-20 12:29:42 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, and where to find the updated
files, follow the link below.

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

http://rhn.redhat.com/errata/RHBA-2012-0780.html