Bug 481443 - httpd cannot write to files
Summary: httpd cannot write to files
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 10
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Daniel Walsh
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-01-24 23:07 UTC by Pierre Ossman
Modified: 2009-11-18 10:53 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-11-18 10:53:15 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Pierre Ossman 2009-01-24 23:07:11 UTC
I get this after an upgrade from F8 to F10:

type=1400 audit(1232838174.113:37): avc:  denied  { write } for  pid=1740 comm="httpd" name="userdb.dat" dev=dm-0 ino=1704493 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_sys_content_t:s0 tclass=file

The problem is that httpd is not allowed to update Gallery's user database anymore. I cannot find any boolean that gives httpd the right to write to its content files.

Comment 1 Pierre Ossman 2009-01-24 23:24:46 UTC
After I set selinux to permissive, I got a whole bunch of other accesses, so I need a general "write enable" switch for httpd on httpd_sys_content_t:

type=1400 audit(1232838568.940:47): avc:  denied  { write } for  pid=1738 comm="httpd" name="userdb.dat" dev=dm-0 ino=1704493 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_sys_content_t:s0 tclass=file
type=1400 audit(1232838569.033:48): avc:  denied  { create } for  pid=1738 comm="httpd" name="photos.dat.0" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_sys_content_t:s0 tclass=file
type=1400 audit(1232838569.035:49): avc:  denied  { rename } for  pid=1738 comm="httpd" name="photos.dat" dev=dm-0 ino=1716710 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_sys_content_t:s0 tclass=file
type=1400 audit(1232838569.035:50): avc:  denied  { unlink } for  pid=1738 comm="httpd" name="photos.dat.bak" dev=dm-0 ino=1716613 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_sys_content_t:s0 tclass=file
type=1400 audit(1232838713.902:52): avc:  denied  { append } for  pid=1739 comm="httpd" name="photos.dat.lock" dev=dm-0 ino=1907011 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_sys_content_t:s0 tclass=file

Comment 2 Daniel Walsh 2009-01-26 18:08:58 UTC
You can change the directory to httpd_sys_content_rw_t using semanage. Or you can turn on the httpd_unified boolean.

What is the path to the directory?

Comment 3 Daniel Walsh 2009-01-26 18:10:11 UTC
setsebool -P httpd_unified=1

Comment 4 Pierre Ossman 2009-01-26 18:51:02 UTC
(In reply to comment #2)
> You can change the directory to httpd_sys_content_rw_t using semanage. Or you
> can turn on the httpd_unified boolean.
> 

Thanks. I noticed now that this was properly documented in httpd_selinux(8), which I for some reason didn't think to look for. :/

> What is the path to the directory?

/var/www/gallery/albums/

Anyhoo, a broad chcon to the mutable portions of the site got things working beautifully. Thanks again. :)

Comment 5 Daniel Walsh 2009-01-26 19:00:57 UTC
Miroslav,

Add
	/var/www/gallery/albums(/.*)?		gen_context(system_u:object_r:httpd_sys_content_rw_t,s0)

To apache.fc for F10 and F9, please

Pierre, you should use semanage to make sure your changes are permanent.

semanage fcontext -a -t httpd_sys_content_rw_t 
'/var/www/gallery/albums(/.*)?'

Comment 6 Pierre Ossman 2009-01-26 19:09:54 UTC
(In reply to comment #5)
> Miroslav,
> 
> Add
>  /var/www/gallery/albums(/.*)? 
> gen_context(system_u:object_r:httpd_sys_content_rw_t,s0)
> 
> To apache.fc for F10 and F9, please
> 

I'm not sure this is a standard location, so I can't say I'd advocate this based on just my setup.

> Pierre, you should use semanage to make sure your changes are permanent.
> 
> semanage fcontext -a -t httpd_sys_content_rw_t 
> '/var/www/gallery/albums(/.*)?'

Ah thanks. Do the tools read all files in /etc/selinux/targeted/contexts/files or just the "well-defined" ones?

Comment 7 Daniel Walsh 2009-01-26 19:22:22 UTC
It reads all of the files.

Comment 8 Miroslav Grepl 2009-01-27 18:39:13 UTC
Fixed in selinux-policy-3.5.13-41.fc10

Comment 9 David Juran 2009-02-05 12:34:17 UTC
Regarding the standard location, at least in the version of gallery that we ship, I belive that should be /srv/gallery2/albums

Comment 10 David Juran 2009-02-05 18:38:22 UTC
Actually, I believe that the entire /srv/gallery2 should be set to httpd_sys_content_rw_t 
AFAIK, the only thing that that directory contain is files that are put there by gallery2. Which is a webb app (php).

Comment 11 Bug Zapper 2009-11-18 10:51:26 UTC
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping


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