Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Servers & Networking
FedoraForum Search

Forgot Password? Join Us!

Servers & Networking Discuss any Fedora server problems and Networking issues such as dhcp, IP numbers, wlan, modems, etc.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 7th February 2010, 12:47 AM
whpsh Offline
Registered User
 
Join Date: Feb 2006
Posts: 7
windows_xp_2003firefox
SELinux denies apache home directories ...

With F12 SELinux on, I get this avc:

type=SYSCALL msg=audit (1265502537.599:24666) arch=c000003e syscall=6 success=no exit=-13 a0=7f35384107d8 a1=7fff909dcb90 a2=7fff909dcb90 a3=0 items=0 ppid=27623 auid=500 uid=48 gid=489 euid=48 suid=48 fsuid=48 egid=489 sgid=489 fsgid=489 tty=(none) ses=11 comm="httpd" exe="/user/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit (1265502804.573:24667): avc: denied {search } for pid=27630 comm="httpd" name="/" dev=sda5 ino=2 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:samba_share_t:s0 tclass=dir

ls -lZ /home/uzr
drwxr-xr-x. uzr uzr unconfined_u:object_r:httpd_sys_content_t:s0 public_html

I'm an ubern00b with linux, but I've followed all the other posts about similar problems. I've run all the chmod commands, configured httpd, run all the setsebool commands I could find that were related (obviously I'm missing one), but with SELinux enforced, I get a 403. Without it, I can get to the pages just fine.

getsebool -a | grep httpd
allow_httpd_anon_write --> off
allow_httpd_mod_auth_ntlm_winbind --> off
allow_httpd_mod_auth_pam --> off
allow_httpd_sys_script_anon_write --> off
httpd_builtin_scripting --> on
httpd_can_network_connect --> off
httpd_can_network_connect_db --> off
httpd_can_network_relay --> off
httpd_can_sendmail --> off
httpd_dbus_avahi --> on
httpd_enable_cgi --> on
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> on
httpd_execmem --> off
httpd_read_user_content --> off
httpd _ssi_exec --> off
httpd_tmp_exec --> off
httpd_tty_comm --> on
httpd_unified --> on
httpd_use_cifs --> off
httpd_use_nfs --> off

Any suggestions would be much appreciated.
Reply With Quote
  #2  
Old 7th February 2010, 12:59 AM
pete_1967 Online
Clueless in a Cuckooland
 
Join Date: Mar 2006
Location: Here now, elsewhere tomorrow.
Posts: 3,916
linuxfedorafirefox
First make sure that Apache has read rights to your home dir (from /home) downwards. Then check the SELinux context for your home html directory with 'ls -Z'.
__________________
A Drink is Not Just For Christmas - SaskyCom :thumb:


“Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime” so now go and...
RTFM FIRST: http://docs.fedoraproject.org/ & http://rute.2038bug.com/index.html.gz
Reply With Quote
  #3  
Old 7th February 2010, 01:05 AM
whpsh Offline
Registered User
 
Join Date: Feb 2006
Posts: 7
windows_xp_2003firefox
ls -lZ /home/uzr
drwxr-xr-x. uzr uzr unconfined_u:object_r:httpd_sys_content_t:s0 public_html

with SELinux enforced, I get a 403. Without it, I can get to the pages just fine.
Reply With Quote
  #4  
Old 7th February 2010, 05:09 AM
aleph's Avatar
aleph Offline
Banned (for/from) behaving just like everybody else!
 
Join Date: Jul 2007
Location: Beijing, China
Posts: 1,307
linuxfedorafirefox
Just follow pete's post. You have to ensure that Apache can SEARCH (the "x" bit) into your home directory. Check if the "x" bit is on:
ls -ld $HOME
if not, use the command chmod o+x $HOME

After that, check the permissions on the public_html directory inside your homedir. Apache must be able to READ and SEARCH as well, recursively. If not, chmod o+rx $HOME/public_html

After that, check the SELinux context on the public_html directory. It should be of context type httpd_user_content_t.
If not, chcon -R -t httpd_user_content_t
__________________
I believe in nerditarianism. I read FedoraForum for the Fedora-related posts.
Reply With Quote
  #5  
Old 7th February 2010, 04:09 PM
whpsh Offline
Registered User
 
Join Date: Feb 2006
Posts: 7
windows_7firefox
Double checked everything in the previous post, again.

I'm still getting a 403 Forbidden

---------- Post added at 10:09 AM CST ---------- Previous post was at 10:01 AM CST ----------

So, just using chcon -R -t httpd_user_content_t public_html isn't enough. SELinux is apparently denying rights before you even get that far into the tree. In order to get it to work for home/uzer/public_html, I had to:

chcon -R -t httpd_user_content_t public_html
chcon -R -t httpd_user_content_t uzer
chcon -R -t httpd_user_content_t home

That begs the question what else I've opened the directory up to, but at least its working.
Reply With Quote
  #6  
Old 7th February 2010, 04:27 PM
aleph's Avatar
aleph Offline
Banned (for/from) behaving just like everybody else!
 
Join Date: Jul 2007
Location: Beijing, China
Posts: 1,307
linuxfedorafirefox
Quote:
Originally Posted by whpsh View Post
Double checked everything in the previous post, again.

