Bug 566331 - Should genhomedircon ignore non-local users?
Summary: Should genhomedircon ignore non-local users?
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: policycoreutils
Version: 12
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Daniel Walsh
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-02-17 22:43 UTC by Orion Poplawski
Modified: 2010-03-23 23:33 UTC (History)
3 users (show)

Fixed In Version: libsemanage-2.0.45-1.fc12
Clone Of:
Environment:
Last Closed: 2010-03-23 23:33:16 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Updated man page (6.13 KB, application/x-troff-man)
2010-02-23 16:22 UTC, Daniel Walsh
no flags Details

Description Orion Poplawski 2010-02-17 22:43:01 UTC
Description of problem:

Should genhomedircon ignore non-local users?  Started having some issues with and ldap defined user having a home diretory in /usr/share/...  I probably need to fix that, but it made me wonder if genhomedircon really should ignore ldap and other non-local users.

Comment 1 Daniel Walsh 2010-02-17 23:14:54 UTC
Sure if you can define a non local user.  If we ever got to the point where nfs shares had labels then we might want it.  I would actually love to get rid of genhomedircon altogether and force admins to add 

semanage fcontext -a -e /home /random/home

Comment 2 Orion Poplawski 2010-02-17 23:37:05 UTC
I guess non-local for me means not in /etc/passwd.  Might mean something else to others.

I'd be happy to do the above - easy to add in my kickstart %post scripts.  Might need to get added to anaconda somehow though so that when people create some strange partition they can mark it as housing users.

Comment 3 Daniel Walsh 2010-02-19 13:51:34 UTC
You could add 

disable-genhomedircon=true

To /etc/selinux/semanage.conf

Which would stop running it after it has been run once.

Although I think I would like to see it just setup the labeling of /home and then allow the admin to put in equivalents via semanage.

Comment 4 MarcH 2010-02-22 12:18:37 UTC
(In reply to comment #1)
> I would actually love to get rid of
> genhomedircon altogether and force admins to add 
> 
> semanage fcontext -a -e /home /random/home    

I wanted to use this great new feature but the man page totally confuses me. It is using a very unfortunate "source / destination / target" terminology. With most Unix commands (mv, ln,...) , the source becomes the destination (or target). Now compare this to the semanage man page:

 -e, --equal
     Substitute source path for target when relabeling.

I am afraid I am not the only one confused, I suspect the example at the bottom of the same man page is just plain wrong:

  # Make /home1 labeling equivalent to /home (used by restorecon)
  $ semanage fcontext -a -e /home1 /home


My suggestion:  "semanage -e referred reference"


(Sorry to hi-jack this bug; I think this does not deserve a new bug)

Comment 5 MarcH 2010-02-22 12:29:40 UTC
(In reply to comment #4)
>  -e, --equal
>  [...]
>   # Make /home1 labeling equivalent to /home

"equal" and "equivalent" are not very good either. Both "x = y" and "y = x" make x equal to y. Yet these are two very different operations.

Comment 6 Daniel Walsh 2010-02-22 17:54:11 UTC
How about

Substiture target path with sourcepath when generating default label.  This is used with fcontext. Requires source and target path arguments.  The context
labeling for the target subtree is made equivalent to that defined for the source.

# Substitute /home1 with /home when setting file context (used by restorecon)
$ semanage fcontext -a -e /home /home1

Comment 7 MarcH 2010-02-23 13:57:04 UTC
Looks much better, thanks. In the example would also change "/home1" by something more explicit like for instance "/disk6/home"

Comment 8 Daniel Walsh 2010-02-23 16:22:58 UTC
Created attachment 395757 [details]
Updated man page

Comment 9 MarcH 2010-02-23 20:02:30 UTC
(In reply to comment #8)
> Created an attachment (id=395757) [details]
> Updated man page    

I think there is a typo: "Substiture"

Comment 10 Daniel Walsh 2010-03-11 16:21:21 UTC
Fixed in policycoreutils-2.0.80-1

Comment 11 Daniel Walsh 2010-03-11 16:22:48 UTC
I should have said, you can add an entry to /etc/selinux/semanage.conf

# usepasswd check tells semanage to scan all pass word records for home directories
# and setup the labeling correctly.  If this is turned off, SELinux will label /home 
# correctly only.  You will need to use semanage fcontext command.  
# For example, if you had home dirs in /althome directory you would have to execute
# semanage fcontext -a -e /home /althome
usepasswd=False


libsemanage-2.0.45-1

Comment 12 MarcH 2010-03-11 16:51:11 UTC
(In reply to comment #11)
> # usepasswd check tells semanage to scan all pass word records for home
> # directories and setup the labeling correctly.

Interesting, thanks.

What happens to "a" and "b" directories in /a/b/althome?

I think whatever happens to them is worth documenting. Especially if it is "nothing".

Comment 13 Daniel Walsh 2010-03-11 17:00:18 UTC
Nothing happens.

The matchpathcon library basically does a string replace of 

/a/b/althome/dwalsh/.ssh becomes /home/dwalsh/.ssh

If /a/b are not searchable by a confined domain, then they will still fail.

If you actually added /a/b/althome, they would be labeled default_t.

Addint the equivalency would end up with

/a -> default_t
/a/b -> default_t
/a/b/althome -> home_root_t
/a/b/althome/dwalsh -> user_home_dir_t
/a/b/althome/dwalsh/.ssh -> ssh_home_t

But sshd_t would not be allowed to read /a/b/althome/dwalsh/.ssh, since it is not allowed to search_dir_perms on default_t.

Best solution would be to add a file context

semanage fcontext -a -t home_root_t '/a(/.*)?'

Comment 14 Fedora Update System 2010-03-11 21:59:04 UTC
libsemanage-2.0.45-1.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/libsemanage-2.0.45-1.fc12

Comment 15 Fedora Update System 2010-03-13 02:24:53 UTC
libsemanage-2.0.45-1.fc12 has been pushed to the Fedora 12 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 libsemanage'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/libsemanage-2.0.45-1.fc12

Comment 16 Fedora Update System 2010-03-23 23:33:09 UTC
libsemanage-2.0.45-1.fc12 has been pushed to the Fedora 12 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.