Ok, i did it!!! Its working

....
SELinux is on and its all working

....
Most people here have disabled SELinux, becuase nobody really knows too much about it, and the SELinux default settings are too restrictive...
To the moderators here, you might want to make this a sticky

....
heres how i got SELinux working with the new user home folder ( which is also located on another hard drive partion )... this user must be able to ftp into his home folder, (
everybody else must not have read and write permissions -
apache, webalizer, log must have entry access only )... this user wants a website...
Now im going to give you a real world example with proper file locations that i used, hopefully you can set it up on your own system in any location....
first thing: you need is to makesure you have the
checkpolicy package installed, if its not installed then..
in the base directory where you want your users to have their websites, that root part of that folder you need to make it readable via apache... in my case, we type in:
then when make it world readable:
Quote:
|
chcon -R -t httpd_sys_content_t /var/users/
|
then i create another folder "k"
now we need to create a new user with the home folder located in /var/users/k/
Quote:
/sbin/useradd -c "Name of user" -m -d /var/users/k/ kojik
passwd --stdin
mkdir /var/users/k/kojik/public_html
chcon -R -t httpd_sys_content_t /var/users/k/kojik/public_html/
|
now we need to add this users new home directory into SELinux ( SELinux requires the user to be created first ).. what we will do is add this new entry into /etc/selinux/targeted/contexts/files/filecontexts.homedirs file...
we do not edit this file directly.. instead we use the genhomedircon script to edit this file...
Quote:
|
/sbin/genhomedircon -t targeted
|
where targeted is the policy currently running...
now we need to build the new policy file and load that into the kernel... first we will make an error via ftping into the home directory.. this will creat a logged message into the /var/audit/audit.log or /var/messages... it depends if you have audit running as a service...
ftp in with the new user and password, this will fail... now copy the message into a separate file....
example error message:
Quote:
|
Jul 26 12:16:58 vhost kernel: audit(1153883818.969:328): avc: denied { search } for pid=16948 comm="vsftpd" name="users" dev=hdb1 ino=33390593 scontext=system_u:system_r:ftpd_t:s0 tcontext=user_u:object_r:httpd_sys_content_t:s0 tclass=dir
|
save to file example: /home/USER/ftpfail.log
now run audit2why on that file to produce a message:
Quote:
|
/usr/sbin/audit2why < /home/USER/ftpfail.log
|
you should see something like this on the screen..
Quote:
Jul 26 12:16:58 vhost kernel: audit(1153883818.969:328): avc: denied { search } for pid=16948 comm="vsftpd" name="users" dev=hdb1 ino=33390593 scontext=system_u:system_r:ftpd_t:s0 tcontext=user_u:object_r:httpd_sys_content_t:s0 tclass=dir
Was caused by:
Missing or disabled TE allow rule.
Allow rules may exist but be disabled by boolean settings; check boolean settings.
You can see the necessary allow rules by running audit2allow with this audit message as input.
|
Save that as a file ( audit.log ), inside your home folder.... we will use this file to add a new policy to our current policy and load that into the kernel ( requires the checkpolicy package )... theres no need to reboot, and all the booleans will have their same settings....
we type in...
Quote:
|
/usr/bin/audit2allow -i /home/troyfa/audit.log -M local
|
you should see something like this:
Quote:
Generating type enforcment file: local.te
Compiling policy
checkmodule -M -m -o local.mod local.te
semodule_package -o local.pp -m local.mod
******************** IMPORTANT ***********************
In order to load this newly created policy package into the kernel,
you are required to execute
semodule -i local.pp
|
Now we need to load this into the kernel.. we type in...
Enjoy, and now ftp into your new home directory...
Known issues... at the very base of the home folder make sure everbody is forbidden to read/write but everybody has "Entry" permission... apache needs this...
heres what the permissions should look like:
Quote:
[root@vhost include]# ls -Z /var/users/k/
drwxr-x--x kojik kojik system_u:object_r:user_home_dir_t kojik
|