I'm still getting a 403 Forbidden

---------- Post added at 10:09 AM CST ---------- Previous post was at 10:01 AM CST ----------

So, just using chcon -R -t httpd_user_content_t public_html isn't enough. SELinux is apparently denying rights before you even get that far into the tree. In order to get it to work for home/uzer/public_html, I had to:

chcon -R -t httpd_user_content_t public_html
chcon -R -t httpd_user_content_t uzer
chcon -R -t httpd_user_content_t home

That begs the question what else I've opened the directory up to, but at least its working.
Changing the type of your $HOME and/or any of its parent directories may have undesirable effects. The type of a home directory must be user_home_dir_t, and the /home directory home_root_t.

I've been running Apache with SELinux settings given in my previous post without problems. If there's a problem it could be caused by incorrect labelling on /home or $HOME but your current setting is definitely *not* correct, and redundantly incorrect, for the -R option of chcon means "recursive".

And have you enabled the corresponding sebool flag?

Code:
# setsebool -P httpd_enable_homedirs 1
__________________
I believe in nerditarianism. I read FedoraForum for the Fedora-related posts.
Reply With Quote
  #7  
Old 7th February 2010, 04:47 PM
kyryder
Guest
 
Posts: n/a
linuxfedorafirefox
Just a thought,

Code:
setsebool -P http_enable_cgi=1 allow_httpd_anon_write=1 \ httpd_can_network_connect=1 httpd_can_network_connect_db=1 \ allow_httpd_sys_script_anon_write=1 httpd_enable_homedirs=1 \ httpd_enable_ftp_server=1 httpd_builtin_scripting=1 httpd_disable_trans=1 \ httpd_suexec_disable_trans=1 httpd_unified=1 httpd_tty_comm=1
is the standard booleans that are needed for Apache

Make sure the booleans are being turned on with the "getsebool" command. To check your homedirs:

Code:
getsebool httpd_enable_homedirs
Hope this helps

Ky

Last edited by kyryder; 7th February 2010 at 04:53 PM.
Reply With Quote
  #8  
Old 7th February 2010, 10:27 PM
marcrblevins's Avatar
marcrblevins Offline
Registered User
 
Join Date: Jun 2006
Location: Texas
Age: 42
Posts: 4,168
linuxfedorafirefox
My notes:
Code:
chmod 711 /home/marc
chmod 755 /home/marc/public_html
setsebool -P httpd_enable_homedirs 1
chcon -R -t httpd_sys_content_t /home/marc/public_html
service httpd restart
Reply With Quote
  #9  
Old 8th February 2010, 07:02 PM
whpsh Offline
Registered User
 
Join Date: Feb 2006
Posts: 7
windows_7firefox
So I re-installed everything.

Made all the necessary changes to httpd.conf to look in /home

Followed Marc Blevins instructions and it worked perfectly.

I'm convinced that in the process of setting up a samba share, some errant directions changed permissions/ownership in the /home directory that was causing my problems with apache.

Thanks Marc.

Now, I don't suppose you know a Samba configuration that works with Win7?

---------- Post added at 12:34 PM CST ---------- Previous post was at 12:00 PM CST ----------

I was right ...

I went through the Samba GUI to create a share and it worked perfectly.
However, doing so immediately stopped serving pages from /home/uzr/public_html

discouraging ...

---------- Post added at 01:02 PM CST ---------- Previous post was at 12:34 PM CST ----------

Even more discouraging ... the samba share isn't accessible until someone logs into the server ... weird
Reply With Quote
  #10  
Old 24th March 2010, 11:38 PM
pepe_boy's Avatar
pepe_boy Offline
Registered User
 
Join Date: Nov 2008
Posts: 14
linuxfedorafirefox
Thumbs up Re: SELinux denies apache home directories ...

Quote:
Originally Posted by marcrblevins View Post
My notes:
Code:
chmod 711 /home/marc
chmod 755 /home/marc/public_html
setsebool -P httpd_enable_homedirs 1
chcon -R -t httpd_sys_content_t /home/marc/public_html
service httpd restart
This solution works perfectly! Finally I have this working in FC11 too.
Thanks for ur notes
Reply With Quote
  #11  
Old 23rd August 2012, 08:40 PM
odalcet Offline
Registered User
 
Join Date: Oct 2005
Location: Caracas Venezuela
Posts: 3
linuxchrome
Re: SELinux denies apache home directories ...

With PHP, this command


Code:
$handle = @fopen( "bm_out02.sql", "r" );
produces this SELinux message in Fedora 17


Code:
SELinux is preventing /usr/sbin/httpd from read access on the file bm_out02.sql.

Problem solved with this command (as root)

Code:
setsebool -P httpd_read_user_content 1
Reply With Quote
Reply

Tags
apache, denies, directories, home, selinux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SELinux is preventing the spamd daemon from reading users' home directories mksmith069 Using Fedora 2 14th September 2009 08:48 PM
Password protect apache home directories paul_mat Servers & Networking 6 22nd March 2006 07:25 AM
openldap apache home directories paul_mat Servers & Networking 0 21st March 2006 01:34 PM
SELinux, vsftpd, home directories and apache GBH Security and Privacy 2 26th October 2005 01:08 PM


Current GMT-time: 10:32 (Saturday, 18-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat