Bug 677715 - SELinux prevents xauth from creating a file in ~/.kde/tmp-<host>/
Summary: SELinux prevents xauth from creating a file in ~/.kde/tmp-<host>/
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 14
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-02-15 16:30 UTC by David Howells
Modified: 2011-02-24 20:53 UTC (History)
2 users (show)

Fixed In Version: selinux-policy-3.9.7-31.fc14
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-02-24 20:53:48 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description David Howells 2011-02-15 16:30:51 UTC
Description of problem:

SELinux is preventing xauth from creating a new version of the xauth file in ~/.kde/tmp-<host>/ which it can then rename over the current xauth file.

    warthog>time /usr/bin/xauth -f /home/dhowells/.kde/tmp-warthog.procyon.org.uk/auth-4043-_0 nlist :0.0
    /usr/bin/xauth:  timeout in locking authority file /home/dhowells/.kde/tmp-warthog.procyon.org.uk/auth-4043-_0

    real    0m20.003s
    user    0m0.001s
    sys     0m0.001s

Running it under strace shows a number of these:

    open("/home/dhowells/.kde/tmp-warthog.procyon.org.uk/auth-4043-_0-c",
    O_WRONLY|O_CREAT|O_EXCL, 0600) = -1 EACCES (Permission denied)

when SELinux is in Enforcing mode.

There appear to be two problems.  The first is that processes running as xauth_t doesn't have permission to do things with files of label config_home_t.  This can be rectified with the following policy addition:

    module local_xauth 1.0;
    require {
	    type xauth_t;
	    type config_home_t;
	    class dir { write remove_name add_name };
	    class file { link create unlink open };
    }
    allow xauth_t config_home_t:dir { write remove_name add_name };
    allow xauth_t config_home_t:file { open create unlink link };

The second problem is not obvious.  If I turn Enforcing mode off, then I see the audit records for the above until I've loaded the module.  But if Enforcing mode is on, I don't see any audit records for the above, and it doesn't work, even if I have the module loaded.

I'm fairly certain this worked before the latest upgrade of selinux.  It's noticeable because 'su' now takes 20 secs or so to go from password to prompt, and I can't start X programs from within the su session without setting the XAUTHORITY envvar manually.  Additionally, "ssh -X" gives a lot of connection failed errors before letting remote X programs connect to the server.

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

kdebase-4.5.5-1.fc14.x86_64
xorg-x11-xauth-1.0.2-7.fc12.x86_64
selinux-policy-3.9.7-29.fc14.noarch

I'm fairly certain this worked in the previous version of the policy.  My updates to this are as follows:

[root@warthog selinux]# grep selinux-policy-3 /var/log/yum.log
Jan 04 13:47:10 Updated: selinux-policy-3.9.7-19.fc14.noarch
Jan 19 12:05:54 Updated: selinux-policy-3.9.7-20.fc14.noarch
Jan 28 10:35:53 Updated: selinux-policy-3.9.7-25.fc14.noarch
Feb 04 23:05:52 Updated: selinux-policy-3.9.7-28.fc14.noarch
Feb 11 13:35:26 Updated: selinux-policy-3.9.7-29.fc14.noarch

Comment 1 Miroslav Grepl 2011-02-16 13:34:10 UTC
We added this label

HOME_DIR/\.kde(/.*)? gen_context(system_u:object_r:config_home_t,s0)


But actually if you try to execute

# restorecon -Rv /home/dhowells/.kde/tmp-warthog.procyon.org.uk

does it work then?

Comment 2 Miroslav Grepl 2011-02-16 13:36:40 UTC
# ls -dZ /home/mgrepl/.kde/tmp-avalanche/
drwx------. mgrepl mgrepl unconfined_u:object_r:user_tmp_t:s0 /home/mgrepl/.kde/tmp-avalanche/

# ls -Z /home/mgrepl/.kde/tmp-avalanche/xauth-500-_0 
-rw-rw-r--. mgrepl mgrepl unconfined_u:object_r:user_tmp_t:s0 /home/mgrepl/.kde/tmp-avalanche/xauth-500-_0

and we have in the policy 

ifdef(`hide_broken_symptoms',`
    ...
    userdom_manage_user_home_content_files(xauth_t)
    userdom_manage_user_tmp_files(xauth_t)
    ...
')

So it looks like I will need to allow xauth to manage gnome config files too.

Comment 3 Miroslav Grepl 2011-02-16 14:32:03 UTC
I am building a scratch build. Could you test it with this scratch build?

http://koji.fedoraproject.org/koji/taskinfo?taskID=2844130

Comment 4 David Howells 2011-02-16 15:02:33 UTC
(In reply to comment #1)
> ...
> But actually if you try to execute
> 
> # restorecon -Rv /home/dhowells/.kde/tmp-warthog.procyon.org.uk
> 
> does it work then?

No.  It makes no difference to the labelling of the directory and the xauth file.  They were both config_home_t before and they are still afterwards.

Comment 5 David Howells 2011-02-16 15:07:40 UTC
(In reply to comment #2)
> # ls -dZ /home/mgrepl/.kde/tmp-avalanche/
> drwx------. mgrepl mgrepl unconfined_u:object_r:user_tmp_t:s0
> /home/mgrepl/.kde/tmp-avalanche/

How come your .kde/tmp-<host>/ dir appears as user_tmp_t and mine appears as config_home_t?

Comment 6 David Howells 2011-02-16 15:11:56 UTC
(In reply to comment #3)
> I am building a scratch build. Could you test it with this scratch build?
> 
> http://koji.fedoraproject.org/koji/taskinfo?taskID=2844130

That seems to work.

Comment 7 Miroslav Grepl 2011-02-16 15:14:23 UTC
Actually the problem is a link

# ls -lZ /home/mgrepl/.kde/
lrwxrwxrwx. mgrepl mgrepl unconfined_u:object_r:config_home_t:s0 cache-avalanche -> /var/tmp/kdecache-mgrepl
drwx------. mgrepl mgrepl unconfined_u:object_r:config_home_t:s0 share
lrwxrwxrwx. mgrepl mgrepl unconfined_u:object_r:config_home_t:s0 socket-avalanche -> /tmp/ksocket-mgrepl
lrwxrwxrwx. mgrepl mgrepl unconfined_u:object_r:config_home_t:s0 tmp-avalanche -> /tmp/kde-mgrepl


Could you test it with the scratch build?

Comment 8 Miroslav Grepl 2011-02-16 15:17:27 UTC
Great. Thanks for testing.

Comment 9 Miroslav Grepl 2011-02-17 09:44:19 UTC
Fixed in selinux-policy-3.9.7-31.fc14

Comment 10 Fedora Update System 2011-02-21 20:28:12 UTC
selinux-policy-3.9.7-31.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/selinux-policy-3.9.7-31.fc14

Comment 11 Fedora Update System 2011-02-22 04:53:47 UTC
selinux-policy-3.9.7-31.fc14 has been pushed to the Fedora 14 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update selinux-policy'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/selinux-policy-3.9.7-31.fc14

Comment 12 Fedora Update System 2011-02-24 20:53:10 UTC
selinux-policy-3.9.7-31.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.


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